From: Bruno Haible Date: Sun, 26 Jul 2026 23:45:50 +0000 (+0200) Subject: [v]szprintf: Improve port to Fil-C. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc686d171c1fdfe85dfed4a7ed224418cc7dee5b;p=thirdparty%2Fgnulib.git [v]szprintf: Improve port to Fil-C. Suggested by Paul Eggert in . * 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. --- diff --git a/ChangeLog b/ChangeLog index 0bf879e0d3..757e1b7fe9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2026-07-26 Bruno Haible + + [v]szprintf: Improve port to Fil-C. + Suggested by Paul Eggert in + . + * 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 Pacify -fsanitize=address in rawmemchr, strchrnul also with clang < 22. diff --git a/lib/szprintf.c b/lib/szprintf.c index 651aae801e..a5a3291c9e 100644 --- a/lib/szprintf.c +++ b/lib/szprintf.c @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -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; diff --git a/lib/unistdio/u-vsprintf.h b/lib/unistdio/u-vsprintf.h index 6f93257c17..4cc7506b54 100644 --- a/lib/unistdio/u-vsprintf.h +++ b/lib/unistdio/u-vsprintf.h @@ -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) diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 750601cfb2..10e6af5bf9 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -230,7 +230,8 @@ || (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 diff --git a/lib/vszprintf.c b/lib/vszprintf.c index 2a65064541..69c6fa05bb 100644 --- a/lib/vszprintf.c +++ b/lib/vszprintf.c @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -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;