On 06/21/16 10:09, Hugh McMaster wrote:
> dlls/msvcrt/msvcrt.spec | 2 +-
> 2 files changed, 36 insertions(+), 1 deletion(-)
Please also update other msvc*/ucrtbase spec files as well.
> /*********************************************************************
> + * _wperror (MSVCRT.@)
> + */
> +void CDECL MSVCRT__wperror(const MSVCRT_wchar_t* str)
> +{
> + int err, size, len;
> + static const WCHAR colon_spaceW[] = {':',' ',0};
> + static const WCHAR newlineW[] = {'\n',0};
> + MSVCRT_wchar_t *buffer = NULL;
> +
> + err = *MSVCRT__errno();
> + if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr;
> +
> + size = MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, NULL, 0) + 1 /* add \n */;
> +
> + if (str && *str)
> + size += lstrlenW(str) + 2; /* add str length, colon and space */
> +
> + buffer = MSVCRT_malloc(size * sizeof(MSVCRT_wchar_t));
> + if (!buffer) return;
> +
> + if (str && *str)
> + {
> + lstrcpyW(buffer, str);
> + lstrcatW(buffer, colon_spaceW);
> + }
> + else buffer[0] = 0;
> +
> + len = lstrlenW(buffer);
> + MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, buffer + len, size - len);
> + lstrcatW(buffer, newlineW);
> + MSVCRT__write(2, buffer, lstrlenW(buffer) * sizeof(MSVCRT_wchar_t));
> + MSVCRT_free(buffer);
> +}
This is not how the function works. It shouldn't print wchar_t string to
stderr. Probably the simplest implementation is to convert input
parameter and call _perror (CP_ACP is not the correct encoding, you can
use MSVCRT_wcstombs).
Thanks,
Piotr