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

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

index a40619eb504e6202cdc720d6731e11892473dca7..2b9750b1a4e297c6d2776f62f3b99e1aa99cea42 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-02-15  Bruno Haible  <bruno@clisp.org>
+
+       isupper_l: New module.
+       * lib/ctype.in.h: (isupper_l): New declaration.
+       * lib/isupper_l.c: New file.
+       * m4/isupper_l.m4: New file.
+       * m4/ctype_h.m4 (gl_CTYPE_H): Test for isupper_l.
+       (gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISUPPER_L.
+       (gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISUPPER_L.
+       * modules/ctype-h (Makefile.am): Substitute GNULIB_ISUPPER_L,
+       HAVE_ISUPPER_L.
+       * modules/isupper_l: New file.
+       * tests/test-ctype-h-c++.cc: Check declaration of isupper_l.
+       * doc/posix-functions/isupper_l.texi: Mention the new module.
+
 2025-02-15  Bruno Haible  <bruno@clisp.org>
 
        isspace_l: Add tests.
index 4249889f9a74639702af54e60248e44cc7231e7d..68e577c8e320c4c381c19c31a321e3f49583f69a 100644 (file)
@@ -4,15 +4,16 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/isupper_l.html}
 
-Gnulib module: ---
+Gnulib module: isupper_l
+@mindex isupper_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 8b04fd0f7c3b2d8ec65dc27bafdd6e41289f1c09..6ede5b8841ca7cf75ae1940def6cc2419cfec9cb 100644 (file)
@@ -57,7 +57,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_ISPUNCT_L@ \
-     || @GNULIB_ISSPACE_L@)
+     || @GNULIB_ISSPACE_L@ || @GNULIB_ISUPPER_L@)
 /* Get locale_t.  */
 # include <locale.h>
 #endif
@@ -259,6 +259,24 @@ _GL_WARN_ON_USE (isspace_l, "isspace_l is unportable - "
 # endif
 #endif
 
+/* Return non-zero if c is uppercase.  */
+#if @GNULIB_ISUPPER_L@
+# if !@HAVE_ISUPPER_L@
+_GL_FUNCDECL_SYS (isupper_l, int, (int c, locale_t locale),
+                                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (isupper_l, int, (int c, locale_t locale));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (isupper_l);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef isupper_l
+# if HAVE_RAW_DECL_ISUPPER_L
+_GL_WARN_ON_USE (isupper_l, "isupper_l is unportable - "
+                 "use gnulib module isupper_l for portability");
+# endif
+#endif
+
 #endif /* _@GUARD_PREFIX@_CTYPE_H */
 #endif
 #endif /* _@GUARD_PREFIX@_CTYPE_H */
diff --git a/lib/isupper_l.c b/lib/isupper_l.c
new file mode 100644 (file)
index 0000000..c4e24b9
--- /dev/null
@@ -0,0 +1,31 @@
+/* Test whether a single-byte character is uppercase.
+   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 isupper_l
+#define GLOBAL_FUNC isupper
+#define C_FUNC(c) \
+  (c >= 'A' && c <= 'Z')
+/* Documentation:
+   <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/isupper-isupper-l-iswupper-iswupper-l>  */
+#define WINDOWS_FUNC _isupper_l
+#include "is_l-impl.h"
index 6c9d86c00b592ab89c4fc6fc977b82b47426f665..c2d042f80e97ab958565bc5c047cae8f9edc7274 100644 (file)
@@ -1,5 +1,5 @@
 # ctype_h.m4
-# serial 19
+# serial 20
 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 ispunct_l isspace_l])
+    islower_l isprint_l ispunct_l isspace_l isupper_l])
 ])
 
 # gl_CTYPE_MODULE_INDICATOR([modulename])
@@ -48,6 +48,7 @@ AC_DEFUN([gl_CTYPE_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISPRINT_L])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISPUNCT_L])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISSPACE_L])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISUPPER_L])
   ])
   m4_require(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS])
   AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
