[PATCH][PR server/24377] Fix mixing English and system default languages in error messages on Windows

Владимир Мартьянов vilgeforce@gmail.com
Tue Apr 2 20:57:00 GMT 2019


вт, 2 апр. 2019 г. в 01:08, Jon Turney <jon.turney@dronecode.org.uk>:
>
> I'm wondering why this problem doesn't crop up in gdb itself?  Are there
> no uses of FormatMessage() in that?

FormatMessage is used in gdb/gdb-dlfcn.c, gdb/common/mingw-strerror.c,
gdb/gdbserver/gdbreplay.c and in gdb/gdbserver/win32-low.c. If I
passed a dummy file name to gdb "gdb.exe foo" it shows me a
non-WIndows message "No such file or directory". I think it's from
libiberty.

> A few comments on your get_lcid() function:
>
> - It looks like this is going to ignore LC_ALL etc. if LocaleNameToLCID
> and Rfc1766ToLcidW can't found.  This doesn't seem correct as the
> environment variable should still have an effect.

it will be just the current behaviour - to use system default locale
in FormatMessage.

> - You're not checking all the environment variables which might control
> the locale for the message locale category (See e.g. [1]). I don't think
> there's any need to do this by hand, since you should be able to use the
> result of setlocale(LC_MESSAGE, NULL)?

Yes, you are right, I missed "LANGUAGE" var because it's in another
file in /intl/
Wish I had a function for this. _nl_locale_name from intl/localename.c
looks good,but it doesn't read LANGUAGE var and I have errors when
include intl/gettextP.h

I'm able to use results from setlocale(), but how can the user
influenсe the result of setlocale?
I wrote i simple program to display it's result:
void main(int argc, char* argv[])
{
    printf("%s\n", setlocale(LC_ALL, 0));
}
Then I run it from Cygwin console:
$ LC_ALL=en_US /cygdrive/c/Programming/Test/Debug/test.exe
C
$ LC_ALL=de_DE /cygdrive/c/Programming/Test/Debug/test.exe
C

Changing env. var doesn't affect setlocale() result.



More information about the Gdb-patches mailing list