From e2cb98413b5b3536bb0404a96715e0dcfaeeb295 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 24 Mar 2023 12:15:42 +0100 Subject: [PATCH] vasnwprintf-gnu: New module. * m4/vasnwprintf-posix.m4 (gl_FUNC_VASNWPRINTF_IS_POSIX): New macro. (gl_FUNC_VASNWPRINTF_POSIX): Require it. Invoke gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS. * m4/vasnwprintf-gnu.m4: New file, based on m4/vasnprintf-gnu.m4. * modules/vasnwprintf-gnu: New file, based on modules/vasnprintf-gnu. --- ChangeLog | 9 +++++++++ m4/vasnwprintf-gnu.m4 | 26 ++++++++++++++++++++++++++ m4/vasnwprintf-posix.m4 | 29 +++++++++++++++-------------- modules/vasnwprintf-gnu | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 14 deletions(-) create mode 100644 m4/vasnwprintf-gnu.m4 create mode 100644 modules/vasnwprintf-gnu diff --git a/ChangeLog b/ChangeLog index ddadbad8d1..994d8792f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2023-03-24 Bruno Haible + + vasnwprintf-gnu: New module. + * m4/vasnwprintf-posix.m4 (gl_FUNC_VASNWPRINTF_IS_POSIX): New macro. + (gl_FUNC_VASNWPRINTF_POSIX): Require it. Invoke + gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS. + * m4/vasnwprintf-gnu.m4: New file, based on m4/vasnprintf-gnu.m4. + * modules/vasnwprintf-gnu: New file, based on modules/vasnprintf-gnu. + 2023-03-24 Bruno Haible obstack-printf-gnu: Add tests. diff --git a/m4/vasnwprintf-gnu.m4 b/m4/vasnwprintf-gnu.m4 new file mode 100644 index 0000000000..ee89bef237 --- /dev/null +++ b/m4/vasnwprintf-gnu.m4 @@ -0,0 +1,26 @@ +# vasnwprintf-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_VASNWPRINTF_GNU], +[ + AC_REQUIRE([gl_FUNC_VASNWPRINTF_IS_POSIX]) + AC_REQUIRE([gl_PRINTF_DIRECTIVE_UPPERCASE_B]) + gl_cv_func_vasnwprintf_gnu=no + if test $gl_cv_func_vasnwprintf_posix = yes; then + case "$gl_cv_func_printf_directive_uppercase_b" in + *yes) + # vasnwprintf exists and is already POSIX compliant and GNU compatible. + gl_cv_func_vasnwprintf_gnu=yes + ;; + esac + fi + if test $gl_cv_func_vasnwprintf_gnu = no; then + dnl Note: This invokes gl_PREREQ_VASNPRINTF_DIRECTIVE_LC although not needed + dnl here. Doesn't matter. + gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS + gl_FUNC_VASNWPRINTF + fi +]) diff --git a/m4/vasnwprintf-posix.m4 b/m4/vasnwprintf-posix.m4 index d9dc41fa97..310b4ffe60 100644 --- a/m4/vasnwprintf-posix.m4 +++ b/m4/vasnwprintf-posix.m4 @@ -1,4 +1,4 @@ -# vasnwprintf-posix.m4 serial 2 +# vasnwprintf-posix.m4 serial 3 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, @@ -6,17 +6,18 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_VASNWPRINTF_POSIX], [ - gl_FUNC_VASNWPRINTF - 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_FLAG_GROUPING - gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST - gl_PREREQ_VASNPRINTF_FLAG_ZERO - gl_PREREQ_VASNPRINTF_PRECISION - gl_PREREQ_VASNPRINTF_ENOMEM + AC_REQUIRE([gl_FUNC_VASNWPRINTF_IS_POSIX]) + if test $gl_cv_func_vasnwprintf_posix = no; then + dnl Note: This invokes gl_PREREQ_VASNPRINTF_DIRECTIVE_LC although not needed + dnl here. Doesn't matter. + gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS + gl_FUNC_VASNWPRINTF + fi +]) + +dnl Test whether vasnwprintf exists and is POSIX compliant. +dnl Result is gl_cv_func_vasnwprintf_posix. +AC_DEFUN([gl_FUNC_VASNWPRINTF_IS_POSIX], +[ + gl_cv_func_vasnwprintf_posix=no ]) diff --git a/modules/vasnwprintf-gnu b/modules/vasnwprintf-gnu new file mode 100644 index 0000000000..582a185edd --- /dev/null +++ b/modules/vasnwprintf-gnu @@ -0,0 +1,32 @@ +Description: +POSIX and GNU compatible vswprintf with automatic memory allocation and bounded +output size. + +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 'vasnwprintf' module, if +that module occurs among the main modules in lib/. + +Files: +m4/vasnwprintf-gnu.m4 + +Depends-on: +vasnwprintf-posix + +configure.ac: +gl_FUNC_VASNWPRINTF_GNU + +Makefile.am: + +Include: +"vasnwprintf.h" + +Link: +$(MBRTOWC_LIB) + +License: +LGPLv2+ + +Maintainer: +all -- 2.39.5