]> Savannah Git Hosting - gnulib.git/commitdiff
*printf-posix: Disable support for the 'n' directive by default.
authorBruno Haible <bruno@clisp.org>
Wed, 21 Feb 2024 14:49:23 +0000 (15:49 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 21 Feb 2024 14:49:23 +0000 (15:49 +0100)
* m4/printf-with-n-directive.m4: New file.
* modules/printf-with-n-directive: New file.
* m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_IS_POSIX): If
gl_PRINTF_SUPPORT_N_DIRECTIVE is not defined, ignore the value of the
gl_cv_func_printf_directive_n variable.
* m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_IS_POSIX): Likewise.
* m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_IS_POSIX): Likewise.
* m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_IS_POSIX): Likewise.
* m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_IS_POSIX): Likewise.
* m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_IS_POSIX): Likewise.
* m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_IS_POSIX): Likewise.
* m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_IS_POSIX): Likewise.
* m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_IS_POSIX): Likewise.
* m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_IS_POSIX): If
gl_PRINTF_SUPPORT_N_DIRECTIVE is not defined, ignore the values of the
gl_cv_func_printf_directive_n and gl_cv_func_snprintf_directive_n
variables.
* m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_IS_POSIX): Likewise.
* lib/printf-parse.c (PRINTF_PARSE): If NEED_PRINTF_WITH_N_DIRECTIVE is
not defined, treat the 'n' directive like an unknown directive.
* lib/vasnprintf.c (VASNPRINTF): If NEED_PRINTF_WITH_N_DIRECTIVE is not
defined, disable the processing of the 'n' directive.
* tests/test-snprintf-posix.h (test_function): If
NEED_PRINTF_WITH_N_DIRECTIVE is not defined, skip the %n test.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-vasnprintf-posix.c (test_function): Likewise.
* tests/test-vasnwprintf-posix.c (test_function): Likewise.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* doc/posix-functions/dprintf.texi: Mention that support for the 'n'
directive is only enabled together with the module
'printf-with-n-directive'.
* 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/obstack_printf.texi: Likewise.
* doc/glibc-functions/obstack_vprintf.texi: Likewise.
* NEWS: Mention the change.

34 files changed:
ChangeLog
NEWS
doc/glibc-functions/obstack_printf.texi
doc/glibc-functions/obstack_vprintf.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/printf-parse.c
lib/vasnprintf.c
m4/dprintf-posix.m4
m4/fprintf-posix.m4
m4/obstack-printf-posix.m4
m4/printf-with-n-directive.m4 [new file with mode: 0644]
m4/snprintf-posix.m4
m4/sprintf-posix.m4
m4/vasnprintf-posix.m4
m4/vasprintf-posix.m4
m4/vdprintf-posix.m4
m4/vfprintf-posix.m4
m4/vsnprintf-posix.m4
m4/vsprintf-posix.m4
modules/printf-with-n-directive [new file with mode: 0644]
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-vasnprintf-posix.c
tests/test-vasnwprintf-posix.c
tests/test-vasprintf-posix.c

