From 4d336756fa7f47aa0a79e98fb4dea5c3e1b35d31 Mon Sep 17 00:00:00 2001 From: Fujii Hironori Date: Tue, 20 Jun 2017 13:17:09 +0200 Subject: [PATCH] cygwin: regtool: encode error messages correctly Error messages of regtool can't be read, which are encoded in, for instance, SHIFT_JIS in Japanese Windows. Fix by using wide chars instead of multibyte. --- winsup/utils/regtool.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/winsup/utils/regtool.cc b/winsup/utils/regtool.cc index ad746adf7..a44d90768 100644 --- a/winsup/utils/regtool.cc +++ b/winsup/utils/regtool.cc @@ -197,13 +197,14 @@ print_version () void Fail (unsigned int rv) { - char *buf; + wchar_t *buf; + if (!quiet) { - FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER - | FORMAT_MESSAGE_FROM_SYSTEM, - 0, rv, 0, (CHAR *) & buf, 0, 0); - fprintf (stderr, "Error (%d): %s\n", rv, buf); + FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_FROM_SYSTEM, + 0, rv, 0, (WCHAR *)& buf, 0, 0); + fprintf (stderr, "Error (%d): %ls\n", rv, buf); LocalFree (buf); } exit (1);