From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39242 invoked by alias); 1 Apr 2019 04:47:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 38814 invoked by uid 89); 1 Apr 2019 04:47:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.0 required=5.0 tests=AWL,BAYES_50,BODY_8BITS,GARBLED_BODY,SPF_PASS autolearn=no version=3.3.1 spammy=HContent-type:plain, H*f:sk:CAL5iTP, H*f:sk:K_aE4fk, H*f:CAL5iTP X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Apr 2019 04:47:34 +0000 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hAoqz-00068S-M9; Mon, 01 Apr 2019 00:47:28 -0400 Received: from [176.228.60.248] (port=1649 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hAoqx-00026h-SX; Mon, 01 Apr 2019 00:47:25 -0400 Date: Mon, 01 Apr 2019 04:47:00 -0000 Message-Id: <83bm1qgwm2.fsf@gnu.org> From: Eli Zaretskii To: =?utf-8?B?0JLQu9Cw0LTQuNC80LjRgCDQnNCw0YDRgtGM0Y/QvdC+0LI=?= CC: gdb-patches@sourceware.org In-reply-to: (message from =?utf-8?B?0JLQu9Cw0LTQuNC80LjRgCDQnNCw0YDRgtGM0Y/QvdC+0LI=?= on Sun, 31 Mar 2019 22:39:01 +0300) Subject: Re: [PATCH][PR server/24377] Fix mixing English and system default languages in error messages on Windows References: <83mullpwg6.fsf@gnu.org> <83ef6qjdbb.fsf@gnu.org> <838swyjafd.fsf@gnu.org> <837echkgjo.fsf@gnu.org> <8336n3hzkx.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-IsSubscribed: yes X-SW-Source: 2019-04/txt/msg00000.txt.bz2 > From: Владимир Мартьянов > Date: Sun, 31 Mar 2019 22:39:01 +0300 > Cc: gdb-patches@sourceware.org > > > If so, would they need to > > control that by setting environment variables? It sounds less > > convenient than it could have been, I think. Why not a GDB variable > > instead? > > Environment variables are used in gettext anyway, I think single > source for localisation language is convenient. I was not talking about _using_ the environment variables, I was talking about making them the (only) way of changing the locale. > + static HMODULE hMlang = LoadLibrary ("Mlang.dll"); > + HMODULE hKernel32 = GetModuleHandle ("kernel32.dll"); I think this should not be an initialization, this should be a run-timer assignment, like this: if (!hMlang) hMlang = LoadLibrary ("Mlang.dll"); Also, we should only try to load mlang.dll if LocaleNameToLCID is not available. > + RFC1766TOLCID Rfc1766ToLcid = NULL; > + LOCALENAMETOLCID LocaleNameToLCID = NULL; These two should also be static. > + strncpy (buf, localeName, COUNTOF (buf) - 1); > + ptr = strchr (buf, '.'); /* cut at "." */ > + if (ptr != NULL) > + *ptr = 0x00; > + > + ptr = strchr (buf, '_'); /* replace "_" */ > + if (ptr != NULL) > + *ptr = '-'; Can you explain in a comment why these modifications of the environment variable's value are needed? I don't think the reasons are trivially clear to everyone. > + if (LocaleNameToLCID != NULL) > + { > + MultiByteToWideChar (CP_ACP, > + 0, > + buf, > + -1, > + wbuf, > + COUNTOF (wbuf) - 1); > + lcid = LocaleNameToLCID (wbuf, 0); This assumes that the code is compiled with UNICODE defined, which will then call LocaleNameToLCIDW. But the code in question is common to Cygwin and MinGW compilations, and the latter defaults to UNICODE undefined. So I think you need to call LocaleNameToLCIDW explicitly here. Thanks.