]> Savannah Git Hosting - gnulib.git/commitdiff
*printf-posix: Revert expectations of %lc of 0.
authorBruno Haible <bruno@clisp.org>
Tue, 14 Nov 2023 13:10:57 +0000 (14:10 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 14 Nov 2023 13:10:57 +0000 (14:10 +0100)
* m4/printf.m4 (gl_PRINTF_DIRECTIVE_LC): Expect a NUL byte in the
output.
* lib/vasnprintf.c (VASNPRINTF): In the %lc implementation, don't
special-case the NUL wide character.
* tests/test-vasnprintf-posix.c (test_function): Change expected result
for %lc of L'\0'.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* doc/posix-functions/dprintf.texi: Update platform list regarding %lc
of 0 bug.
* doc/posix-functions/fprintf.texi: Likewise.
* doc/posix-functions/printf.texi: Likewise.
* doc/posix-functions/snprintf.texi: Likewise.
* doc/posix-functions/sprintf.texi: Likewise.
* doc/posix-functions/vdprintf.texi: Likewise.
* doc/posix-functions/vfprintf.texi: Likewise.
* doc/posix-functions/vprintf.texi: Likewise.
* doc/posix-functions/vsnprintf.texi: Likewise.
* doc/posix-functions/vsprintf.texi: Likewise.
* doc/glibc-functions/asprintf.texi: Likewise.
* doc/glibc-functions/vasprintf.texi: Likewise.
* doc/glibc-functions/obstack_printf.texi: Likewise.
* doc/glibc-functions/obstack_vprintf.texi: Likewise.

21 files changed:
ChangeLog
doc/glibc-functions/asprintf.texi
doc/glibc-functions/obstack_printf.texi
doc/glibc-functions/obstack_vprintf.texi
doc/glibc-functions/vasprintf.texi
doc/posix-functions/dprintf.texi
doc/posix-functions/fprintf.texi
doc/posix-functions/printf.texi
doc/posix-functions/snprintf.texi
doc/posix-functions/sprintf.texi
doc/posix-functions/vdprintf.texi
doc/posix-functions/vfprintf.texi
doc/posix-functions/vprintf.texi
doc/posix-functions/vsnprintf.texi
doc/posix-functions/vsprintf.texi
lib/vasnprintf.c
m4/printf.m4
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-vasnprintf-posix.c
tests/test-vasprintf-posix.c

index 9673099168ffa44ca04d197ec9e6e15a4f717edb..9f42fe888d73080b8f18d2eea4bba94e6ddcbce5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2023-11-14  Bruno Haible  <bruno@clisp.org>
+
+       *printf-posix: Revert expectations of %lc of 0.
+       * m4/printf.m4 (gl_PRINTF_DIRECTIVE_LC): Expect a NUL byte in the
+       output.
+       * lib/vasnprintf.c (VASNPRINTF): In the %lc implementation, don't
+       special-case the NUL wide character.
+       * tests/test-vasnprintf-posix.c (test_function): Change expected result
+       for %lc of L'\0'.
+       * tests/test-vasprintf-posix.c (test_function): Likewise.
+       * tests/test-snprintf-posix.h (test_function): Likewise.
+       * tests/test-sprintf-posix.h (test_function): Likewise.
+       * doc/posix-functions/dprintf.texi: Update platform list regarding %lc
+       of 0 bug.
+       * doc/posix-functions/fprintf.texi: Likewise.
+       * doc/posix-functions/printf.texi: Likewise.
+       * doc/posix-functions/snprintf.texi: Likewise.
+       * doc/posix-functions/sprintf.texi: Likewise.
+       * doc/posix-functions/vdprintf.texi: Likewise.
+       * doc/posix-functions/vfprintf.texi: Likewise.
+       * doc/posix-functions/vprintf.texi: Likewise.
+       * doc/posix-functions/vsnprintf.texi: Likewise.
+       * doc/posix-functions/vsprintf.texi: Likewise.
+       * doc/glibc-functions/asprintf.texi: Likewise.
+       * doc/glibc-functions/vasprintf.texi: Likewise.
+       * doc/glibc-functions/obstack_printf.texi: Likewise.
+       * doc/glibc-functions/obstack_vprintf.texi: Likewise.
+
 2023-11-13  Bruno Haible  <bruno@clisp.org>
 
        doc: Add a note.
index 19602929ccabebb9c8acbde2edf8af8d7e3e2e64..5e0cc116c991250fdc0c8ef654fdda9b510aa3b7 100644 (file)
@@ -77,7 +77,7 @@ Mac OS X 10.6.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 975b2552741c6482b75a6175ac1d38df06c1a296..5d6dae0f844cbfc3f08874804925b235b193508c 100644 (file)
@@ -83,7 +83,7 @@ Solaris 10/x86, mingw, MSVC/clang.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index a3ec3d364b412dfaf79ea404a4a4eb6546425dc6..da8ed204910834429d71300bc943838bf27a1b30 100644 (file)
@@ -83,7 +83,7 @@ Solaris 10/x86, mingw, MSVC/clang.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index b33ad91642a616b057c309bf0a9504575ee8347d..e3940baac98b9d804a03a64b14f5889a01acce59 100644 (file)
@@ -77,7 +77,7 @@ Mac OS X 10.6.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index b10939879376bd2f5609188f4c928c59c76c7406..7e787399e74d59b0fab7e07e014f977186382dd4 100644 (file)
@@ -57,7 +57,7 @@ AIX 7.1.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{dprintf-gnu}:
index 7bd9ff50d8a74e0a1d5bdddabb86ea0d45d82077..1b881e07850d547fb079e76e04a5b3b83fbc63bf 100644 (file)
@@ -81,7 +81,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 12ba645734b59abf59c9579b00fc25d2cffbac05..ea08c0f07e88bb75d1b4fb593c718d46b780bacc 100644 (file)
@@ -81,7 +81,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index f907e9cc7fb22058033602eb673663e345bfee37..aa74b9e288444933b57412fdf0fbb78190eaaf1b 100644 (file)
@@ -92,7 +92,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 2652acdebce7a01897d1e484c1244cf6e55ffff3..676190bbcf94585b4059047337b5461a0ae07ddd 100644 (file)
@@ -81,7 +81,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 22ac3d17b4d873e9cd7dd6f2ff6aa6b141b9d403..5c95dc77ecf344c36ab9bafcf805ad3922532390 100644 (file)
@@ -57,7 +57,7 @@ AIX 7.1.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{vdprintf-gnu}:
index 94bd3a75d45dc29a91f694497152d71c47fc72cf..bdf9f81795084185d71051dcb3fda7415d8738ee 100644 (file)
@@ -81,7 +81,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 8877376b91941679f2a69f3aacee706fcefe152e..7f39cca067bea05a4336d174e22a81457d0720eb 100644 (file)
@@ -81,7 +81,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 5bc943fde39bae794045fb46bba9d47d95d04e3f..b4b1ce82b52d4fc2aa346c24a710b83f8a0a973b 100644 (file)
@@ -85,7 +85,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 4e726f96b0de2f8ad51f041fe68cebfc63c02348..0160862df4b02beba0c6a341e9663430c821ee52 100644 (file)
@@ -81,7 +81,7 @@ Solaris 10.
 @item
 This function produces wrong output for the @samp{lc} directive with a NUL
 wide character argument on some platforms:
-glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
+musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 13.0, NetBSD 5.0.
index 2cfdbe97bdaa970e2b1a9f11ebc9438b02385886..06abb5afe26d6714ad7edd066ed9cce72ab058b5 100644 (file)
@@ -3424,21 +3424,18 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                     {
                       /* Count the number of bytes.  */
                       characters = 0;
-                      if (arg != 0)
-                        {
-                          char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
-                          int count;
+                      char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
+                      int count;
 # if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
-                          mbstate_t state;
-                          mbszero (&state);
+                      mbstate_t state;
+                      mbszero (&state);
 # endif
 
-                          count = local_wcrtomb (cbuf, arg, &state);
-                          if (count < 0)
-                            /* Cannot convert.  */
-                            goto fail_with_EILSEQ;
-                          characters = count;
-                        }
+                      count = local_wcrtomb (cbuf, arg, &state);
+                      if (count < 0)
+                        /* Cannot convert.  */
+                        goto fail_with_EILSEQ;
+                      characters = count;
                     }
 # if DCHAR_IS_TCHAR
                   else
@@ -3450,7 +3447,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 
 # if !DCHAR_IS_TCHAR
                   /* Convert the string into a piece of temporary memory.  */
-                  if (characters > 0) /* implies arg != 0 */
+                  if (characters > 0)
                     {
                       char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
                       int count;
@@ -3507,7 +3504,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                     {
                       /* We know the number of bytes in advance.  */
                       ENSURE_ALLOCATION (xsum (length, characters));
-                      if (characters > 0) /* implies arg != 0 */
+                      if (characters > 0)
                         {
                           int count;
 #  if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
@@ -3524,23 +3521,20 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                     }
                   else
                     {
-                      if (arg != 0)
-                        {
-                          char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
-                          int count;
+                      char cbuf[64]; /* Assume MB_CUR_MAX <= 64.  */
+                      int count;
 #  if HAVE_WCRTOMB && !defined GNULIB_defined_mbstate_t
-                          mbstate_t state;
-                          mbszero (&state);
+                      mbstate_t state;
+                      mbszero (&state);
 #  endif
 
-                          count = local_wcrtomb (cbuf, arg, &state);
-                          if (count < 0)
-                            /* Cannot convert.  */
-                            goto fail_with_EILSEQ;
-                          ENSURE_ALLOCATION (xsum (length, count));
-                          memcpy (result + length, cbuf, count);
-                          length += count;
-                        }
+                      count = local_wcrtomb (cbuf, arg, &state);
+                      if (count < 0)
+                        /* Cannot convert.  */
+                        goto fail_with_EILSEQ;
+                      ENSURE_ALLOCATION (xsum (length, count));
+                      memcpy (result + length, cbuf, count);
+                      length += count;
                     }
 # else
                   ENSURE_ALLOCATION_ELSE (xsum (length, tmpdst_len),
index 729847b0aabf42721d023b9ea5b0aeedcbe84ce1..bf0f7ecab4fb59f447d8fb367581cbe7b97eaf75 100644 (file)
@@ -1,4 +1,4 @@
-# printf.m4 serial 87
+# printf.m4 serial 88
 dnl Copyright (C) 2003, 2007-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,
@@ -1032,7 +1032,8 @@ changequote([,])dnl
 
 dnl Test whether the *printf family of functions supports the %lc format
 dnl directive and in particular, when the argument is a null wide character,
-dnl whether the functions don't produce a NUL byte.
+dnl whether the functions produce a NUL byte, as specified in ISO C 23
+dnl after the issue GB-141 was fixed.
 dnl Result is gl_cv_func_printf_directive_lc.
 
 AC_DEFUN([gl_PRINTF_DIRECTIVE_LC],
@@ -1051,13 +1052,11 @@ int main ()
 {
   int result = 0;
   char buf[100];
-  /* This test fails on glibc 2.35, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2,
-     macOS 12.5, AIX 7.2, Solaris 11.4.
-     glibc 2.35 bug: <https://sourceware.org/bugzilla/show_bug.cgi?id=30257>  */
+  /* This test fails on musl libc 1.2.4.  */
   {
     buf[0] = '\0';
     if (sprintf (buf, "%lc%lc%lc", (wint_t) 'a', (wint_t) 0, (wint_t) 'z') < 0
-        || strcmp (buf, "az") != 0)
+        || memcmp (buf, "a\0z", 4) != 0)
       result |= 1;
   }
   return result;
@@ -1067,10 +1066,10 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-                               # Guess yes on musl libc.
-           *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing yes";;
-                               # Guess no otherwise.
-           *)                  gl_cv_func_printf_directive_lc="guessing no";;
+                               # Guess no on musl libc.
+           *-musl* | midipix*) gl_cv_func_printf_directive_lc="guessing no";;
+                               # Guess yes otherwise.
+           *)                  gl_cv_func_printf_directive_lc="guessing yes";;
          esac
 changequote([,])dnl
         ])