index 766d4c798dfa6441bd968978303879a60ac51240..9779a09ac613a854f25fb28989f13aac958d84d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,50 @@
+2024-02-21  Bruno Haible  <bruno@clisp.org>
+
+       *printf-posix: Disable support for the 'n' directive by default.
+       * m4/printf-with-n-directive.m4: New file.
+       * modules/printf-with-n-directive: New file.
+       * m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_IS_POSIX): If
+       gl_PRINTF_SUPPORT_N_DIRECTIVE is not defined, ignore the value of the
+       gl_cv_func_printf_directive_n variable.
+       * m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_IS_POSIX): Likewise.
+       * m4/obstack-printf-posix.m4 (gl_FUNC_OBSTACK_PRINTF_IS_POSIX): Likewise.
+       * m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_IS_POSIX): Likewise.
+       * m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_IS_POSIX): Likewise.
+       * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_IS_POSIX): Likewise.
+       * m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_IS_POSIX): Likewise.
+       * m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_IS_POSIX): Likewise.
+       * m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_IS_POSIX): Likewise.
+       * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_IS_POSIX): If
+       gl_PRINTF_SUPPORT_N_DIRECTIVE is not defined, ignore the values of the
+       gl_cv_func_printf_directive_n and gl_cv_func_snprintf_directive_n
+       variables.
+       * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_IS_POSIX): Likewise.
+       * lib/printf-parse.c (PRINTF_PARSE): If NEED_PRINTF_WITH_N_DIRECTIVE is
+       not defined, treat the 'n' directive like an unknown directive.
+       * lib/vasnprintf.c (VASNPRINTF): If NEED_PRINTF_WITH_N_DIRECTIVE is not
+       defined, disable the processing of the 'n' directive.
+       * tests/test-snprintf-posix.h (test_function): If
+       NEED_PRINTF_WITH_N_DIRECTIVE is not defined, skip the %n test.
+       * tests/test-sprintf-posix.h (test_function): Likewise.
+       * tests/test-vasnprintf-posix.c (test_function): Likewise.
+       * tests/test-vasnwprintf-posix.c (test_function): Likewise.
+       * tests/test-vasprintf-posix.c (test_function): Likewise.
+       * doc/posix-functions/dprintf.texi: Mention that support for the 'n'
+       directive is only enabled together with the module
+       'printf-with-n-directive'.
+       * 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/obstack_printf.texi: Likewise.
+       * doc/glibc-functions/obstack_vprintf.texi: Likewise.
+       * NEWS: Mention the change.
+
 2024-02-21  Bruno Haible  <bruno@clisp.org>
 
        *printf-posix: Avoid crash in another configure test.
diff --git a/NEWS b/NEWS
index ed9b2e6569a62f7f0592c2437bd80e3d39bd5d08..6caf3ad8e1eceaa227e2ddcda7ca11c6ebe5a839 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,11 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2024-02-21  *printf-posix   These modules no longer support the 'n' directive
+                            by default.  In order to keep the 'n' directive
+                            enabled, you need to additionally request the
+                            module 'printf-with-n-directive'.
+
 2024-02-09  strftime        This module, deprecated on 2017-07-23, is removed.
                             Use module 'nstrftime' instead.
 
@@ -812,15 +817,15 @@ Date        Modules         Changes
 2009-06-25  fpurge          The include file is changed from "fpurge.h" to
                             <stdio.h>.
 
-2009-04-26  modules/uniconv/u8-conv-from-enc
-            modules/uniconv/u16-conv-from-enc
-            modules/uniconv/u32-conv-from-enc
+2009-04-26  uniconv/u8-conv-from-enc
+            uniconv/u16-conv-from-enc
+            uniconv/u32-conv-from-enc
                             The calling convention of the functions
                             u*_conv_from_encoding is changed.
 
-2009-04-26  modules/uniconv/u8-conv-to-enc
-            modules/uniconv/u16-conv-to-enc
-            modules/uniconv/u32-conv-to-enc
+2009-04-26  uniconv/u8-conv-to-enc
+            uniconv/u16-conv-to-enc
+            uniconv/u32-conv-to-enc
                             The calling convention of the functions
                             u*_conv_to_encoding is changed.
 
