Project

General

Profile

Actions

Bug #282

open

Use OS-agnostic string comparison functions

Added by wrobelda over 3 years ago. Updated over 3 years ago.

Status:
New
Priority:
Normal
Category:
-
Start date:
08/25/2022
Due date:
Betriebssystem:
Windows
AqBanking-Version:
5.10.1
Anwendung:
andere
Version der Anwendung:

Description

This patch is dirty, not intended for merging, but I post it anyway so that it is clear what needs to be done.

Before I begin, it's important to remember that strings.h is not available on Windows (only string.h is).

What it does is:
1) it removes all explicit calls for inclusion of <strings.h>
2) removes all inclusions of <strings.h>, be it standalone or HAVE_STRINGS_H-guarded. The latter unnecessary, but was done to keep code clean, given the 3b) below
3) adds checks to configure.ac that determine which string comparison functions are available, i.e. POSIX or WIN API version, and:
a) add the relevant HAVE_DECL_STR*CMP defines to config.h and defines POSIX names for equivalent WIN API functions.
b) includes strings.h if it's available. Since that's done in config.h, which is pretty much included in all source code across the board, all other <strings.h> usage was removed, as noted in 2)

As noted, this is dirty, but I did that to deal with this problem en-masse, as I was progressing towards obtaining a successful build with clang.

What I suggest to be done is to add wrapper methods for all these functions in gwenhywfar/text.h, akin to the existing GWEN_Text_strndup. This would probably be the cleanest approach and consistent with your existing code.


Files

Actions #2

Updated by wrobelda over 3 years ago

One more thing that I realized is that the project could use gnulib where relevant to provide the drop-in cross-platform compatibility — this includes MSVC compatibility as well: https://www.gnu.org/software/gnulib/manual/html_node/Native-Windows-Support.html

See e.g. https://www.gnu.org/software/gnulib/manual/html_node/strcasecmp.html

Although the integration is not required, easiest way to use it is to literally include a subset of it with the source code (see the notes on the main website https://www.gnu.org/software/gnulib/) and just use it as is.

Actions

Also available in: Atom PDF