sshock / AFFLIBv3

AFF is an open and extensible file format to store disk images and associated metadata.
Other
80 stars 21 forks source link

Cygwin's CRT (newlib) sets __BSD_VISIBLE but does not provide isnumber() #55

Closed chrfranke closed 7 months ago

chrfranke commented 7 months ago

AFFLIB 3.7.20 builds and runs OOTB on Cygwin, except for the missing isnumber(). Here the quick patch from the source package of the new afflib packages for Cygwin:

--- origsrc/AFFLIBv3-3.7.20/tools/affcopy.cpp   2024-03-22 10:00:00.000000000 +0000
+++ src/AFFLIBv3-3.7.20/tools/affcopy.cpp       2024-03-22 10:00:00.000000000 +0000
@@ -146,7 +146,7 @@ void unlink_outfiles(vector<string> outf
     if(failure) exit(1);
 }

-#if !defined( __BSD_VISIBLE) && !defined(isnumber)
+#if (!defined(__BSD_VISIBLE) || defined(__CYGWIN__)) && !defined(isnumber)
 #define isnumber(x) isdigit(x)
 #endif

Does the use of isnumber() provide real benefit on BSD platforms? If not, I would suggest to always use isdigit().

sshock commented 7 months ago

I think technically isnumber() could recognize additional characters based on the locale, but how often this becomes practically useful seems pretty slim.

In any case, at the very least I'll incorporate your fix.