index 6cb1ad00689db590a3a68f66b9cd4ed6345ec2c9..6b1a9e6e90defa94f1c55b5ede0930878174c943 100644 (file)
@@ -48,9 +48,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -87,9 +84,6 @@ musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 14.0, NetBSD 5.0.
-@item
-This function does not fully support the @samp{n} directive on some platforms:
-HP-UX 11, mingw, MSVC 14.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{obstack-printf-gnu}:
@@ -99,6 +93,17 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{obstack-printf-posix} or @code{obstack-printf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+MSVC 14.
+@item
+This function does not fully support the @samp{n} directive on some platforms:
+HP-UX 11, mingw, MSVC 14.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index eed1b0ef6d40248b70a3ea4213787d8b7887bb09..ad57a90f00905848ac789de76688d942819e079b 100644 (file)
@@ -48,9 +48,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -87,9 +84,6 @@ musl libc 1.2.4.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 FreeBSD 14.0, NetBSD 5.0.
-@item
-This function does not fully support the @samp{n} directive on some platforms:
-HP-UX 11, mingw, MSVC 14.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{obstack-printf-gnu}:
@@ -99,6 +93,17 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{obstack-printf-posix} or @code{obstack-printf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+MSVC 14.
+@item
+This function does not fully support the @samp{n} directive on some platforms:
+HP-UX 11, mingw, MSVC 14.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index 4a30b77663abfd26510dfb68fd2430d7cb0e5506..4b2714ced5d77da4d5cadf8d8e0a0220fe557bce 100644 (file)
@@ -35,10 +35,6 @@ on some platforms:
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, Solaris 11.4, Cygwin 2.9.0.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1.
-@item
 This function does not support precisions in the @samp{ls} directive correctly
 on some platforms:
 Solaris 11.4.
@@ -67,6 +63,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{dprintf-posix} or @code{dprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index 40d1aff463b07c07486a7beadb30ef6d3614df47..421e88b1d168bef804cd44bb187b9914e89d6a97 100644 (file)
@@ -40,10 +40,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -94,6 +90,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{fprintf-posix} or @code{fprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, MSVC 14.
+@end itemize
+
 Portability problems fixed by Gnulib module @code{stdio} or @code{fprintf-posix} or @code{fprintf-gnu}, together with module @code{nonblocking}:
 @itemize
 @item
index 4b34314630d727121ec69ebba1a9f1a84cd4146e..f6cc6f2f6728dfb2aba1a8716087882bfb8f4c22 100644 (file)
@@ -40,10 +40,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -94,6 +90,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{printf-posix} or @code{printf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, MSVC 14.
+@end itemize
+
 Portability problems fixed by Gnulib module @code{stdio} or @code{printf-posix} or @code{printf-gnu}, together with module @code{nonblocking}:
 @itemize
 @item
index 582951e55d9aa31c63ad605255fe87b67168f73d..61267260acbd9648ebb0d211786879de1744f7ae 100644 (file)
@@ -55,10 +55,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -111,6 +107,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{snprintf-posix} or @code{snprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, MSVC 14.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index d89677858342e6911165609b6a963ec3e7ce2665..b8a0b6fc1a4fd2de0bd2a845e4c2d555bf30e10d 100644 (file)
@@ -40,10 +40,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -97,6 +93,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{sprintf-posix} or @code{sprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, MSVC 14.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index 8ce6b859f48ece78c531e72d83810ffe262387f7..f3b3d3f0f805f05431530129878cbbdff0134b6a 100644 (file)
@@ -35,10 +35,6 @@ on some platforms:
 glibc 2.34, musl libc, macOS 12.5, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2,
 AIX 7.2, Solaris 11.4, Cygwin 2.9.0.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1.
-@item
 This function does not support precisions in the @samp{ls} directive correctly
 on some platforms:
 Solaris 11.4.
@@ -67,6 +63,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{vdprintf-posix} or @code{vdprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index df40d348ec0c845cb9c1f09540c14fb2d5bffa6d..bfbb39b29fc17055836aa7b6915b5c553c526988 100644 (file)
@@ -40,10 +40,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -94,6 +90,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{vfprintf-posix} or @code{vfprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, MSVC 14.
+@end itemize
+
 Portability problems fixed by Gnulib module @code{stdio} or @code{vfprintf-posix} or @code{vfprintf-gnu}, together with module @code{nonblocking}:
 @itemize
 @item
index 2c32262450b1199e3b8f028e77296c910b5cefe8..c30dc2ea15dd2ace70c954239a0d7ed6f2189270 100644 (file)
@@ -40,10 +40,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -94,6 +90,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{vprintf-posix} or @code{vprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, MSVC 14.
+@end itemize
+
 Portability problems fixed by Gnulib module @code{stdio} or @code{vprintf-posix} or @code{vprintf-gnu}, together with module @code{nonblocking}:
 @itemize
 @item
index d6005e60aaae338ee8a161114840a80291118295..b2613c9183118d401798dff7b10e3aaf58436766 100644 (file)
@@ -93,10 +93,6 @@ FreeBSD 14.0, NetBSD 5.0.
 This function does not truncate the result as specified in C99 on some platforms:
 mingw, MSVC 14.
 @item
-This function does not fully support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, HP-UX 11, mingw, MSVC 14.
-@item
 This function overwrites memory even when a zero size argument is passed on some
 platforms:
 HP-UX 11.
@@ -109,6 +105,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{vsnprintf-posix} or @code{vsnprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not fully support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, HP-UX 11, mingw, MSVC 14.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index 79058f53f43b9b5cb681015bd45b3974b8b6924b..328e8b9e96eeefea8df8c0563ca9660b0d71369b 100644 (file)
@@ -40,10 +40,6 @@ This function does not support the @samp{F} directive on some platforms:
 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
 Cygwin 1.5.x, mingw, MSVC 14.
 @item
-This function does not support the @samp{n} directive on some platforms:
-glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
-Android, OpenBSD, macOS 11.1, MSVC 14.
-@item
 This function does not support the @samp{ls} directive on some platforms:
 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
 @item
@@ -97,6 +93,15 @@ This function does not support the @samp{B} directive on some platforms:
 glibc 2.34, FreeBSD 13.2, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others.
 @end itemize
 
+Portability problems fixed by either Gnulib module @code{vsprintf-posix} or @code{vsprintf-gnu}
+and additionally the Gnulib module @code{printf-with-n-directive}:
+@itemize
+@item
+This function does not support the @samp{n} directive on some platforms:
+glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
+Android, OpenBSD, macOS 11.1, MSVC 14.
+@end itemize
+
 Portability problems not fixed by Gnulib:
 @itemize
 @item
index c0532900adf8060e48d80f5d2cdcbed290fac14c..a33e27a0b8fd60be736db9972d1bb4c7e8805078 100644 (file)
@@ -558,6 +558,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
                 cp += 3;
               }
 #endif
+            (void) pointer_type;
 
             /* Read the conversion character.  */
             c = *cp++;
@@ -616,9 +617,11 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
               case 'p':
                 type = TYPE_POINTER;
                 break;
+#if NEED_PRINTF_WITH_N_DIRECTIVE
               case 'n':
                 type = pointer_type;
                 break;
+#endif
 #if ENABLE_UNISTDIO
               /* The unistdio extensions.  */
               case 'U':
index 544ae62d9ff871b8231586b4e47da6f3ad70abd8..de20445894aab9b512c7567ac820b96448e50943 100644 (file)
@@ -2335,6 +2335,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 
             if (dp->conversion == 'n')
               {
+#if NEED_PRINTF_WITH_N_DIRECTIVE
                 switch (a.arg[dp->arg_index].type)
                   {
                   case TYPE_COUNT_SCHAR_POINTER:
@@ -2379,6 +2380,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
                   default:
                     abort ();
                   }
+#else
+                abort ();
+#endif
               }
 #if ENABLE_UNISTDIO
             /* The unistdio extensions.  */
index bfdf1552907859135ccfcf47d21fbecab62ee952..56189ca551e18e509a7a27889ae1855fa63f6cfb 100644 (file)
@@ -1,4 +1,4 @@
-# dprintf-posix.m4 serial 8
+# dprintf-posix.m4 serial 9
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -55,7 +55,7 @@ AC_DEFUN([gl_FUNC_DPRINTF_IS_POSIX],
                               *yes)
                                 case "$gl_cv_func_printf_directive_f" in
                                   *yes)
-                                    case "$gl_cv_func_printf_directive_n" in
+                                    case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                       *yes)
                                         case "$gl_cv_func_printf_directive_ls" in
                                           *yes)
index 97af45f69245816cacfaab748e5f319db9ef33fe..c23e10f953729017a44522a92860bcf9469d73a8 100644 (file)
@@ -1,4 +1,4 @@
-# fprintf-posix.m4 serial 19
+# fprintf-posix.m4 serial 20
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,7 +53,7 @@ AC_DEFUN([gl_FUNC_FPRINTF_IS_POSIX],
                             *yes)
                               case "$gl_cv_func_printf_directive_f" in
                                 *yes)
-                                  case "$gl_cv_func_printf_directive_n" in
+                                  case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                     *yes)
                                       case "$gl_cv_func_printf_directive_ls" in
                                         *yes)
index 3c5c3772631ec309aee5aea7abdde0929d1f768a..e1fc538176dd98ebbb191518ddb66e5241e80ba5 100644 (file)
@@ -1,4 +1,4 @@
-# obstack-printf-posix.m4 serial 9
+# obstack-printf-posix.m4 serial 10
 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -59,7 +59,7 @@ AC_DEFUN([gl_FUNC_OBSTACK_PRINTF_IS_POSIX],
                               *yes)
                                 case "$gl_cv_func_printf_directive_f" in
                                   *yes)
-                                    case "$gl_cv_func_printf_directive_n" in
+                                    case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                       *yes)
                                         case "$gl_cv_func_printf_directive_ls" in
                                           *yes)
diff --git a/m4/printf-with-n-directive.m4 b/m4/printf-with-n-directive.m4
new file mode 100644 (file)
index 0000000..b3b7fcb
--- /dev/null
@@ -0,0 +1,12 @@
+# printf-with-n-directive.m4 serial 1
+dnl Copyright (C) 2024 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 macro is a witness that support of the %n directive in *printf
+dnl functions is desired.
+AC_DEFUN([gl_PRINTF_SUPPORT_N_DIRECTIVE], [
+  AC_DEFINE([NEED_PRINTF_WITH_N_DIRECTIVE], [1],
+    [Define to 1 to enable support of the %n directive in *printf functions.])
+])
index 01c69cfbec6baccdac74f7355e750eb7c93a34d8..563f6aa8f797b742dc9f5d351f4351adbeebd219 100644 (file)
@@ -1,4 +1,4 @@
-# snprintf-posix.m4 serial 19
+# snprintf-posix.m4 serial 21
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -60,7 +60,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_IS_POSIX],
                               *yes)
                                 case "$gl_cv_func_printf_directive_f" in
                                   *yes)
