[Patch] Fix libstdc++/11844

Paolo Carlini pcarlini@unitus.it
Thu Oct 9 15:19:00 GMT 2003


Hi,

the fix itself seems quite obvious: according to 22.2.1, the categories 
'alnum'
and 'graph', at variance with what happens in the C locale model, are not
independent but defined in terms of the other (i.e., 'alnum' = 
'alpha'|'digit'
and then 'graph' = 'alnum'|'punct'). Therefore modify the 
config/os/*/ctype_base.h
tables accordingly.

However, testing the fix in the generic locale model too revealed a 
latent problem
in the implementations of the two generic ctype<wchar_t>::do_is.
For instance, for the first one:

  bool
  ctype<wchar_t>::
  do_is(mask __m, char_type __c) const
  {
    bool __ret = false;
    const size_t __bitmasksize = 10;
    for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
      {
        const mask __bit = static_cast<mask>(1 << __bitcur);
        if (__m & __bit)
          __ret |= iswctype(__c, _M_convert_to_wmask(__bit));
      }
    return __ret;   
  }

Generically, 10 is too small since we don't really know the *numeric* 
encoding
of the various categories in the underlying /usr/include/ctype.h. 
Indeed, glibc
itself uses an encoding which depends on the endianity of the target and 
leads
to the highest (15th) bit set for 'graph' on little endian platforms (as 
i686).

Ok with everyone?

Paolo.

/////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_11844
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20031009/686ae62d/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_11844
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20031009/686ae62d/attachment-0001.ksh>


More information about the Libstdc++ mailing list