From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21112 invoked by alias); 10 Aug 2011 12:26:09 -0000 Received: (qmail 21088 invoked by uid 22791); 10 Aug 2011 12:26:09 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 10 Aug 2011 12:25:48 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7ACPmxS025248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 10 Aug 2011 08:25:48 -0400 Received: from hase.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7ACPk7M007804 for ; Wed, 10 Aug 2011 08:25:47 -0400 From: Andreas Schwab To: libc-hacker@sourceware.org Subject: [PATCH] Normalize locale names independent of current locale X-Yow: Everybody is going somewhere!! It's probably a garage sale or a disaster Movie!! Date: Wed, 10 Aug 2011 12:26:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2011-08/txt/msg00002.txt.bz2 2011-08-10 Andreas Schwab * intl/l10nflist.c (_nl_normalize_codeset): Use locale-independent conversions. --- intl/l10nflist.c | 33 +++++++++++++++++++++------------ 1 files changed, 21 insertions(+), 12 deletions(-) diff --git a/intl/l10nflist.c b/intl/l10nflist.c index 2c06a91..2a5e038 100644 --- a/intl/l10nflist.c +++ b/intl/l10nflist.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995-2002, 2004, 2005 Free Software Foundation, Inc. +/* Copyright (C) 1995-2002, 2004, 2005, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1995. @@ -332,15 +332,21 @@ _nl_normalize_codeset (codeset, name_len) char *retval; char *wp; size_t cnt; + char c; for (cnt = 0; cnt < name_len; ++cnt) - if (isalnum ((unsigned char) codeset[cnt])) - { - ++len; - - if (isalpha ((unsigned char) codeset[cnt])) - only_digit = 0; - } + { + c = codeset[cnt]; + if ((c >= '0' && c <= '9') + || (c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z')) + { + ++len; + + if (!(c >= '0' && c <= '9')) + only_digit = 0; + } + } retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1); @@ -352,10 +358,13 @@ _nl_normalize_codeset (codeset, name_len) wp = retval; for (cnt = 0; cnt < name_len; ++cnt) - if (isalpha ((unsigned char) codeset[cnt])) - *wp++ = tolower ((unsigned char) codeset[cnt]); - else if (isdigit ((unsigned char) codeset[cnt])) - *wp++ = codeset[cnt]; + { + c = codeset[cnt]; + if (c >= 'A' && c <= 'Z') + *wp++ = c - 'A' + 'a'; + else if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) + *wp++ = codeset[cnt]; + } *wp = '\0'; } -- 1.7.6 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."