-                                    case "$gl_cv_func_printf_directive_n" in
+                                    case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                       *yes)
                                         case "$gl_cv_func_printf_directive_ls" in
                                           *yes)
@@ -84,7 +84,7 @@ AC_DEFUN([gl_FUNC_SNPRINTF_IS_POSIX],
                                                                               *yes)
                                                                                 case "$gl_cv_func_snprintf_retval_c99" in
                                                                                   *yes)
-                                                                                    case "$gl_cv_func_snprintf_directive_n" in
+                                                                                    case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_snprintf_directive_n"],["yes"]) in
                                                                                       *yes)
                                                                                         case "$gl_cv_func_snprintf_size1" in
                                                                                           *yes)
index 09f28ded9ef2d6078510623c9fd5fbb47a8aeb85..c7ce64a1bfa530c63fd03886cca5d728c25abc7f 100644 (file)
@@ -1,4 +1,4 @@
-# sprintf-posix.m4 serial 17
+# sprintf-posix.m4 serial 18
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,7 +53,7 @@ AC_DEFUN([gl_FUNC_SPRINTF_IS_POSIX],
                             *yes)
                               case "$gl_cv_func_printf_directive_f" in
                                 *yes)
-                                  case "$gl_cv_func_printf_directive_n" in
+                                  case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                     *yes)
                                       case "$gl_cv_func_printf_directive_ls" in
                                         *yes)
