public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* locales fixes
@ 2014-12-08 22:53 François Dumont
  2014-12-09 11:03 ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: François Dumont @ 2014-12-08 22:53 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1250 bytes --]

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


[-- Attachment #2: 22_locale.patch --]
[-- Type: text/x-patch, Size: 4125 bytes --]

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",

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: locales fixes
  2014-12-08 22:53 locales fixes François Dumont
@ 2014-12-09 11:03 ` Jonathan Wakely
  2014-12-09 19:34   ` Marc Glisse
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2014-12-09 11:03 UTC (permalink / raw)
  To: François Dumont; +Cc: libstdc++, gcc-patches

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: locales fixes
  2014-12-09 11:03 ` Jonathan Wakely
@ 2014-12-09 19:34   ` Marc Glisse
  2014-12-09 23:24     ` Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Marc Glisse @ 2014-12-09 19:34 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: François Dumont, libstdc++, gcc-patches

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.

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: locales fixes
  2014-12-09 19:34   ` Marc Glisse
@ 2014-12-09 23:24     ` Jonathan Wakely
  2014-12-10 14:01       ` Jonathan Wakely
  2014-12-10 18:45       ` François Dumont
  0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Wakely @ 2014-12-09 23:24 UTC (permalink / raw)
  To: libstdc++; +Cc: François Dumont, gcc-patches

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: locales fixes
  2014-12-09 23:24     ` Jonathan Wakely
@ 2014-12-10 14:01       ` Jonathan Wakely
  2014-12-10 18:45       ` François Dumont
  1 sibling, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2014-12-10 14:01 UTC (permalink / raw)
  To: libstdc++; +Cc: François Dumont, gcc-patches

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: locales fixes
  2014-12-09 23:24     ` Jonathan Wakely
  2014-12-10 14:01       ` Jonathan Wakely
@ 2014-12-10 18:45       ` François Dumont
  1 sibling, 0 replies; 6+ messages in thread
From: François Dumont @ 2014-12-10 18:45 UTC (permalink / raw)
  To: Jonathan Wakely, libstdc++; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-12-10 18:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-08 22:53 locales fixes François Dumont
2014-12-09 11:03 ` Jonathan Wakely
2014-12-09 19:34   ` Marc Glisse
2014-12-09 23:24     ` Jonathan Wakely
2014-12-10 14:01       ` Jonathan Wakely
2014-12-10 18:45       ` François Dumont

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).