@@ -2172,39 +2171,39 @@ dnl
 dnl . = yes, # = no.
 dnl
 dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
-dnl   musl libc 1.2.3                .  #  .  .  .  .  #  #  .  .  .  .  .  .  .  .  ?  .  .  .  .  .  .  .  .  #  .  #
-dnl   glibc 2.35                     .  #  .  .  .  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   glibc 2.5                      .  #  .  .  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .
-dnl   glibc 2.3.6                    .  #  .  .  .  #  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .
-dnl   FreeBSD 13.0                   .  #  .  .  .  #  #  #  .  .  .  #  .  .  .  .  .  .  #  .  .  .  .  .  .  #  .  #
-dnl   FreeBSD 5.4, 6.1               .  #  .  .  .  #  #  #  .  .  .  #  .  .  .  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
-dnl   Mac OS X 10.13.5               .  #  .  .  #  #  #  #  .  #  .  #  .  .  .  .  .  .  .  .  .  .  #  .  .  #  ?  ?
-dnl   Mac OS X 10.5.8                .  #  .  .  #  #  #  #  .  .  .  #  .  .  .  #  #  .  .  .  .  .  .  .  .  #  ?  ?
-dnl   Mac OS X 10.3.9                .  #  .  .  .  #  #  #  .  .  .  #  .  .  .  #  #  .  #  .  .  .  .  .  .  #  ?  ?
-dnl   OpenBSD 6.0, 6.7               .  #  .  .  .  #  #  #  .  .  .  #  .  .  .  .  .  .  #  .  .  .  .  .  .  #  .  #
-dnl   OpenBSD 3.9, 4.0               .  #  .  #  #  #  #  #  #  .  #  #  .  #  .  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
+dnl   musl libc 1.2.3                .  #  .  .  .  .  #  #  .  .  .  #  .  .  .  .  ?  .  .  .  .  .  .  .  .  #  .  #
+dnl   glibc 2.35                     .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
+dnl   glibc 2.5                      .  #  .  .  .  .  #  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .
+dnl   glibc 2.3.6                    .  #  .  .  .  #  #  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .
+dnl   FreeBSD 13.0                   .  #  .  .  .  #  #  #  .  .  .  .  .  .  .  .  .  .  #  .  .  .  .  .  .  #  .  #
+dnl   FreeBSD 5.4, 6.1               .  #  .  .  .  #  #  #  .  .  .  .  .  .  .  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
+dnl   Mac OS X 10.13.5               .  #  .  .  #  #  #  #  .  #  .  .  .  .  .  .  .  .  .  .  .  .  #  .  .  #  ?  ?
+dnl   Mac OS X 10.5.8                .  #  .  .  #  #  #  #  .  .  .  .  .  .  .  #  #  .  .  .  .  .  .  .  .  #  ?  ?
+dnl   Mac OS X 10.3.9                .  #  .  .  .  #  #  #  .  .  .  .  .  .  .  #  #  .  #  .  .  .  .  .  .  #  ?  ?
+dnl   OpenBSD 6.0, 6.7               .  #  .  .  .  #  #  #  .  .  .  .  .  .  .  .  .  .  #  .  .  .  .  .  .  #  .  #
+dnl   OpenBSD 3.9, 4.0               .  #  .  #  #  #  #  #  #  .  #  .  .  #  .  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
 dnl   Cygwin 1.7.0 (2009)            .  #  .  .  #  .  #  #  .  .  ?  ?  .  .  .  .  ?  .  ?  .  .  .  .  .  .  ?  ?  ?
 dnl   Cygwin 1.5.25 (2008)           .  #  .  .  #  #  #  #  .  .  #  ?  .  .  .  .  ?  .  #  .  .  .  .  .  .  ?  ?  ?
 dnl   Cygwin 1.5.19 (2006)           #  #  .  .  #  #  #  #  #  .  #  ?  .  #  .  #  ?  #  #  .  .  .  .  .  .  ?  ?  ?
