{ Copy-paste of https://github.com/mingw-w64/mingw-w64/issues/102 }

Hello all!

I found two issues when digging in the mingw crt/stdio code, and I wonder
if this is something you would like a patch for.

First issue :
emu__vscwprintf (in mingw-w64-crt/stdio/_vscwprintf.c)

_vsnwprintf expects to receive a buffer size in number of wchar_t, but the
size being passed is in bytes
(hence, the actual buffer is 2x or 4x too small vs what expected : Thanks
ASan!)

Second issue :
mingw_pformat.c does not honor some Microsoft specific format behavior for
strings, in relation to Unicode/WideChar.

per
https://learn.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=msvc-170

For historical reasons, the wprintf functions use c and s to refer to
wchar_t characters, and C and S specify narrow characters.

In short, %s is the 'native' wideness for the format function, and %S is
the opposite.
So, for wide function : %s is wide, %S is narrow, and for narrow function :
%s is narrow, and %S is wide.
(idem for %c %C)

The 'w' size prefix is also not supported (same a 'l').

Are those changes you will be interested to receive a PR for?
(I would not change the behavior if __BUILD_WIDEAPI_ISO is defined)


Regards, and thanks for this amazing project.

Julien

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to