]> Savannah Git Hosting - gnulib.git/commitdiff
isalpha_l: New module.
authorBruno Haible <bruno@clisp.org>
Sat, 15 Feb 2025 09:31:25 +0000 (10:31 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 15 Feb 2025 09:31:25 +0000 (10:31 +0100)
* lib/ctype.in.h: (isalpha_l): New declaration.
* lib/isalpha_l.c: New file.
* m4/isalpha_l.m4: New file.
* m4/ctype_h.m4 (gl_CTYPE_H): Test for isalpha_l.
(gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISALPHA_L.
(gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISALPHA_L.
* modules/ctype-h (Makefile.am): Substitute GNULIB_ISALPHA_L,
HAVE_ISALPHA_L.
* modules/isalpha_l: New file.
* tests/test-ctype-h-c++.cc: Check declaration of isalpha_l.
* doc/posix-functions/isalpha_l.texi: Mention the new module.

ChangeLog
doc/posix-functions/isalpha_l.texi
lib/ctype.in.h
lib/isalpha_l.c [new file with mode: 0644]
m4/ctype_h.m4
m4/isalpha_l.m4 [new file with mode: 0644]
modules/ctype-h
modules/isalpha_l [new file with mode: 0644]
tests/test-ctype-h-c++.cc

index 4e2c23cea865d21744c214b3b656af86fe616c3c..986e9b22530d19405344bbdba8c413b26b717a44 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-02-15  Bruno Haible  <bruno@clisp.org>
+
+       isalpha_l: New module.
+       * lib/ctype.in.h: (isalpha_l): New declaration.
+       * lib/isalpha_l.c: New file.
+       * m4/isalpha_l.m4: New file.
+       * m4/ctype_h.m4 (gl_CTYPE_H): Test for isalpha_l.
+       (gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISALPHA_L.
+       (gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISALPHA_L.
+       * modules/ctype-h (Makefile.am): Substitute GNULIB_ISALPHA_L,
+       HAVE_ISALPHA_L.
+       * modules/isalpha_l: New file.
+       * tests/test-ctype-h-c++.cc: Check declaration of isalpha_l.
+       * doc/posix-functions/isalpha_l.texi: Mention the new module.
+
 2025-02-14  Paul Eggert  <eggert@cs.ucla.edu>
 
        isascii: stop using it
index 898f17bb36793df157cde8368940950956f96c4a..71dc9fb6ee4c7744c13eb6cb334f2cf86887ab3b 100644 (file)
@@ -4,15 +4,16 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/isalpha_l.html}
 
-Gnulib module: ---
+Gnulib module: isalpha_l
+@mindex isalpha_l
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on many platforms:
+FreeBSD 9.0, NetBSD 6.1, OpenBSD 6.1, Minix 3.1.8, AIX 6.1, HP-UX 11, Solaris 11.3, Cygwin 2.5.x, mingw, MSVC 14, Android 4.4.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function is missing on many platforms:
-FreeBSD 6.0, NetBSD 5.0, OpenBSD 6.0, Minix 3.1.8, AIX 5.1, HP-UX 11, Solaris 11.3, Cygwin 1.7.x, mingw, MSVC 14, Android 4.4.
 @end itemize
index 231c0b6601614d6064eda4d0453d22f5d2c02711..13c867150bd78235d963032652c7ad3d91e92b09 100644 (file)
@@ -54,7 +54,7 @@
  #error "Please include config.h first."
 #endif
 
-#if @GNULIB_ISALNUM_L@
+#if @GNULIB_ISALNUM_L@ || @GNULIB_ISALPHA_L@
 /* Get locale_t.  */
 # include <locale.h>
 #endif
@@ -81,6 +81,24 @@ _GL_WARN_ON_USE (isalnum_l, "isalnum_l is unportable - "
 # endif
 #endif
 
+/* Return non-zero if c is alphabetic.  */
+#if @GNULIB_ISALPHA_L@
+# if !@HAVE_ISALPHA_L@
+_GL_FUNCDECL_SYS (isalpha_l, int, (int c, locale_t locale),
+                                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (isalpha_l, int, (int c, locale_t locale));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (isalpha_l);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef isalpha_l
+# if HAVE_RAW_DECL_ISALPHA_L
+_GL_WARN_ON_USE (isalpha_l, "isalpha_l is unportable - "
+                 "use gnulib module isalpha_l for portability");
+# endif
+#endif
+
 /* Return non-zero if c is a blank, i.e. a space or tab character.  */
 #if @GNULIB_ISBLANK@
 # if !@HAVE_ISBLANK@
diff --git a/lib/isalpha_l.c b/lib/isalpha_l.c
new file mode 100644 (file)
index 0000000..b8a7f85
--- /dev/null
@@ -0,0 +1,31 @@
+/* Test whether a single-byte character is alphabetic.
+   Copyright (C) 2025 Free Software Foundation, Inc.
+
+   This file is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   This file is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2025.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <ctype.h>
+
+#define FUNC isalpha_l
+#define GLOBAL_FUNC isalpha
+#define C_FUNC(c) \
+  ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
+/* Documentation:
+   <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/isalpha-iswalpha-isalpha-l-iswalpha-l>  */
+#define WINDOWS_FUNC _isalpha_l
+#include "is_l-impl.h"
index c97a7b93521fe1032f5da4d31d6f21bd98cdaa21..e2f8798a74cbe0f2e6a9a216e083e6a2b5759e60 100644 (file)
@@ -1,5 +1,5 @@
 # ctype_h.m4
-# serial 10
+# serial 11
 dnl Copyright (C) 2009-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,7 +16,7 @@ AC_DEFUN_ONCE([gl_CTYPE_H],
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <ctype.h>
-    ]], [isalnum_l isblank])
+    ]], [isalnum_l isalpha_l isblank])
 ])
 
 # gl_CTYPE_MODULE_INDICATOR([modulename])
