]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
ispunct_l: New module.
authorBruno Haible <bruno@clisp.org>
Sat, 15 Feb 2025 19:42:59 +0000 (20:42 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 15 Feb 2025 20:19:27 +0000 (21:19 +0100)
* lib/ctype.in.h: (ispunct_l): New declaration.
* lib/ispunct_l.c: New file.
* m4/ispunct_l.m4: New file.
* m4/ctype_h.m4 (gl_CTYPE_H): Test for ispunct_l.
(gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISPUNCT_L.
(gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISPUNCT_L.
* modules/ctype-h (Makefile.am): Substitute GNULIB_ISPUNCT_L,
HAVE_ISPUNCT_L.
* modules/ispunct_l: New file.
* tests/test-ctype-h-c++.cc: Check declaration of ispunct_l.
* doc/posix-functions/ispunct_l.texi: Mention the new module.

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

index 17ba141a13fcf68791c615739848bc34aaaa3006..d1a2eb7e0a39357b3f69a58a36e57cd250b0d4aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-02-15  Bruno Haible  <bruno@clisp.org>
+
+       ispunct_l: New module.
+       * lib/ctype.in.h: (ispunct_l): New declaration.
+       * lib/ispunct_l.c: New file.
+       * m4/ispunct_l.m4: New file.
+       * m4/ctype_h.m4 (gl_CTYPE_H): Test for ispunct_l.
+       (gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISPUNCT_L.
+       (gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISPUNCT_L.
+       * modules/ctype-h (Makefile.am): Substitute GNULIB_ISPUNCT_L,
+       HAVE_ISPUNCT_L.
+       * modules/ispunct_l: New file.
+       * tests/test-ctype-h-c++.cc: Check declaration of ispunct_l.
+       * doc/posix-functions/ispunct_l.texi: Mention the new module.
+
 2025-02-15  Bruno Haible  <bruno@clisp.org>
 
        isprint_l: Add tests.
index f8220d5bd58a981297fbb172683993589f74d094..6ce92eb323d3ef7319b126bc223ad3461f4fa3d7 100644 (file)
@@ -4,15 +4,16 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/ispunct_l.html}
 
-Gnulib module: ---
+Gnulib module: ispunct_l
+@mindex ispunct_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 ec78d9293959986121397065e6e8405ae75e03a4..8a5aeaac210703cbee5433e23fb4849fdc0113ae 100644 (file)
@@ -56,7 +56,7 @@
 
 #if (@GNULIB_ISALNUM_L@ || @GNULIB_ISALPHA_L@ || @GNULIB_ISBLANK_L@ \
      || @GNULIB_ISCNTRL_L@ || @GNULIB_ISDIGIT_L@ || @GNULIB_ISGRAPH_L@ \
-     || @GNULIB_ISLOWER_L@ || @GNULIB_ISPRINT_L@)
+     || @GNULIB_ISLOWER_L@ || @GNULIB_ISPRINT_L@ || @GNULIB_ISPUNCT_L@)
 /* Get locale_t.  */
 # include <locale.h>
 #endif
@@ -222,6 +222,24 @@ _GL_WARN_ON_USE (isprint_l, "isprint_l is unportable - "
 # endif
 #endif
 
+/* Return non-zero if c is a punctuation or symbol character.  */
+#if @GNULIB_ISPUNCT_L@
+# if !@HAVE_ISPUNCT_L@
+_GL_FUNCDECL_SYS (ispunct_l, int, (int c, locale_t locale),
+                                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (ispunct_l, int, (int c, locale_t locale));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (ispunct_l);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef ispunct_l
+# if HAVE_RAW_DECL_ISPUNCT_L
+_GL_WARN_ON_USE (ispunct_l, "ispunct_l is unportable - "
+                 "use gnulib module ispunct_l for portability");
+# endif
+#endif
+
 #endif /* _@GUARD_PREFIX@_CTYPE_H */
 #endif
 #endif /* _@GUARD_PREFIX@_CTYPE_H */
diff --git a/lib/ispunct_l.c b/lib/ispunct_l.c
new file mode 100644 (file)
index 0000000..dcb832d
--- /dev/null
@@ -0,0 +1,32 @@
+/* Test whether a single-byte character is a punctuation or symbol character.
+   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 ispunct_l
+#define GLOBAL_FUNC ispunct
+#define C_FUNC(c) \
+  ((c >= 0x21 && c <= 0x7e) \
+   && !((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')))
+/* Documentation:
+   <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/ispunct-iswpunct-ispunct-l-iswpunct-l>  */
+#define WINDOWS_FUNC _ispunct_l
+#include "is_l-impl.h"
index 67663c8b9d96af450cae2a35cf78e3cd3d5f6658..e52fa65da4d4e6e7b0b0a0f3ee514c15bd38e0a5 100644 (file)
@@ -1,5 +1,5 @@
 # ctype_h.m4
-# serial 17
+# serial 18
 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,
@@ -17,7 +17,7 @@ AC_DEFUN_ONCE([gl_CTYPE_H],
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <ctype.h>
     ]], [isalnum_l isalpha_l isblank isblank_l iscntrl_l isdigit_l isgraph_l
-    islower_l isprint_l])
+    islower_l isprint_l ispunct_l])
 ])
 
 # gl_CTYPE_MODULE_INDICATOR([modulename])