-dnl   Solaris 11.4                   .  #  .  #  #  #  #  #  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  #  .
-dnl   Solaris 11.3                   .  #  .  .  .  #  #  #  .  .  #  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .
-dnl   Solaris 11.0                   .  #  .  #  #  #  #  #  .  .  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  ?  ?  ?
-dnl   Solaris 10                     .  #  .  #  #  #  #  #  .  .  #  #  .  .  .  #  .  #  .  .  .  .  .  .  .  .  #  .
-dnl   Solaris 2.6 ... 9              #  #  .  #  #  #  #  #  #  .  #  #  .  .  .  #  ?  #  .  .  .  #  .  .  .  ?  ?  ?
-dnl   Solaris 2.5.1                  #  #  .  #  #  #  #  #  #  .  #  #  .  .  .  #  ?  .  .  #  #  #  #  #  #  ?  ?  ?
-dnl   AIX 7.1                        .  #  .  #  #  #  #  #  .  .  .  #  .  .  .  #  .  #  .  .  .  .  .  .  .  #  .  .
-dnl   AIX 5.2                        .  #  .  #  #  #  #  #  .  .  .  #  .  .  .  #  ?  .  .  .  .  .  .  .  .  #  ?  ?
-dnl   AIX 4.3.2, 5.1                 #  #  .  #  #  #  #  #  #  .  .  #  .  .  .  #  ?  .  .  .  .  #  .  .  .  #  ?  ?
+dnl   Solaris 11.4                   .  #  .  #  #  #  #  #  .  .  #  .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  #  .
+dnl   Solaris 11.3                   .  #  .  .  .  #  #  #  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .
+dnl   Solaris 11.0                   .  #  .  #  #  #  #  #  .  .  #  .  .  .  .  #  .  .  .  .  .  .  .  .  .  ?  ?  ?
+dnl   Solaris 10                     .  #  .  #  #  #  #  #  .  .  #  .  .  .  .  #  .  #  .  .  .  .  .  .  .  .  #  .
+dnl   Solaris 2.6 ... 9              #  #  .  #  #  #  #  #  #  .  #  .  .  .  .  #  ?  #  .  .  .  #  .  .  .  ?  ?  ?
+dnl   Solaris 2.5.1                  #  #  .  #  #  #  #  #  #  .  #  .  .  .  .  #  ?  .  .  #  #  #  #  #  #  ?  ?  ?
+dnl   AIX 7.1                        .  #  .  #  #  #  #  #  .  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .  .  #  .  .
+dnl   AIX 5.2                        .  #  .  #  #  #  #  #  .  .  .  .  .  .  .  #  ?  .  .  .  .  .  .  .  .  #  ?  ?
+dnl   AIX 4.3.2, 5.1                 #  #  .  #  #  #  #  #  #  .  .  .  .  .  .  #  ?  .  .  .  .  #  .  .  .  #  ?  ?
 dnl   HP-UX 11.31                    .  #  .  .  .  #  #  #  .  .  .  ?  .  .  .  #  ?  .  .  .  .  #  #  .  .  ?  ?  ?
 dnl   HP-UX 11.{00,11,23}            #  #  .  .  .  #  #  #  #  .  .  ?  .  .  .  #  ?  .  .  .  .  #  #  .  #  ?  ?  ?
 dnl   HP-UX 10.20                    #  #  .  #  .  #  #  #  #  .  ?  ?  .  .  #  #  ?  .  .  .  .  #  #  ?  #  ?  ?  ?
