Patchwork fix libstdc++/47387 AIX ctype mask override

login
register
mail settings
Submitter Graham Reed
Date Jan. 24, 2011, 6:47 p.m.
Message ID <4D3DC955.8060207@pobox.com>
Download mbox | patch
Permalink /patch/80228/
State New
Headers show

Comments

Graham Reed - Jan. 24, 2011, 6:47 p.m.
Per bug 47387, the attached patch fixes the problem, found by the 
libstdc++ regression suite, where ctype mask override isn't working.  It 
applies only to AIX.

The existing testcase '22_locale/ctype/is/char/3.cc' is sufficient to 
verify the fix.

    PR libstdc++/47387
    * config/os/aix/ctype_inline.h: Use _M_table if provided.

I have run the regression suite with this change on 
powerpc-ibm-aix5.3.0.0, verifying 4 multilib combinations: '', 'ppc64', 
'pthread', and 'pthread/ppc64' in the 4.5.2 release code.
Paolo Carlini - Jan. 24, 2011, 7:04 p.m.
On 01/24/2011 07:47 PM, Graham Reed wrote:
> Per bug 47387, the attached patch fixes the problem, found by the
> libstdc++ regression suite, where ctype mask override isn't working. 
> It applies only to AIX.
>
> The existing testcase '22_locale/ctype/is/char/3.cc' is sufficient to
> verify the fix.
>
>    PR libstdc++/47387
>    * config/os/aix/ctype_inline.h: Use _M_table if provided.
>
> I have run the regression suite with this change on
> powerpc-ibm-aix5.3.0.0, verifying 4 multilib combinations: '',
> 'ppc64', 'pthread', and 'pthread/ppc64' in the 4.5.2 release code.
>
Excellent. I think the path is fine for mainline, I can take care of
applying it. Note the ChangeLog entry should mention the touched
functions, thus, I would say, concisely:

    PR libstdc++/47387
    * config/os/aix/ctype_inline.h (ctype<char>::is): Use _M_table if
provided.

Thanks,
Paolo.

Patch

Index: libstdc++-v3/config/os/aix/ctype_inline.h
===================================================================
--- libstdc++-v3/config/os/aix/ctype_inline.h	(revision 169055)
+++ libstdc++-v3/config/os/aix/ctype_inline.h	(working copy)
@@ -39,14 +39,23 @@ 
   bool
   ctype<char>::
   is(mask __m, char __c) const
-  { return __OBJ_DATA(__lc_ctype)->mask[__c] & __m; }
+  { 
+    if(_M_table)
+      return _M_table[static_cast<unsigned char>(__c)] & __m;
+    else
+      return __OBJ_DATA(__lc_ctype)->mask[__c] & __m;
+  }
 
   const char*
   ctype<char>::
   is(const char* __low, const char* __high, mask* __vec) const
   {
-    while (__low < __high)
-      *__vec++ = __OBJ_DATA(__lc_ctype)->mask[*__low++];
+    if(_M_table)
+      while (__low < __high)
+	*__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
+    else
+      while (__low < __high)
+        *__vec++ = __OBJ_DATA(__lc_ctype)->mask[*__low++];
     return __high;
   }