From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17264 invoked by alias); 11 Jun 2014 02:22:45 -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 17206 invoked by uid 89); 11 Jun 2014 02:22:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Jun 2014 02:22:27 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WuYBD-0002Yr-5r from Yao_Qi@mentor.com ; Tue, 10 Jun 2014 19:22:23 -0700 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 10 Jun 2014 19:22:20 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.2.247.3; Tue, 10 Jun 2014 19:22:19 -0700 Message-ID: <5397BCEC.8080300@codesourcery.com> Date: Wed, 11 Jun 2014 02:22:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Pedro Alves CC: Tom Tromey , Joel Brobecker , Subject: Re: [ping] [PATCH] Different outputs affected by locale References: <1401192650-29688-1-git-send-email-yao@codesourcery.com> <538EAEE5.2080708@codesourcery.com> <20140604124708.GR4289@adacore.com> <538F1CC3.9090605@codesourcery.com> <87oay8a0t6.fsf@fleche.redhat.com> <538F803A.9020007@redhat.com> <538FE412.1050806@codesourcery.com> <53903119.6000204@redhat.com> <53903EE5.8090107@codesourcery.com> <539042A2.4050409@redhat.com> <539571C6.40605@codesourcery.com> <53958862.5020106@redhat.com> In-Reply-To: <53958862.5020106@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00432.txt.bz2 On 06/09/2014 06:11 PM, Pedro Alves wrote: > I think the test caught a real GDB bug on Windows, and we > should fix GDB to make it look at the environment variables, > as is expected of GNU programs. And that the best way > to handle this is to import the gnulib setlocale module. I've started setlocale module import, but during the work, I did some experiments and the result is confusing me. We import setlocale so that we can set locale through env var, assuming that different locales affect the return value of iswprint (0xa2). However, this assumption isn't true on Windows :( I write the following program to check the return value of iswprint under different locales. On Linux, the output is reasonable $ ./iswprint 4 C: 0 en_US.UTF-8: 1 C: 0 On Windows, iswprint always return true! C:\>iswprint.win.exe 2 C: 16 English_United States.1252: 16 C: 16 iswprint return value depends on LC_CTYPE, but under LC_CTYPE=C, iswprint (0xa2) behaves differently on Windows and Linux. -- Yao (齐尧) #include #include #include #include int main (void) { wchar_t c = 0xa2; printf ("%d\n", sizeof c); printf ("%s: %d\n", setlocale (LC_CTYPE, NULL), iswprint (c)); setlocale (LC_CTYPE, ""); printf ("%s: %d\n", setlocale (LC_CTYPE, NULL), iswprint (c)); setlocale (LC_CTYPE, "C"); printf ("%s: %d\n", setlocale (LC_CTYPE, NULL), iswprint (c)); return 0; }