On Thu, 15 Oct 2015, Martin Storsjo wrote:
Not all functions are implemented (yet not all variants are implemented in the normal msvcrt either).
The new functions are more generalized and are C99 compliant. They take an options parameter that e.g. for the snprintf family of functions indicate whether the truncation and return value should be handled as before or in the standards compliant way.
Some rudimentary tests are added (based on the msvcrt printf tests), testing to make sure the snprintf truncation/return values are handled correctly.
These new functions also should support the C99 conversion specifiers; this is not yet implemented.
Signed-off-by: Martin Storsjo martin@martin.st
.../api-ms-win-crt-stdio-l1-1-0.spec | 10 +- dlls/msvcrt/file.c | 28 +++ dlls/msvcrt/printf.h | 20 ++ dlls/msvcrt/wcs.c | 34 +++ dlls/ucrtbase/tests/Makefile.in | 1 + dlls/ucrtbase/tests/printf.c | 259 +++++++++++++++++++++ dlls/ucrtbase/ucrtbase.spec | 10 +- 7 files changed, 352 insertions(+), 10 deletions(-) create mode 100644 dlls/ucrtbase/tests/printf.c
diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h index 4757931..bd2dbf3 100644 --- a/dlls/msvcrt/printf.h +++ b/dlls/msvcrt/printf.h @@ -64,6 +64,26 @@ static int FUNC_NAME(puts_clbk_str)(void *ctx, int len, const APICHAR *str) return len; }
+static int FUNC_NAME(puts_clbk_str_c99)(void *ctx, int len, const APICHAR *str) +{
- struct FUNC_NAME(_str_ctx) *out = ctx;
- if(!out->buf)
return len;
- if(out->len - 1 < len) {
memcpy(out->buf, str, (out->len - 1)*sizeof(APICHAR));
out->buf += out->len - 1;
out->len = 1;
return len;
- }
- memcpy(out->buf, str, len*sizeof(APICHAR));
- out->buf += len;
- out->len -= len;
- return len;
+}
FWIW, this gives warnings about puts_clbk_str_c99_w being defined but unused. It will be necessary later in case someone wants to implement the wchar versions of the printf functions for ucrtbase, but what should be done in the meantime? Just define this function somewhere else in wcs.c instead?
// Martin
Hi,
On 10/20/15 10:50, Martin Storsjö wrote:
FWIW, this gives warnings about puts_clbk_str_c99_w being defined but unused. It will be necessary later in case someone wants to implement the wchar versions of the printf functions for ucrtbase, but what should be done in the meantime? Just define this function somewhere else in wcs.c instead?
I don't think it's useful to add some kind of workaround in this case. The function will be needed when e.g. __stdio_common_vfwprintf is implemented. The simplest solution is to include implementation of wchar_t variant of the function in this patch.
Please note that your tests are failing in 64-bit wine: ../../../../wine_src/tools/runtest -q -P wine -T ../../.. -M ucrtbase.dll -p ucrtbase_test.exe.so printf && touch printf.ok fixme:msvcrt:pf_printf_a multibyte characters printing not supported printf.c:167: Test failed: buf = containsmnull
fixme:msvcrt:pf_printf_a multibyte characters printing not supported printf.c:194: Test failed: buf = containscnull
Makefile:160: recipe for target 'printf.ok' failed make: *** [printf.ok] Error 2
Thanks, Piotr
On Mon, 26 Oct 2015, Piotr Caban wrote:
Hi,
On 10/20/15 10:50, Martin Storsjö wrote:
FWIW, this gives warnings about puts_clbk_str_c99_w being defined but unused. It will be necessary later in case someone wants to implement the wchar versions of the printf functions for ucrtbase, but what should be done in the meantime? Just define this function somewhere else in wcs.c instead?
I don't think it's useful to add some kind of workaround in this case. The function will be needed when e.g. __stdio_common_vfwprintf is implemented. The simplest solution is to include implementation of wchar_t variant of the function in this patch.
Thanks, that's probably the easiest, especially for an initial implementation of it.
Please note that your tests are failing in 64-bit wine: ../../../../wine_src/tools/runtest -q -P wine -T ../../.. -M ucrtbase.dll -p ucrtbase_test.exe.so printf && touch printf.ok fixme:msvcrt:pf_printf_a multibyte characters printing not supported printf.c:167: Test failed: buf = containsmnull
fixme:msvcrt:pf_printf_a multibyte characters printing not supported printf.c:194: Test failed: buf = containscnull
Makefile:160: recipe for target 'printf.ok' failed make: *** [printf.ok] Error 2
Thanks, the varargs wrappers were missing __cdecl (which I didn't seen the need for before, when basing this on the msvcrt tests).
// Martin