]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
[v]szprintf: Improve port to Fil-C.
authorBruno Haible <bruno@clisp.org>
Sun, 26 Jul 2026 23:45:50 +0000 (01:45 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 26 Jul 2026 23:45:50 +0000 (01:45 +0200)
Suggested by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2026-07/msg00181.html>.

* lib/vasnprintf.c (USE_SNPRINTF): Define to 0 on Fil-C.
* lib/szprintf.c (szprintf): Revert last change.
* lib/vszprintf.c (vszprintf): Likewise.
* lib/unistdio/u-vsprintf.h (VSPRINTF): Likewise.

ChangeLog
lib/szprintf.c
lib/unistdio/u-vsprintf.h
lib/vasnprintf.c
lib/vszprintf.c

index 0bf879e0d326e6ebb0dd616baa5cd2b20a71f0e4..757e1b7fe9a4672ca20a7980c91a7d3f03abd6fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-07-26  Bruno Haible  <bruno@clisp.org>
+
+       [v]szprintf: Improve port to Fil-C.
+       Suggested by Paul Eggert in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2026-07/msg00181.html>.
+       * lib/vasnprintf.c (USE_SNPRINTF): Define to 0 on Fil-C.
+       * lib/szprintf.c (szprintf): Revert last change.
+       * lib/vszprintf.c (vszprintf): Likewise.
+       * lib/unistdio/u-vsprintf.h (VSPRINTF): Likewise.
+
 2026-07-26  Bruno Haible  <bruno@clisp.org>
 
        Pacify -fsanitize=address in rawmemchr, strchrnul also with clang < 22.
index 651aae801e890c5d36090bd8ff6c81457a0290db..a5a3291c9e174d7a07a2ef063cc229a8dc6ac6f7 100644 (file)
@@ -22,7 +22,6 @@
 #include <stdio.h>
 
 #include <errno.h>
-#include <limits.h>
 #include <stdarg.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -39,10 +38,6 @@ szprintf (char *str, const char *format, ...)
   size_t lenbuf = SIZE_MAX;
   if (lenbuf >= ~ (uintptr_t) str)
     lenbuf = ~ (uintptr_t) str;
-#if defined __FILC__
-  if (lenbuf > INT_MAX)
-    lenbuf = INT_MAX;
-#endif
 
   char *output = vasnprintf (str, &lenbuf, format, args);
   size_t len = lenbuf;
index 6f93257c179773337405dd03285a69732d261485..4cc7506b54d7c22be10b6ab8db7a7c95401021a2 100644 (file)
@@ -39,10 +39,6 @@ VSPRINTF (DCHAR_T *buf, const FCHAR_T *format, va_list args)
   size_t length = (SIZE_MAX < INT_MAX ? SIZE_MAX : INT_MAX);
   if (length > (~ (uintptr_t) buf) / sizeof (DCHAR_T))
     length = (~ (uintptr_t) buf) / sizeof (DCHAR_T);
-#if defined __FILC__
-  if (length > INT_MAX / sizeof (DCHAR_T))
-    length = INT_MAX / sizeof (DCHAR_T);
-#endif
 
   DCHAR_T *result = VASNPRINTF (buf, &length, format, args);
   if (result == NULL)
index 750601cfb25df840130f7daad88b35fbeb744389..10e6af5bf9fd1050c5e3c57bf1e9938a961aa90f 100644 (file)
           || (defined __APPLE__ && defined __MACH__) \
           || (defined __FreeBSD__ || defined __DragonFly__) \
           || defined __OpenBSD__ \
-          || defined __ANDROID__ || defined _UCRT))
+          || defined __ANDROID__ || defined _UCRT) \
+      && !defined __FILC__)
 #  define USE_SNPRINTF 1
 # else
 #  define USE_SNPRINTF 0
index 2a65064541e84e2d9ea756c732f4022fc5c938a7..69c6fa05bbaf7456b62ad31a53cd8cafeb4ab62d 100644 (file)
@@ -22,7 +22,6 @@
 #include <stdio.h>
 
 #include <errno.h>
-#include <limits.h>
 #include <stdarg.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -36,10 +35,6 @@ vszprintf (char *str, const char *format, va_list args)
   size_t lenbuf = SIZE_MAX;
   if (lenbuf >= ~ (uintptr_t) str)
     lenbuf = ~ (uintptr_t) str;
-#if defined __FILC__
-  if (lenbuf > INT_MAX)
-    lenbuf = INT_MAX;
-#endif
 
   char *output = vasnprintf (str, &lenbuf, format, args);
   size_t len = lenbuf;