index a3bd402a8107dec6ccd909be85039389540eae88..93ae256f290b607bd32a6e1a3d6118f364e508f3 100644 (file)
@@ -1,4 +1,4 @@
-# vasnprintf-posix.m4 serial 18
+# vasnprintf-posix.m4 serial 19
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,7 +53,7 @@ AC_DEFUN_ONCE([gl_FUNC_VASNPRINTF_IS_POSIX],
                             *yes)
                               case "$gl_cv_func_printf_directive_f" in
                                 *yes)
-                                  case "$gl_cv_func_printf_directive_n" in
+                                  case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                     *yes)
                                       case "$gl_cv_func_printf_directive_ls" in
                                         *yes)
index b82ccd3df78dffd7c1da3d675db1ff3f44447a29..02537f2d48dc46df1cb8442d746c073c49dbdd57 100644 (file)
@@ -1,4 +1,4 @@
-# vasprintf-posix.m4 serial 18
+# vasprintf-posix.m4 serial 19
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -54,7 +54,7 @@ AC_DEFUN([gl_FUNC_VASPRINTF_IS_POSIX],
                             *yes)
                               case "$gl_cv_func_printf_directive_f" in
                                 *yes)
-                                  case "$gl_cv_func_printf_directive_n" in
+                                  case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                     *yes)
                                       case "$gl_cv_func_printf_directive_ls" in
                                         *yes)
