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

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

index 4c7a159cc324865af866775c71c1a55ca912e80c..82f5c115273aa1b61c9cf92531bf080ac8ae085c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-02-15  Bruno Haible  <bruno@clisp.org>
+
+       islower_l: New module.
+       * lib/ctype.in.h: (islower_l): New declaration.
+       * lib/islower_l.c: New file.
+       * m4/islower_l.m4: New file.
+       * m4/ctype_h.m4 (gl_CTYPE_H): Test for islower_l.
+       (gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISLOWER_L.
+       (gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISLOWER_L.
+       * modules/ctype-h (Makefile.am): Substitute GNULIB_ISLOWER_L,
+       HAVE_ISLOWER_L.
+       * modules/islower_l: New file.
+       * tests/test-ctype-h-c++.cc: Check declaration of islower_l.
+       * doc/posix-functions/islower_l.texi: Mention the new module.
+
 2025-02-15  Bruno Haible  <bruno@clisp.org>
 
        isgraph_l: Add tests.
index 023182afeecaaee87c3cf1cb86c23dfbe17cdc6a..21086714853670a8b3c8bb24c44bc4f543e8f292 100644 (file)
@@ -4,15 +4,16 @@
 
 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/islower_l.html}
 
-Gnulib module: ---
+Gnulib module: islower_l
+@mindex islower_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 c7f37047db77c4abb169d6cd857267b940004dd0..7706f7a3df559127066985a4fd760adaed47bf4d 100644 (file)
@@ -55,7 +55,8 @@
 #endif
 
 #if (@GNULIB_ISALNUM_L@ || @GNULIB_ISALPHA_L@ || @GNULIB_ISBLANK_L@ \
-     || @GNULIB_ISCNTRL_L@ || @GNULIB_ISDIGIT_L@ || @GNULIB_ISGRAPH_L@)
+     || @GNULIB_ISCNTRL_L@ || @GNULIB_ISDIGIT_L@ || @GNULIB_ISGRAPH_L@ \
+     || @GNULIB_ISLOWER_L@)
 /* Get locale_t.  */
 # include <locale.h>
 #endif
@@ -185,6 +186,24 @@ _GL_WARN_ON_USE (isgraph_l, "isgraph_l is unportable - "
 # endif
 #endif
 
+/* Return non-zero if c is lowercase.  */
+#if @GNULIB_ISLOWER_L@
+# if !@HAVE_ISLOWER_L@
+_GL_FUNCDECL_SYS (islower_l, int, (int c, locale_t locale),
+                                  _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (islower_l, int, (int c, locale_t locale));
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (islower_l);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef islower_l
+# if HAVE_RAW_DECL_ISLOWER_L
+_GL_WARN_ON_USE (islower_l, "islower_l is unportable - "
+                 "use gnulib module islower_l for portability");
+# endif
+#endif
+
 #endif /* _@GUARD_PREFIX@_CTYPE_H */
 #endif
 #endif /* _@GUARD_PREFIX@_CTYPE_H */
diff --git a/lib/islower_l.c b/lib/islower_l.c
new file mode 100644 (file)
index 0000000..0a5b40a
--- /dev/null
@@ -0,0 +1,31 @@
+/* Test whether a single-byte character is lowercase.
+   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 islower_l
+#define GLOBAL_FUNC islower
+#define C_FUNC(c) \
+  (c >= 'a' && c <= 'z')
+/* Documentation:
+   <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/islower-iswlower-islower-l-iswlower-l>  */
+#define WINDOWS_FUNC _islower_l
+#include "is_l-impl.h"
index 684aa66d8cd01d9a3bf501d3ee2c817eca7065be..8ddbdb26bb76204e9b96240989acfaf0a3ddaf3b 100644 (file)
@@ -1,5 +1,5 @@
 # ctype_h.m4
-# serial 15
+# serial 16
 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,8 @@ 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 isalpha_l isblank isblank_l iscntrl_l isdigit_l isgraph_l])
+    ]], [isalnum_l isalpha_l isblank isblank_l iscntrl_l isdigit_l isgraph_l
+    islower_l])
 ])
 
 # gl_CTYPE_MODULE_INDICATOR([modulename])
