From: Bruno Haible Date: Wed, 22 Mar 2023 05:13:18 +0000 (+0100) Subject: unistdio/u*-vasnprintf: Fix conversion of %Id directive result. X-Git-Tag: v1.0~1610 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c9e246f596836d1eb57120a2d3b65687170356a1;p=gnulib.git unistdio/u*-vasnprintf: Fix conversion of %Id directive result. * lib/vasnprintf.c (VASNPRINTF): Don't assume that snprintf's result is entirely ASCII if the directive contain the glibc 'I' flag. --- diff --git a/ChangeLog b/ChangeLog index 93086af107..33d54f7202 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-03-21 Bruno Haible + + unistdio/u*-vasnprintf: Fix conversion of %Id directive result. + * lib/vasnprintf.c (VASNPRINTF): Don't assume that snprintf's result is + entirely ASCII if the directive contain the glibc 'I' flag. + 2023-03-21 Bruno Haible vasnwprintf: Fix for older platforms without swprintf. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index bd13002e98..8e6596df2f 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -5836,11 +5836,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #if !DCHAR_IS_TCHAR /* Convert from TCHAR_T[] to DCHAR_T[]. */ - if (dp->conversion == 'c' || dp->conversion == 's') + if (dp->conversion == 'c' || dp->conversion == 's' +# if __GLIBC__ >= 2 && !defined __UCLIBC__ + || (flags & FLAG_LOCALIZED) +# endif + ) { - /* type = TYPE_CHAR or TYPE_WIDE_CHAR or TYPE_STRING - TYPE_WIDE_STRING. - The result string is not certainly ASCII. */ + /* The result string is not guaranteed to be ASCII. */ const TCHAR_T *tmpsrc; DCHAR_T *tmpdst; size_t tmpdst_len;