index d3a9f129bacfbcbcb605589cb6a3e75f5f3ba90c..84ebbabc52d105a70edacc797fc330f8f319097e 100644 (file)
@@ -1,4 +1,4 @@
-# vdprintf-posix.m4 serial 8
+# vdprintf-posix.m4 serial 9
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -55,7 +55,7 @@ AC_DEFUN([gl_FUNC_VDPRINTF_IS_POSIX],
                               *yes)
                                 case "$gl_cv_func_printf_directive_f" in
                                   *yes)
-                                    case "$gl_cv_func_printf_directive_n" in
+                                    case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                       *yes)
                                         case "$gl_cv_func_printf_directive_ls" in
                                           *yes)
index 9c53db9d423faedeceb0cd6c45e554efaad572b2..5c53a8b215c1841383958e3292d31b2fe9843d24 100644 (file)
@@ -1,4 +1,4 @@
-# vfprintf-posix.m4 serial 19
+# vfprintf-posix.m4 serial 20
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,7 +53,7 @@ AC_DEFUN([gl_FUNC_VFPRINTF_IS_POSIX],
                             *yes)
                               case "$gl_cv_func_printf_directive_f" in
                                 *yes)
-                                  case "$gl_cv_func_printf_directive_n" in
+                                  case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                     *yes)
                                       case "$gl_cv_func_printf_directive_ls" in
                                         *yes)
index 94d3d18ef97be3e2dda896efaceea0e90002f172..cec5b1af85610a0692c07a6e59bd2c545e01a4c5 100644 (file)
@@ -1,4 +1,4 @@
-# vsnprintf-posix.m4 serial 20
+# vsnprintf-posix.m4 serial 22
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -61,7 +61,7 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_IS_POSIX],
                               *yes)
                                 case "$gl_cv_func_printf_directive_f" in
                                   *yes)
-                                    case "$gl_cv_func_printf_directive_n" in
+                                    case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                       *yes)
                                         case "$gl_cv_func_printf_directive_ls" in
                                           *yes)
@@ -85,7 +85,7 @@ AC_DEFUN([gl_FUNC_VSNPRINTF_IS_POSIX],
                                                                               *yes)
                                                                                 case "$gl_cv_func_snprintf_retval_c99" in
                                                                                   *yes)
-                                                                                    case "$gl_cv_func_snprintf_directive_n" in
+                                                                                    case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_snprintf_directive_n"],["yes"]) in
                                                                                       *yes)
                                                                                         case "$gl_cv_func_snprintf_size1" in
                                                                                           *yes)
