From 891708e6f2a0d348660f45102958b27f5fce3c2c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 24 Mar 2023 11:28:38 +0100 Subject: [PATCH] vasprintf-gnu: New module. * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_IS_POSIX): New macro, extracted from gl_FUNC_VASPRINTF_POSIX. (gl_FUNC_VASPRINTF_POSIX): Require it. Invoke gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS. * m4/vasprintf-gnu.m4: New file, based on m4/vasprintf-posix.m4. * modules/vasprintf-gnu: New file, based on modules/vasnprintf-gnu. * doc/glibc-functions/vasprintf.texi: Mention the new module. * doc/glibc-functions/asprintf.texi: Likewise. --- ChangeLog | 12 ++++++++++++ doc/glibc-functions/asprintf.texi | 13 ++++++++++--- doc/glibc-functions/vasprintf.texi | 13 ++++++++++--- m4/vasprintf-gnu.m4 | 25 ++++++++++++++++++++++++ m4/vasprintf-posix.m4 | 31 +++++++++++++----------------- modules/vasprintf-gnu | 28 +++++++++++++++++++++++++++ 6 files changed, 98 insertions(+), 24 deletions(-) create mode 100644 m4/vasprintf-gnu.m4 create mode 100644 modules/vasprintf-gnu diff --git a/ChangeLog b/ChangeLog index d9421f29bf..4810cf6291 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2023-03-24 Bruno Haible + + vasprintf-gnu: New module. + * m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_IS_POSIX): New macro, + extracted from gl_FUNC_VASPRINTF_POSIX. + (gl_FUNC_VASPRINTF_POSIX): Require it. Invoke + gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS. + * m4/vasprintf-gnu.m4: New file, based on m4/vasprintf-posix.m4. + * modules/vasprintf-gnu: New file, based on modules/vasnprintf-gnu. + * doc/glibc-functions/vasprintf.texi: Mention the new module. + * doc/glibc-functions/asprintf.texi: Likewise. + 2023-03-24 Bruno Haible sprintf-gnu: Add tests. diff --git a/doc/glibc-functions/asprintf.texi b/doc/glibc-functions/asprintf.texi index 70de08dd1c..017220f66f 100644 --- a/doc/glibc-functions/asprintf.texi +++ b/doc/glibc-functions/asprintf.texi @@ -17,16 +17,16 @@ Documentation: @uref{https://www.kernel.org/doc/man-pages/online/pages/man3/asprintf.3.html,,man asprintf}. @end itemize -Gnulib module: vasprintf or vasprintf-posix +Gnulib module: vasprintf or vasprintf-posix or vasprintf-gnu -Portability problems fixed by either Gnulib module @code{vasprintf} or @code{vasprintf-posix}: +Portability problems fixed by either Gnulib module @code{vasprintf} or @code{vasprintf-posix} or @code{vasprintf-gnu}: @itemize @item This function is missing on some platforms: AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw, MSVC 14. @end itemize -Portability problems fixed by Gnulib module @code{vasprintf-posix}: +Portability problems fixed by either Gnulib module @code{vasprintf-posix} or @code{vasprintf-gnu}: @itemize @item This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @@ -79,6 +79,13 @@ This function can crash in out-of-memory conditions on some platforms: FreeBSD 13.0, NetBSD 5.0. @end itemize +Portability problems fixed by Gnulib module @code{vasprintf-gnu}: +@itemize +@item +This function does not support the @samp{B} directive on some platforms: +glibc 2.34, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others. +@end itemize + Portability problems not fixed by Gnulib: @itemize @item diff --git a/doc/glibc-functions/vasprintf.texi b/doc/glibc-functions/vasprintf.texi index ef1be6bb88..91cf7d5635 100644 --- a/doc/glibc-functions/vasprintf.texi +++ b/doc/glibc-functions/vasprintf.texi @@ -17,16 +17,16 @@ Documentation: @uref{https://www.kernel.org/doc/man-pages/online/pages/man3/vasprintf.3.html,,man vasprintf}. @end itemize -Gnulib module: vasprintf or vasprintf-posix +Gnulib module: vasprintf or vasprintf-posix or vasprintf-gnu -Portability problems fixed by either Gnulib module @code{vasprintf} or @code{vasprintf-posix}: +Portability problems fixed by either Gnulib module @code{vasprintf} or @code{vasprintf-posix} or @code{vasprintf-gnu}: @itemize @item This function is missing on some platforms: AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw, MSVC 14. @end itemize -Portability problems fixed by Gnulib module @code{vasprintf-posix}: +Portability problems fixed by either Gnulib module @code{vasprintf-posix} or @code{vasprintf-gnu}: @itemize @item This function does not support size specifiers as in C99 (@code{hh}, @code{ll}, @@ -79,6 +79,13 @@ This function can crash in out-of-memory conditions on some platforms: FreeBSD 13.0, NetBSD 5.0. @end itemize +Portability problems fixed by Gnulib module @code{vasprintf-gnu}: +@itemize +@item +This function does not support the @samp{B} directive on some platforms: +glibc 2.34, FreeBSD 13.1, NetBSD 9.0, OpenBSD 7.2, macOS 12.5, AIX 7.2, Solaris 11.4, and others. +@end itemize + Portability problems not fixed by Gnulib: @itemize @item diff --git a/m4/vasprintf-gnu.m4 b/m4/vasprintf-gnu.m4 new file mode 100644 index 0000000000..be4e13be34 --- /dev/null +++ b/m4/vasprintf-gnu.m4 @@ -0,0 +1,25 @@ +# vasprintf-gnu.m4 serial 1 +dnl Copyright (C) 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, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_VASPRINTF_GNU], +[ + AC_REQUIRE([gl_FUNC_VASPRINTF_IS_POSIX]) + AC_REQUIRE([gl_PRINTF_DIRECTIVE_UPPERCASE_B]) + gl_cv_func_vasprintf_gnu=no + if test $gl_cv_func_vasprintf_posix = yes; then + case "$gl_cv_func_printf_directive_uppercase_b" in + *yes) + # vasprintf exists and is already POSIX compliant and GNU compatible. + gl_cv_func_vasprintf_gnu=yes + ;; + esac + fi + if test $gl_cv_func_vasprintf_gnu = no; then + gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS + gl_REPLACE_VASNPRINTF + gl_REPLACE_VASPRINTF + fi +]) diff --git a/m4/vasprintf-posix.m4 b/m4/vasprintf-posix.m4 index aa879de711..1be95c2f22 100644 --- a/m4/vasprintf-posix.m4 +++ b/m4/vasprintf-posix.m4 @@ -1,10 +1,22 @@ -# vasprintf-posix.m4 serial 15 +# vasprintf-posix.m4 serial 16 dnl Copyright (C) 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, dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_VASPRINTF_POSIX], +[ + AC_REQUIRE([gl_FUNC_VASPRINTF_IS_POSIX]) + if test $gl_cv_func_vasprintf_posix = no; then + gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS + gl_REPLACE_VASNPRINTF + gl_REPLACE_VASPRINTF + fi +]) + +dnl Test whether vasprintf exists and is POSIX compliant. +dnl Result is gl_cv_func_vasprintf_posix. +AC_DEFUN([gl_FUNC_VASPRINTF_IS_POSIX], [ AC_REQUIRE([gl_PRINTF_SIZES_C99]) AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) @@ -93,21 +105,4 @@ AC_DEFUN([gl_FUNC_VASPRINTF_POSIX], esac ;; esac - if test $gl_cv_func_vasprintf_posix = no; then - gl_PREREQ_VASNPRINTF_LONG_DOUBLE - gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE - gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE - gl_PREREQ_VASNPRINTF_DIRECTIVE_A - gl_PREREQ_VASNPRINTF_DIRECTIVE_B - gl_PREREQ_VASNPRINTF_DIRECTIVE_F - gl_PREREQ_VASNPRINTF_DIRECTIVE_LS - gl_PREREQ_VASNPRINTF_DIRECTIVE_LC - gl_PREREQ_VASNPRINTF_FLAG_GROUPING - gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST - gl_PREREQ_VASNPRINTF_FLAG_ZERO - gl_PREREQ_VASNPRINTF_PRECISION - gl_PREREQ_VASNPRINTF_ENOMEM - gl_REPLACE_VASNPRINTF - gl_REPLACE_VASPRINTF - fi ]) diff --git a/modules/vasprintf-gnu b/modules/vasprintf-gnu new file mode 100644 index 0000000000..9635b10f84 --- /dev/null +++ b/modules/vasprintf-gnu @@ -0,0 +1,28 @@ +Description: +POSIX and GNU compatible vsprintf with automatic memory allocation. + +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/vasprintf-gnu.m4 + +Depends-on: +vasprintf-posix + +configure.ac: +gl_FUNC_VASPRINTF_GNU + +Makefile.am: + +Include: +"vasprintf.h" + +License: +LGPL + +Maintainer: +all -- 2.39.5