On AIX, I noticed that GNULIB_defined_mbstate_t gets defined to 1 by the mbrtowc module, but when I compile the c32is* modules standalone, it does not get defined. However, the implementation of these modules depends on GNULIB_defined_mbstate_t, to ensure consistency with mbrtoc32 and mbrtowc.
This could cause problems in a package that invokes gnulib-tool several times, because then GNULIB_defined_mbstate_t is not consistent across compilation units. This set of patches fixes it. 2023-04-09 Bruno Haible <br...@clisp.org> c32is*: Ensure GNULIB_defined_mbstate_t is defined on AIX. * m4/mbrtowc.m4 (gl_MBSTATE_T_BROKEN): Define through AC_DEFUN_ONCE. * m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32): Require it. * modules/c32isalnum (Files): Add m4/mbrtowc.m4, m4/locale-ja.m4. (configure.ac): Require gl_MBSTATE_T_BROKEN. * modules/c32isalpha: Likewise. * modules/c32isblank: Likewise. * modules/c32iscntrl: Likewise. * modules/c32isdigit: Likewise. * modules/c32isgraph: Likewise. * modules/c32islower: Likewise. * modules/c32isprint: Likewise. * modules/c32ispunct: Likewise. * modules/c32isspace: Likewise. * modules/c32isupper: Likewise. * modules/c32isxdigit: Likewise. 2023-04-09 Bruno Haible <br...@clisp.org> mbrtoc32: Add comments. * lib/mbrtoc32.c: Add comment regarding AIX. * m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32): Add comment regarding GNULIB_defined_mbstate_t.
>From 70f1f0e64c1c1d722cb60560b76e4aef3f5d8d61 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 9 Apr 2023 18:02:51 +0200 Subject: [PATCH 1/6] mbrtoc32: Add comments. * lib/mbrtoc32.c: Add comment regarding AIX. * m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32): Add comment regarding GNULIB_defined_mbstate_t. --- ChangeLog | 7 +++++++ lib/mbrtoc32.c | 7 +++++++ m4/mbrtoc32.m4 | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d13727e2eb..9a62ffa171 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-04-09 Bruno Haible <br...@clisp.org> + + mbrtoc32: Add comments. + * lib/mbrtoc32.c: Add comment regarding AIX. + * m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32): Add comment regarding + GNULIB_defined_mbstate_t. + 2023-04-09 Bruno Haible <br...@clisp.org> doc: Mention a NetBSD bug. diff --git a/lib/mbrtoc32.c b/lib/mbrtoc32.c index bd90132086..2dca9e1e50 100644 --- a/lib/mbrtoc32.c +++ b/lib/mbrtoc32.c @@ -30,6 +30,13 @@ /* Implement mbrtoc32() on top of mbtowc() for the non-UTF-8 locales and directly for the UTF-8 locales. */ +/* Note: On AIX (64-bit) we can implement mbrtoc32 in two equivalent ways: + - in a way that parallels the override of mbrtowc; this is the code branch + here; + - in a way that invokes the overridden mbrtowc; this would be the #else + branch below. + They are equivalent. */ + # if defined _WIN32 && !defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN /* avoid including junk */ diff --git a/m4/mbrtoc32.m4 b/m4/mbrtoc32.m4 index acbd7f537c..ed0234fbc0 100644 --- a/m4/mbrtoc32.m4 +++ b/m4/mbrtoc32.m4 @@ -1,4 +1,4 @@ -# mbrtoc32.m4 serial 12 +# mbrtoc32.m4 serial 13 dnl Copyright (C) 2014-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,6 +9,9 @@ AC_DEFUN([gl_FUNC_MBRTOC32] AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) AC_REQUIRE([AC_TYPE_MBSTATE_T]) + dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is + dnl determined. It describes how our overridden mbrtowc is implemented. + dnl We then implement mbrtoc32 accordingly. gl_MBSTATE_T_BROKEN AC_REQUIRE([gl_TYPE_CHAR32_T]) -- 2.34.1
>From d822a76da0101d6a789943862d960812c3a0c09a Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 9 Apr 2023 18:14:46 +0200 Subject: [PATCH 2/6] c32is*: Ensure GNULIB_defined_mbstate_t is defined on AIX. * m4/mbrtowc.m4 (gl_MBSTATE_T_BROKEN): Define through AC_DEFUN_ONCE. * m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32): Require it. * modules/c32isalnum (Files): Add m4/mbrtowc.m4, m4/locale-ja.m4. (configure.ac): Require gl_MBSTATE_T_BROKEN. * modules/c32isalpha: Likewise. * modules/c32isblank: Likewise. * modules/c32iscntrl: Likewise. * modules/c32isdigit: Likewise. * modules/c32isgraph: Likewise. * modules/c32islower: Likewise. * modules/c32isprint: Likewise. * modules/c32ispunct: Likewise. * modules/c32isspace: Likewise. * modules/c32isupper: Likewise. * modules/c32isxdigit: Likewise. --- ChangeLog | 19 +++++++++++++++++++ m4/mbrtoc32.m4 | 4 ++-- m4/mbrtowc.m4 | 4 ++-- modules/c32isalnum | 5 +++++ modules/c32isalpha | 5 +++++ modules/c32isblank | 5 +++++ modules/c32iscntrl | 5 +++++ modules/c32isdigit | 5 +++++ modules/c32isgraph | 5 +++++ modules/c32islower | 5 +++++ modules/c32isprint | 5 +++++ modules/c32ispunct | 5 +++++ modules/c32isspace | 5 +++++ modules/c32isupper | 5 +++++ modules/c32isxdigit | 5 +++++ 15 files changed, 83 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a62ffa171..ea2857a38c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2023-04-09 Bruno Haible <br...@clisp.org> + + c32is*: Ensure GNULIB_defined_mbstate_t is defined on AIX. + * m4/mbrtowc.m4 (gl_MBSTATE_T_BROKEN): Define through AC_DEFUN_ONCE. + * m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32): Require it. + * modules/c32isalnum (Files): Add m4/mbrtowc.m4, m4/locale-ja.m4. + (configure.ac): Require gl_MBSTATE_T_BROKEN. + * modules/c32isalpha: Likewise. + * modules/c32isblank: Likewise. + * modules/c32iscntrl: Likewise. + * modules/c32isdigit: Likewise. + * modules/c32isgraph: Likewise. + * modules/c32islower: Likewise. + * modules/c32isprint: Likewise. + * modules/c32ispunct: Likewise. + * modules/c32isspace: Likewise. + * modules/c32isupper: Likewise. + * modules/c32isxdigit: Likewise. + 2023-04-09 Bruno Haible <br...@clisp.org> mbrtoc32: Add comments. diff --git a/m4/mbrtoc32.m4 b/m4/mbrtoc32.m4 index ed0234fbc0..b53636236c 100644 --- a/m4/mbrtoc32.m4 +++ b/m4/mbrtoc32.m4 @@ -1,4 +1,4 @@ -# mbrtoc32.m4 serial 13 +# mbrtoc32.m4 serial 14 dnl Copyright (C) 2014-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_MBRTOC32] dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is dnl determined. It describes how our overridden mbrtowc is implemented. dnl We then implement mbrtoc32 accordingly. - gl_MBSTATE_T_BROKEN + AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_TYPE_CHAR32_T]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 0c7a8bae69..893faff637 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -1,4 +1,4 @@ -# mbrtowc.m4 serial 39 -*- coding: utf-8 -*- +# mbrtowc.m4 serial 40 -*- coding: utf-8 -*- dnl Copyright (C) 2001-2002, 2004-2005, 2008-2023 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -117,7 +117,7 @@ AC_DEFUN([gl_FUNC_MBRTOWC] dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to dnl avoid inconsistencies. -AC_DEFUN([gl_MBSTATE_T_BROKEN], +AC_DEFUN_ONCE([gl_MBSTATE_T_BROKEN], [ AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) diff --git a/modules/c32isalnum b/modules/c32isalnum index 41c8727f22..55719b534c 100644 --- a/modules/c32isalnum +++ b/modules/c32isalnum @@ -5,7 +5,9 @@ Files: lib/c32isalnum.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isalnum]) diff --git a/modules/c32isalpha b/modules/c32isalpha index 486b7cd0c5..cd33949d54 100644 --- a/modules/c32isalpha +++ b/modules/c32isalpha @@ -5,7 +5,9 @@ Files: lib/c32isalpha.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isalpha]) diff --git a/modules/c32isblank b/modules/c32isblank index f38de16016..b99f347074 100644 --- a/modules/c32isblank +++ b/modules/c32isblank @@ -5,7 +5,9 @@ Files: lib/c32isblank.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -21,6 +23,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isblank]) diff --git a/modules/c32iscntrl b/modules/c32iscntrl index b7a15bcd5e..3b789e0f94 100644 --- a/modules/c32iscntrl +++ b/modules/c32iscntrl @@ -5,7 +5,9 @@ Files: lib/c32iscntrl.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32iscntrl]) diff --git a/modules/c32isdigit b/modules/c32isdigit index 67c253ad25..823b1c8dac 100644 --- a/modules/c32isdigit +++ b/modules/c32isdigit @@ -5,7 +5,9 @@ Files: lib/c32isdigit.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -21,6 +23,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isdigit]) diff --git a/modules/c32isgraph b/modules/c32isgraph index 39b7bfe817..e39affd97f 100644 --- a/modules/c32isgraph +++ b/modules/c32isgraph @@ -5,7 +5,9 @@ Files: lib/c32isgraph.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isgraph]) diff --git a/modules/c32islower b/modules/c32islower index c69cc49876..48c35548b1 100644 --- a/modules/c32islower +++ b/modules/c32islower @@ -5,7 +5,9 @@ Files: lib/c32islower.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32islower]) diff --git a/modules/c32isprint b/modules/c32isprint index 6c147902c5..290ee094ae 100644 --- a/modules/c32isprint +++ b/modules/c32isprint @@ -5,7 +5,9 @@ Files: lib/c32isprint.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isprint]) diff --git a/modules/c32ispunct b/modules/c32ispunct index 932978c5a2..d828130fa2 100644 --- a/modules/c32ispunct +++ b/modules/c32ispunct @@ -6,7 +6,9 @@ Files: lib/c32ispunct.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -21,6 +23,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32ispunct]) diff --git a/modules/c32isspace b/modules/c32isspace index c1a3cd43ae..86132cecf2 100644 --- a/modules/c32isspace +++ b/modules/c32isspace @@ -5,7 +5,9 @@ Files: lib/c32isspace.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isspace]) diff --git a/modules/c32isupper b/modules/c32isupper index 7a51f1cf85..0efe245522 100644 --- a/modules/c32isupper +++ b/modules/c32isupper @@ -5,7 +5,9 @@ Files: lib/c32isupper.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -20,6 +22,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isupper]) diff --git a/modules/c32isxdigit b/modules/c32isxdigit index e958285ee1..11616c2e71 100644 --- a/modules/c32isxdigit +++ b/modules/c32isxdigit @@ -6,7 +6,9 @@ Files: lib/c32isxdigit.c lib/c32is-impl.h m4/mbrtoc32.m4 +m4/mbrtowc.m4 m4/locale-fr.m4 +m4/locale-ja.m4 m4/locale-zh.m4 m4/codeset.m4 @@ -22,6 +24,9 @@ assert-h configure.ac: AC_REQUIRE([gl_UCHAR_H]) +dnl Determine REPLACE_MBSTATE_T, from which GNULIB_defined_mbstate_t is +dnl determined. It describes how mbrtoc32 is implemented. +AC_REQUIRE([gl_MBSTATE_T_BROKEN]) AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) gl_UCHAR_MODULE_INDICATOR([c32isxdigit]) -- 2.34.1