From patchwork Mon Dec 8 22:53:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 418900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AD5B11400D5 for ; Tue, 9 Dec 2014 09:53:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=a41bGWNYsI7l0Wui9hvjF0TkJNfG6nV1Xl4NEkLIIsS7Y9 ufFiFU6pmXt1bqCn9/kERXhYvxlQr064XJ36rLbtBZUmPSCH+AwG/hEj1zimCi28 M/XBZYHjLLyWUCP7r446BA9Y1ZSxBgC6DEoZXzDH4PYu/ggCdsCyX4LrUFRHU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=+yE4EJNcGEMUabwrhjW7xM9xao4=; b=iN9wvl8OIRZbQVwaGCS4 qfNF2r/p3Dd/nl5HExkE4ifiBcXgBfrFgxcIB8C2ybuGbF2mSBd+RWcJwW5Qstfx xHiXEHUx9HQOr/uoJUiOEGPyXlTeT0+qybiyrKqTO/hVtxLx4HLBlP5C5NjF9oOM 1PlurAyqsDf/xrG5rHWdpZk= Received: (qmail 28523 invoked by alias); 8 Dec 2014 22:53:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 28506 invoked by uid 89); 8 Dec 2014 22:53:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wi0-f177.google.com Received: from mail-wi0-f177.google.com (HELO mail-wi0-f177.google.com) (209.85.212.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 08 Dec 2014 22:53:31 +0000 Received: by mail-wi0-f177.google.com with SMTP id l15so6316463wiw.4 for ; Mon, 08 Dec 2014 14:53:28 -0800 (PST) X-Received: by 10.194.250.105 with SMTP id zb9mr49139677wjc.123.1418079208254; Mon, 08 Dec 2014 14:53:28 -0800 (PST) Received: from [10.2.116.176] (lhc-ac1.isrighthere.com. [193.93.203.40]) by mx.google.com with ESMTPSA id iz19sm11481224wic.8.2014.12.08.14.53.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Dec 2014 14:53:27 -0800 (PST) Message-ID: <54862BE6.9090407@gmail.com> Date: Mon, 08 Dec 2014 23:53:26 +0100 From: =?UTF-8?B?RnJhbsOnb2lzIER1bW9udA==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "libstdc++@gcc.gnu.org" , gcc-patches Subject: locales fixes Hi After having installed all necessary locales on my system I end up with 4 failures. Here is a patch to fix them all. For numpunct test I consider that checking value of numpunct::grouping() result was not correct. libstdc++ doesn't control this value. I prefer to just check that values returned by numpunct are consistent with how numeric values are formatted. For the others, regarding time_get, I found nothing really smart to do. For 4.cc I simply had to remove some characters not present anymore. And for 38081-1 and 38081-2, despite having glibc 2.19 it is still showing previous values on my system. I even wonder if it has anything to do with glibc version, it rather depends on the installed locale info, no ? 2014-12-08 François Dumont * testsuite/22_locale/numpunct/members/char/3.cc: Check numpunct returned values are consistent with how numbers are formatted. * testsuite/22_locale/time_get/get_date/wchar_t/4.cc: Update expected values. * testsuite/22_locale/time_get/get_weekday/char/38081-1.cc: Don't use new values before glibc 2.20. * testsuite/22_locale/time_get/get_weekday/char/38081-2.cc: Likewise. Tested under Linux x86_64. François Index: testsuite/22_locale/numpunct/members/char/3.cc =================================================================== --- testsuite/22_locale/numpunct/members/char/3.cc (revision 218492) +++ testsuite/22_locale/numpunct/members/char/3.cc (working copy) @@ -21,6 +21,7 @@ // 22.2.3.2 Template class numpunct_byname +#include #include #include @@ -30,13 +31,52 @@ bool test __attribute__((unused)) = true; - locale loc_it = locale("it_IT"); + // Use numpunct to generate representation for an arbitrary number. + const int number = 1000000000; - const numpunct& nump_it = use_facet >(loc_it); + ostringstream ostr; + ostr.imbue(locale::classic()); + + ostr << number; + string c_number = ostr.str(); + locale loc_it = locale("it_IT"); + const numpunct& nump_it = use_facet >(loc_it); string g = nump_it.grouping(); - VERIFY( g == "" ); + size_t group_index = 0; + string it_number; + size_t it_pos = 0; + size_t offset = 0; + for (size_t pos = 0; pos != c_number.size(); ++pos) + { + int group_size = + group_index < g.size() ? (int)g[group_index] + : (g.empty() + // No grouping, just make group size big enough so that + // there will be no insertion of thousands separator. + ? c_number.size() + : g[g.size() - 1]); + if (pos + offset < it_pos + group_size) + it_number.insert(it_number.begin(), c_number[c_number.size() - pos - 1]); + else + { + // Time to add the group separator. + it_number.insert(it_number.begin(), nump_it.thousands_sep()); + it_number.insert(it_number.begin(), c_number[c_number.size() - pos - 1]); + ++offset; + ++group_index; + it_pos = it_number.size() - 1; + } + } + + // Check that the result is identical to the one obtained with an + // ostringstream imbued with the it_IT locale. + ostr.str(""); + ostr.imbue(loc_it); + ostr << number; + + VERIFY( ostr.str() == it_number ); } int main() Index: testsuite/22_locale/time_get/get_date/wchar_t/4.cc =================================================================== --- testsuite/22_locale/time_get/get_date/wchar_t/4.cc (revision 218492) +++ testsuite/22_locale/time_get/get_date/wchar_t/4.cc (working copy) @@ -43,7 +43,7 @@ const ios_base::iostate good = ios_base::goodbit; ios_base::iostate errorstate = good; - const wchar_t wstr[] = { 0x897f, 0x5143, L'2', L'0', L'0', L'3', + const wchar_t wstr[] = { /* 0x897f, 0x5143,*/ L'2', L'0', L'0', L'3', 0x5e74, L'1', L'2', 0x6708, L'1', L'7', 0x65e5 , 0x0 }; Index: testsuite/22_locale/time_get/get_weekday/char/38081-1.cc =================================================================== --- testsuite/22_locale/time_get/get_weekday/char/38081-1.cc (revision 218492) +++ testsuite/22_locale/time_get/get_weekday/char/38081-1.cc (working copy) @@ -50,7 +50,7 @@ // ios_base::iostate&, tm*) const #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) -# if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 17 +# if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 20 iss.str("\xbf\xdd"); # else iss.str("\xbf\xdd\x2e"); @@ -76,7 +76,7 @@ VERIFY( errorstate == ios_base::eofbit ); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) -# if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 17 +# if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 20 iss.str("\xbf\xdd\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); # else iss.str("\xbf\xdd\x2e\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); Index: testsuite/22_locale/time_get/get_weekday/char/38081-2.cc =================================================================== --- testsuite/22_locale/time_get/get_weekday/char/38081-2.cc (revision 218492) +++ testsuite/22_locale/time_get/get_weekday/char/38081-2.cc (working copy) @@ -51,7 +51,7 @@ // ios_base::iostate&, tm*) const #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) -# if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 17 +# if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 20 const char* awdays[7] = { "\u0412\u0441", "\u041F\u043D", "\u0412\u0442",