texlive[74979] Build/source/texk/kpathsea: define and use

commits+karl at tug.org commits+karl at tug.org
Sat Apr 19 00:00:53 CEST 2025


Revision: 74979
          https://tug.org/svn/texlive?view=revision&revision=74979
Author:   karl
Date:     2025-04-19 00:00:53 +0200 (Sat, 19 Apr 2025)
Log Message:
-----------
define and use kpse_isascii, to avoid isascii non-portability

Modified Paths:
--------------
    trunk/Build/source/texk/kpathsea/ChangeLog
    trunk/Build/source/texk/kpathsea/c-ctype.h

Modified: trunk/Build/source/texk/kpathsea/ChangeLog
===================================================================
--- trunk/Build/source/texk/kpathsea/ChangeLog	2025-04-18 20:56:19 UTC (rev 74978)
+++ trunk/Build/source/texk/kpathsea/ChangeLog	2025-04-18 22:00:53 UTC (rev 74979)
@@ -1,3 +1,10 @@
+2025-04-18  Karl Berry  <karl at freefriends.org>
+
+	* c-ctype.h (kpse_isascii): new macro, since isascii() can
+	apparently longer be used portably, thanks to POSIX and gcc 15.
+	(ISALNUM, ..., ISBLANK): use it. Discussion:
+	https://tug.org/pipermail/tlbuild/2025q2/005743.html
+
 2025-04-08  Karl Berry  <karl at freefriends.org>
 
 	* c-memstr.h (strtok, strstr): remove () fallback declarations,

Modified: trunk/Build/source/texk/kpathsea/c-ctype.h
===================================================================
--- trunk/Build/source/texk/kpathsea/c-ctype.h	2025-04-18 20:56:19 UTC (rev 74978)
+++ trunk/Build/source/texk/kpathsea/c-ctype.h	2025-04-18 22:00:53 UTC (rev 74979)
@@ -1,6 +1,6 @@
 /* c-ctype.h: ASCII-safe versions of the <ctype.h> macros.
 
-   Copyright 1992, 1994, 2008, 2010, 2011, 2015 Karl Berry.
+   Copyright 1992, 1994, 2008, 2010, 2011, 2015, 2025 Karl Berry.
    Copyright 1998, 2000, 2005 Olaf Weber.
 
    This library is free software; you can redistribute it and/or
@@ -28,28 +28,42 @@
 #endif
 #endif
 
-#define ISALNUM(c) (isascii (c) && isalnum((unsigned char)c))
-#define ISALPHA(c) (isascii (c) && isalpha((unsigned char)c))
-#define ISASCII isascii
-#define ISCNTRL(c) (isascii (c) && iscntrl((unsigned char)c))
-#define ISDIGIT(c) (isascii (c) && isdigit ((unsigned char)c))
-#define ISGRAPH(c) (isascii (c) && isgraph((unsigned char)c))
-#define ISLOWER(c) (isascii (c) && islower((unsigned char)c))
-#define ISPRINT(c) (isascii (c) && isprint((unsigned char)c))
-#define ISPUNCT(c) (isascii (c) && ispunct((unsigned char)c))
-#define ISSPACE(c) (isascii (c) && isspace((unsigned char)c))
-#define ISUPPER(c) (isascii (c) && isupper((unsigned char)c))
-#define ISXDIGIT(c) (isascii (c) && isxdigit((unsigned char)c))
+/* However, we don't use isascii, since POSIX + compilers have made it
+   impossible to do so portably (first failure reports for gcc 15;
+   underlying reason is unclear). Leave the definition above just
+   because we've always defined it, but for our use here, apparently we
+   now have to define and use our own macro.  Discussion:
+   https://tug.org/pipermail/tlbuild/2025q2/005743.html */
+
+/* We want to possibly accept integers as an argument, because of the
+   old problems described in the comment below. So cast to unsigned
+   since otherwise checking for (i)>0 runs the risk of more useless
+   compiler warnings/errors about redundant comparisons.  */
+#define kpse_isascii(i) ((unsigned) (i) <= 127)
+
+#define ISALNUM(c) (kpse_isascii (c) && isalnum((unsigned char)c))
+#define ISALPHA(c) (kpse_isascii (c) && isalpha((unsigned char)c))
+#define KPSE_ISASCII kpse_isascii
+#define ISCNTRL(c) (kpse_isascii (c) && iscntrl((unsigned char)c))
+#define ISDIGIT(c) (kpse_isascii (c) && isdigit ((unsigned char)c))
+#define ISGRAPH(c) (kpse_isascii (c) && isgraph((unsigned char)c))
+#define ISLOWER(c) (kpse_isascii (c) && islower((unsigned char)c))
+#define ISPRINT(c) (kpse_isascii (c) && isprint((unsigned char)c))
+#define ISPUNCT(c) (kpse_isascii (c) && ispunct((unsigned char)c))
+#define ISSPACE(c) (kpse_isascii (c) && isspace((unsigned char)c))
+#define ISUPPER(c) (kpse_isascii (c) && isupper((unsigned char)c))
+#define ISXDIGIT(c) (kpse_isascii (c) && isxdigit((unsigned char)c))
 #define TOASCII toascii
 #define TOLOWER(c) (ISUPPER (c) ? tolower ((unsigned char)c) : (c))
 #define TOUPPER(c) (ISLOWER (c) ? toupper ((unsigned char)c) : (c))
 
-/* This isn't part of the usual <ctype.h>, but it's useful sometimes.  */
+/* This isn't part of the usual <ctype.h>, but it's useful sometimes.
+   We don't consider vertical tab blank, since in normal use, it isn't.  */
 #ifndef isblank
 #define isblank(c) ((c) == ' ' || (c) == '\t')
 #endif
 
-#define ISBLANK(c) (isascii (c) && isblank ((unsigned char)c))
+#define ISBLANK(c) (kpse_isascii (c) && isblank ((unsigned char)c))
 
 
 /* Here's why this mess is necessary:
@@ -70,7 +84,7 @@
   own versions of the ctype macros.
 
   A pretty clean approach to using <ctype.h> and isascii was
-  suggested by David MacKenzie:
+  suggested by David MacKenzie: [but as of 2025, no longer works; see above]
 
   #ifndef isascii
   #define isascii(c) 1



More information about the tex-live-commits mailing list.