]> Savannah Git Hosting - gnulib.git/commitdiff
vasprintf-gnu: New module.
authorBruno Haible <bruno@clisp.org>
Fri, 24 Mar 2023 10:28:38 +0000 (11:28 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 24 Mar 2023 10:28:38 +0000 (11:28 +0100)
* 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
doc/glibc-functions/asprintf.texi
doc/glibc-functions/vasprintf.texi
m4/vasprintf-gnu.m4 [new file with mode: 0644]
m4/vasprintf-posix.m4
modules/vasprintf-gnu [new file with mode: 0644]

index d9421f29bf3189d137bf11a02ececfa0cf390ee3..4810cf6291a6875bce7f232797047d5b6daddebf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-03-24  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        sprintf-gnu: Add tests.
index 70de08dd1c772aa8a06974f36db995d0b12287a9..017220f66fad35c6c68f10dfc9546e83c1b5e273 100644 (file)
@@ -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
index ef1be6bb88240a5630275e7c918039fcd1232ddd..91cf7d5635610725cf04506ee91a51673f278352 100644 (file)
@@ -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 (file)
index 0000000..be4e13b
--- /dev/null
@@ -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
+])
index aa879de7115692431a656e8163960da26680f6a9..1be95c2f22d4edadce6a584d5affb9518ab5c32c 100644 (file)
@@ -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 (file)
index 0000000..9635b10
--- /dev/null
@@ -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