-dnl   IRIX 6.5                       #  #  .  #  #  #  #  #  #  .  #  #  .  .  .  #  ?  .  .  .  .  #  .  .  .  #  ?  ?
+dnl   IRIX 6.5                       #  #  .  #  #  #  #  #  #  .  #  .  .  .  .  #  ?  .  .  .  .  #  .  .  .  #  ?  ?
 dnl   OSF/1 5.1                      #  #  .  #  #  #  #  #  #  .  .  ?  .  .  .  #  ?  .  .  .  .  #  .  .  #  ?  ?  ?
 dnl   OSF/1 4.0d                     #  #  .  #  #  #  #  #  #  .  .  ?  .  .  .  #  ?  .  .  #  #  #  #  #  #  ?  ?  ?
-dnl   NetBSD 9.0                     .  #  .  .  .  #  #  #  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .  #
-dnl   NetBSD 5.0                     .  #  .  .  #  #  #  #  .  .  .  #  .  .  .  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
-dnl   NetBSD 4.0                     .  #  ?  ?  ?  ?  #  #  ?  .  ?  #  .  ?  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?  #  ?  ?
-dnl   NetBSD 3.0                     .  #  .  .  .  #  #  #  #  .  ?  #  #  #  ?  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
+dnl   NetBSD 9.0                     .  #  .  .  .  #  #  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  #  .  #
+dnl   NetBSD 5.0                     .  #  .  .  #  #  #  #  .  .  .  .  .  .  .  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
+dnl   NetBSD 4.0                     .  #  ?  ?  ?  ?  #  #  ?  .  ?  .  .  ?  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?  #  ?  ?
+dnl   NetBSD 3.0                     .  #  .  .  .  #  #  #  #  .  ?  .  #  #  ?  #  ?  .  #  .  .  .  .  .  .  #  ?  ?
 dnl   Haiku                          .  #  .  .  #  #  #  #  #  .  #  ?  .  .  .  .  ?  .  ?  .  .  ?  .  .  .  .  #  .
 dnl   BeOS                           #  #  #  .  #  #  #  #  #  .  ?  ?  #  .  ?  .  ?  #  ?  .  .  ?  .  .  .  ?  ?  ?
 dnl   Android 4.3                    .  #  .  #  #  #  #  #  #  #  #  ?  .  #  .  #  ?  .  #  .  .  .  #  .  .  ?  ?  ?