@@ -43,6 +44,7 @@ AC_DEFUN([gl_CTYPE_H_REQUIRE_DEFAULTS],
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISCNTRL_L])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISDIGIT_L])
     gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISGRAPH_L])
+    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISLOWER_L])
   ])
   m4_require(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS])
   AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
@@ -58,4 +60,5 @@ AC_DEFUN([gl_CTYPE_H_DEFAULTS],
   HAVE_ISCNTRL_L=1;   AC_SUBST([HAVE_ISCNTRL_L])
   HAVE_ISDIGIT_L=1;   AC_SUBST([HAVE_ISDIGIT_L])
   HAVE_ISGRAPH_L=1;   AC_SUBST([HAVE_ISGRAPH_L])
+  HAVE_ISLOWER_L=1;   AC_SUBST([HAVE_ISLOWER_L])
 ])
diff --git a/m4/islower_l.m4 b/m4/islower_l.m4
new file mode 100644 (file)
index 0000000..556076c
--- /dev/null
@@ -0,0 +1,23 @@
+# islower_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_ISLOWER_L],
+[
+  AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+
+  dnl Persuade glibc <ctype.h> to declare islower_l().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_CHECK_FUNCS_ONCE([islower_l])
+  if test $ac_cv_func_islower_l = no; then
+    HAVE_ISLOWER_L=0
+  fi
+
+  dnl Prerequisites of lib/islower_l.c.
+  AC_REQUIRE([gt_FUNC_USELOCALE])
+])
index 3b72cc7aed24ebd100089dbb0845cb3e6e8926e0..040d739187add392c8777d94fc3cfe64f0150a15 100644 (file)
@@ -37,6 +37,7 @@ ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's/@''GNULIB_ISCNTRL_L''@/$(GNULIB_ISCNTRL_L)/g' \
              -e 's/@''GNULIB_ISDIGIT_L''@/$(GNULIB_ISDIGIT_L)/g' \
              -e 's/@''GNULIB_ISGRAPH_L''@/$(GNULIB_ISGRAPH_L)/g' \
+             -e 's/@''GNULIB_ISLOWER_L''@/$(GNULIB_ISLOWER_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' \
@@ -44,6 +45,7 @@ ctype.h: ctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
              -e 's/@''HAVE_ISCNTRL_L''@/$(HAVE_ISCNTRL_L)/g' \
              -e 's/@''HAVE_ISDIGIT_L''@/$(HAVE_ISDIGIT_L)/g' \
              -e 's/@''HAVE_ISGRAPH_L''@/$(HAVE_ISGRAPH_L)/g' \
+             -e 's/@''HAVE_ISLOWER_L''@/$(HAVE_ISLOWER_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/islower_l b/modules/islower_l
new file mode 100644 (file)
index 0000000..50f3fd9
--- /dev/null
@@ -0,0 +1,33 @@
+Description:
+islower_l() function: test whether a single-byte character is lowercase.
+
+Files:
+lib/islower_l.c
+lib/is_l-impl.h
+m4/islower_l.m4
+m4/intl-thread-locale.m4
+
+Depends-on:
+ctype-h
+locale-h
+extensions
+
+configure.ac:
+gl_FUNC_ISLOWER_L
+gl_CONDITIONAL([GL_COND_OBJ_ISLOWER_L], [test $HAVE_ISLOWER_L = 0])
+gl_MODULE_INDICATOR([islower_l])
+gl_CTYPE_MODULE_INDICATOR([islower_l])
+
+Makefile.am:
+if GL_COND_OBJ_ISLOWER_L
+lib_SOURCES += islower_l.c
+endif
+
+Include:
+<ctype.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
index f795a50378666eb9b498a04e9cb8e640d15e1fe4..aad61d2ac660ac1f72e34dce3a85a0ca398ccf88 100644 (file)
@@ -52,6 +52,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::isdigit_l, int, (int, locale_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::isgraph_l, int, (int, locale_t));
 #endif
 
+#if GNULIB_TEST_ISLOWER_L
+SIGNATURE_CHECK (GNULIB_NAMESPACE::islower_l, int, (int, locale_t));
+#endif
+
 
 int
 main ()