* lib/aszprintf.c: Renamed from lib/azsprintf.c.
* lib/c-aszprintf.c: Renamed from lib/c-azsprintf.c.
* lib/c-vaszprintf.c: Renamed from lib/c-vazsprintf.c.
* lib/c-vsnzprintf.c: Renamed from lib/c-vzsnprintf.c.
* lib/c-snzprintf.c: Renamed from lib/c-zsnprintf.c.
* lib/vaszprintf.c: Renamed from lib/vazsprintf.c.
* lib/vsnzprintf.c: Renamed from lib/vzsnprintf.c.
* lib/vszprintf.c: Renamed from lib/vzsprintf.c.
* lib/snzprintf.c: Renamed from lib/zsnprintf.c.
* lib/szprintf.c: Renamed from lib/zsprintf.c.
* tests/test-c-vaszprintf-gnu.c: Renamed from
tests/test-c-vazsprintf-gnu.c.
* tests/test-c-vaszprintf-gnu.sh: Renamed from
tests/test-c-vazsprintf-gnu.sh.
* tests/test-c-vsnzprintf-gnu.c: Renamed from
tests/test-c-vzsnprintf-gnu.c.
* tests/test-c-vsnzprintf-gnu.sh: Renamed from
tests/test-c-vzsnprintf-gnu.sh.
* tests/test-c-snzprintf-gnu.c: Renamed from
tests/test-c-zsnprintf-gnu.c.
* tests/test-c-snzprintf-gnu.sh: Renamed from
tests/test-c-zsnprintf-gnu.sh.
* tests/test-vaszprintf-gnu.c: Renamed from tests/test-vazsprintf-gnu.c.
* tests/test-vaszprintf-gnu.h: Renamed from tests/test-vazsprintf-gnu.h.
* tests/test-vaszprintf-posix.c: Renamed from
tests/test-vazsprintf-posix.c.
* tests/test-vsnzprintf-gnu.c: Renamed from tests/test-vzsnprintf-gnu.c.
* tests/test-vsnzprintf-posix.c: Renamed from
tests/test-vzsnprintf-posix.c.
* tests/test-vszprintf-gnu.c: Renamed from tests/test-vzsprintf-gnu.c.
* tests/test-vszprintf-posix.c: Renamed from
tests/test-vzsprintf-posix.c.
* tests/test-snzprintf-gnu.c: Renamed from tests/test-zsnprintf-gnu.c.
* tests/test-snzprintf-gnu.h: Renamed from tests/test-zsnprintf-gnu.h.
* tests/test-snzprintf-posix.c: Renamed from
tests/test-zsnprintf-posix.c.
* tests/test-snzprintf-posix.h: Renamed from
tests/test-zsnprintf-posix.h.
* tests/test-szprintf-gnu.c: Renamed from tests/test-zsprintf-gnu.c.
* tests/test-szprintf-gnu.h: Renamed from tests/test-zsprintf-gnu.h.
* tests/test-szprintf-posix.c: Renamed from tests/test-zsprintf-posix.c.
* tests/test-szprintf-posix.h: Renamed from tests/test-zsprintf-posix.h.
* modules/c-vaszprintf: Renamed from modules/c-vazsprintf.
* modules/c-vaszprintf-gnu: Renamed from modules/c-vazsprintf-gnu.
* modules/c-vaszprintf-gnu-tests: Renamed from
modules/c-vazsprintf-gnu-tests.
* modules/c-vsnzprintf: Renamed from modules/c-vzsnprintf.
* modules/c-vsnzprintf-gnu: Renamed from modules/c-vzsnprintf-gnu.
* modules/c-vsnzprintf-gnu-tests: Renamed from
modules/c-vzsnprintf-gnu-tests.
* modules/c-snzprintf: Renamed from modules/c-zsnprintf.
* modules/c-snzprintf-gnu: Renamed from modules/c-zsnprintf-gnu.
* modules/c-snzprintf-gnu-tests: Renamed from
modules/c-zsnprintf-gnu-tests.
* modules/vaszprintf: Renamed from modules/vazsprintf.
* modules/vaszprintf-gnu: Renamed from modules/vazsprintf-gnu.
* modules/vaszprintf-gnu-tests: Renamed from
modules/vazsprintf-gnu-tests.
* modules/vaszprintf-posix: Renamed from modules/vazsprintf-posix.
* modules/vaszprintf-posix-tests: Renamed from
modules/vazsprintf-posix-tests.
* modules/vsnzprintf: Renamed from modules/vzsnprintf.
* modules/vsnzprintf-gnu: Renamed from modules/vzsnprintf-gnu.
* modules/vsnzprintf-gnu-tests: Renamed from
modules/vzsnprintf-gnu-tests.
* modules/vsnzprintf-posix: Renamed from modules/vzsnprintf-posix.
* modules/vsnzprintf-posix-tests: Renamed from
modules/vzsnprintf-posix-tests.
* modules/vszprintf: Renamed from modules/vzsprintf.
* modules/vszprintf-gnu: Renamed from modules/vzsprintf-gnu.
* modules/vszprintf-gnu-tests: Renamed from modules/vzsprintf-gnu-tests.
* modules/vszprintf-posix: Renamed from modules/vzsprintf-posix.
* modules/vszprintf-posix-tests: Renamed from
modules/vzsprintf-posix-tests.
* modules/snzprintf: Renamed from modules/zsnprintf.
* modules/snzprintf-gnu: Renamed from modules/zsnprintf-gnu.
* modules/snzprintf-gnu-tests: Renamed from modules/zsnprintf-gnu-tests.
* modules/snzprintf-posix: Renamed from modules/zsnprintf-posix.
* modules/snzprintf-posix-tests: Renamed from
modules/zsnprintf-posix-tests.
* modules/szprintf: Renamed from modules/zsprintf.
* modules/szprintf-gnu: Renamed from modules/zsprintf-gnu.
* modules/szprintf-gnu-tests: Renamed from modules/zsprintf-gnu-tests.
* modules/szprintf-posix: Renamed from modules/zsprintf-posix.
* modules/szprintf-posix-tests: Renamed from
modules/zsprintf-posix-tests.
All function names updated.
* lib/stdio.in.h, m4/stdio_h.m4, modules/stdio: Update module indicator
names.
+2024-06-29 Bruno Haible <bruno@clisp.org>
+
+ Global rename *zs[n]printf -> *s[n]zprintf.
+ * lib/aszprintf.c: Renamed from lib/azsprintf.c.
+ * lib/c-aszprintf.c: Renamed from lib/c-azsprintf.c.
+ * lib/c-vaszprintf.c: Renamed from lib/c-vazsprintf.c.
+ * lib/c-vsnzprintf.c: Renamed from lib/c-vzsnprintf.c.
+ * lib/c-snzprintf.c: Renamed from lib/c-zsnprintf.c.
+ * lib/vaszprintf.c: Renamed from lib/vazsprintf.c.
+ * lib/vsnzprintf.c: Renamed from lib/vzsnprintf.c.
+ * lib/vszprintf.c: Renamed from lib/vzsprintf.c.
+ * lib/snzprintf.c: Renamed from lib/zsnprintf.c.
+ * lib/szprintf.c: Renamed from lib/zsprintf.c.
+ * tests/test-c-vaszprintf-gnu.c: Renamed from
+ tests/test-c-vazsprintf-gnu.c.
+ * tests/test-c-vaszprintf-gnu.sh: Renamed from
+ tests/test-c-vazsprintf-gnu.sh.
+ * tests/test-c-vsnzprintf-gnu.c: Renamed from
+ tests/test-c-vzsnprintf-gnu.c.
+ * tests/test-c-vsnzprintf-gnu.sh: Renamed from
+ tests/test-c-vzsnprintf-gnu.sh.
+ * tests/test-c-snzprintf-gnu.c: Renamed from
+ tests/test-c-zsnprintf-gnu.c.
+ * tests/test-c-snzprintf-gnu.sh: Renamed from
+ tests/test-c-zsnprintf-gnu.sh.
+ * tests/test-vaszprintf-gnu.c: Renamed from tests/test-vazsprintf-gnu.c.
+ * tests/test-vaszprintf-gnu.h: Renamed from tests/test-vazsprintf-gnu.h.
+ * tests/test-vaszprintf-posix.c: Renamed from
+ tests/test-vazsprintf-posix.c.
+ * tests/test-vsnzprintf-gnu.c: Renamed from tests/test-vzsnprintf-gnu.c.
+ * tests/test-vsnzprintf-posix.c: Renamed from
+ tests/test-vzsnprintf-posix.c.
+ * tests/test-vszprintf-gnu.c: Renamed from tests/test-vzsprintf-gnu.c.
+ * tests/test-vszprintf-posix.c: Renamed from
+ tests/test-vzsprintf-posix.c.
+ * tests/test-snzprintf-gnu.c: Renamed from tests/test-zsnprintf-gnu.c.
+ * tests/test-snzprintf-gnu.h: Renamed from tests/test-zsnprintf-gnu.h.
+ * tests/test-snzprintf-posix.c: Renamed from
+ tests/test-zsnprintf-posix.c.
+ * tests/test-snzprintf-posix.h: Renamed from
+ tests/test-zsnprintf-posix.h.
+ * tests/test-szprintf-gnu.c: Renamed from tests/test-zsprintf-gnu.c.
+ * tests/test-szprintf-gnu.h: Renamed from tests/test-zsprintf-gnu.h.
+ * tests/test-szprintf-posix.c: Renamed from tests/test-zsprintf-posix.c.
+ * tests/test-szprintf-posix.h: Renamed from tests/test-zsprintf-posix.h.
+ * modules/c-vaszprintf: Renamed from modules/c-vazsprintf.
+ * modules/c-vaszprintf-gnu: Renamed from modules/c-vazsprintf-gnu.
+ * modules/c-vaszprintf-gnu-tests: Renamed from
+ modules/c-vazsprintf-gnu-tests.
+ * modules/c-vsnzprintf: Renamed from modules/c-vzsnprintf.
+ * modules/c-vsnzprintf-gnu: Renamed from modules/c-vzsnprintf-gnu.
+ * modules/c-vsnzprintf-gnu-tests: Renamed from
+ modules/c-vzsnprintf-gnu-tests.
+ * modules/c-snzprintf: Renamed from modules/c-zsnprintf.
+ * modules/c-snzprintf-gnu: Renamed from modules/c-zsnprintf-gnu.
+ * modules/c-snzprintf-gnu-tests: Renamed from
+ modules/c-zsnprintf-gnu-tests.
+ * modules/vaszprintf: Renamed from modules/vazsprintf.
+ * modules/vaszprintf-gnu: Renamed from modules/vazsprintf-gnu.
+ * modules/vaszprintf-gnu-tests: Renamed from
+ modules/vazsprintf-gnu-tests.
+ * modules/vaszprintf-posix: Renamed from modules/vazsprintf-posix.
+ * modules/vaszprintf-posix-tests: Renamed from
+ modules/vazsprintf-posix-tests.
+ * modules/vsnzprintf: Renamed from modules/vzsnprintf.
+ * modules/vsnzprintf-gnu: Renamed from modules/vzsnprintf-gnu.
+ * modules/vsnzprintf-gnu-tests: Renamed from
+ modules/vzsnprintf-gnu-tests.
+ * modules/vsnzprintf-posix: Renamed from modules/vzsnprintf-posix.
+ * modules/vsnzprintf-posix-tests: Renamed from
+ modules/vzsnprintf-posix-tests.
+ * modules/vszprintf: Renamed from modules/vzsprintf.
+ * modules/vszprintf-gnu: Renamed from modules/vzsprintf-gnu.
+ * modules/vszprintf-gnu-tests: Renamed from modules/vzsprintf-gnu-tests.
+ * modules/vszprintf-posix: Renamed from modules/vzsprintf-posix.
+ * modules/vszprintf-posix-tests: Renamed from
+ modules/vzsprintf-posix-tests.
+ * modules/snzprintf: Renamed from modules/zsnprintf.
+ * modules/snzprintf-gnu: Renamed from modules/zsnprintf-gnu.
+ * modules/snzprintf-gnu-tests: Renamed from modules/zsnprintf-gnu-tests.
+ * modules/snzprintf-posix: Renamed from modules/zsnprintf-posix.
+ * modules/snzprintf-posix-tests: Renamed from
+ modules/zsnprintf-posix-tests.
+ * modules/szprintf: Renamed from modules/zsprintf.
+ * modules/szprintf-gnu: Renamed from modules/zsprintf-gnu.
+ * modules/szprintf-gnu-tests: Renamed from modules/zsprintf-gnu-tests.
+ * modules/szprintf-posix: Renamed from modules/zsprintf-posix.
+ * modules/szprintf-posix-tests: Renamed from
+ modules/zsprintf-posix-tests.
+ All function names updated.
+ * lib/stdio.in.h, m4/stdio_h.m4, modules/stdio: Update module indicator
+ names.
+
2024-06-29 Jim Meyering <meyering@meta.com>
bootstrap-funclib.sh: shrink or split too-long lines
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999-2024 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+#include <stdarg.h>
+
+ptrdiff_t
+aszprintf (char **resultp, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t result;
+
+ va_start (args, format);
+ result = vaszprintf (resultp, format, args);
+ va_end (args);
+ return result;
+}
+++ /dev/null
-/* Formatted output to strings.
- Copyright (C) 1999-2024 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <stdio.h>
-
-#include <stdarg.h>
-
-ptrdiff_t
-azsprintf (char **resultp, const char *format, ...)
-{
- va_list args;
- ptrdiff_t result;
-
- va_start (args, format);
- result = vazsprintf (resultp, format, args);
- va_end (args);
- return result;
-}
--- /dev/null
+/* Formatted output to strings in C locale.
+ Copyright (C) 1999-2024 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "c-vasprintf.h"
+
+#include <stdarg.h>
+
+ptrdiff_t
+c_aszprintf (char **resultp, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t result;
+
+ va_start (args, format);
+ result = c_vaszprintf (resultp, format, args);
+ va_end (args);
+ return result;
+}
+++ /dev/null
-/* Formatted output to strings in C locale.
- Copyright (C) 1999-2024 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "c-vasprintf.h"
-
-#include <stdarg.h>
-
-ptrdiff_t
-c_azsprintf (char **resultp, const char *format, ...)
-{
- va_list args;
- ptrdiff_t result;
-
- va_start (args, format);
- result = c_vazsprintf (resultp, format, args);
- va_end (args);
- return result;
-}
ptrdiff_t ret;
va_start (args, format);
- ret = c_vzsnprintf (str, size, format, args);
+ ret = c_vsnzprintf (str, size, format, args);
va_end (args);
#if PTRDIFF_MAX > INT_MAX
Formatting takes place in the C locale, that is, the decimal point
used in floating-point formatting directives is always '.'. */
-extern ptrdiff_t c_zsnprintf (char *restrict str, size_t size,
+extern ptrdiff_t c_snzprintf (char *restrict str, size_t size,
const char *format, ...)
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 4));
--- /dev/null
+/* Formatted output to strings in C locale.
+ Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
+ Written by Simon Josefsson and Paul Eggert.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "c-snprintf.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "c-vasnprintf.h"
+
+ptrdiff_t
+c_snzprintf (char *str, size_t size, const char *format, ...)
+{
+ char *output;
+ size_t len;
+ size_t lenbuf = size;
+ va_list args;
+
+ va_start (args, format);
+ output = c_vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
+ va_end (args);
+
+ if (!output)
+ return -1;
+
+ if (output != str)
+ {
+ if (size)
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
+
+ free (output);
+ }
+
+ if (len > PTRDIFF_MAX)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ return len;
+}
Formatting takes place in the C locale, that is, the decimal point
used in floating-point formatting directives is always '.'. */
-ptrdiff_t c_azsprintf (char **resultp, const char *format, ...)
+ptrdiff_t c_aszprintf (char **resultp, const char *format, ...)
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 2, 3));
-ptrdiff_t c_vazsprintf (char **resultp, const char *format, va_list args)
+ptrdiff_t c_vaszprintf (char **resultp, const char *format, va_list args)
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 2, 0));
/* Prints formatted output to a string dynamically allocated with malloc().
--- /dev/null
+/* Formatted output to strings in C locale.
+ Copyright (C) 1999-2024 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include "c-vasprintf.h"
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "c-vasnprintf.h"
+
+ptrdiff_t
+c_vaszprintf (char **resultp, const char *format, va_list args)
+{
+ size_t length;
+ char *result = c_vasnprintf (NULL, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ if (length > PTRDIFF_MAX)
+ {
+ free (result);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ *resultp = result;
+ /* Return the number of resulting bytes, excluding the trailing NUL. */
+ return length;
+}
+++ /dev/null
-/* Formatted output to strings in C locale.
- Copyright (C) 1999-2024 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "c-vasprintf.h"
-
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "c-vasnprintf.h"
-
-ptrdiff_t
-c_vazsprintf (char **resultp, const char *format, va_list args)
-{
- size_t length;
- char *result = c_vasnprintf (NULL, &length, format, args);
- if (result == NULL)
- return -1;
-
- if (length > PTRDIFF_MAX)
- {
- free (result);
- errno = ENOMEM;
- return -1;
- }
-
- *resultp = result;
- /* Return the number of resulting bytes, excluding the trailing NUL. */
- return length;
-}
int
c_vsnprintf (char *str, size_t size, const char *format, va_list args)
{
- ptrdiff_t ret = c_vzsnprintf (str, size, format, args);
+ ptrdiff_t ret = c_vsnzprintf (str, size, format, args);
#if PTRDIFF_MAX > INT_MAX
if (ret > INT_MAX)
Formatting takes place in the C locale, that is, the decimal point
used in floating-point formatting directives is always '.'. */
-extern ptrdiff_t c_vzsnprintf (char *restrict str, size_t size,
+extern ptrdiff_t c_vsnzprintf (char *restrict str, size_t size,
const char *format, va_list args)
_GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
--- /dev/null
+/* Formatted output to strings in C locale.
+ Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
+ Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
+ Modified for C locale by Ben Pfaff.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include "c-vsnprintf.h"
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "c-vasnprintf.h"
+
+ptrdiff_t
+c_vsnzprintf (char *str, size_t size, const char *format, va_list args)
+{
+ char *output;
+ size_t len;
+ size_t lenbuf = size;
+
+ output = c_vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
+
+ if (!output)
+ return -1;
+
+ if (output != str)
+ {
+ if (size)
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
+
+ free (output);
+ }
+
+ if (len > PTRDIFF_MAX)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ return len;
+}
+++ /dev/null
-/* Formatted output to strings in C locale.
- Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
- Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
- Modified for C locale by Ben Pfaff.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#include "c-vsnprintf.h"
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "c-vasnprintf.h"
-
-ptrdiff_t
-c_vzsnprintf (char *str, size_t size, const char *format, va_list args)
-{
- char *output;
- size_t len;
- size_t lenbuf = size;
-
- output = c_vasnprintf (str, &lenbuf, format, args);
- len = lenbuf;
-
- if (!output)
- return -1;
-
- if (output != str)
- {
- if (size)
- {
- size_t pruned_len = (len < size ? len : size - 1);
- memcpy (str, output, pruned_len);
- str[pruned_len] = '\0';
- }
-
- free (output);
- }
-
- if (len > PTRDIFF_MAX)
- {
- errno = ENOMEM;
- return -1;
- }
-
- return len;
-}
{
char *result;
- if (c_vazsprintf (&result, format, args) < 0)
+ if (c_vaszprintf (&result, format, args) < 0)
{
if (errno == ENOMEM)
xalloc_die ();
+++ /dev/null
-/* Formatted output to strings in C locale.
- Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
- Written by Simon Josefsson and Paul Eggert.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include "c-snprintf.h"
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "c-vasnprintf.h"
-
-ptrdiff_t
-c_zsnprintf (char *str, size_t size, const char *format, ...)
-{
- char *output;
- size_t len;
- size_t lenbuf = size;
- va_list args;
-
- va_start (args, format);
- output = c_vasnprintf (str, &lenbuf, format, args);
- len = lenbuf;
- va_end (args);
-
- if (!output)
- return -1;
-
- if (output != str)
- {
- if (size)
- {
- size_t pruned_len = (len < size ? len : size - 1);
- memcpy (str, output, pruned_len);
- str[pruned_len] = '\0';
- }
-
- free (output);
- }
-
- if (len > PTRDIFF_MAX)
- {
- errno = ENOMEM;
- return -1;
- }
-
- return len;
-}
ptrdiff_t ret;
va_start (args, format);
- ret = vzsnprintf (str, size, format, args);
+ ret = vsnzprintf (str, size, format, args);
va_end (args);
#if PTRDIFF_MAX > INT_MAX
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
+ Written by Simon Josefsson and Paul Eggert.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vasnprintf.h"
+
+ptrdiff_t
+snzprintf (char *str, size_t size, const char *format, ...)
+{
+ char *output;
+ size_t len;
+ size_t lenbuf = size;
+ va_list args;
+
+ va_start (args, format);
+ output = vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
+ va_end (args);
+
+ if (!output)
+ return -1;
+
+ if (output != str)
+ {
+ if (size)
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
+
+ free (output);
+ }
+
+ if (len > PTRDIFF_MAX)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ return len;
+}
ptrdiff_t ret;
va_start (args, format);
- ret = vzsprintf (str, format, args);
+ ret = vszprintf (str, format, args);
va_end (args);
#if PTRDIFF_MAX > INT_MAX
# endif
#endif
-#if @GNULIB_ZSNPRINTF@
+#if @GNULIB_SNZPRINTF@
/* Prints formatted output to string STR. Similar to sprintf, but the
additional parameter SIZE limits how much is written into STR.
STR may be NULL, in which case nothing will be written.
Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
Therefore, if the format string is valid and does not use %ls/%lc
directives nor widths, the only possible failure code is ENOMEM. */
-_GL_FUNCDECL_SYS (zsnprintf, ptrdiff_t,
+_GL_FUNCDECL_SYS (snzprintf, ptrdiff_t,
(char *restrict str, size_t size,
const char *restrict format, ...)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
_GL_ARG_NONNULL ((3)));
-_GL_CXXALIAS_SYS (zsnprintf, ptrdiff_t,
+_GL_CXXALIAS_SYS (snzprintf, ptrdiff_t,
(char *restrict str, size_t size,
const char *restrict format, ...));
#endif
# endif
#endif
-#if @GNULIB_ZSPRINTF@
+#if @GNULIB_SZPRINTF@
/* Prints formatted output to string STR.
Returns the string length of the formatted string. Upon failure,
returns -1 with errno set.
Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
Therefore, if the format string is valid and does not use %ls/%lc
directives nor widths, the only possible failure code is ENOMEM. */
-_GL_FUNCDECL_SYS (zsprintf, ptrdiff_t,
+_GL_FUNCDECL_SYS (szprintf, ptrdiff_t,
(char *restrict str,
const char *restrict format, ...)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_SYS (zsprintf, ptrdiff_t,
+_GL_CXXALIAS_SYS (szprintf, ptrdiff_t,
(char *restrict str,
const char *restrict format, ...));
#endif
# endif
#endif
-#if @GNULIB_VAZSPRINTF@
+#if @GNULIB_VASZPRINTF@
/* Prints formatted output to a string dynamically allocated with malloc().
If the memory allocation succeeds, it stores the address of the string in
*RESULT and returns the number of resulting bytes, excluding the trailing
Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
Therefore, if the format string is valid and does not use %ls/%lc
directives nor widths, the only possible failure code is ENOMEM. */
-_GL_FUNCDECL_SYS (azsprintf, ptrdiff_t,
+_GL_FUNCDECL_SYS (aszprintf, ptrdiff_t,
(char **result, const char *format, ...)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
_GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_SYS (azsprintf, ptrdiff_t,
+_GL_CXXALIAS_SYS (aszprintf, ptrdiff_t,
(char **result, const char *format, ...));
-_GL_FUNCDECL_SYS (vazsprintf, ptrdiff_t,
+_GL_FUNCDECL_SYS (vaszprintf, ptrdiff_t,
(char **result, const char *format, va_list args)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_SYS (vazsprintf, ptrdiff_t,
+_GL_CXXALIAS_SYS (vaszprintf, ptrdiff_t,
(char **result, const char *format, va_list args));
#endif
# endif
#endif
-#if @GNULIB_VZSNPRINTF@
+#if @GNULIB_VSNZPRINTF@
/* Prints formatted output to string STR. Similar to sprintf, but the
additional parameter SIZE limits how much is written into STR.
STR may be NULL, in which case nothing will be written.
Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
Therefore, if the format string is valid and does not use %ls/%lc
directives nor widths, the only possible failure code is ENOMEM. */
-_GL_FUNCDECL_SYS (vzsnprintf, ptrdiff_t,
+_GL_FUNCDECL_SYS (vsnzprintf, ptrdiff_t,
(char *restrict str, size_t size,
const char *restrict format, va_list args)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
_GL_ARG_NONNULL ((3)));
-_GL_CXXALIAS_SYS (vzsnprintf, ptrdiff_t,
+_GL_CXXALIAS_SYS (vsnzprintf, ptrdiff_t,
(char *restrict str, size_t size,
const char *restrict format, va_list args));
#endif
# endif
#endif
-#if @GNULIB_VZSPRINTF@
+#if @GNULIB_VSZPRINTF@
/* Prints formatted output to string STR.
Returns the string length of the formatted string. Upon failure,
returns -1 with errno set.
Failure code EOVERFLOW can only occur when a width > INT_MAX is used.
Therefore, if the format string is valid and does not use %ls/%lc
directives nor widths, the only possible failure code is ENOMEM. */
-_GL_FUNCDECL_SYS (vzsprintf, ptrdiff_t,
+_GL_FUNCDECL_SYS (vszprintf, ptrdiff_t,
(char *restrict str,
const char *restrict format, va_list args)
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
_GL_ARG_NONNULL ((1, 2)));
-_GL_CXXALIAS_SYS (vzsprintf, ptrdiff_t,
+_GL_CXXALIAS_SYS (vszprintf, ptrdiff_t,
(char *restrict str,
const char *restrict format, va_list args));
#endif
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include <stdio.h>
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "vasnprintf.h"
+
+ptrdiff_t
+szprintf (char *str, const char *format, ...)
+{
+ char *output;
+ size_t len;
+ size_t lenbuf;
+ va_list args;
+
+ /* Set lenbuf = min (SIZE_MAX, - (uintptr_t) str - 1). */
+ lenbuf = SIZE_MAX;
+ if (lenbuf >= ~ (uintptr_t) str)
+ lenbuf = ~ (uintptr_t) str;
+
+ va_start (args, format);
+ output = vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
+ va_end (args);
+
+ if (!output)
+ return -1;
+
+ if (output != str)
+ {
+ /* len is near SIZE_MAX. */
+ free (output);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ if (len > PTRDIFF_MAX)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ return len;
+}
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 1999-2024 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+/* Specification. */
+#include <stdio.h>
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "vasnprintf.h"
+
+ptrdiff_t
+vaszprintf (char **resultp, const char *format, va_list args)
+{
+ size_t length;
+ char *result = vasnprintf (NULL, &length, format, args);
+ if (result == NULL)
+ return -1;
+
+ if (length > PTRDIFF_MAX)
+ {
+ free (result);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ *resultp = result;
+ /* Return the number of resulting bytes, excluding the trailing NUL. */
+ return length;
+}
+++ /dev/null
-/* Formatted output to strings.
- Copyright (C) 1999-2024 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <stdio.h>
-
-#include <errno.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "vasnprintf.h"
-
-ptrdiff_t
-vazsprintf (char **resultp, const char *format, va_list args)
-{
- size_t length;
- char *result = vasnprintf (NULL, &length, format, args);
- if (result == NULL)
- return -1;
-
- if (length > PTRDIFF_MAX)
- {
- free (result);
- errno = ENOMEM;
- return -1;
- }
-
- *resultp = result;
- /* Return the number of resulting bytes, excluding the trailing NUL. */
- return length;
-}
int
vsnprintf (char *str, size_t size, const char *format, va_list args)
{
- ptrdiff_t ret = vzsnprintf (str, size, format, args);
+ ptrdiff_t ret = vsnzprintf (str, size, format, args);
#if PTRDIFF_MAX > INT_MAX
if (ret > INT_MAX)
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
+ Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include <stdio.h>
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "vasnprintf.h"
+
+ptrdiff_t
+vsnzprintf (char *str, size_t size, const char *format, va_list args)
+{
+ char *output;
+ size_t len;
+ size_t lenbuf = size;
+
+ output = vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
+
+ if (!output)
+ return -1;
+
+ if (output != str)
+ {
+ if (size)
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
+
+ free (output);
+ }
+
+ if (len > PTRDIFF_MAX)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ return len;
+}
int
vsprintf (char *str, const char *format, va_list args)
{
- ptrdiff_t ret = vzsprintf (str, format, args);
+ ptrdiff_t ret = vszprintf (str, format, args);
#if PTRDIFF_MAX > INT_MAX
if (ret > INT_MAX)
--- /dev/null
+/* Formatted output to strings.
+ Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Specification. */
+#include <stdio.h>
+
+#include <errno.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "vasnprintf.h"
+
+ptrdiff_t
+vszprintf (char *str, const char *format, va_list args)
+{
+ char *output;
+ size_t len;
+ size_t lenbuf;
+
+ /* Set lenbuf = min (SIZE_MAX, - (uintptr_t) str - 1). */
+ lenbuf = SIZE_MAX;
+ if (lenbuf >= ~ (uintptr_t) str)
+ lenbuf = ~ (uintptr_t) str;
+
+ output = vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
+
+ if (!output)
+ return -1;
+
+ if (output != str)
+ {
+ /* len is near SIZE_MAX. */
+ free (output);
+ errno = ENOMEM;
+ return -1;
+ }
+
+ if (len > PTRDIFF_MAX)
+ {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ return len;
+}
+++ /dev/null
-/* Formatted output to strings.
- Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
- Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#include <stdio.h>
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "vasnprintf.h"
-
-ptrdiff_t
-vzsnprintf (char *str, size_t size, const char *format, va_list args)
-{
- char *output;
- size_t len;
- size_t lenbuf = size;
-
- output = vasnprintf (str, &lenbuf, format, args);
- len = lenbuf;
-
- if (!output)
- return -1;
-
- if (output != str)
- {
- if (size)
- {
- size_t pruned_len = (len < size ? len : size - 1);
- memcpy (str, output, pruned_len);
- str[pruned_len] = '\0';
- }
-
- free (output);
- }
-
- if (len > PTRDIFF_MAX)
- {
- errno = ENOMEM;
- return -1;
- }
-
- return len;
-}
+++ /dev/null
-/* Formatted output to strings.
- Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#include <stdio.h>
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "vasnprintf.h"
-
-ptrdiff_t
-vzsprintf (char *str, const char *format, va_list args)
-{
- char *output;
- size_t len;
- size_t lenbuf;
-
- /* Set lenbuf = min (SIZE_MAX, - (uintptr_t) str - 1). */
- lenbuf = SIZE_MAX;
- if (lenbuf >= ~ (uintptr_t) str)
- lenbuf = ~ (uintptr_t) str;
-
- output = vasnprintf (str, &lenbuf, format, args);
- len = lenbuf;
-
- if (!output)
- return -1;
-
- if (output != str)
- {
- /* len is near SIZE_MAX. */
- free (output);
- errno = ENOMEM;
- return -1;
- }
-
- if (len > PTRDIFF_MAX)
- {
- errno = ENOMEM;
- return -1;
- }
-
- return len;
-}
}
}
- if (vazsprintf (&result, format, args) < 0)
+ if (vaszprintf (&result, format, args) < 0)
{
if (errno == ENOMEM)
xalloc_die ();
+++ /dev/null
-/* Formatted output to strings.
- Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
- Written by Simon Josefsson and Paul Eggert.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-/* Specification. */
-#include <stdio.h>
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "vasnprintf.h"
-
-ptrdiff_t
-zsnprintf (char *str, size_t size, const char *format, ...)
-{
- char *output;
- size_t len;
- size_t lenbuf = size;
- va_list args;
-
- va_start (args, format);
- output = vasnprintf (str, &lenbuf, format, args);
- len = lenbuf;
- va_end (args);
-
- if (!output)
- return -1;
-
- if (output != str)
- {
- if (size)
- {
- size_t pruned_len = (len < size ? len : size - 1);
- memcpy (str, output, pruned_len);
- str[pruned_len] = '\0';
- }
-
- free (output);
- }
-
- if (len > PTRDIFF_MAX)
- {
- errno = ENOMEM;
- return -1;
- }
-
- return len;
-}
+++ /dev/null
-/* Formatted output to strings.
- Copyright (C) 2004, 2006-2024 Free Software Foundation, Inc.
-
- This file is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This file is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#include <stdio.h>
-
-#include <errno.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "vasnprintf.h"
-
-ptrdiff_t
-zsprintf (char *str, const char *format, ...)
-{
- char *output;
- size_t len;
- size_t lenbuf;
- va_list args;
-
- /* Set lenbuf = min (SIZE_MAX, - (uintptr_t) str - 1). */
- lenbuf = SIZE_MAX;
- if (lenbuf >= ~ (uintptr_t) str)
- lenbuf = ~ (uintptr_t) str;
-
- va_start (args, format);
- output = vasnprintf (str, &lenbuf, format, args);
- len = lenbuf;
- va_end (args);
-
- if (!output)
- return -1;
-
- if (output != str)
- {
- /* len is near SIZE_MAX. */
- free (output);
- errno = ENOMEM;
- return -1;
- }
-
- if (len > PTRDIFF_MAX)
- {
- errno = ENOMEM;
- return -1;
- }
-
- return len;
-}
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STDIO_H_SIGPIPE])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TMPFILE])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASPRINTF])
- gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VAZSPRINTF])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VASZPRINTF])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VFSCANF])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSCANF])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VDPRINTF])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VPRINTF_POSIX])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNPRINTF])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSPRINTF_POSIX])
- gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VZSNPRINTF])
- gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VZSPRINTF])
- gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ZSNPRINTF])
- gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ZSPRINTF])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSNZPRINTF])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_VSZPRINTF])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SNZPRINTF])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SZPRINTF])
dnl Support Microsoft deprecated alias function names by default.
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FCLOSEALL], [1])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_FDOPEN], [1])
Depends-on:
stdint
stdio
-c-vzsnprintf
+c-vsnzprintf
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
--- /dev/null
+Description:
+c_snzprintf(): print formatted output to a fixed length string (without
+INT_MAX limitation) in C locale
+
+Files:
+lib/c-snprintf.h
+lib/c-snzprintf.c
+
+Depends-on:
+stdint
+stdio
+c-vasnprintf
+
+configure.ac:
+AC_REQUIRE([AC_C_RESTRICT])
+
+Makefile.am:
+lib_SOURCES += c-snzprintf.c
+
+Include:
+"c-snprintf.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Description:
+c_snzprintf() function
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+c-snzprintf
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+"c-snprintf.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-c-snzprintf-gnu.c
+tests/test-snzprintf-gnu.h
+tests/test-c-snzprintf-gnu.sh
+tests/macros.h
+m4/locale-fr.m4
+m4/codeset.m4
+
+Depends-on:
+setlocale
+
+configure.ac:
+gt_LOCALE_FR
+
+Makefile.am:
+TESTS += test-c-snzprintf-gnu.sh
+TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@'
+check_PROGRAMS += test-c-snzprintf-gnu
+test_c_snzprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB)
--- /dev/null
+Description:
+aszprintf() and vaszprintf() in C locale
+
+Files:
+lib/c-vasprintf.h
+lib/c-aszprintf.c
+lib/c-vaszprintf.c
+
+Depends-on:
+stdint
+stdio
+c-vasnprintf
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += c-aszprintf.c c-vaszprintf.c
+
+Include:
+"c-vasprintf.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Description:
+c_aszprintf() and c_vaszprintf() functions
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+c-vaszprintf
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+"c-vasprintf.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-c-vaszprintf-gnu.c
+tests/test-vaszprintf-gnu.h
+tests/test-c-vaszprintf-gnu.sh
+tests/macros.h
+m4/locale-fr.m4
+m4/codeset.m4
+
+Depends-on:
+setlocale
+
+configure.ac:
+gt_LOCALE_FR
+
+Makefile.am:
+TESTS += test-c-vaszprintf-gnu.sh
+TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@'
+check_PROGRAMS += test-c-vaszprintf-gnu
+test_c_vaszprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB)
+++ /dev/null
-Description:
-azsprintf() and vazsprintf() in C locale
-
-Files:
-lib/c-vasprintf.h
-lib/c-azsprintf.c
-lib/c-vazsprintf.c
-
-Depends-on:
-stdint
-stdio
-c-vasnprintf
-
-configure.ac:
-
-Makefile.am:
-lib_SOURCES += c-azsprintf.c c-vazsprintf.c
-
-Include:
-"c-vasprintf.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Description:
-c_azsprintf() and c_vazsprintf() functions
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-c-vazsprintf
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-"c-vasprintf.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-c-vazsprintf-gnu.c
-tests/test-vazsprintf-gnu.h
-tests/test-c-vazsprintf-gnu.sh
-tests/macros.h
-m4/locale-fr.m4
-m4/codeset.m4
-
-Depends-on:
-setlocale
-
-configure.ac:
-gt_LOCALE_FR
-
-Makefile.am:
-TESTS += test-c-vazsprintf-gnu.sh
-TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@'
-check_PROGRAMS += test-c-vazsprintf-gnu
-test_c_vazsprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB)
Depends-on:
stdint
stdio
-c-vzsnprintf
+c-vsnzprintf
configure.ac:
AC_REQUIRE([AC_C_RESTRICT])
--- /dev/null
+Description:
+c_vsnzprintf(): print formatted output from an stdarg argument list to a
+fixed length string (without INT_MAX limitation) in C locale
+
+Files:
+lib/c-vsnprintf.h
+lib/c-vsnzprintf.c
+
+Depends-on:
+stdint
+stdio
+c-vasnprintf
+
+configure.ac:
+AC_REQUIRE([AC_C_RESTRICT])
+
+Makefile.am:
+lib_SOURCES += c-vsnzprintf.c
+
+Include:
+"c-vsnprintf.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Description:
+c_vsnzprintf() function
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+c-vsnzprintf
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+"c-vsnprintf.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-c-vsnzprintf-gnu.c
+tests/test-snzprintf-gnu.h
+tests/test-c-vsnzprintf-gnu.sh
+tests/macros.h
+m4/locale-fr.m4
+m4/codeset.m4
+
+Depends-on:
+setlocale
+
+configure.ac:
+gt_LOCALE_FR
+
+Makefile.am:
+TESTS += test-c-vsnzprintf-gnu.sh
+TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@'
+check_PROGRAMS += test-c-vsnzprintf-gnu
+test_c_vsnzprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB)
+++ /dev/null
-Description:
-c_vzsnprintf(): print formatted output from an stdarg argument list to a
-fixed length string (without INT_MAX limitation) in C locale
-
-Files:
-lib/c-vsnprintf.h
-lib/c-vzsnprintf.c
-
-Depends-on:
-stdint
-stdio
-c-vasnprintf
-
-configure.ac:
-AC_REQUIRE([AC_C_RESTRICT])
-
-Makefile.am:
-lib_SOURCES += c-vzsnprintf.c
-
-Include:
-"c-vsnprintf.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Description:
-c_vzsnprintf() function
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-c-vzsnprintf
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-"c-vsnprintf.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-c-vzsnprintf-gnu.c
-tests/test-zsnprintf-gnu.h
-tests/test-c-vzsnprintf-gnu.sh
-tests/macros.h
-m4/locale-fr.m4
-m4/codeset.m4
-
-Depends-on:
-setlocale
-
-configure.ac:
-gt_LOCALE_FR
-
-Makefile.am:
-TESTS += test-c-vzsnprintf-gnu.sh
-TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@'
-check_PROGRAMS += test-c-vzsnprintf-gnu
-test_c_vzsnprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB)
Depends-on:
extensions
stdio
-c-vazsprintf
+c-vaszprintf
xalloc-die
configure.ac:
+++ /dev/null
-Description:
-c_zsnprintf(): print formatted output to a fixed length string (without
-INT_MAX limitation) in C locale
-
-Files:
-lib/c-snprintf.h
-lib/c-zsnprintf.c
-
-Depends-on:
-stdint
-stdio
-c-vasnprintf
-
-configure.ac:
-AC_REQUIRE([AC_C_RESTRICT])
-
-Makefile.am:
-lib_SOURCES += c-zsnprintf.c
-
-Include:
-"c-snprintf.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Description:
-c_zsnprintf() function
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-c-zsnprintf
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-"c-snprintf.h"
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-c-zsnprintf-gnu.c
-tests/test-zsnprintf-gnu.h
-tests/test-c-zsnprintf-gnu.sh
-tests/macros.h
-m4/locale-fr.m4
-m4/codeset.m4
-
-Depends-on:
-setlocale
-
-configure.ac:
-gt_LOCALE_FR
-
-Makefile.am:
-TESTS += test-c-zsnprintf-gnu.sh
-TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@'
-check_PROGRAMS += test-c-zsnprintf-gnu
-test_c_zsnprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB)
stdio
errno [test $ac_cv_func_snprintf = no || test $REPLACE_SNPRINTF = 1]
stdint [test $ac_cv_func_snprintf = no || test $REPLACE_SNPRINTF = 1]
-vzsnprintf [test $ac_cv_func_snprintf = no || test $REPLACE_SNPRINTF = 1]
+vsnzprintf [test $ac_cv_func_snprintf = no || test $REPLACE_SNPRINTF = 1]
configure.ac:
gl_FUNC_SNPRINTF
--- /dev/null
+Description:
+snzprintf() function: print formatted output to a fixed length string
+(without INT_MAX limitation)
+
+Files:
+lib/snzprintf.c
+
+Depends-on:
+stdio
+vasnprintf
+errno
+stdint
+
+configure.ac:
+gl_STDIO_MODULE_INDICATOR([snzprintf])
+
+Makefile.am:
+lib_SOURCES += snzprintf.c
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Description:
+snzprintf() function
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+snzprintf-posix
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-snzprintf-gnu.c
+tests/test-snzprintf-gnu.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-snzprintf-gnu
+check_PROGRAMS += test-snzprintf-gnu
--- /dev/null
+Description:
+snzprintf() function with POSIX compliant format string interpretation
+
+Files:
+
+Depends-on:
+snzprintf
+mixin/printf-posix
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-snzprintf-posix.c
+tests/test-snzprintf-posix.h
+tests/infinity.h
+tests/macros.h
+
+Depends-on:
+nan
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-snzprintf-posix
+check_PROGRAMS += test-snzprintf-posix
nocrash
printf-safe
multiarch
-vzsprintf [test $REPLACE_SPRINTF = 1]
+vszprintf [test $REPLACE_SPRINTF = 1]
mixin/printf-posix [test $REPLACE_SPRINTF = 1]
stdint [test $REPLACE_SPRINTF = 1]
errno [test $REPLACE_SPRINTF = 1]
-e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \
-e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \
-e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \
- -e 's/@''GNULIB_VAZSPRINTF''@/$(GNULIB_VAZSPRINTF)/g' \
+ -e 's/@''GNULIB_VASZPRINTF''@/$(GNULIB_VASZPRINTF)/g' \
-e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \
-e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \
-e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \
-e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \
-e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \
-e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \
- -e 's/@''GNULIB_VZSNPRINTF''@/$(GNULIB_VZSNPRINTF)/g' \
- -e 's/@''GNULIB_VZSPRINTF''@/$(GNULIB_VZSPRINTF)/g' \
- -e 's/@''GNULIB_ZSNPRINTF''@/$(GNULIB_ZSNPRINTF)/g' \
- -e 's/@''GNULIB_ZSPRINTF''@/$(GNULIB_ZSPRINTF)/g' \
+ -e 's/@''GNULIB_VSNZPRINTF''@/$(GNULIB_VSNZPRINTF)/g' \
+ -e 's/@''GNULIB_VSZPRINTF''@/$(GNULIB_VSZPRINTF)/g' \
+ -e 's/@''GNULIB_SNZPRINTF''@/$(GNULIB_SNZPRINTF)/g' \
+ -e 's/@''GNULIB_SZPRINTF''@/$(GNULIB_SZPRINTF)/g' \
-e 's/@''GNULIB_MDA_FCLOSEALL''@/$(GNULIB_MDA_FCLOSEALL)/g' \
-e 's/@''GNULIB_MDA_FDOPEN''@/$(GNULIB_MDA_FDOPEN)/g' \
-e 's/@''GNULIB_MDA_FILENO''@/$(GNULIB_MDA_FILENO)/g' \
--- /dev/null
+Description:
+szprintf() function: print formatted output to a string (without INT_MAX
+limitation)
+
+Files:
+lib/szprintf.c
+
+Depends-on:
+stdio
+vasnprintf
+errno
+stdint
+
+configure.ac:
+gl_STDIO_MODULE_INDICATOR([szprintf])
+
+Makefile.am:
+lib_SOURCES += szprintf.c
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+all
--- /dev/null
+Description:
+szprintf() function
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+szprintf-posix
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-szprintf-gnu.c
+tests/test-szprintf-gnu.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-szprintf-gnu
+check_PROGRAMS += test-szprintf-gnu
--- /dev/null
+Description:
+szprintf() function with POSIX compliant format string interpretation
+
+Files:
+
+Depends-on:
+szprintf
+mixin/printf-posix
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-szprintf-posix.c
+tests/test-szprintf-posix.h
+tests/infinity.h
+tests/macros.h
+
+Depends-on:
+nan
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-szprintf-posix
+check_PROGRAMS += test-szprintf-posix
--- /dev/null
+Description:
+vsprintf (without INT_MAX limitation) with automatic memory allocation
+
+Files:
+lib/vaszprintf.c
+lib/aszprintf.c
+
+Depends-on:
+stdio
+vasnprintf
+errno
+stdint
+
+configure.ac:
+gl_STDIO_MODULE_INDICATOR([vaszprintf])
+m4_ifdef([AM_XGETTEXT_OPTION],
+ [AM_][XGETTEXT_OPTION([--flag=aszprintf:2:c-format])
+ AM_][XGETTEXT_OPTION([--flag=vaszprintf:2:c-format])])
+
+Makefile.am:
+lib_SOURCES += vaszprintf.c aszprintf.c
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Description:
+aszprintf() and vaszprintf() functions
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+vaszprintf-posix
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-vaszprintf-gnu.c
+tests/test-vaszprintf-gnu.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vaszprintf-gnu
+check_PROGRAMS += test-vaszprintf-gnu
--- /dev/null
+Description:
+aszprintf() and vaszprintf() functions
+with POSIX compliant format string interpretation
+
+Files:
+
+Depends-on:
+vaszprintf
+mixin/printf-posix
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-vaszprintf-posix.c
+tests/infinity.h
+tests/macros.h
+
+Depends-on:
+nan
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vaszprintf-posix
+check_PROGRAMS += test-vaszprintf-posix
+++ /dev/null
-Description:
-vsprintf (without INT_MAX limitation) with automatic memory allocation
-
-Files:
-lib/vazsprintf.c
-lib/azsprintf.c
-
-Depends-on:
-stdio
-vasnprintf
-errno
-stdint
-
-configure.ac:
-gl_STDIO_MODULE_INDICATOR([vazsprintf])
-m4_ifdef([AM_XGETTEXT_OPTION],
- [AM_][XGETTEXT_OPTION([--flag=azsprintf:2:c-format])
- AM_][XGETTEXT_OPTION([--flag=vazsprintf:2:c-format])])
-
-Makefile.am:
-lib_SOURCES += vazsprintf.c azsprintf.c
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Description:
-azsprintf() and vazsprintf() functions
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-vazsprintf-posix
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-vazsprintf-gnu.c
-tests/test-vazsprintf-gnu.h
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-vazsprintf-gnu
-check_PROGRAMS += test-vazsprintf-gnu
+++ /dev/null
-Description:
-azsprintf() and vazsprintf() functions
-with POSIX compliant format string interpretation
-
-Files:
-
-Depends-on:
-vazsprintf
-mixin/printf-posix
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-vazsprintf-posix.c
-tests/infinity.h
-tests/macros.h
-
-Depends-on:
-nan
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-vazsprintf-posix
-check_PROGRAMS += test-vazsprintf-posix
stdio
errno [test $ac_cv_func_vsnprintf = no || test $REPLACE_VSNPRINTF = 1]
stdint [test $ac_cv_func_vsnprintf = no || test $REPLACE_VSNPRINTF = 1]
-vzsnprintf [test $ac_cv_func_vsnprintf = no || test $REPLACE_VSNPRINTF = 1]
+vsnzprintf [test $ac_cv_func_vsnprintf = no || test $REPLACE_VSNPRINTF = 1]
configure.ac:
gl_FUNC_VSNPRINTF
--- /dev/null
+Description:
+vsnzprintf() function: print formatted output from an stdarg argument list
+to a fixed length string (without INT_MAX limitation)
+
+Files:
+lib/vsnzprintf.c
+
+Depends-on:
+stdio
+vasnprintf
+errno
+stdint
+
+configure.ac:
+gl_STDIO_MODULE_INDICATOR([vsnzprintf])
+
+Makefile.am:
+lib_SOURCES += vsnzprintf.c
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Description:
+vsnzprintf() function
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+vsnzprintf-posix
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-vsnzprintf-gnu.c
+tests/test-snzprintf-gnu.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vsnzprintf-gnu
+check_PROGRAMS += test-vsnzprintf-gnu
--- /dev/null
+Description:
+vsnzprintf() function with POSIX compliant format string interpretation
+
+Files:
+
+Depends-on:
+vsnzprintf
+mixin/printf-posix
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-vsnzprintf-posix.c
+tests/test-snzprintf-posix.h
+tests/infinity.h
+tests/macros.h
+
+Depends-on:
+nan
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vsnzprintf-posix
+check_PROGRAMS += test-vsnzprintf-posix
nocrash
printf-safe
multiarch
-vzsprintf [test $REPLACE_VSPRINTF = 1]
+vszprintf [test $REPLACE_VSPRINTF = 1]
mixin/printf-posix [test $REPLACE_VSPRINTF = 1]
stdint [test $REPLACE_VSPRINTF = 1]
errno [test $REPLACE_VSPRINTF = 1]
--- /dev/null
+Description:
+vszprintf() function: print formatted output from an stdarg argument list
+to a string (without INT_MAX limitation)
+
+Files:
+lib/vszprintf.c
+
+Depends-on:
+stdio
+vasnprintf
+errno
+stdint
+
+configure.ac:
+gl_STDIO_MODULE_INDICATOR([vszprintf])
+
+Makefile.am:
+lib_SOURCES += vszprintf.c
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+all
--- /dev/null
+Description:
+vszprintf() function
+with POSIX compliant and GNU compatible format string interpretation
+
+Files:
+
+Depends-on:
+vszprintf-posix
+mixin/printf-gnu
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-vszprintf-gnu.c
+tests/test-szprintf-gnu.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vszprintf-gnu
+check_PROGRAMS += test-vszprintf-gnu
--- /dev/null
+Description:
+vszprintf() function with POSIX compliant format string interpretation
+
+Files:
+
+Depends-on:
+vszprintf
+mixin/printf-posix
+
+configure.ac:
+gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
+
+Makefile.am:
+
+Include:
+<stdio.h>
+
+License:
+LGPL
+
+Maintainer:
+all
--- /dev/null
+Files:
+tests/test-vszprintf-posix.c
+tests/test-szprintf-posix.h
+tests/infinity.h
+tests/macros.h
+
+Depends-on:
+nan
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-vszprintf-posix
+check_PROGRAMS += test-vszprintf-posix
+++ /dev/null
-Description:
-vzsnprintf() function: print formatted output from an stdarg argument list
-to a fixed length string (without INT_MAX limitation)
-
-Files:
-lib/vzsnprintf.c
-
-Depends-on:
-stdio
-vasnprintf
-errno
-stdint
-
-configure.ac:
-gl_STDIO_MODULE_INDICATOR([vzsnprintf])
-
-Makefile.am:
-lib_SOURCES += vzsnprintf.c
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Description:
-vzsnprintf() function
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-vzsnprintf-posix
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-vzsnprintf-gnu.c
-tests/test-zsnprintf-gnu.h
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-vzsnprintf-gnu
-check_PROGRAMS += test-vzsnprintf-gnu
+++ /dev/null
-Description:
-vzsnprintf() function with POSIX compliant format string interpretation
-
-Files:
-
-Depends-on:
-vzsnprintf
-mixin/printf-posix
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-vzsnprintf-posix.c
-tests/test-zsnprintf-posix.h
-tests/infinity.h
-tests/macros.h
-
-Depends-on:
-nan
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-vzsnprintf-posix
-check_PROGRAMS += test-vzsnprintf-posix
+++ /dev/null
-Description:
-vzsprintf() function: print formatted output from an stdarg argument list
-to a string (without INT_MAX limitation)
-
-Files:
-lib/vzsprintf.c
-
-Depends-on:
-stdio
-vasnprintf
-errno
-stdint
-
-configure.ac:
-gl_STDIO_MODULE_INDICATOR([vzsprintf])
-
-Makefile.am:
-lib_SOURCES += vzsprintf.c
-
-Include:
-<stdio.h>
-
-License:
-LGPL
-
-Maintainer:
-all
+++ /dev/null
-Description:
-vzsprintf() function
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-vzsprintf-posix
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPL
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-vzsprintf-gnu.c
-tests/test-zsprintf-gnu.h
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-vzsprintf-gnu
-check_PROGRAMS += test-vzsprintf-gnu
+++ /dev/null
-Description:
-vzsprintf() function with POSIX compliant format string interpretation
-
-Files:
-
-Depends-on:
-vzsprintf
-mixin/printf-posix
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPL
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-vzsprintf-posix.c
-tests/test-zsprintf-posix.h
-tests/infinity.h
-tests/macros.h
-
-Depends-on:
-nan
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-vzsprintf-posix
-check_PROGRAMS += test-vzsprintf-posix
Depends-on:
extensions
stdio
-vazsprintf
+vaszprintf
xalloc
xalloc-die
extern-inline
+++ /dev/null
-Description:
-zsnprintf() function: print formatted output to a fixed length string
-(without INT_MAX limitation)
-
-Files:
-lib/zsnprintf.c
-
-Depends-on:
-stdio
-vasnprintf
-errno
-stdint
-
-configure.ac:
-gl_STDIO_MODULE_INDICATOR([zsnprintf])
-
-Makefile.am:
-lib_SOURCES += zsnprintf.c
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Description:
-zsnprintf() function
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-zsnprintf-posix
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-zsnprintf-gnu.c
-tests/test-zsnprintf-gnu.h
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-zsnprintf-gnu
-check_PROGRAMS += test-zsnprintf-gnu
+++ /dev/null
-Description:
-zsnprintf() function with POSIX compliant format string interpretation
-
-Files:
-
-Depends-on:
-zsnprintf
-mixin/printf-posix
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPLv2+
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-zsnprintf-posix.c
-tests/test-zsnprintf-posix.h
-tests/infinity.h
-tests/macros.h
-
-Depends-on:
-nan
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-zsnprintf-posix
-check_PROGRAMS += test-zsnprintf-posix
+++ /dev/null
-Description:
-zsprintf() function: print formatted output to a string (without INT_MAX
-limitation)
-
-Files:
-lib/zsprintf.c
-
-Depends-on:
-stdio
-vasnprintf
-errno
-stdint
-
-configure.ac:
-gl_STDIO_MODULE_INDICATOR([zsprintf])
-
-Makefile.am:
-lib_SOURCES += zsprintf.c
-
-Include:
-<stdio.h>
-
-License:
-LGPL
-
-Maintainer:
-all
+++ /dev/null
-Description:
-zsprintf() function
-with POSIX compliant and GNU compatible format string interpretation
-
-Files:
-
-Depends-on:
-zsprintf-posix
-mixin/printf-gnu
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPL
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-zsprintf-gnu.c
-tests/test-zsprintf-gnu.h
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-zsprintf-gnu
-check_PROGRAMS += test-zsprintf-gnu
+++ /dev/null
-Description:
-zsprintf() function with POSIX compliant format string interpretation
-
-Files:
-
-Depends-on:
-zsprintf
-mixin/printf-posix
-
-configure.ac:
-gl_PREREQ_VASNPRINTF_WITH_POSIX_EXTRAS
-
-Makefile.am:
-
-Include:
-<stdio.h>
-
-License:
-LGPL
-
-Maintainer:
-all
+++ /dev/null
-Files:
-tests/test-zsprintf-posix.c
-tests/test-zsprintf-posix.h
-tests/infinity.h
-tests/macros.h
-
-Depends-on:
-nan
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-zsprintf-posix
-check_PROGRAMS += test-zsprintf-posix
--- /dev/null
+/* Test of POSIX and GNU compatible c_snzprintf() function.
+ Copyright (C) 2011-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+#include <config.h>
+
+#include "c-snprintf.h"
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-snzprintf-gnu.h"
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_function (c_snzprintf);
+
+ return test_exit_status;
+}
--- /dev/null
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: "${LOCALE_FR=fr_FR}"
+if test $LOCALE_FR = none; then
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no traditional french locale is installed"
+ else
+ echo "Skipping test: no traditional french locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+${CHECKER} ./test-c-snzprintf-gnu${EXEEXT} 1
--- /dev/null
+/* Test of POSIX and GNU compatible c_vaszprintf() and c_aszprintf() functions.
+ Copyright (C) 2011-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+#include <config.h>
+
+#include "c-vasprintf.h"
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-vaszprintf-gnu.h"
+
+static ptrdiff_t
+my_c_aszprintf (char **result, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = c_vaszprintf (result, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_c_vaszprintf ()
+{
+ test_function (my_c_aszprintf);
+}
+
+static void
+test_c_aszprintf ()
+{
+ test_function (c_aszprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_c_vaszprintf ();
+ test_c_aszprintf ();
+
+ return test_exit_status;
+}
--- /dev/null
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: "${LOCALE_FR=fr_FR}"
+if test $LOCALE_FR = none; then
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no traditional french locale is installed"
+ else
+ echo "Skipping test: no traditional french locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+${CHECKER} ./test-c-vaszprintf-gnu${EXEEXT} 1
+++ /dev/null
-/* Test of POSIX and GNU compatible c_vazsprintf() and c_azsprintf() functions.
- Copyright (C) 2011-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-#include <config.h>
-
-#include "c-vasprintf.h"
-
-#include <locale.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-vazsprintf-gnu.h"
-
-static ptrdiff_t
-my_c_azsprintf (char **result, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = c_vazsprintf (result, format, args);
- va_end (args);
- return ret;
-}
-
-static void
-test_c_vazsprintf ()
-{
- test_function (my_c_azsprintf);
-}
-
-static void
-test_c_azsprintf ()
-{
- test_function (c_azsprintf);
-}
-
-int
-main (int argc, char *argv[])
-{
- /* configure should already have checked that the locale is supported. */
- if (setlocale (LC_ALL, "") == NULL)
- return 1;
-
- test_c_vazsprintf ();
- test_c_azsprintf ();
-
- return test_exit_status;
-}
+++ /dev/null
-#!/bin/sh
-
-# Test in an ISO-8859-1 or ISO-8859-15 locale.
-: "${LOCALE_FR=fr_FR}"
-if test $LOCALE_FR = none; then
- if test -f /usr/bin/localedef; then
- echo "Skipping test: no traditional french locale is installed"
- else
- echo "Skipping test: no traditional french locale is supported"
- fi
- exit 77
-fi
-
-LC_ALL=$LOCALE_FR \
-${CHECKER} ./test-c-vazsprintf-gnu${EXEEXT} 1
--- /dev/null
+/* Test of POSIX and GNU compatible c_vsnzprintf() function.
+ Copyright (C) 2011-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+#include <config.h>
+
+#include "c-vsnprintf.h"
+
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-snzprintf-gnu.h"
+
+static ptrdiff_t
+my_c_snzprintf (char *str, size_t size, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = c_vsnzprintf (str, size, format, args);
+ va_end (args);
+ return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+ /* configure should already have checked that the locale is supported. */
+ if (setlocale (LC_ALL, "") == NULL)
+ return 1;
+
+ test_function (my_c_snzprintf);
+
+ return test_exit_status;
+}
--- /dev/null
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: "${LOCALE_FR=fr_FR}"
+if test $LOCALE_FR = none; then
+ if test -f /usr/bin/localedef; then
+ echo "Skipping test: no traditional french locale is installed"
+ else
+ echo "Skipping test: no traditional french locale is supported"
+ fi
+ exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+${CHECKER} ./test-c-vsnzprintf-gnu${EXEEXT} 1
+++ /dev/null
-/* Test of POSIX and GNU compatible c_vzsnprintf() function.
- Copyright (C) 2011-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-#include <config.h>
-
-#include "c-vsnprintf.h"
-
-#include <locale.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsnprintf-gnu.h"
-
-static ptrdiff_t
-my_c_zsnprintf (char *str, size_t size, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = c_vzsnprintf (str, size, format, args);
- va_end (args);
- return ret;
-}
-
-int
-main (int argc, char *argv[])
-{
- /* configure should already have checked that the locale is supported. */
- if (setlocale (LC_ALL, "") == NULL)
- return 1;
-
- test_function (my_c_zsnprintf);
-
- return test_exit_status;
-}
+++ /dev/null
-#!/bin/sh
-
-# Test in an ISO-8859-1 or ISO-8859-15 locale.
-: "${LOCALE_FR=fr_FR}"
-if test $LOCALE_FR = none; then
- if test -f /usr/bin/localedef; then
- echo "Skipping test: no traditional french locale is installed"
- else
- echo "Skipping test: no traditional french locale is supported"
- fi
- exit 77
-fi
-
-LC_ALL=$LOCALE_FR \
-${CHECKER} ./test-c-vzsnprintf-gnu${EXEEXT} 1
+++ /dev/null
-/* Test of POSIX and GNU compatible c_zsnprintf() function.
- Copyright (C) 2011-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-#include <config.h>
-
-#include "c-snprintf.h"
-
-#include <locale.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsnprintf-gnu.h"
-
-int
-main (int argc, char *argv[])
-{
- /* configure should already have checked that the locale is supported. */
- if (setlocale (LC_ALL, "") == NULL)
- return 1;
-
- test_function (c_zsnprintf);
-
- return test_exit_status;
-}
+++ /dev/null
-#!/bin/sh
-
-# Test in an ISO-8859-1 or ISO-8859-15 locale.
-: "${LOCALE_FR=fr_FR}"
-if test $LOCALE_FR = none; then
- if test -f /usr/bin/localedef; then
- echo "Skipping test: no traditional french locale is installed"
- else
- echo "Skipping test: no traditional french locale is supported"
- fi
- exit 77
-fi
-
-LC_ALL=$LOCALE_FR \
-${CHECKER} ./test-c-zsnprintf-gnu${EXEEXT} 1
--- /dev/null
+/* Test of POSIX and GNU compatible snzprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-snzprintf-gnu.h"
+
+int
+main (int argc, char *argv[])
+{
+ test_function (snzprintf);
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX and GNU compatible vsnzprintf() and snzprintf() functions.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+/* This test exercises only a few POSIX compliance problems that are still
+ visible on platforms relevant in 2024. For a much more complete test suite,
+ see test-snprintf-posix.h. */
+
+static void
+test_function (ptrdiff_t (*my_snzprintf) (char *, size_t, const char *, ...))
+{
+ char result[5000];
+
+ /* Test the support of the 'B' conversion specifier for binary output of
+ integers. */
+
+ { /* This test would fail on all platforms other than glibc ≥ 2.35. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%#B %d", 12345, 33, 44, 55);
+ ASSERT (strcmp (result, "0B11000000111001 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+}
--- /dev/null
+/* Test of POSIX compatible snzprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-snzprintf-posix.h"
+
+int
+main (int argc, char *argv[])
+{
+ test_function (snzprintf);
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX compatible vsnzprintf() and snzprintf() functions.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+/* This test exercises only a few POSIX compliance problems that are still
+ visible on platforms relevant in 2024. For a much more complete test suite,
+ see test-snprintf-posix.h. */
+
+#include "infinity.h"
+#include "nan.h"
+
+/* Test whether string[start_index..end_index-1] is a valid textual
+ representation of NaN. */
+static int
+strisnan (const char *string, size_t start_index, size_t end_index, int uppercase)
+{
+ if (start_index < end_index)
+ {
+ if (string[start_index] == '-')
+ start_index++;
+ if (start_index + 3 <= end_index
+ && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0)
+ {
+ start_index += 3;
+ if (start_index == end_index
+ || (string[start_index] == '(' && string[end_index - 1] == ')'))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void
+test_function (ptrdiff_t (*my_snzprintf) (char *, size_t, const char *, ...))
+{
+ char result[5000];
+
+ /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
+ output of floating-point numbers. */
+
+ { /* This test would fail on Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%a %d", 3.1416015625, 33, 44, 55);
+ ASSERT (strcmp (result, "0x1.922p+1 33") == 0
+ || strcmp (result, "0x3.244p+0 33") == 0
+ || strcmp (result, "0x6.488p-1 33") == 0
+ || strcmp (result, "0xc.91p-2 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%A %d", -3.1416015625, 33, 44, 55);
+ ASSERT (strcmp (result, "-0X1.922P+1 33") == 0
+ || strcmp (result, "-0X3.244P+0 33") == 0
+ || strcmp (result, "-0X6.488P-1 33") == 0
+ || strcmp (result, "-0XC.91P-2 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on FreeBSD 6.1, NetBSD 10.0. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%.2a %d", 1.51, 33, 44, 55);
+ ASSERT (strcmp (result, "0x1.83p+0 33") == 0
+ || strcmp (result, "0x3.05p-1 33") == 0
+ || strcmp (result, "0x6.0ap-2 33") == 0
+ || strcmp (result, "0xc.14p-3 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on macOS 14, FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
+ Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%.0a %d", 1.51, 33, 44, 55);
+ ASSERT (strcmp (result, "0x2p+0 33") == 0
+ || strcmp (result, "0x3p-1 33") == 0
+ || strcmp (result, "0x6p-2 33") == 0
+ || strcmp (result, "0xcp-3 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the %f format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%f %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%f %d", NaNd (), 33, 44, 55);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%010f %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, " inf 33") == 0
+ || strcmp (result, " infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the %e format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%e %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%e %d", NaNd (), 33, 44, 55);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the %g format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%g %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%g %d", NaNd (), 33, 44, 55);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of large precision. */
+
+ { /* This test would fail on AIX 7.1. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%.4000d %d", 1234567, 99);
+ size_t i;
+ for (i = 0; i < 4000 - 7; i++)
+ ASSERT (result[i] == '0');
+ ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the 'b' conversion specifier for binary output of
+ integers. */
+
+ { /* This test would fail on glibc 2.34, musl libc, macOS 14,
+ FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_snzprintf (result, sizeof (result), "%b %d", 12345, 33, 44, 55);
+ ASSERT (strcmp (result, "11000000111001 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+}
--- /dev/null
+/* Test of POSIX and GNU compatible szprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-szprintf-gnu.h"
+
+int
+main (int argc, char *argv[])
+{
+ test_function (szprintf);
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX and GNU compatible vszprintf() and szprintf() functions.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+/* This test exercises only a few POSIX compliance problems that are still
+ visible on platforms relevant in 2024. For a much more complete test suite,
+ see test-sprintf-posix.h. */
+
+static void
+test_function (ptrdiff_t (*my_szprintf) (char *, const char *, ...))
+{
+ char result[5000];
+
+ /* Test the support of the 'B' conversion specifier for binary output of
+ integers. */
+
+ { /* This test would fail on all platforms other than glibc ≥ 2.35. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%#B %d", 12345, 33, 44, 55);
+ ASSERT (strcmp (result, "0B11000000111001 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+}
--- /dev/null
+/* Test of POSIX compatible szprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-szprintf-posix.h"
+
+int
+main (int argc, char *argv[])
+{
+ test_function (szprintf);
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX compatible vszprintf() and szprintf() functions.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+/* This test exercises only a few POSIX compliance problems that are still
+ visible on platforms relevant in 2024. For a much more complete test suite,
+ see test-sprintf-posix.h. */
+
+#include "infinity.h"
+#include "nan.h"
+
+/* Test whether string[start_index..end_index-1] is a valid textual
+ representation of NaN. */
+static int
+strisnan (const char *string, size_t start_index, size_t end_index, int uppercase)
+{
+ if (start_index < end_index)
+ {
+ if (string[start_index] == '-')
+ start_index++;
+ if (start_index + 3 <= end_index
+ && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0)
+ {
+ start_index += 3;
+ if (start_index == end_index
+ || (string[start_index] == '(' && string[end_index - 1] == ')'))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void
+test_function (ptrdiff_t (*my_szprintf) (char *, const char *, ...))
+{
+ char result[5000];
+
+ /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
+ output of floating-point numbers. */
+
+ { /* This test would fail on Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%a %d", 3.1416015625, 33, 44, 55);
+ ASSERT (strcmp (result, "0x1.922p+1 33") == 0
+ || strcmp (result, "0x3.244p+0 33") == 0
+ || strcmp (result, "0x6.488p-1 33") == 0
+ || strcmp (result, "0xc.91p-2 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%A %d", -3.1416015625, 33, 44, 55);
+ ASSERT (strcmp (result, "-0X1.922P+1 33") == 0
+ || strcmp (result, "-0X3.244P+0 33") == 0
+ || strcmp (result, "-0X6.488P-1 33") == 0
+ || strcmp (result, "-0XC.91P-2 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on FreeBSD 6.1, NetBSD 10.0. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%.2a %d", 1.51, 33, 44, 55);
+ ASSERT (strcmp (result, "0x1.83p+0 33") == 0
+ || strcmp (result, "0x3.05p-1 33") == 0
+ || strcmp (result, "0x6.0ap-2 33") == 0
+ || strcmp (result, "0xc.14p-3 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on macOS 14, FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
+ Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%.0a %d", 1.51, 33, 44, 55);
+ ASSERT (strcmp (result, "0x2p+0 33") == 0
+ || strcmp (result, "0x3p-1 33") == 0
+ || strcmp (result, "0x6p-2 33") == 0
+ || strcmp (result, "0xcp-3 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the %f format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%f %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%f %d", NaNd (), 33, 44, 55);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%010f %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, " inf 33") == 0
+ || strcmp (result, " infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the %e format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%e %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%e %d", NaNd (), 33, 44, 55);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the %g format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%g %d", Infinityd (), 33, 44, 55);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%g %d", NaNd (), 33, 44, 55);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of large precision. */
+
+ { /* This test would fail on AIX 7.1. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%.4000d %d", 1234567, 99);
+ size_t i;
+ for (i = 0; i < 4000 - 7; i++)
+ ASSERT (result[i] == '0');
+ ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
+ ASSERT (retval == strlen (result));
+ }
+
+ /* Test the support of the 'b' conversion specifier for binary output of
+ integers. */
+
+ { /* This test would fail on glibc 2.34, musl libc, macOS 14,
+ FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */
+ ptrdiff_t retval =
+ my_szprintf (result, "%b %d", 12345, 33, 44, 55);
+ ASSERT (strcmp (result, "11000000111001 33") == 0);
+ ASSERT (retval == strlen (result));
+ }
+}
--- /dev/null
+/* Test of POSIX and GNU compatible vaszprintf() and aszprintf() functions.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+/* This test exercises only a few POSIX compliance problems that are still
+ visible on platforms relevant in 2024. For a much more complete test suite,
+ see test-vasprintf-posix.c. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-vaszprintf-gnu.h"
+
+static ptrdiff_t
+my_aszprintf (char **result, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = vaszprintf (result, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vaszprintf ()
+{
+ test_function (my_aszprintf);
+}
+
+static void
+test_aszprintf ()
+{
+ test_function (aszprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vaszprintf ();
+ test_aszprintf ();
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX and GNU compatible vaszprintf() and aszprintf() functions.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+static void
+test_function (ptrdiff_t (*my_aszprintf) (char **, const char *, ...))
+{
+ /* Test the support of the 'B' conversion specifier for binary output of
+ integers. */
+
+ { /* This test would fail on all platforms other than glibc ≥ 2.35. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%#B %d", 12345, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0B11000000111001 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+}
--- /dev/null
+/* Test of POSIX compatible vaszprintf() and aszprintf() functions.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
+
+/* This test exercises only a few POSIX compliance problems that are still
+ visible on platforms relevant in 2024. For a much more complete test suite,
+ see test-vasprintf-posix.c. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+#include "infinity.h"
+#include "nan.h"
+
+/* Test whether string[start_index..end_index-1] is a valid textual
+ representation of NaN. */
+static int
+strisnan (const char *string, size_t start_index, size_t end_index, int uppercase)
+{
+ if (start_index < end_index)
+ {
+ if (string[start_index] == '-')
+ start_index++;
+ if (start_index + 3 <= end_index
+ && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0)
+ {
+ start_index += 3;
+ if (start_index == end_index
+ || (string[start_index] == '(' && string[end_index - 1] == ')'))
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static void
+test_function (ptrdiff_t (*my_aszprintf) (char **, const char *, ...))
+{
+ char result[5000];
+
+ /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
+ output of floating-point numbers. */
+
+ { /* This test would fail on Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%a %d", 3.1416015625, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.922p+1 33") == 0
+ || strcmp (result, "0x3.244p+0 33") == 0
+ || strcmp (result, "0x6.488p-1 33") == 0
+ || strcmp (result, "0xc.91p-2 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ { /* This test would fail on Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%A %d", -3.1416015625, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "-0X1.922P+1 33") == 0
+ || strcmp (result, "-0X3.244P+0 33") == 0
+ || strcmp (result, "-0X6.488P-1 33") == 0
+ || strcmp (result, "-0XC.91P-2 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ { /* This test would fail on FreeBSD 6.1, NetBSD 10.0. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%.2a %d", 1.51, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x1.83p+0 33") == 0
+ || strcmp (result, "0x3.05p-1 33") == 0
+ || strcmp (result, "0x6.0ap-2 33") == 0
+ || strcmp (result, "0xc.14p-3 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ { /* This test would fail on macOS 14, FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
+ Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%.0a %d", 1.51, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "0x2p+0 33") == 0
+ || strcmp (result, "0x3p-1 33") == 0
+ || strcmp (result, "0x6p-2 33") == 0
+ || strcmp (result, "0xcp-3 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ /* Test the support of the %f format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%f %d", Infinityd (), 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%f %d", NaNd (), 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%010f %d", Infinityd (), 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, " inf 33") == 0
+ || strcmp (result, " infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ /* Test the support of the %e format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%e %d", Infinityd (), 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%e %d", NaNd (), 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ /* Test the support of the %g format directive. */
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%g %d", Infinityd (), 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "inf 33") == 0
+ || strcmp (result, "infinity 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ { /* This test would fail on AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%g %d", NaNd (), 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strlen (result) >= 3 + 3
+ && strisnan (result, 0, strlen (result) - 3, 0)
+ && strcmp (result + strlen (result) - 3, " 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ /* Test the support of large precision. */
+
+ { /* This test would fail on AIX 7.1. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%.4000d %d", 1234567, 99);
+ ASSERT (result != NULL);
+ size_t i;
+ for (i = 0; i < 4000 - 7; i++)
+ ASSERT (result[i] == '0');
+ ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
+ /* Test the support of the 'b' conversion specifier for binary output of
+ integers. */
+
+ { /* This test would fail on glibc 2.34, musl libc, macOS 14,
+ FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */
+ char *result;
+ ptrdiff_t retval =
+ my_aszprintf (&result, "%b %d", 12345, 33, 44, 55);
+ ASSERT (result != NULL);
+ ASSERT (strcmp (result, "11000000111001 33") == 0);
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+}
+
+static ptrdiff_t
+my_aszprintf (char **result, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = vaszprintf (result, format, args);
+ va_end (args);
+ return ret;
+}
+
+static void
+test_vaszprintf ()
+{
+ test_function (my_aszprintf);
+}
+
+static void
+test_aszprintf ()
+{
+ test_function (aszprintf);
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_vaszprintf ();
+ test_aszprintf ();
+ return test_exit_status;
+}
+++ /dev/null
-/* Test of POSIX and GNU compatible vazsprintf() and azsprintf() functions.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-/* This test exercises only a few POSIX compliance problems that are still
- visible on platforms relevant in 2024. For a much more complete test suite,
- see test-vasprintf-posix.c. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-vazsprintf-gnu.h"
-
-static ptrdiff_t
-my_azsprintf (char **result, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = vazsprintf (result, format, args);
- va_end (args);
- return ret;
-}
-
-static void
-test_vazsprintf ()
-{
- test_function (my_azsprintf);
-}
-
-static void
-test_azsprintf ()
-{
- test_function (azsprintf);
-}
-
-int
-main (int argc, char *argv[])
-{
- test_vazsprintf ();
- test_azsprintf ();
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX and GNU compatible vazsprintf() and azsprintf() functions.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-static void
-test_function (ptrdiff_t (*my_azsprintf) (char **, const char *, ...))
-{
- /* Test the support of the 'B' conversion specifier for binary output of
- integers. */
-
- { /* This test would fail on all platforms other than glibc ≥ 2.35. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%#B %d", 12345, 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "0B11000000111001 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-}
+++ /dev/null
-/* Test of POSIX compatible vazsprintf() and azsprintf() functions.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-/* This test exercises only a few POSIX compliance problems that are still
- visible on platforms relevant in 2024. For a much more complete test suite,
- see test-vasprintf-posix.c. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "macros.h"
-#include "infinity.h"
-#include "nan.h"
-
-/* Test whether string[start_index..end_index-1] is a valid textual
- representation of NaN. */
-static int
-strisnan (const char *string, size_t start_index, size_t end_index, int uppercase)
-{
- if (start_index < end_index)
- {
- if (string[start_index] == '-')
- start_index++;
- if (start_index + 3 <= end_index
- && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0)
- {
- start_index += 3;
- if (start_index == end_index
- || (string[start_index] == '(' && string[end_index - 1] == ')'))
- return 1;
- }
- }
- return 0;
-}
-
-static void
-test_function (ptrdiff_t (*my_azsprintf) (char **, const char *, ...))
-{
- char result[5000];
-
- /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
- output of floating-point numbers. */
-
- { /* This test would fail on Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%a %d", 3.1416015625, 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "0x1.922p+1 33") == 0
- || strcmp (result, "0x3.244p+0 33") == 0
- || strcmp (result, "0x6.488p-1 33") == 0
- || strcmp (result, "0xc.91p-2 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- { /* This test would fail on Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%A %d", -3.1416015625, 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "-0X1.922P+1 33") == 0
- || strcmp (result, "-0X3.244P+0 33") == 0
- || strcmp (result, "-0X6.488P-1 33") == 0
- || strcmp (result, "-0XC.91P-2 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- { /* This test would fail on FreeBSD 6.1, NetBSD 10.0. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%.2a %d", 1.51, 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "0x1.83p+0 33") == 0
- || strcmp (result, "0x3.05p-1 33") == 0
- || strcmp (result, "0x6.0ap-2 33") == 0
- || strcmp (result, "0xc.14p-3 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- { /* This test would fail on macOS 14, FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
- Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%.0a %d", 1.51, 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "0x2p+0 33") == 0
- || strcmp (result, "0x3p-1 33") == 0
- || strcmp (result, "0x6p-2 33") == 0
- || strcmp (result, "0xcp-3 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- /* Test the support of the %f format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%f %d", Infinityd (), 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%f %d", NaNd (), 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%010f %d", Infinityd (), 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, " inf 33") == 0
- || strcmp (result, " infinity 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- /* Test the support of the %e format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%e %d", Infinityd (), 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%e %d", NaNd (), 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- /* Test the support of the %g format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%g %d", Infinityd (), 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%g %d", NaNd (), 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- /* Test the support of large precision. */
-
- { /* This test would fail on AIX 7.1. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%.4000d %d", 1234567, 99);
- ASSERT (result != NULL);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
- ASSERT (result[i] == '0');
- ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-
- /* Test the support of the 'b' conversion specifier for binary output of
- integers. */
-
- { /* This test would fail on glibc 2.34, musl libc, macOS 14,
- FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */
- char *result;
- ptrdiff_t retval =
- my_azsprintf (&result, "%b %d", 12345, 33, 44, 55);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "11000000111001 33") == 0);
- ASSERT (retval == strlen (result));
- free (result);
- }
-}
-
-static ptrdiff_t
-my_azsprintf (char **result, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = vazsprintf (result, format, args);
- va_end (args);
- return ret;
-}
-
-static void
-test_vazsprintf ()
-{
- test_function (my_azsprintf);
-}
-
-static void
-test_azsprintf ()
-{
- test_function (azsprintf);
-}
-
-int
-main (int argc, char *argv[])
-{
- test_vazsprintf ();
- test_azsprintf ();
- return test_exit_status;
-}
--- /dev/null
+/* Test of POSIX and GNU compatible vsnzprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-snzprintf-gnu.h"
+
+static ptrdiff_t
+my_snzprintf (char *str, size_t size, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = vsnzprintf (str, size, format, args);
+ va_end (args);
+ return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_function (my_snzprintf);
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX compatible vsnzprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-snzprintf-posix.h"
+
+static ptrdiff_t
+my_snzprintf (char *str, size_t size, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = vsnzprintf (str, size, format, args);
+ va_end (args);
+ return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_function (my_snzprintf);
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX and GNU compatible vszprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-szprintf-gnu.h"
+
+static ptrdiff_t
+my_szprintf (char *str, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = vszprintf (str, format, args);
+ va_end (args);
+ return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_function (my_szprintf);
+ return test_exit_status;
+}
--- /dev/null
+/* Test of POSIX compatible vszprintf() function.
+ Copyright (C) 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "macros.h"
+
+#include "test-szprintf-posix.h"
+
+static ptrdiff_t
+my_szprintf (char *str, const char *format, ...)
+{
+ va_list args;
+ ptrdiff_t ret;
+
+ va_start (args, format);
+ ret = vszprintf (str, format, args);
+ va_end (args);
+ return ret;
+}
+
+int
+main (int argc, char *argv[])
+{
+ test_function (my_szprintf);
+ return test_exit_status;
+}
+++ /dev/null
-/* Test of POSIX and GNU compatible vzsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsnprintf-gnu.h"
-
-static ptrdiff_t
-my_zsnprintf (char *str, size_t size, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = vzsnprintf (str, size, format, args);
- va_end (args);
- return ret;
-}
-
-int
-main (int argc, char *argv[])
-{
- test_function (my_zsnprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX compatible vzsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsnprintf-posix.h"
-
-static ptrdiff_t
-my_zsnprintf (char *str, size_t size, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = vzsnprintf (str, size, format, args);
- va_end (args);
- return ret;
-}
-
-int
-main (int argc, char *argv[])
-{
- test_function (my_zsnprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX and GNU compatible vzsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsprintf-gnu.h"
-
-static ptrdiff_t
-my_zsprintf (char *str, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = vzsprintf (str, format, args);
- va_end (args);
- return ret;
-}
-
-int
-main (int argc, char *argv[])
-{
- test_function (my_zsprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX compatible vzsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsprintf-posix.h"
-
-static ptrdiff_t
-my_zsprintf (char *str, const char *format, ...)
-{
- va_list args;
- ptrdiff_t ret;
-
- va_start (args, format);
- ret = vzsprintf (str, format, args);
- va_end (args);
- return ret;
-}
-
-int
-main (int argc, char *argv[])
-{
- test_function (my_zsprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX and GNU compatible zsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsnprintf-gnu.h"
-
-int
-main (int argc, char *argv[])
-{
- test_function (zsnprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX and GNU compatible vzsnprintf() and zsnprintf() functions.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-/* This test exercises only a few POSIX compliance problems that are still
- visible on platforms relevant in 2024. For a much more complete test suite,
- see test-snprintf-posix.h. */
-
-static void
-test_function (ptrdiff_t (*my_zsnprintf) (char *, size_t, const char *, ...))
-{
- char result[5000];
-
- /* Test the support of the 'B' conversion specifier for binary output of
- integers. */
-
- { /* This test would fail on all platforms other than glibc ≥ 2.35. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%#B %d", 12345, 33, 44, 55);
- ASSERT (strcmp (result, "0B11000000111001 33") == 0);
- ASSERT (retval == strlen (result));
- }
-}
+++ /dev/null
-/* Test of POSIX compatible zsnprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsnprintf-posix.h"
-
-int
-main (int argc, char *argv[])
-{
- test_function (zsnprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX compatible vzsnprintf() and zsnprintf() functions.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-/* This test exercises only a few POSIX compliance problems that are still
- visible on platforms relevant in 2024. For a much more complete test suite,
- see test-snprintf-posix.h. */
-
-#include "infinity.h"
-#include "nan.h"
-
-/* Test whether string[start_index..end_index-1] is a valid textual
- representation of NaN. */
-static int
-strisnan (const char *string, size_t start_index, size_t end_index, int uppercase)
-{
- if (start_index < end_index)
- {
- if (string[start_index] == '-')
- start_index++;
- if (start_index + 3 <= end_index
- && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0)
- {
- start_index += 3;
- if (start_index == end_index
- || (string[start_index] == '(' && string[end_index - 1] == ')'))
- return 1;
- }
- }
- return 0;
-}
-
-static void
-test_function (ptrdiff_t (*my_zsnprintf) (char *, size_t, const char *, ...))
-{
- char result[5000];
-
- /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
- output of floating-point numbers. */
-
- { /* This test would fail on Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%a %d", 3.1416015625, 33, 44, 55);
- ASSERT (strcmp (result, "0x1.922p+1 33") == 0
- || strcmp (result, "0x3.244p+0 33") == 0
- || strcmp (result, "0x6.488p-1 33") == 0
- || strcmp (result, "0xc.91p-2 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%A %d", -3.1416015625, 33, 44, 55);
- ASSERT (strcmp (result, "-0X1.922P+1 33") == 0
- || strcmp (result, "-0X3.244P+0 33") == 0
- || strcmp (result, "-0X6.488P-1 33") == 0
- || strcmp (result, "-0XC.91P-2 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on FreeBSD 6.1, NetBSD 10.0. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%.2a %d", 1.51, 33, 44, 55);
- ASSERT (strcmp (result, "0x1.83p+0 33") == 0
- || strcmp (result, "0x3.05p-1 33") == 0
- || strcmp (result, "0x6.0ap-2 33") == 0
- || strcmp (result, "0xc.14p-3 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on macOS 14, FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
- Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%.0a %d", 1.51, 33, 44, 55);
- ASSERT (strcmp (result, "0x2p+0 33") == 0
- || strcmp (result, "0x3p-1 33") == 0
- || strcmp (result, "0x6p-2 33") == 0
- || strcmp (result, "0xcp-3 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the %f format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%f %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%f %d", NaNd (), 33, 44, 55);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%010f %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, " inf 33") == 0
- || strcmp (result, " infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the %e format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%e %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%e %d", NaNd (), 33, 44, 55);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the %g format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%g %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%g %d", NaNd (), 33, 44, 55);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of large precision. */
-
- { /* This test would fail on AIX 7.1. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%.4000d %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
- ASSERT (result[i] == '0');
- ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the 'b' conversion specifier for binary output of
- integers. */
-
- { /* This test would fail on glibc 2.34, musl libc, macOS 14,
- FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsnprintf (result, sizeof (result), "%b %d", 12345, 33, 44, 55);
- ASSERT (strcmp (result, "11000000111001 33") == 0);
- ASSERT (retval == strlen (result));
- }
-}
+++ /dev/null
-/* Test of POSIX and GNU compatible zsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsprintf-gnu.h"
-
-int
-main (int argc, char *argv[])
-{
- test_function (zsprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX and GNU compatible vzsprintf() and zsprintf() functions.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-/* This test exercises only a few POSIX compliance problems that are still
- visible on platforms relevant in 2024. For a much more complete test suite,
- see test-sprintf-posix.h. */
-
-static void
-test_function (ptrdiff_t (*my_zsprintf) (char *, const char *, ...))
-{
- char result[5000];
-
- /* Test the support of the 'B' conversion specifier for binary output of
- integers. */
-
- { /* This test would fail on all platforms other than glibc ≥ 2.35. */
- ptrdiff_t retval =
- my_zsprintf (result, "%#B %d", 12345, 33, 44, 55);
- ASSERT (strcmp (result, "0B11000000111001 33") == 0);
- ASSERT (retval == strlen (result));
- }
-}
+++ /dev/null
-/* Test of POSIX compatible zsprintf() function.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-
-#include <config.h>
-
-#include <stdio.h>
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <string.h>
-
-#include "macros.h"
-
-#include "test-zsprintf-posix.h"
-
-int
-main (int argc, char *argv[])
-{
- test_function (zsprintf);
- return test_exit_status;
-}
+++ /dev/null
-/* Test of POSIX compatible vzsprintf() and zsprintf() functions.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>. */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2024. */
-
-/* This test exercises only a few POSIX compliance problems that are still
- visible on platforms relevant in 2024. For a much more complete test suite,
- see test-sprintf-posix.h. */
-
-#include "infinity.h"
-#include "nan.h"
-
-/* Test whether string[start_index..end_index-1] is a valid textual
- representation of NaN. */
-static int
-strisnan (const char *string, size_t start_index, size_t end_index, int uppercase)
-{
- if (start_index < end_index)
- {
- if (string[start_index] == '-')
- start_index++;
- if (start_index + 3 <= end_index
- && memcmp (string + start_index, uppercase ? "NAN" : "nan", 3) == 0)
- {
- start_index += 3;
- if (start_index == end_index
- || (string[start_index] == '(' && string[end_index - 1] == ')'))
- return 1;
- }
- }
- return 0;
-}
-
-static void
-test_function (ptrdiff_t (*my_zsprintf) (char *, const char *, ...))
-{
- char result[5000];
-
- /* Test the support of the 'a' and 'A' conversion specifier for hexadecimal
- output of floating-point numbers. */
-
- { /* This test would fail on Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%a %d", 3.1416015625, 33, 44, 55);
- ASSERT (strcmp (result, "0x1.922p+1 33") == 0
- || strcmp (result, "0x3.244p+0 33") == 0
- || strcmp (result, "0x6.488p-1 33") == 0
- || strcmp (result, "0xc.91p-2 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%A %d", -3.1416015625, 33, 44, 55);
- ASSERT (strcmp (result, "-0X1.922P+1 33") == 0
- || strcmp (result, "-0X3.244P+0 33") == 0
- || strcmp (result, "-0X6.488P-1 33") == 0
- || strcmp (result, "-0XC.91P-2 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on FreeBSD 6.1, NetBSD 10.0. */
- ptrdiff_t retval =
- my_zsprintf (result, "%.2a %d", 1.51, 33, 44, 55);
- ASSERT (strcmp (result, "0x1.83p+0 33") == 0
- || strcmp (result, "0x3.05p-1 33") == 0
- || strcmp (result, "0x6.0ap-2 33") == 0
- || strcmp (result, "0xc.14p-3 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on macOS 14, FreeBSD 14.0, OpenBSD 7.5, AIX 7.3,
- Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%.0a %d", 1.51, 33, 44, 55);
- ASSERT (strcmp (result, "0x2p+0 33") == 0
- || strcmp (result, "0x3p-1 33") == 0
- || strcmp (result, "0x6p-2 33") == 0
- || strcmp (result, "0xcp-3 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the %f format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%f %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%f %d", NaNd (), 33, 44, 55);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%010f %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, " inf 33") == 0
- || strcmp (result, " infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the %e format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%e %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%e %d", NaNd (), 33, 44, 55);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the %g format directive. */
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%g %d", Infinityd (), 33, 44, 55);
- ASSERT (strcmp (result, "inf 33") == 0
- || strcmp (result, "infinity 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- { /* This test would fail on AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%g %d", NaNd (), 33, 44, 55);
- ASSERT (strlen (result) >= 3 + 3
- && strisnan (result, 0, strlen (result) - 3, 0)
- && strcmp (result + strlen (result) - 3, " 33") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of large precision. */
-
- { /* This test would fail on AIX 7.1. */
- ptrdiff_t retval =
- my_zsprintf (result, "%.4000d %d", 1234567, 99);
- size_t i;
- for (i = 0; i < 4000 - 7; i++)
- ASSERT (result[i] == '0');
- ASSERT (strcmp (result + 4000 - 7, "1234567 99") == 0);
- ASSERT (retval == strlen (result));
- }
-
- /* Test the support of the 'b' conversion specifier for binary output of
- integers. */
-
- { /* This test would fail on glibc 2.34, musl libc, macOS 14,
- FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4. */
- ptrdiff_t retval =
- my_zsprintf (result, "%b %d", 12345, 33, 44, 55);
- ASSERT (strcmp (result, "11000000111001 33") == 0);
- ASSERT (retval == strlen (result));
- }
-}