index 748b2775a6fb8a3d2710964f6d141e096c6f2e9e..3c15f11d4a920fd708c1811b9742b7bc3d717e72 100644 (file)
@@ -3184,11 +3184,14 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
     int retval =
       my_snprintf (result, sizeof (result),
                    "a%lcz %d", (wint_t) L'\0', 33, 44, 55);
-    /* No NUL byte between 'a' and 'z'.  This is surprising, but is a
-       consequence of how POSIX:2018 and ISO C 23 specify the handling
-       of %lc.  */
-    ASSERT (memcmp (result, "az 33\0", 5 + 1) == 0);
-    ASSERT (retval == 5);
+    /* ISO C had this wrong for decades.  ISO C 23 now corrects it, through
+       this wording:
+       "If an l length modifier is present, the wint_t argument is converted
+        as if by a call to the wcrtomb function with a pointer to storage of
+        at least MB_CUR_MAX bytes, the wint_t argument converted to wchar_t,
+        and an initial shift state."  */
+    ASSERT (memcmp (result, "a\0z 33\0", 6 + 1) == 0);
+    ASSERT (retval == 6);
   }
 
   static wint_t L_invalid = (wchar_t) 0x76543210;
index aabd182a8be6589188231e0ecc96912cf6322d8c..9a1e0c380d492fe2f34aec85b51af8217d426b3a 100644 (file)
@@ -3162,11 +3162,14 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
   { /* NUL character.  */
     int retval =
       my_sprintf (result, "a%lcz %d", (wint_t) L'\0', 33, 44, 55);
-    /* No NUL byte between 'a' and 'z'.  This is surprising, but is a
-       consequence of how POSIX:2018 and ISO C 23 specify the handling
-       of %lc.  */
-    ASSERT (memcmp (result, "az 33\0", 5 + 1) == 0);
-    ASSERT (retval == 5);
+    /* ISO C had this wrong for decades.  ISO C 23 now corrects it, through
+       this wording:
+       "If an l length modifier is present, the wint_t argument is converted
+        as if by a call to the wcrtomb function with a pointer to storage of
+        at least MB_CUR_MAX bytes, the wint_t argument converted to wchar_t,
+        and an initial shift state."  */
+    ASSERT (memcmp (result, "a\0z 33\0", 6 + 1) == 0);
+    ASSERT (retval == 6);
   }
 
   static wint_t L_invalid = (wchar_t) 0x76543210;
