From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32097 invoked by alias); 6 Jun 2011 17:30:34 -0000 Received: (qmail 32088 invoked by uid 22791); 6 Jun 2011 17:30:34 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from service87.mimecast.com (HELO service87.mimecast.com) (94.185.240.25) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Mon, 06 Jun 2011 17:30:17 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Mon, 06 Jun 2011 18:30:14 +0100 Received: from e102530 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 6 Jun 2011 18:30:40 +0100 From: "Yufeng Zhang" To: Subject: [PATCH, libstdc++-v3] Add newlib specific ctype_members.cc Date: Mon, 06 Jun 2011 17:30:00 -0000 Message-ID: <000001cc246f$72b81c20$58285460$@Zhang@arm.com> MIME-Version: 1.0 x-cr-hashedpuzzle: BFnr BYeq BnKY CUpd CbPU CqcN Dbvr Dvci EFwS EUs+ FEfj GCys IVkS JQxI JggH JnEk;1;ZwBjAGMALQBwAGEAdABjAGgAZQBzAEAAZwBjAGMALgBnAG4AdQAuAG8AcgBnAA==;Sosha1_v1;7;{636F8332-3446-4FC8-B121-FD372A0EEF84};eQB1AGYAZQBuAGcALgB6AGgAYQBuAGcAQABhAHIAbQAuAGMAbwBtAA==;Mon, 06 Jun 2011 17:30:30 GMT;WwBQAEEAVABDAEgALAAgAGwAaQBiAHMAdABkAGMAKwArAC0AdgAzAF0AIABBAGQAZAAgAG4AZQB3AGwAaQBiACAAcwBwAGUAYwBpAGYAaQBjACAAYwB0AHkAcABlAF8AbQBlAG0AYgBlAHIAcwAuAGMAYwA= x-cr-puzzleid: {636F8332-3446-4FC8-B121-FD372A0EEF84} X-MC-Unique: 111060618301401501 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg00439.txt.bz2 Hi, This patch fixes an issue in the ctype implementation when the newlib C library is used. The generic version of ctype::_M_convert_to_wmask() in config/locale/generic/ctype_members.cc assumes that a character type mask is either a bitmask with only 1 bit set or a bitwise-OR result of other character type masks; for instance, as illustrated in the C++ Standard 2003 TC1 [lib.category.ctype]: enum mask { // numeric values are for exposition only. space=3D1<<0, print=3D1<<1, cntrl=3D1<<2, upper=3D1<<3, lower=3D1<<4, alpha=3D1<<5, digit=3D1<<6, punct=3D1<<7, xdigit=3D1<<8, alnum=3Dalpha|digit, graph=3Dalnum|punct }; The newlibc has a more compact character type mask definition; it uses one byte only to represent the masks: (newlib/libc/include/ctype.h) #define _U 01 #define _L 02 #define _N 04 #define _S 010 #define _P 020 #define _C 040 #define _X 0100 #define _B 0200 (libstdc++-v3/config/os/newlib/ctype_base.h) typedef char mask; static const mask upper =3D _U; static const mask lower =3D _L; static const mask alpha =3D _U | _L; static const mask digit =3D _N; static const mask xdigit =3D _X | _N; static const mask space =3D _S; static const mask print =3D _P | _U | _L | _N | _B; static const mask graph =3D _P | _U | _L | _N; static const mask cntrl =3D _C; static const mask punct =3D _P; static const mask alnum =3D _U | _L | _N; For _X and _B, the generic version of ctype::_M_convert_to_wmask() fails to obtain their corresponding wmasks, while other ctype_members.cc variants at config/locale/{gnu,darwin}/ are not capable in handling this case either. Therefore, in this patch, a newlib specific ctype_members.cc is added at config/locale/newlib/, and acinclude.m4 is modified to use the new ctype_members.cc when with_newlib is enabled. The main difference in this ctype_members.cc from the generic version is the addition of the special handling of xdigit and print at the end of ctype::_M_convert_to_wmask(). With this patch the following test failure (when the C library is the newlib C) will be fixed: libstdc++-v3/testsuite/22_locale/ctype/scan/wchar_t/1.cc. The patch has passed the regression test with armv7-a arm-eabi on qemu. Is it OK for trunk? Thanks, Yufeng libstdc++-v3/ChangeLog 2011-06-06 Yufeng Zhang * config/locale/newlib/ctype_members.cc: New file. * acinclude.m4 (GLIBCXX_ENABLE_CLOCALE): Add a new C locale kind: newlib. Configure to use the newlib specific ctype_members.cc when with_newlib is enabled. * configure: Regenerate.