@@ -67,4 +68,5 @@ AC_DEFUN([gl_CTYPE_H_DEFAULTS],
   HAVE_ISPRINT_L=1;   AC_SUBST([HAVE_ISPRINT_L])
   HAVE_ISPUNCT_L=1;   AC_SUBST([HAVE_ISPUNCT_L])
   HAVE_ISSPACE_L=1;   AC_SUBST([HAVE_ISSPACE_L])
+  HAVE_ISUPPER_L=1;   AC_SUBST([HAVE_ISUPPER_L])
 ])
diff --git a/m4/isupper_l.m4 b/m4/isupper_l.m4
new file mode 100644 (file)
index 0000000..fb330be
--- /dev/null
@@ -0,0 +1,23 @@
+# isupper_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_ISUPPER_L],
+[
+  AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+
+  dnl Persuade glibc <ctype.h> to declare isupper_l().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_FUNCS_ONCE([isupper_l])
+  if test $ac_cv_func_isupper_l = no; then
+    HAVE_ISUPPER_L=0
+  fi
+
+  dnl Prerequisites of lib/isupper_l.c.
+  AC_REQUIRE([gt_FUNC_USELOCALE])
+])
index 4c34a0b0190fd4a6d351c41ec1dbeb06cbcdb23b..b46ca2e3f9e9669b5fc23e6e5540da1752e51278 100644 (file)
@@ -41,6 +41,7 @@ ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's/@''GNULIB_ISPRINT_L''@/$(GNULIB_ISPRINT_L)/g' \
              -e 's/@''GNULIB_ISPUNCT_L''@/$(GNULIB_ISPUNCT_L)/g' \
              -e 's/@''GNULIB_ISSPACE_L''@/$(GNULIB_ISSPACE_L)/g' \
+             -e 's/@''GNULIB_ISUPPER_L''@/$(GNULIB_ISUPPER_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' \
@@ -52,6 +53,7 @@ ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's/@''HAVE_ISPRINT_L''@/$(HAVE_ISPRINT_L)/g' \
              -e 's/@''HAVE_ISPUNCT_L''@/$(HAVE_ISPUNCT_L)/g' \
              -e 's/@''HAVE_ISSPACE_L''@/$(HAVE_ISSPACE_L)/g' \
+             -e 's/@''HAVE_ISUPPER_L''@/$(HAVE_ISUPPER_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/isupper_l b/modules/isupper_l
new file mode 100644 (file)
index 0000000..e102579
--- /dev/null
@@ -0,0 +1,33 @@
+Description:
+isupper_l() function: test whether a single-byte character is uppercase.
+
+Files:
+lib/isupper_l.c
+lib/is_l-impl.h
+m4/isupper_l.m4
+m4/intl-thread-locale.m4
+
+Depends-on:
+ctype-h
+locale-h
+extensions
+
+configure.ac:
+gl_FUNC_ISUPPER_L
+gl_CONDITIONAL([GL_COND_OBJ_ISUPPER_L], [test $HAVE_ISUPPER_L = 0])
+gl_MODULE_INDICATOR([isupper_l])
+gl_CTYPE_MODULE_INDICATOR([isupper_l])
+
+Makefile.am:
+if GL_COND_OBJ_ISUPPER_L
+lib_SOURCES += isupper_l.c
+endif
+
+Include:
+<ctype.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
index df044c91195975aca71d9c57c5bba9cbbde03180..c10be107efb4b82157e17d2e93a332c58f5e71ea 100644 (file)
@@ -68,6 +68,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::ispunct_l, int, (int, locale_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::isspace_l, int, (int, locale_t));
 #endif
 
+#if GNULIB_TEST_ISUPPER_L
+SIGNATURE_CHECK (GNULIB_NAMESPACE::isupper_l, int, (int, locale_t));
+#endif
+
 
 int
 main ()