index 92b61b1329d58ecac187f39cef4c607517e35fec..5124138c56fca6a57f9733daa81e90f62a67463e 100644 (file)
@@ -4139,11 +4139,14 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     size_t length;
     char *result =
       my_asnprintf (NULL, &length, "a%lcz %d", (wint_t) L'\0', 33, 44, 55);
-    /* No NUL byte between 'a' and 'z'.  This is surprising, but is a
-       consequence of how POSIX:2018 and ISO C 23 specify the handling
-       of %lc.  */
-    ASSERT (memcmp (result, "az 33\0", 5 + 1) == 0);
-    ASSERT (length == 5);
+    /* ISO C had this wrong for decades.  ISO C 23 now corrects it, through
+       this wording:
+       "If an l length modifier is present, the wint_t argument is converted
+        as if by a call to the wcrtomb function with a pointer to storage of
+        at least MB_CUR_MAX bytes, the wint_t argument converted to wchar_t,
+        and an initial shift state."  */
+    ASSERT (memcmp (result, "a\0z 33\0", 6 + 1) == 0);
+    ASSERT (length == 6);
     free (result);
   }
 
index 3499451745c08e5d7550f5a51f46a469daa40941..00a3b047c3cd0393a1515e5cecb48190748ec921 100644 (file)
@@ -4078,11 +4078,14 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     char *result;
     int retval =
       my_asprintf (&result, "a%lcz %d", (wint_t) L'\0', 33, 44, 55);
-    /* No NUL byte between 'a' and 'z'.  This is surprising, but is a
-       consequence of how POSIX:2018 and ISO C 23 specify the handling
-       of %lc.  */
-    ASSERT (memcmp (result, "az 33\0", 5 + 1) == 0);
-    ASSERT (retval == 5);
+    /* ISO C had this wrong for decades.  ISO C 23 now corrects it, through
+       this wording:
+       "If an l length modifier is present, the wint_t argument is converted
+        as if by a call to the wcrtomb function with a pointer to storage of
+        at least MB_CUR_MAX bytes, the wint_t argument converted to wchar_t,
+        and an initial shift state."  */
+    ASSERT (memcmp (result, "a\0z 33\0", 6 + 1) == 0);
+    ASSERT (retval == 6);
     free (result);
   }