index b99ab10153716db34db084956fb9f5aa629c317f..71ea4adb2053df518584813263b849a83c30a213 100644 (file)
@@ -1,4 +1,4 @@
-# vsprintf-posix.m4 serial 17
+# vsprintf-posix.m4 serial 18
 dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,7 +53,7 @@ AC_DEFUN([gl_FUNC_VSPRINTF_IS_POSIX],
                             *yes)
                               case "$gl_cv_func_printf_directive_f" in
                                 *yes)
-                                  case "$gl_cv_func_printf_directive_n" in
+                                  case m4_ifdef([gl_PRINTF_SUPPORT_N_DIRECTIVE],["$gl_cv_func_printf_directive_n"],["yes"]) in
                                     *yes)
                                       case "$gl_cv_func_printf_directive_ls" in
                                         *yes)
diff --git a/modules/printf-with-n-directive b/modules/printf-with-n-directive
new file mode 100644 (file)
index 0000000..6a99c94
--- /dev/null
@@ -0,0 +1,26 @@
+Description:
+Enable processing of the %n directive in *printf functions.
+
+Comment:
+This module should not be used as a dependency from a test module,
+otherwise when this module occurs as a tests-related module, it will
+have side effects on the compilation of the 'vasnprintf' module, if
+that module occurs among the main modules in lib/.
+
+Files:
+m4/printf-with-n-directive.m4
+
+Depends-on:
+
+configure.ac:
+gl_PRINTF_SUPPORT_N_DIRECTIVE
+
+Makefile.am:
+
+Include:
+
+License:
+LGPLv2+
+
+Maintainer:
+all
index 99c2f8d73817f4546de129d095bca9cab0e68552..40c45db1bb67258b4b73f87a41d98404ec43770a 100644 (file)
@@ -2822,6 +2822,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 
+#if NEED_PRINTF_WITH_N_DIRECTIVE
   /* Test the support of the %n format directive.  */
 
   {
@@ -2832,6 +2833,7 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
     ASSERT (retval == strlen (result));
     ASSERT (count == 4);
   }
+#endif
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
 
index 9a0fcedae46d3249c238b5b96ef5f8c9f02c6d27..f09a17fd483f026f069b815d910133c446eb1959 100644 (file)
@@ -2808,6 +2808,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 
+#if NEED_PRINTF_WITH_N_DIRECTIVE
   /* Test the support of the %n format directive.  */
 
   {
@@ -2818,6 +2819,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
     ASSERT (retval == strlen (result));
     ASSERT (count == 4);
   }
+#endif
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
 
index 5c14b88dd129bd5cf1c5f2bff53d36b264770f8a..26a97332841d911069db3084e4597ee2b1e91c3a 100644 (file)
@@ -3630,6 +3630,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     free (result);
   }
 
+#if NEED_PRINTF_WITH_N_DIRECTIVE
   /* Test the support of the %n format directive.  */
 
   {
@@ -3643,6 +3644,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     ASSERT (count == 4);
     free (result);
   }
+#endif
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
 
index af0bb64bbb40a85c1c300ea1ec9d8318c1c9c0b0..fb6ce0fdd8a4314b5fba157a11adaefb96fdbfe7 100644 (file)
@@ -3630,6 +3630,7 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
     free (result);
   }
 
+#if NEED_PRINTF_WITH_N_DIRECTIVE
   /* Test the support of the %n format directive.  */
 
   {
@@ -3643,6 +3644,7 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
     ASSERT (count == 4);
     free (result);
   }
+#endif
 
   /* Test the support of the POSIX/XSI format strings with positions.  */
 
index bcd1077dd9d9126f2e40176acad21e08111bf619..f6f9159ddd9f27e24cc4e0c8a4a2eca6c78d076e 100644 (file)
@@ -3615,6 +3615,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     free (result);
   }
 
+#if NEED_PRINTF_WITH_N_DIRECTIVE
   /* Test the support of the %n format directive.  */
 
   {
@@ -3628,6 +3629,7 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     ASSERT (count == 4);
     free (result);
   }
+#endif
 
   /* Test the support of the POSIX/XSI format strings with positions.  */