diff mbox

locales fixes

Message ID 54862BE6.9090407@gmail.com
State New
Headers show

Commit Message

François Dumont Dec. 8, 2014, 10:53 p.m. UTC
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  <fdumont@gcc.gnu.org>

     * 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

Comments

Jonathan Wakely Dec. 9, 2014, 11:03 a.m. UTC | #1
On 08/12/14 23:53 +0100, François Dumont wrote:
>    After having installed all necessary locales on my system I end up 
>with 4 failures. Here is a patch to fix them all.

Did you discover why only you are seeing failures?

The whole testsuite passes for me, with glibc 2.18, including the
tests you are "fixing" (i.e. I don't see any need for a fix).

The changes to the glibc versions tests are definitely not correct.
Marc Glisse Dec. 9, 2014, 7:34 p.m. UTC | #2
On Tue, 9 Dec 2014, Jonathan Wakely wrote:

> On 08/12/14 23:53 +0100, François Dumont wrote:
>>    After having installed all necessary locales on my system I end up with 
>> 4 failures. Here is a patch to fix them all.
>
> Did you discover why only you are seeing failures?

Not just him, anyone with a debian-based system (assuming we are talking 
about the same thing). I believe it was documented somewhere, Paolo should 
know.
Jonathan Wakely Dec. 9, 2014, 11:24 p.m. UTC | #3
On 09/12/14 20:34 +0100, Marc Glisse wrote:
>On Tue, 9 Dec 2014, Jonathan Wakely wrote:
>
>>On 08/12/14 23:53 +0100, François Dumont wrote:
>>>   After having installed all necessary locales on my system I end 
>>>up with 4 failures. Here is a patch to fix them all.
>>
>>Did you discover why only you are seeing failures?
>
>Not just him, anyone with a debian-based system (assuming we are 
>talking about the same thing). I believe it was documented somewhere, 
>Paolo should know.

Ah OK. I've requested the locale data to be installed on gcc20, which
is the only Debian machine I have access to. All those tests are
UNSUPPORTED there, so I have to test any locale-related changes on
Fedora machines.

I still say the change to "if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 20"
is simply wrong. It works for me with 2.18, but if it doesn't work
with 2.19 on Debian then why should it work any better with 2.20?
Jonathan Wakely Dec. 10, 2014, 2:01 p.m. UTC | #4
On 09/12/14 23:24 +0000, Jonathan Wakely wrote:
>On 09/12/14 20:34 +0100, Marc Glisse wrote:
>>On Tue, 9 Dec 2014, Jonathan Wakely wrote:
>>
>>>On 08/12/14 23:53 +0100, François Dumont wrote:
>>>>  After having installed all necessary locales on my system I 
>>>>end up with 4 failures. Here is a patch to fix them all.
>>>
>>>Did you discover why only you are seeing failures?
>>
>>Not just him, anyone with a debian-based system (assuming we are 
>>talking about the same thing). I believe it was documented 
>>somewhere, Paolo should know.
>
>Ah OK. I've requested the locale data to be installed on gcc20, which
>is the only Debian machine I have access to.

And I can see the failures now.
François Dumont Dec. 10, 2014, 6:44 p.m. UTC | #5
On 10/12/2014 00:24, Jonathan Wakely wrote:
> I still say the change to "if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 20"
> is simply wrong. It works for me with 2.18, but if it doesn't work
> with 2.19 on Debian then why should it work any better with 2.20?
>
>
     Yes, it was indeed a wild guess because I didn't understand what 
should be the relation between the glibc version and locale data 
returned by the system. I shouldn't have done that.

     But what to do then ? Consider those tests as simply unsupported on 
systems where glibc version doesn't give any info regarding what to expect ?

François
diff mbox

Patch

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 <sstream>
 #include <locale>
 #include <testsuite_hooks.h>
 
@@ -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<char>& nump_it = use_facet<numpunct<char> >(loc_it); 
+  ostringstream ostr;
+  ostr.imbue(locale::classic());
+  
+  ostr << number;
+  string c_number = ostr.str();
 
+  locale loc_it = locale("it_IT");
+  const numpunct<char>& nump_it = use_facet<numpunct<char> >(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",