stdcpp/src/ctype.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
       
     3  *
       
     4  * Copyright (c) 1999
       
     5  * Silicon Graphics Computer Systems, Inc.
       
     6  *
       
     7  * Copyright (c) 1999 
       
     8  * Boris Fomitchev
       
     9  *
       
    10  * This material is provided "as is", with absolutely no warranty expressed
       
    11  * or implied. Any use is at your own risk.
       
    12  *
       
    13  * Permission to use or copy this software for any purpose is hereby granted 
       
    14  * without fee, provided the above notices are retained on all copies.
       
    15  * Permission to modify the code and to distribute modified code is granted,
       
    16  * provided the above notices are retained, and a notice that the code was
       
    17  * modified is included with the above copyright notice.
       
    18  *
       
    19  */ 
       
    20 
       
    21 # include "stlport_prefix.h"
       
    22 
       
    23 #include <algorithm>
       
    24 #include <stl/_ctype.h>
       
    25 #include <stl/_function.h>
       
    26 #include "c_locale.h"
       
    27 #include "libstdcppwsd.h"
       
    28 
       
    29 _STLP_BEGIN_NAMESPACE
       
    30 
       
    31 //----------------------------------------------------------------------
       
    32 // ctype<char>
       
    33 
       
    34 // The classic table: static data members.
       
    35 
       
    36 # if !defined(_STLP_STATIC_CONST_INIT_BUG) && !(defined(__MRC__) || defined(__SC__))
       
    37 //*TY 02/25/2000 - added workaround for MPW compilers; they confuse on in-class static const
       
    38 const size_t ctype<char>::table_size;
       
    39 # endif
       
    40 
       
    41 // This macro is specifically for platforms where isprint() relies
       
    42 // on separate flag
       
    43 
       
    44 # define PRINTFLAG ctype_base::mask( _Locale_PRINT & ~(_Locale_UPPER | _Locale_LOWER | _Locale_ALPHA | _Locale_DIGIT | _Locale_PUNCT | _Locale_SPACE | _Locale_XDIGIT )) 
       
    45 
       
    46 // Ctype table for the ASCII character set.
       
    47 // There are 257 entries in this table.  The first is EOF (-1).  
       
    48 // That is, the "table" seen by ctype<char> member functions is
       
    49 // _S_classic_table + 1.
       
    50 const ctype_base::mask 
       
    51 ctype<char>::_S_classic_table[257] = 
       
    52 {
       
    53   ctype_base::mask(0) /* EOF */,
       
    54   cntrl /* null */,
       
    55   cntrl /* ^A */,
       
    56   cntrl /* ^B */,
       
    57   cntrl /* ^C */,
       
    58   cntrl /* ^D */,
       
    59   cntrl /* ^E */,
       
    60   cntrl /* ^F */,
       
    61   cntrl /* ^G */,
       
    62   cntrl /* ^H */,
       
    63   ctype_base::mask(space | cntrl) /* tab */,
       
    64   ctype_base::mask(space | cntrl) /* LF */,
       
    65   ctype_base::mask(space | cntrl) /* ^K */,
       
    66   ctype_base::mask(space | cntrl) /* FF */,
       
    67   ctype_base::mask(space | cntrl) /* ^M */,
       
    68   cntrl /* ^N */,
       
    69   cntrl /* ^O */,
       
    70   cntrl /* ^P */,
       
    71   cntrl /* ^Q */,
       
    72   cntrl /* ^R */,
       
    73   cntrl /* ^S */,
       
    74   cntrl /* ^T */,
       
    75   cntrl /* ^U */,
       
    76   cntrl /* ^V */,
       
    77   cntrl /* ^W */,
       
    78   cntrl /* ^X */,
       
    79   cntrl /* ^Y */,
       
    80   cntrl /* ^Z */,
       
    81   cntrl /* esc */,
       
    82   cntrl /* ^\ */,
       
    83   cntrl /* ^] */,
       
    84   cntrl /* ^^ */,
       
    85   cntrl /* ^_ */,
       
    86   ctype_base::mask (space | PRINTFLAG) /*  */,
       
    87   ctype_base::mask (punct | PRINTFLAG ) /* ! */,
       
    88   ctype_base::mask (punct | PRINTFLAG ) /* " */,
       
    89   ctype_base::mask (punct | PRINTFLAG ) /* # */,
       
    90   ctype_base::mask (punct | PRINTFLAG ) /* $ */,
       
    91   ctype_base::mask (punct | PRINTFLAG ) /* % */,
       
    92   ctype_base::mask (punct | PRINTFLAG ) /* & */,
       
    93   ctype_base::mask (punct | PRINTFLAG ) /* ' */,
       
    94   ctype_base::mask (punct | PRINTFLAG ) /* ( */,
       
    95   ctype_base::mask (punct | PRINTFLAG ) /* ) */,
       
    96   ctype_base::mask (punct | PRINTFLAG ) /* * */,
       
    97   ctype_base::mask (punct | PRINTFLAG ) /* + */,
       
    98   ctype_base::mask (punct | PRINTFLAG ) /* , */,
       
    99   ctype_base::mask (punct | PRINTFLAG ) /* - */,
       
   100   ctype_base::mask (punct | PRINTFLAG ) /* . */,
       
   101   ctype_base::mask (punct | PRINTFLAG ) /* / */,
       
   102   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 0 */,
       
   103   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 1 */,
       
   104   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 2 */,
       
   105   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 3 */,
       
   106   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 4 */,
       
   107   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 5 */,
       
   108   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 6 */,
       
   109   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 7 */,
       
   110   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 8 */,
       
   111   ctype_base::mask(digit | PRINTFLAG | xdigit) /* 9 */,
       
   112   ctype_base::mask (punct | PRINTFLAG ) /* : */,
       
   113   ctype_base::mask (punct | PRINTFLAG ) /* ; */,
       
   114   ctype_base::mask (punct | PRINTFLAG ) /* < */,
       
   115   ctype_base::mask (punct | PRINTFLAG ) /* = */,
       
   116   ctype_base::mask (punct | PRINTFLAG ) /* > */,
       
   117   ctype_base::mask (punct | PRINTFLAG ) /* ? */,
       
   118   ctype_base::mask (punct | PRINTFLAG ) /* ! */,
       
   119   ctype_base::mask(alpha | PRINTFLAG | upper | xdigit) /* A */,
       
   120   ctype_base::mask(alpha | PRINTFLAG | upper | xdigit) /* B */,
       
   121   ctype_base::mask(alpha | PRINTFLAG | upper | xdigit) /* C */,
       
   122   ctype_base::mask(alpha | PRINTFLAG | upper | xdigit) /* D */,
       
   123   ctype_base::mask(alpha | PRINTFLAG | upper | xdigit) /* E */,
       
   124   ctype_base::mask(alpha | PRINTFLAG | upper | xdigit) /* F */,
       
   125   ctype_base::mask(alpha | PRINTFLAG | upper) /* G */,
       
   126   ctype_base::mask(alpha | PRINTFLAG | upper) /* H */,
       
   127   ctype_base::mask(alpha | PRINTFLAG | upper) /* I */,
       
   128   ctype_base::mask(alpha | PRINTFLAG | upper) /* J */,
       
   129   ctype_base::mask(alpha | PRINTFLAG | upper) /* K */,
       
   130   ctype_base::mask(alpha | PRINTFLAG | upper) /* L */,
       
   131   ctype_base::mask(alpha | PRINTFLAG | upper) /* M */,
       
   132   ctype_base::mask(alpha | PRINTFLAG | upper) /* N */,
       
   133   ctype_base::mask(alpha | PRINTFLAG | upper) /* O */,
       
   134   ctype_base::mask(alpha | PRINTFLAG | upper) /* P */,
       
   135   ctype_base::mask(alpha | PRINTFLAG | upper) /* Q */,
       
   136   ctype_base::mask(alpha | PRINTFLAG | upper) /* R */,
       
   137   ctype_base::mask(alpha | PRINTFLAG | upper) /* S */,
       
   138   ctype_base::mask(alpha | PRINTFLAG | upper) /* T */,
       
   139   ctype_base::mask(alpha | PRINTFLAG | upper) /* U */,
       
   140   ctype_base::mask(alpha | PRINTFLAG | upper) /* V */,
       
   141   ctype_base::mask(alpha | PRINTFLAG | upper) /* W */,
       
   142   ctype_base::mask(alpha | PRINTFLAG | upper) /* X */,
       
   143   ctype_base::mask(alpha | PRINTFLAG | upper) /* Y */,
       
   144   ctype_base::mask(alpha | PRINTFLAG | upper) /* Z */,
       
   145   ctype_base::mask (punct | PRINTFLAG ) /* [ */,
       
   146   ctype_base::mask (punct | PRINTFLAG ) /* \ */,
       
   147   ctype_base::mask (punct | PRINTFLAG ) /* ] */,
       
   148   ctype_base::mask (punct | PRINTFLAG ) /* ^ */,
       
   149   ctype_base::mask (punct | PRINTFLAG ) /* _ */,
       
   150   ctype_base::mask (punct | PRINTFLAG ) /* ` */,
       
   151   ctype_base::mask(alpha | PRINTFLAG | lower | xdigit) /* a */,
       
   152   ctype_base::mask(alpha | PRINTFLAG | lower | xdigit) /* b */,
       
   153   ctype_base::mask(alpha | PRINTFLAG | lower | xdigit) /* c */,
       
   154   ctype_base::mask(alpha | PRINTFLAG | lower | xdigit) /* d */,
       
   155   ctype_base::mask(alpha | PRINTFLAG | lower | xdigit) /* e */,
       
   156   ctype_base::mask(alpha | PRINTFLAG | lower | xdigit) /* f */,
       
   157   ctype_base::mask(alpha | PRINTFLAG | lower) /* g */,
       
   158   ctype_base::mask(alpha | PRINTFLAG | lower) /* h */,
       
   159   ctype_base::mask(alpha | PRINTFLAG | lower) /* i */,
       
   160   ctype_base::mask(alpha | PRINTFLAG | lower) /* j */,
       
   161   ctype_base::mask(alpha | PRINTFLAG | lower) /* k */,
       
   162   ctype_base::mask(alpha | PRINTFLAG | lower) /* l */,
       
   163   ctype_base::mask(alpha | PRINTFLAG | lower) /* m */,
       
   164   ctype_base::mask(alpha | PRINTFLAG | lower) /* n */,
       
   165   ctype_base::mask(alpha | PRINTFLAG | lower) /* o */,
       
   166   ctype_base::mask(alpha | PRINTFLAG | lower) /* p */,
       
   167   ctype_base::mask(alpha | PRINTFLAG | lower) /* q */,
       
   168   ctype_base::mask(alpha | PRINTFLAG | lower) /* r */,
       
   169   ctype_base::mask(alpha | PRINTFLAG | lower) /* s */,
       
   170   ctype_base::mask(alpha | PRINTFLAG | lower) /* t */,
       
   171   ctype_base::mask(alpha | PRINTFLAG | lower) /* u */,
       
   172   ctype_base::mask(alpha | PRINTFLAG | lower) /* v */,
       
   173   ctype_base::mask(alpha | PRINTFLAG | lower) /* w */,
       
   174   ctype_base::mask(alpha | PRINTFLAG | lower) /* x */,
       
   175   ctype_base::mask(alpha | PRINTFLAG | lower) /* y */,
       
   176   ctype_base::mask(alpha | PRINTFLAG | lower) /* x */,
       
   177   ctype_base::mask (punct | PRINTFLAG ) /* { */,
       
   178   ctype_base::mask (punct | PRINTFLAG ) /* | */,
       
   179   ctype_base::mask (punct | PRINTFLAG ) /* } */,
       
   180   ctype_base::mask (punct | PRINTFLAG ) /* ~ */,
       
   181   cntrl /* del (0x7f)*/,
       
   182     /* ASCII is a 7-bit code, so everything else is non-ASCII */
       
   183 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   184 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   185 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   186 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   187 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   188 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   189 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   190 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   191 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   192 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   193 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   194 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   195 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   196 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   197 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   198 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0)
       
   199 };
       
   200 
       
   201 // For every c in the range 0 <= c < 256, _S_upper[c] is the
       
   202 // uppercased version of c and _S_lower[c] is the lowercased
       
   203 // version.  As before, these two tables assume the ASCII character
       
   204 // set.
       
   205 
       
   206 const unsigned char ctype<char>::_S_upper[256] =
       
   207 {
       
   208   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
       
   209   0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
       
   210   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
       
   211   0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
       
   212   0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
       
   213   0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
       
   214   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
       
   215   0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
       
   216   0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
       
   217   0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
       
   218   0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
       
   219   0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
       
   220   0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
       
   221   0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
       
   222   0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
       
   223   0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
       
   224   0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
       
   225   0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
       
   226   0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
       
   227   0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
       
   228   0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
       
   229   0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
       
   230   0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
       
   231   0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
       
   232   0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
       
   233   0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
       
   234   0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
       
   235   0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
       
   236   0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
       
   237   0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
       
   238   0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
       
   239   0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
       
   240 };
       
   241 
       
   242 const unsigned char ctype<char>::_S_lower[256] =
       
   243 {
       
   244   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
       
   245   0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
       
   246   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
       
   247   0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
       
   248   0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
       
   249   0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
       
   250   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
       
   251   0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
       
   252   0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
       
   253   0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
       
   254   0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
       
   255   0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
       
   256   0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
       
   257   0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
       
   258   0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
       
   259   0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
       
   260   0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
       
   261   0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
       
   262   0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
       
   263   0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
       
   264   0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
       
   265   0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
       
   266   0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
       
   267   0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
       
   268   0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
       
   269   0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
       
   270   0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
       
   271   0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
       
   272   0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
       
   273   0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
       
   274   0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
       
   275   0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
       
   276 };
       
   277 
       
   278 #ifdef	__SYMBIAN32__ //classic, upper and lower tables to use in ctype<charT> templates
       
   279 // repeated the tables, not to make helper functions friend in ctype<char> class.
       
   280 
       
   281 const ctype_base::mask _S_classic_table[257] = 
       
   282 {
       
   283   ctype_base::mask(0) /* EOF */,
       
   284   ctype_base::mask (_Locale_CNTRL)/* null */,
       
   285  ctype_base::mask (_Locale_CNTRL)/* ^A */,
       
   286   ctype_base::mask (_Locale_CNTRL)/* ^B */,
       
   287   ctype_base::mask (_Locale_CNTRL)/* ^C */,
       
   288   ctype_base::mask (_Locale_CNTRL)/* ^D */,
       
   289   ctype_base::mask (_Locale_CNTRL)/* ^E */,
       
   290  ctype_base::mask (_Locale_CNTRL)/* ^F */,
       
   291   ctype_base::mask (_Locale_CNTRL)/* ^G */,
       
   292   ctype_base::mask (_Locale_CNTRL)/* ^H */,
       
   293  ctype_base::mask  (_Locale_SPACE | _Locale_CNTRL) /* tab */,
       
   294  ctype_base::mask  (_Locale_SPACE | _Locale_CNTRL) /* LF */,
       
   295  ctype_base::mask  (_Locale_SPACE | _Locale_CNTRL) /* ^K */,
       
   296  ctype_base::mask  (_Locale_SPACE | _Locale_CNTRL) /* FF */,
       
   297  ctype_base::mask  (_Locale_SPACE | _Locale_CNTRL) /* ^M */,
       
   298  ctype_base::mask (_Locale_CNTRL)/* ^N */,
       
   299   ctype_base::mask (_Locale_CNTRL)/* ^O */,
       
   300   ctype_base::mask (_Locale_CNTRL)/* ^P */,
       
   301   ctype_base::mask (_Locale_CNTRL)/* ^Q */,
       
   302   ctype_base::mask (_Locale_CNTRL)/* ^R */,
       
   303   ctype_base::mask (_Locale_CNTRL)/* ^S */,
       
   304   ctype_base::mask (_Locale_CNTRL)/* ^T */,
       
   305  ctype_base::mask (_Locale_CNTRL)/* ^U */,
       
   306   ctype_base::mask (_Locale_CNTRL) /* ^V */,
       
   307   ctype_base::mask (_Locale_CNTRL) /* ^W */,
       
   308   ctype_base::mask (_Locale_CNTRL)/* ^X */,
       
   309   ctype_base::mask (_Locale_CNTRL) /* ^Y */,
       
   310   ctype_base::mask (_Locale_CNTRL)/* ^Z */,
       
   311  ctype_base::mask (_Locale_CNTRL) /* esc */,
       
   312  ctype_base::mask (_Locale_CNTRL)/* ^\ */,
       
   313  ctype_base::mask (_Locale_CNTRL)/* ^] */,
       
   314  ctype_base::mask (_Locale_CNTRL)/* ^^ */,
       
   315   ctype_base::mask (_Locale_CNTRL )/* ^_ */,
       
   316   ctype_base::mask (_Locale_SPACE | PRINTFLAG) /*  */,
       
   317   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ! */,
       
   318   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* " */,
       
   319   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* # */,
       
   320   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* $ */,
       
   321   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* % */,
       
   322   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* & */,
       
   323   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ' */,
       
   324   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ( */,
       
   325   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ) */,
       
   326   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* * */,
       
   327   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* + */,
       
   328   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* , */,
       
   329   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* - */,
       
   330   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* . */,
       
   331   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* / */,
       
   332   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 0 */,
       
   333   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 1 */,
       
   334   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 2 */,
       
   335   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 3 */,
       
   336   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 4 */,
       
   337   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 5 */,
       
   338   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 6 */,
       
   339   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 7 */,
       
   340   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 8 */,
       
   341   ctype_base::mask(_Locale_DIGIT | PRINTFLAG | _Locale_XDIGIT) /* 9 */,
       
   342   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* : */,
       
   343   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ; */,
       
   344   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* < */,
       
   345   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* = */,
       
   346   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* > */,
       
   347   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ? */,
       
   348   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ! */,
       
   349   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER | _Locale_XDIGIT) /* A */,
       
   350   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER | _Locale_XDIGIT) /* B */,
       
   351   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER | _Locale_XDIGIT) /* C */,
       
   352   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER | _Locale_XDIGIT) /* D */,
       
   353   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER | _Locale_XDIGIT) /* E */,
       
   354   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER | _Locale_XDIGIT) /* F */,
       
   355   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* G */,
       
   356   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* H */,
       
   357   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* I */,
       
   358   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* J */,
       
   359   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* K */,
       
   360   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* L */,
       
   361   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* M */,
       
   362   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* N */,
       
   363   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* O */,
       
   364   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* P */,
       
   365   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* Q */,
       
   366   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* R */,
       
   367   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* S */,
       
   368   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* T */,
       
   369   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* U */,
       
   370   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* V */,
       
   371   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* W */,
       
   372   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* X */,
       
   373   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* Y */,
       
   374   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_UPPER) /* Z */,
       
   375   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* [ */,
       
   376   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* \ */,
       
   377   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ] */,
       
   378   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ^ */,
       
   379   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* _ */,
       
   380   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ` */,
       
   381   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER | _Locale_XDIGIT) /* a */,
       
   382   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER | _Locale_XDIGIT) /* b */,
       
   383   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER | _Locale_XDIGIT) /* c */,
       
   384   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER | _Locale_XDIGIT) /* d */,
       
   385   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER | _Locale_XDIGIT) /* e */,
       
   386   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER | _Locale_XDIGIT) /* f */,
       
   387   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* g */,
       
   388   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* h */,
       
   389   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* i */,
       
   390   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* j */,
       
   391   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* k */,
       
   392   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* l */,
       
   393   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* m */,
       
   394   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* n */,
       
   395   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* o */,
       
   396   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* p */,
       
   397   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* q */,
       
   398   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* r */,
       
   399   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* s */,
       
   400   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* t */,
       
   401   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* u */,
       
   402   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* v */,
       
   403   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* w */,
       
   404   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* x */,
       
   405   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* y */,
       
   406   ctype_base::mask(_Locale_ALPHA | PRINTFLAG | _Locale_LOWER) /* x */,
       
   407   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* { */,
       
   408   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* | */,
       
   409   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* } */,
       
   410   ctype_base::mask (_Locale_PUNCT | PRINTFLAG ) /* ~ */,
       
   411    ctype_base::mask(_Locale_CNTRL )/* del (0x7f)*/,
       
   412     /* ASCII is a 7-bit code, so everything else is non-ASCII */
       
   413 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   414 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   415 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   416 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   417 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   418 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   419 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   420 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   421 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   422 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   423 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   424 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   425 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   426 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   427 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),
       
   428 ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0),  ctype_base::mask(0)
       
   429 };
       
   430 
       
   431 // For every c in the range 0 <= c < 256, _S_upper[c] is the
       
   432 // uppercased version of c and _S_lower[c] is the lowercased
       
   433 // version.  As before, these two tables assume the ASCII character
       
   434 // set.
       
   435 
       
   436 const unsigned char _S_upper[256] =
       
   437 {
       
   438   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
       
   439   0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
       
   440   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
       
   441   0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
       
   442   0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
       
   443   0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
       
   444   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
       
   445   0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
       
   446   0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
       
   447   0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
       
   448   0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
       
   449   0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
       
   450   0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
       
   451   0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
       
   452   0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
       
   453   0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
       
   454   0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
       
   455   0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
       
   456   0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
       
   457   0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
       
   458   0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
       
   459   0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
       
   460   0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
       
   461   0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
       
   462   0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
       
   463   0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
       
   464   0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
       
   465   0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
       
   466   0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
       
   467   0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
       
   468   0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
       
   469   0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
       
   470 };
       
   471 
       
   472 const unsigned char _S_lower[256] =
       
   473 {
       
   474   0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
       
   475   0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
       
   476   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
       
   477   0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
       
   478   0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
       
   479   0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
       
   480   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
       
   481   0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
       
   482   0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
       
   483   0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
       
   484   0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
       
   485   0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
       
   486   0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
       
   487   0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
       
   488   0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
       
   489   0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
       
   490   0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
       
   491   0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
       
   492   0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
       
   493   0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
       
   494   0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
       
   495   0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
       
   496   0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
       
   497   0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
       
   498   0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
       
   499   0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
       
   500   0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
       
   501   0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
       
   502   0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
       
   503   0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
       
   504   0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
       
   505   0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
       
   506 };
       
   507 
       
   508 extern _Locale_mask_t  Get_locale_char_ctype(unsigned char);
       
   509 
       
   510 //Helper functions to return address of classic, upper and lower table address.
       
   511 _STLP_EXP_DECLSPEC	const ctype_base::mask* _get_classic_table()
       
   512 {
       
   513 	return &_S_classic_table[1];
       
   514 }
       
   515 
       
   516 _STLP_EXP_DECLSPEC	const unsigned char*  _get_S_upper_table()
       
   517 {
       
   518 	return _S_upper;
       
   519 }
       
   520 
       
   521 _STLP_EXP_DECLSPEC	const unsigned char*  _get_S_lower_table()
       
   522 {
       
   523 	return _S_lower;
       
   524 }
       
   525 
       
   526 _Locale_ctype* __acquire_ctype(const char* name); 
       
   527 void __release_ctype(_Locale_ctype* cat);
       
   528 // Dummy api to call the inline APIs to expand, to get exported
       
   529 void Dummy_API(void)
       
   530 {
       
   531 	Ctype_charT_GetFacetLocaleId("");
       
   532 	Numpunct_charT_GetFacetLocaleId("");
       
   533 	Moneypunct_charT_GetFacetLocaleId("");	
       
   534 	
       
   535 }
       
   536 
       
   537 _STLP_EXP_DECLSPEC _Locale_ctype* __acquire_ctypeE(const char* name )
       
   538 {
       
   539 	return __acquire_ctype(name);
       
   540 }
       
   541 _STLP_EXP_DECLSPEC void __release_ctypeE(_Locale_ctype* lctype)
       
   542 {
       
   543 	__release_ctype(lctype);
       
   544 }
       
   545 
       
   546 _STLP_EXP_DECLSPEC ctype_base::mask __Locale_ctypeE(_Locale_ctype*  lctype, wint_t c, ctype_base::mask m)
       
   547 {
       
   548 
       
   549 	_Locale_mask_t  ret = 0;
       
   550 	
       
   551 	if (iscntrl(c))  ret |= _Locale_CNTRL;
       
   552 	if (isupper(c))  ret |= _Locale_UPPER;
       
   553 	if (islower(c))  ret |= _Locale_LOWER;
       
   554 	if (isdigit(c))  ret |= _Locale_DIGIT;
       
   555 	if (isxdigit(c)) ret |= _Locale_XDIGIT;
       
   556 	if (ispunct(c))  ret |= _Locale_PUNCT;
       
   557 	if (isspace(c))  ret |= _Locale_SPACE;
       
   558 	if (isprint(c))  ret |= _Locale_PRINT;
       
   559 	if (isalpha(c))  ret |= _Locale_ALPHA;
       
   560 	
       
   561 	return (ctype_base::mask)(m & ret);
       
   562 }
       
   563 _STLP_EXP_DECLSPEC wint_t __Locale_toupperE(_Locale_ctype* lctype, wint_t c)
       
   564 {
       
   565 	return _Locale_toupper(lctype,c);
       
   566 }
       
   567 _STLP_EXP_DECLSPEC wint_t __Locale_tolowerE(_Locale_ctype* lctype, wint_t  c)
       
   568 {
       
   569 	return _Locale_tolower(lctype,c);
       
   570 }
       
   571 
       
   572 
       
   573 
       
   574 #endif //#ifdef	__SYMBIAN32__
       
   575 
       
   576 struct _Ctype_is_mask {
       
   577   typedef char argument_type;
       
   578   typedef bool result_type;
       
   579   
       
   580   ctype_base::mask _Mask;
       
   581   const ctype_base::mask* _M_table;
       
   582   
       
   583   _Ctype_is_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {}
       
   584   bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) != 0; }
       
   585 };
       
   586 
       
   587 struct _Ctype_not_mask {
       
   588   typedef char argument_type;
       
   589   typedef bool result_type;
       
   590   
       
   591   ctype_base::mask _Mask;
       
   592   const ctype_base::mask* _M_table;
       
   593   
       
   594   _Ctype_not_mask(ctype_base::mask __m, const ctype_base::mask* __t) : _Mask(__m), _M_table(__t) {}
       
   595   bool operator()(char __c) const { return (_M_table[(unsigned char) __c] & _Mask) == 0; }
       
   596 };
       
   597  
       
   598 _STLP_EXP_DECLSPEC ctype<char>::ctype(const ctype_base::mask * __tab, bool __del, size_t __refs) : 
       
   599   _BaseFacet(__refs) /* , _M_ctype_table(0) */ {
       
   600   _M_ctype_table = __tab ? __tab : classic_table();
       
   601   _M_delete = __tab && __del;
       
   602 }
       
   603 
       
   604 _STLP_EXP_DECLSPEC const ctype_base::mask* ctype<char>::classic_table() _STLP_NOTHROW
       
   605 {
       
   606 	return & _S_classic_table [1];
       
   607 }
       
   608 _STLP_EXP_DECLSPEC ctype<char>::~ctype() {
       
   609   if (_M_delete)
       
   610     delete[] __CONST_CAST(ctype_base::mask *, _M_ctype_table);
       
   611 }
       
   612 
       
   613 _STLP_EXP_DECLSPEC const char*
       
   614 ctype<char>::scan_is(ctype_base::mask  __m, const char* __low, const char* __high) const  {
       
   615   return _STLP_STD::find_if(__low, __high, _Ctype_is_mask(__m, _M_ctype_table));
       
   616 }
       
   617 
       
   618 _STLP_EXP_DECLSPEC const char* 
       
   619 ctype<char>::scan_not(ctype_base::mask  __m, const char* __low, const char* __high) const {
       
   620   return _STLP_STD::find_if(__low, __high, _Ctype_not_mask(__m, _M_ctype_table));
       
   621 }
       
   622 
       
   623 _STLP_EXP_DECLSPEC char        
       
   624 ctype<char>::do_toupper(char __c) const
       
   625 { return (char) _S_upper[(unsigned char) __c]; }
       
   626 _STLP_EXP_DECLSPEC char        
       
   627 ctype<char>::do_tolower(char __c) const
       
   628 { return (char) _S_lower[(unsigned char) __c]; }
       
   629 _STLP_EXP_DECLSPEC const char* 
       
   630 ctype<char>::do_toupper(char* __low, const char* __high) const {
       
   631   for ( ; __low < __high; ++__low)
       
   632     *__low = (char) _S_upper[(unsigned char) *__low];
       
   633   return __high;
       
   634 }
       
   635   
       
   636 _STLP_EXP_DECLSPEC const char* 
       
   637 ctype<char>::do_tolower(char* __low, const char* __high) const {
       
   638   for ( ; __low < __high; ++__low)
       
   639     *__low = (char) _S_lower[(unsigned char) *__low];
       
   640   return __high;
       
   641 }
       
   642 
       
   643 _STLP_EXP_DECLSPEC char        
       
   644 ctype<char>::do_widen(char __c) const { return __c; }
       
   645 
       
   646 _STLP_EXP_DECLSPEC const char* 
       
   647 ctype<char>::do_widen(const char* __low, const char* __high,
       
   648                       char* __to) const {
       
   649   __copy_trivial(__low, __high, __to);
       
   650   return __high;    
       
   651 }
       
   652 _STLP_EXP_DECLSPEC char
       
   653 ctype<char>::do_narrow(char __c, char /* dfault */ ) const { return __c; }
       
   654 _STLP_EXP_DECLSPEC const char* 
       
   655 ctype<char>::do_narrow(const char* __low, const char* __high,
       
   656                        char /* dfault */, char* __to) const {
       
   657   __copy_trivial(__low, __high, __to);
       
   658   return __high; 
       
   659 }
       
   660 
       
   661 
       
   662 # ifndef _STLP_NO_WCHAR_T
       
   663 
       
   664   struct _Ctype_w_is_mask {
       
   665     typedef wchar_t argument_type;
       
   666     typedef bool    result_type;
       
   667 
       
   668     ctype_base::mask M;
       
   669     const ctype_base::mask* table;
       
   670     
       
   671     _Ctype_w_is_mask(ctype_base::mask m, const ctype_base::mask* t)
       
   672       : M(m), table(t) {}
       
   673     bool operator()(wchar_t c) const
       
   674       { 
       
   675 #ifdef __SYMBIAN32__
       
   676       return size_t(c) < ctype<char>::table_size && (table[c] & M); 
       
   677 #else
       
   678       return c >= 0 && size_t(c) < ctype<char>::table_size && (table[c] & M); 
       
   679 #endif
       
   680       }
       
   681   };
       
   682 
       
   683 
       
   684 //----------------------------------------------------------------------
       
   685 // ctype<wchar_t>
       
   686 
       
   687 _STLP_EXP_DECLSPEC ctype<wchar_t>::~ctype() {}
       
   688 
       
   689 
       
   690 _STLP_EXP_DECLSPEC bool ctype<wchar_t>::do_is(ctype_base::mask  m, wchar_t c) const
       
   691 {
       
   692   const ctype_base::mask * table = ctype<char>::classic_table();
       
   693 #ifdef __SYMBIAN32__
       
   694   return size_t(c) < ctype<char>::table_size && (m & table[c]);
       
   695 #else
       
   696   return c >= 0 && size_t(c) < ctype<char>::table_size && (m & table[c]);
       
   697 #endif
       
   698 }
       
   699 
       
   700 _STLP_EXP_DECLSPEC const wchar_t* ctype<wchar_t>::do_is(const wchar_t* low, const wchar_t* high,
       
   701                                      ctype_base::mask * vec) const
       
   702 {
       
   703   // boris : not clear if this is the right thing to do...
       
   704   const ctype_base::mask * table = ctype<char>::classic_table();
       
   705   for ( ; low < high; ++low, ++vec) {
       
   706     wchar_t c = *low;
       
   707 #ifdef __SYMBIAN32__
       
   708     *vec = size_t(c) < ctype<char>::table_size ? table[c] : ctype_base::mask (0);
       
   709 #else
       
   710     *vec = c >= 0 && size_t(c) < ctype<char>::table_size ? table[c] : ctype_base::mask (0);
       
   711 #endif
       
   712   }
       
   713   return high;
       
   714 }
       
   715 
       
   716 _STLP_EXP_DECLSPEC const wchar_t*
       
   717 ctype<wchar_t>::do_scan_is(ctype_base::mask  m,
       
   718                            const wchar_t* low, const wchar_t* high) const
       
   719 {
       
   720   return find_if(low, high, _Ctype_w_is_mask(m, ctype<char>::classic_table()));
       
   721 }
       
   722 
       
   723 
       
   724 _STLP_EXP_DECLSPEC const wchar_t*
       
   725 ctype<wchar_t>::do_scan_not(ctype_base::mask  m,
       
   726                             const wchar_t* low, const wchar_t* high) const
       
   727 {
       
   728     return find_if(low, high, not1(_Ctype_w_is_mask(m, ctype<char>::classic_table())));
       
   729 }
       
   730 
       
   731 _STLP_EXP_DECLSPEC wchar_t ctype<wchar_t>::do_toupper(wchar_t c) const
       
   732 {
       
   733 #ifdef __SYMBIAN32__
       
   734   return size_t(c) < ctype<char>::table_size
       
   735     ? (wchar_t) ctype<char>::_S_upper[c]
       
   736     : c;
       
   737 #else
       
   738   return c >= 0 && size_t(c) < ctype<char>::table_size
       
   739     ? (wchar_t) ctype<char>::_S_upper[c]
       
   740     : c;
       
   741 #endif
       
   742 }
       
   743 
       
   744 _STLP_EXP_DECLSPEC const wchar_t* 
       
   745 ctype<wchar_t>::do_toupper(wchar_t* low, const wchar_t* high) const
       
   746 {
       
   747   for ( ; low < high; ++low) {
       
   748     wchar_t c = *low;
       
   749 #ifdef __SYMBIAN32__
       
   750     *low = size_t(c) < ctype<char>::table_size
       
   751       ? (wchar_t) ctype<char>::_S_upper[c]
       
   752       : c;
       
   753 #else
       
   754     *low = c >= 0 && size_t(c) < ctype<char>::table_size
       
   755       ? (wchar_t) ctype<char>::_S_upper[c]
       
   756       : c;
       
   757 #endif
       
   758   }
       
   759   return high;
       
   760 }
       
   761 
       
   762 _STLP_EXP_DECLSPEC wchar_t ctype<wchar_t>::do_tolower(wchar_t c) const
       
   763 {
       
   764 #ifdef __SYMBIAN32__
       
   765   return size_t(c) < ctype<char>::table_size
       
   766     ? (wchar_t) ctype<char>::_S_lower[c]
       
   767     : c;
       
   768 #else
       
   769   return c >= 0 && size_t(c) < ctype<char>::table_size
       
   770     ? (wchar_t) ctype<char>::_S_lower[c]
       
   771     : c;
       
   772 #endif
       
   773 }
       
   774 
       
   775 _STLP_EXP_DECLSPEC const wchar_t* 
       
   776 ctype<wchar_t>::do_tolower(wchar_t* low, const wchar_t* high) const
       
   777 {
       
   778   for ( ; low < high; ++low) {
       
   779     wchar_t c = *low;
       
   780 #ifdef __SYMBIAN32__
       
   781     *low = size_t(c) < ctype<char>::table_size
       
   782       ? (wchar_t) ctype<char>::_S_lower[c]
       
   783       : c;
       
   784 #else
       
   785     *low = c >= 0 && size_t(c) < ctype<char>::table_size
       
   786       ? (wchar_t) ctype<char>::_S_lower[c]
       
   787       : c;
       
   788 #endif
       
   789   }
       
   790   return high;
       
   791 }
       
   792 
       
   793 _STLP_EXP_DECLSPEC wchar_t ctype<wchar_t>::do_widen(char c) const 
       
   794 {
       
   795   return (wchar_t) c;
       
   796 }
       
   797 
       
   798 _STLP_EXP_DECLSPEC const char* 
       
   799 ctype<wchar_t>::do_widen(const char* low, const char* high,
       
   800                          wchar_t* dest) const
       
   801 {
       
   802   while (low != high)
       
   803     *dest++ = (wchar_t) *low++;
       
   804   return high;
       
   805 }
       
   806 
       
   807 _STLP_EXP_DECLSPEC char ctype<wchar_t>::do_narrow(wchar_t c, char dfault) const 
       
   808 {
       
   809   return (char) c == c ? c : dfault;
       
   810 }
       
   811 
       
   812 _STLP_EXP_DECLSPEC const wchar_t* ctype<wchar_t>::do_narrow(const wchar_t* low,
       
   813                                          const wchar_t* high,
       
   814                                          char dfault, char* dest) const
       
   815 {
       
   816   while (low != high) {
       
   817     wchar_t c = *low++;
       
   818     *dest++ = (char) c == c ? c : dfault;
       
   819   }
       
   820 
       
   821   return high;
       
   822 }
       
   823 
       
   824 # endif
       
   825 _STLP_END_NAMESPACE
       
   826 
       
   827 // Local Variables:
       
   828 // mode:C++
       
   829 // End:
       
   830