Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 23240 invoked from network); 4 Oct 2007 17:44:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Oct 2007 17:44:17 -0000 Received: (qmail 35626 invoked by uid 500); 4 Oct 2007 17:44:03 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 35613 invoked by uid 500); 4 Oct 2007 17:44:03 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 35602 invoked by uid 99); 4 Oct 2007 17:44:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2007 10:44:03 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Farid_Zaripov@epam.com designates 217.21.63.3 as permitted sender) Received: from [217.21.63.3] (HELO EPMSA009.epam.com) (217.21.63.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2007 17:44:05 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: [PATCH] ctype fixes Date: Thu, 4 Oct 2007 20:43:20 +0300 Message-ID: <7BDB2168BEAEF14C98F1901FD2DE6438010B2498@epmsa009.minsk.epam.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] ctype fixes Thread-Index: AcgGrg2mruDQ+a2PTHyFKSZ5a+aKYQ== From: "Farid Zaripov" To: X-Virus-Checked: Checked by ClamAV on apache.org The following patch fixes the rw_asserts in 22.locale.ctype.narrow.cpp test. ChangeLog: * _ctype.h (ctype::narrow): Don't cast __c to unsigned char to avoid using the same __idx for the different __c (i.e. 2 and 258). * wctype.cpp (ctype_byname::do_narrow): Compare tmp with _RWSTD_EOF instead of < 0. Set locale before invoking wctomb(). (ctype_byname::do_widen): Use mbtowc() if it's available and if btowc() is not available. --------------------- Index: include/loc/_ctype.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- include/loc/_ctype.h (revision 581916) +++ include/loc/_ctype.h (working copy) @@ -541,7 +541,7 @@ inline char ctype::narrow (char_type __c, char __dfault) const { - const _RWSTD_SIZE_T __inx =3D _RWSTD_STATIC_CAST (unsigned char, __c); + const _RWSTD_SIZE_T __inx =3D __c; =20 // optimize away all but the first call to the virtual do_widen() if ( __inx < sizeof _C_narrow_tab / sizeof *_C_narrow_tab Index: src/wctype.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- src/wctype.cpp (revision 581916) +++ src/wctype.cpp (working copy) @@ -881,11 +881,12 @@ const _RW::__rw_setlocale clocale (_C_name, LC_CTYPE); =20 const int tmp =3D wctob (c); + ch =3D _RWSTD_EOF =3D=3D tmp ? dfault : char (tmp); =20 - ch =3D tmp < 0 ? dfault : char (tmp); - #elif !defined (_RWSTD_NO_WCTOMB) =20 + const _RW::__rw_setlocale clocale (_C_name, LC_CTYPE); + char tmp [_RWSTD_MB_LEN_MAX]; ch =3D 1 =3D=3D wctomb (tmp, c) ? *tmp : dfault; =20 @@ -1005,8 +1006,15 @@ // prevent sign extension if `c' is negative ch =3D btowc (u_c); =20 -#else // if defined (_RWSTD_NO_BTOWC) +#elif !defined (_RWSTD_NO_MBTOWC) =20 + const _RW::__rw_setlocale clocale (_C_name, LC_CTYPE); + + char_type tmp; + ch =3D 1 =3D=3D mbtowc (&tmp, &c, 1) ? tmp : char_type = (_RWSTD_WEOF); + +#else // if defined (_RWSTD_NO_MBTOWC) + ch =3D char_type (u_c); =20 #endif // _RWSTD_NO_BTOWC --------------------- Farid.