* lib/ctype.in.h: Include <locale.h>.
(isalnum_l): New declaration.
* lib/isalnum_l.c: New file.
* lib/is_l-impl.h: New file.
* m4/isalnum_l.m4: New file.
* m4/ctype_h.m4 (gl_CTYPE_H): Test for isalnum_l.
(gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISALNUM_L.
(gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISALNUM_L.
* modules/ctype-h (Makefile.am): Substitute GNULIB_ISALNUM_L,
HAVE_ISALNUM_L.
* modules/isalnum_l: New file.
* tests/test-ctype-h-c++.cc: Check declaration of isalnum_l.
* doc/posix-functions/isalnum_l.texi: Mention the new module.
+2025-02-14 Bruno Haible <bruno@clisp.org>
+
+ isalnum_l: New module.
+ * lib/ctype.in.h: Include <locale.h>.
+ (isalnum_l): New declaration.
+ * lib/isalnum_l.c: New file.
+ * lib/is_l-impl.h: New file.
+ * m4/isalnum_l.m4: New file.
+ * m4/ctype_h.m4 (gl_CTYPE_H): Test for isalnum_l.
+ (gl_CTYPE_H_REQUIRE_DEFAULTS): Initialize GNULIB_ISALNUM_L.
+ (gl_CTYPE_H_DEFAULTS): Initialize HAVE_ISALNUM_L.
+ * modules/ctype-h (Makefile.am): Substitute GNULIB_ISALNUM_L,
+ HAVE_ISALNUM_L.
+ * modules/isalnum_l: New file.
+ * tests/test-ctype-h-c++.cc: Check declaration of isalnum_l.
+ * doc/posix-functions/isalnum_l.texi: Mention the new module.
+
2025-02-14 Bruno Haible <bruno@clisp.org>
freelocale: Allow non-POSIX prototype on macOS.
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/isalnum_l.html}
-Gnulib module: ---
+Gnulib module: isalnum_l
+@mindex isalnum_l
Portability problems 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
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
#endif
@PRAGMA_COLUMNS@
+/* On Solaris 11 OmniOS, we cannot include <locale.h> until after <wchar.h> has
+ been entirely included. That is because
+ - <locale.h> includes <xlocale.h>, which makes use of the mbstate_t type.
+ - <wchar.h> includes <iso/wchar_iso.h>, which includes <ctype.h> *before*
+ defining mbstate_t, WEOF, etc. */
+#if defined __sun && defined _ISO_WCHAR_ISO_H && !defined WEOF
+/* We're in the middle of including <iso/wchar_iso.h>.
+ Include just the original <ctype.h>. */
+
+#@INCLUDE_NEXT@ @NEXT_CTYPE_H@
+
+#else
+
/* Include the original <ctype.h>. */
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @NEXT_CTYPE_H@
#error "Please include config.h first."
#endif
+#if @GNULIB_ISALNUM_L@
+/* Get locale_t. */
+# include <locale.h>
+#endif
+
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
+/* Return non-zero if c is alphanumeric. */
+#if @GNULIB_ISALNUM_L@
+# if !@HAVE_ISALNUM_L@
+_GL_FUNCDECL_SYS (isalnum_l, int, (int c, locale_t locale),
+ _GL_ARG_NONNULL ((2)));
+# endif
+_GL_CXXALIAS_SYS (isalnum_l, int, (int c, locale_t locale));
+_GL_CXXALIASWARN (isalnum_l);
+#elif defined GNULIB_POSIXCHECK
+# undef isalnum_l
+# if HAVE_RAW_DECL_ISALNUM_L
+_GL_WARN_ON_USE (isalnum_l, "isalnum_l is unportable - "
+ "use gnulib module isalnum_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@
#endif
#endif /* _@GUARD_PREFIX@_CTYPE_H */
+#endif
#endif /* _@GUARD_PREFIX@_CTYPE_H */
--- /dev/null
+/* Test whether a single-byte character belongs to a specific character class.
+ 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 <locale.h>
+#include <stdio.h>
+
+int
+FUNC (int c, locale_t locale)
+{
+ struct gl_locale_category_t *plc =
+ &locale->category[gl_log2_lc_mask (LC_CTYPE)];
+ if (plc->is_c_locale)
+ /* Implementation for the "C" locale. */
+ return C_FUNC (c);
+#if HAVE_WINDOWS_LOCALE_T
+# ifdef __MINGW32__
+ /* mingw mistreats EOF by casting the argument to 'unsigned char'.
+ <https://sourceforge.net/p/mingw-w64/mingw-w64/ci/b633824ecafdf52a76e6a205e6776b182978720d> */
+ if (c == EOF)
+ return 0;
+# endif
+ return WINDOWS_FUNC (c, plc->system_locale);
+#else
+ /* Implementation for the global locale. */
+ {
+ int ret;
+# if HAVE_WORKING_USELOCALE
+ locale_t saved_locale = uselocale (LC_GLOBAL_LOCALE);
+# endif
+ ret = GLOBAL_FUNC (c);
+# if HAVE_WORKING_USELOCALE
+ uselocale (saved_locale);
+# endif
+ return ret;
+ }
+#endif
+}
--- /dev/null
+/* Test whether a single-byte character is alphanumeric.
+ 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 isalnum_l
+#define GLOBAL_FUNC isalnum
+#define C_FUNC(c) \
+ ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'))
+/* Documentation:
+ <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/isalnum-iswalnum-isalnum-l-iswalnum-l> */
+#define WINDOWS_FUNC _isalnum_l
+#include "is_l-impl.h"
# ctype_h.m4
-# serial 9
+# serial 10
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 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>
- ]], [isblank])
+ ]], [isalnum_l isblank])
])
# gl_CTYPE_MODULE_INDICATOR([modulename])
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_ISBLANK])
])
m4_require(GL_MODULE_INDICATOR_PREFIX[_CTYPE_H_MODULE_INDICATOR_DEFAULTS])
AC_DEFUN([gl_CTYPE_H_DEFAULTS],
[
dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_ISBLANK=1; AC_SUBST([HAVE_ISBLANK])
+ HAVE_ISALNUM_L=1; AC_SUBST([HAVE_ISALNUM_L])
+ HAVE_ISBLANK=1; AC_SUBST([HAVE_ISBLANK])
])
--- /dev/null
+# isalnum_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_ISALNUM_L],
+[
+ AC_REQUIRE([gl_CTYPE_H_DEFAULTS])
+
+ dnl Persuade glibc <ctype.h> to declare isalnum_l().
+ AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+ AC_CHECK_FUNCS_ONCE([isalnum_l])
+ if test $ac_cv_func_isalnum_l = no; then
+ HAVE_ISALNUM_L=0
+ fi
+
+ dnl Prerequisites of lib/isalnum_l.c.
+ AC_REQUIRE([gt_FUNC_USELOCALE])
+])
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-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_ISBLANK''@/$(GNULIB_ISBLANK)/g' \
+ -e 's/@''HAVE_ISALNUM_L''@/$(HAVE_ISALNUM_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)' \
--- /dev/null
+Description:
+isalnum_l() function: test whether a single-byte character is alphanumeric.
+
+Files:
+lib/isalnum_l.c
+lib/is_l-impl.h
+m4/isalnum_l.m4
+m4/intl-thread-locale.m4
+
+Depends-on:
+ctype-h
+locale-h
+extensions
+
+configure.ac:
+gl_FUNC_ISALNUM_L
+gl_CONDITIONAL([GL_COND_OBJ_ISALNUM_L], [test $HAVE_ISALNUM_L = 0])
+gl_MODULE_INDICATOR([isalnum_l])
+gl_CTYPE_MODULE_INDICATOR([isalnum_l])
+
+Makefile.am:
+if GL_COND_OBJ_ISALNUM_L
+lib_SOURCES += isalnum_l.c
+endif
+
+Include:
+<ctype.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
#include "signature.h"
+#if GNULIB_TEST_ISALNUM_L
+SIGNATURE_CHECK (GNULIB_NAMESPACE::isalnum_l, int, (int, locale-t));
+#endif
+
#if 0
SIGNATURE_CHECK (GNULIB_NAMESPACE::isblank, int, (int));
#endif