@@ -46,6 +46,7 @@ AC_DEFUN([gl_CTYPE_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISGRAPH_L])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISLOWER_L])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISPRINT_L])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISPUNCT_L])
   ])
   m4_require(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS])
   AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
@@ -63,4 +64,5 @@ AC_DEFUN([gl_CTYPE_H_DEFAULTS],
   HAVE_ISGRAPH_L=1;   AC_SUBST([HAVE_ISGRAPH_L])
   HAVE_ISLOWER_L=1;   AC_SUBST([HAVE_ISLOWER_L])
   HAVE_ISPRINT_L=1;   AC_SUBST([HAVE_ISPRINT_L])
+  HAVE_ISPUNCT_L=1;   AC_SUBST([HAVE_ISPUNCT_L])
 ])
diff --git a/m4/ispunct_l.m4 b/m4/ispunct_l.m4
new file mode 100644 (file)
index 0000000..2c74624
--- /dev/null
@@ -0,0 +1,23 @@
+# ispunct_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_ISPUNCT_L],
+[
+  AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+
+  dnl Persuade glibc <ctype.h> to declare ispunct_l().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_FUNCS_ONCE([ispunct_l])
+  if test $ac_cv_func_ispunct_l = no; then
+    HAVE_ISPUNCT_L=0
+  fi
+
+  dnl Prerequisites of lib/ispunct_l.c.
+  AC_REQUIRE([gt_FUNC_USELOCALE])
+])
index 20afedde7e5a31d28a613066eaa8a81663b039f1..1dbc3ce3b1698b90af0619c7b2cd97e32b8d1898 100644 (file)
@@ -39,6 +39,7 @@ ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's/@''GNULIB_ISGRAPH_L''@/$(GNULIB_ISGRAPH_L)/g' \
              -e 's/@''GNULIB_ISLOWER_L''@/$(GNULIB_ISLOWER_L)/g' \
              -e 's/@''GNULIB_ISPRINT_L''@/$(GNULIB_ISPRINT_L)/g' \
+             -e 's/@''GNULIB_ISPUNCT_L''@/$(GNULIB_ISPUNCT_L)/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' \
@@ -48,6 +49,7 @@ ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's/@''HAVE_ISGRAPH_L''@/$(HAVE_ISGRAPH_L)/g' \
              -e 's/@''HAVE_ISLOWER_L''@/$(HAVE_ISLOWER_L)/g' \
              -e 's/@''HAVE_ISPRINT_L''@/$(HAVE_ISPRINT_L)/g' \
+             -e 's/@''HAVE_ISPUNCT_L''@/$(HAVE_ISPUNCT_L)/g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              $(srcdir)/ctype.in.h > $@-t
diff --git a/modules/ispunct_l b/modules/ispunct_l
new file mode 100644 (file)
index 0000000..af3b572
--- /dev/null
@@ -0,0 +1,33 @@
+Description:
+ispunct_l() function: test whether a single-byte character is a punctuation or symbol character.
+
+Files:
+lib/ispunct_l.c
+lib/is_l-impl.h
+m4/ispunct_l.m4
+m4/intl-thread-locale.m4
+
+Depends-on:
+ctype-h
+locale-h
+extensions
+
+configure.ac:
+gl_FUNC_ISPUNCT_L
+gl_CONDITIONAL([GL_COND_OBJ_ISPUNCT_L], [test $HAVE_ISPUNCT_L = 0])
+gl_MODULE_INDICATOR([ispunct_l])
+gl_CTYPE_MODULE_INDICATOR([ispunct_l])
+
+Makefile.am:
+if GL_COND_OBJ_ISPUNCT_L
+lib_SOURCES += ispunct_l.c
+endif
+
+Include:
+<ctype.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
index e28477122defc27ad6c9f3c17dddd8afce4c9625..2e2d5f8cda78a167f9d59b9137aaad70337b8a3a 100644 (file)
@@ -60,6 +60,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::islower_l, int, (int, locale_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::isprint_l, int, (int, locale_t));
 #endif
 
+#if GNULIB_TEST_ISPUNCT_L
+SIGNATURE_CHECK (GNULIB_NAMESPACE::ispunct_l, int, (int, locale_t));
+#endif
+
 
 int
 main ()