From owner-freebsd-current@FreeBSD.ORG Fri Oct 25 01:13:56 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 125473EB for ; Fri, 25 Oct 2013 01:13:56 +0000 (UTC) (envelope-from sean_bruno@yahoo.com) Received: from nm35.bullet.mail.bf1.yahoo.com (nm35.bullet.mail.bf1.yahoo.com [72.30.238.197]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A5EC72D04 for ; Fri, 25 Oct 2013 01:13:55 +0000 (UTC) Received: from [98.139.215.142] by nm35.bullet.mail.bf1.yahoo.com with NNFMP; 25 Oct 2013 01:13:48 -0000 Received: from [98.139.211.161] by tm13.bullet.mail.bf1.yahoo.com with NNFMP; 25 Oct 2013 01:13:48 -0000 Received: from [127.0.0.1] by smtp218.mail.bf1.yahoo.com with NNFMP; 25 Oct 2013 01:13:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1382663628; bh=BuPTsm2u15HQ8F9pK9QX4hyQ1zsTOMYK2hyokkEQMYI=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Subject:From:Reply-To:To:Cc:In-Reply-To:References:Content-Type:Date:Message-ID:Mime-Version:X-Mailer; b=g4l+kZ962qYgMh6pjaBr0z7iZVWmZzuIvYgZTfTp/7JuakfBnRk0qHK3UJx+NyW/Sqq3wGZP7zB0Iqa7oboaSmKlMCID3XL+OAOjoxCgHPd7d9LE5TeAcmBkoyu8YjutgZgpUS7iD0g+iDnmeaWpMsTd5HvdF+Nj/Ygq1nc+EqU= X-Yahoo-Newman-Id: 308390.75820.bm@smtp218.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: KsuPFoMVM1mzGxZPAsf0JRpmqvgM2qbwtxOucZ1B5kE9J0D 208maOgOx6wcjzFJE.3Gajc6FY4RG5F31bDbAknA7jPyjM0LBqaA_WBSj.ou oOEdaVBKWF4Q6pdhQ0NsxsdNeXcQhzKs44A9uZNTtW3S4f9bXO0CUHDbBi7k 5bPsTG_Ax5hwCSxL7OoXWi9Y4A_Z9tp96vTqnhhLee9wk1DdhZBxvD_egwXe zIwgZiTMN.4WzgzZER7tIYFsvV2mh5PGHEcXSuk3m0qCT3ETYbvSQOpck8NA UTCD_DiV4iOhEIiO9gycggJvAaU4SIifbYNlvPsQAnMGytI1cj1RL605cuha a2L0d9rdbeAxjIdPppEPToLCoiKDaeYLr6_4dsbN2Er9V_xypN4QvYPr_Jw_ syVTH00dHjlVrAcH9D_lDO8qNRhGEdH.AtGnotPY45imlpxRuGnT.OuI63Fz GncoX9xe8PtSfw1aydFQbGeL1BE41r9SY_g1a66UBWgQ4VFI4HMdji5gEpdD YOyCJUW8Qf17j2MeDymtWnt.GmOTH8EOD5Fl8beFLMoQCCXEENuJuX7.AeXH AP7ZqY5vZgpmqgjWNsuF_Sh2pIXc2tYJUyvO_y5D7egqQTZA- X-Yahoo-SMTP: u5BKR6OswBC_iZJVfGRoMkTIpc8pEA4- X-Rocket-Received: from [192.168.100.5] (sean_bruno@63.138.121.126 with ) by smtp218.mail.bf1.yahoo.com with SMTP; 24 Oct 2013 18:13:48 -0700 PDT Subject: Re: gperf/src/options.cc -- quiesce clang warnings -Wlogical-op-parentheses From: Sean Bruno To: David Chisnall In-Reply-To: <0744E30D-89EF-4340-A7DC-968AC27F302B@FreeBSD.org> References: <1382327452.2610.5.camel@localhost> <1382399026.7749.3.camel@localhost> <0744E30D-89EF-4340-A7DC-968AC27F302B@FreeBSD.org> Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-v5MEAmV5OoPcecnCReXG" Date: Thu, 24 Oct 2013 21:13:46 -0400 Message-ID: <1382663626.2498.4.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: Matthew Fleming , "freebsd-current@freebsd.org" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: sbruno@freebsd.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2013 01:13:56 -0000 --=-v5MEAmV5OoPcecnCReXG Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable On Tue, 2013-10-22 at 09:47 +0100, David Chisnall wrote: > On 22 Oct 2013, at 00:43, Sean Bruno wrote: >=20 > > Heh, Matthew suggested the obvious in private mail, it seems that this > > would be better "spelled" as "isalpha" :-) >=20 > This looks wrong. The behaviour of isalpha() depends on the current loca= le. You probably want isalpha_l(), with the "C" locale. >=20 > David Took me a bit of wrangling to figure out what the proper implementation of isalpha_l() and friends. How about this then? Index: options.cc =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 --- options.cc (revision 257083) +++ options.cc (working copy) @@ -28,6 +28,7 @@ #include /* declares strcmp() */ #include /* declares isdigit() */ #include /* defines CHAR_MAX */ +#include /* support for newlocale() */ #include "getopt.h" #include "version.h" =20 @@ -275,13 +276,15 @@ for (int i =3D 0; i < _argument_count; i++) { const char *arg =3D _argument_vector[i]; + locale_t loc;=09 =20 + loc =3D newlocale(LC_ALL_MASK, "C", 0); /* Escape arg if it contains shell metacharacters. */ if (*arg =3D=3D '-') { putchar (*arg); arg++; - if (*arg >=3D 'A' && *arg <=3D 'Z' || *arg >=3D 'a' && *arg <=3D= 'z') + if (isalpha_l(*arg, loc)) { putchar (*arg); arg++; @@ -293,7 +296,7 @@ putchar (*arg); arg++; } - while (*arg >=3D 'A' && *arg <=3D 'Z' || *arg >=3D 'a' && *a= rg <=3D 'z' || *arg =3D=3D '-'); + while (isalpha_l(*arg, loc) || *arg =3D=3D '-'); if (*arg =3D=3D '=3D') { putchar (*arg); --=-v5MEAmV5OoPcecnCReXG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (FreeBSD) iQEcBAABAgAGBQJSacXJAAoJEBkJRdwI6BaH3J0IAIjo4bRhQqx5hL9hyH4McJNI aPtA/f4kzZy0hh0qheunt+6JLROP7HgpcKq3Kji9BRnY/6XnDCprT8//iAciD6Zx 0EXM4TtyzZgjCebkhr3UH6w19js+T6hJfAqm6G/IYjtDjCp4rmHQM+dqg8xMMHwX xocKSFu0NtwzMhSP2IKfv6GWbiPaLQJ4QZxEdoIYMUpZQEl4kv0TuBiPUDFRaIs3 3BMEz9PUNr9gAWSYZNTWaoCtb1s2MyTTchOkztaHKW+vB2TncNRPyfxNldCQVp7k 2RHnxUTQhKGeCnvtPuBoy+k27KUmc7HLU6E/bvYZNwPqT8vYrRaj2D+G0Tcbkaw= =T2jz -----END PGP SIGNATURE----- --=-v5MEAmV5OoPcecnCReXG--