@@ -37,6 +37,7 @@ AC_DEFUN([gl_CTYPE_H_REQUIRE_DEFAULTS],
 [
   m4_defun(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS], [
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISALNUM_L])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISALPHA_L])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISBLANK])
   ])
   m4_require(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS])
@@ -47,5 +48,6 @@ AC_DEFUN([gl_CTYPE_H_DEFAULTS],
 [
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_ISALNUM_L=1;   AC_SUBST([HAVE_ISALNUM_L])
+  HAVE_ISALPHA_L=1;   AC_SUBST([HAVE_ISALPHA_L])
   HAVE_ISBLANK=1;     AC_SUBST([HAVE_ISBLANK])
 ])
diff --git a/m4/isalpha_l.m4 b/m4/isalpha_l.m4
new file mode 100644 (file)
index 0000000..a0a037b
--- /dev/null
@@ -0,0 +1,23 @@
+# isalpha_l.m4
+# serial 1
+dnl Copyright (C) 2009-2025 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+dnl This file is offered as-is, without any warranty.
+
+AC_DEFUN([gl_FUNC_ISALPHA_L],
+[
+  AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+
+  dnl Persuade glibc <ctype.h> to declare isalpha_l().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_FUNCS_ONCE([isalpha_l])
+  if test $ac_cv_func_isalpha_l = no; then
+    HAVE_ISALPHA_L=0
+  fi
+
+  dnl Prerequisites of lib/isalpha_l.c.
+  AC_REQUIRE([gt_FUNC_USELOCALE])
+])
index a7f04a3621e584a137a430cd3cf7c68bc6aaaff7..9e9c1c5c657d42b3a291f56a3585e951ff6e8634 100644 (file)
@@ -31,8 +31,10 @@ ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_CTYPE_H''@|$(NEXT_CTYPE_H)|g' \
              -e 's/@''GNULIB_ISALNUM_L''@/$(GNULIB_ISALNUM_L)/g' \
+             -e 's/@''GNULIB_ISALPHA_L''@/$(GNULIB_ISALPHA_L)/g' \
              -e 's/@''GNULIB_ISBLANK''@/$(GNULIB_ISBLANK)/g' \
              -e 's/@''HAVE_ISALNUM_L''@/$(HAVE_ISALNUM_L)/g' \
+             -e 's/@''HAVE_ISALPHA_L''@/$(HAVE_ISALPHA_L)/g' \
              -e 's/@''HAVE_ISBLANK''@/$(HAVE_ISBLANK)/g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
diff --git a/modules/isalpha_l b/modules/isalpha_l
new file mode 100644 (file)
index 0000000..a09a09e
--- /dev/null
@@ -0,0 +1,33 @@
+Description:
+isalpha_l() function: test whether a single-byte character is alphabetic.
+
+Files:
+lib/isalpha_l.c
+lib/is_l-impl.h
+m4/isalpha_l.m4
+m4/intl-thread-locale.m4
+
+Depends-on:
+ctype-h
+locale-h
+extensions
+
+configure.ac:
+gl_FUNC_ISALPHA_L
+gl_CONDITIONAL([GL_COND_OBJ_ISALPHA_L], [test $HAVE_ISALPHA_L = 0])
+gl_MODULE_INDICATOR([isalpha_l])
+gl_CTYPE_MODULE_INDICATOR([isalpha_l])
+
+Makefile.am:
+if GL_COND_OBJ_ISALPHA_L
+lib_SOURCES += isalpha_l.c
+endif
+
+Include:
+<ctype.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
index 981eda6671f9be5dd887e3c3704f68775176166f..cd8ef91d38f87bc4897b6dbb4b3d014bac02940d 100644 (file)
 SIGNATURE_CHECK (GNULIB_NAMESPACE::isalnum_l, int, (int, locale_t));
 #endif
 
+#if GNULIB_TEST_ISALPHA_L
+SIGNATURE_CHECK (GNULIB_NAMESPACE::isalpha_l, int, (int, locale_t));
+#endif
+
 #if 0
 SIGNATURE_CHECK (GNULIB_NAMESPACE::isblank, int, (int));
 #endif