build/stlport/src/c_locale_glibc/c_locale_glibc2.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/stlport/src/c_locale_glibc/c_locale_glibc2.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,705 @@
     1.4 +#include <locale.h>
     1.5 +#include <langinfo.h>
     1.6 +#include <stdio.h>
     1.7 +#include <stdlib.h>
     1.8 +#include <wctype.h>
     1.9 +#include <string.h>
    1.10 +#include <stdint.h>
    1.11 +
    1.12 +static const char *_empty_str = "";
    1.13 +static const char *_C_name = "C";
    1.14 +
    1.15 +static wchar_t* _ToWChar(const char* buf, wchar_t *wbuf, size_t wbufSize) {
    1.16 +  wchar_t *wcur = wbuf;
    1.17 +  wchar_t *wend = wbuf + wbufSize - 1;
    1.18 +  for (; wcur != wend && *buf != 0; ++buf, ++wcur)
    1.19 +    *wcur = *buf;
    1.20 +  *wcur = 0;
    1.21 +  return wbuf;
    1.22 +}
    1.23 +
    1.24 +#if 0
    1.25 +struct _Locale_ctype
    1.26 +{
    1.27 +  locale_t __cloc;
    1.28 +};
    1.29 +
    1.30 +struct _Locale_numeric
    1.31 +{
    1.32 +  locale_t __cloc;
    1.33 +};
    1.34 +
    1.35 +struct _Locale_time
    1.36 +{
    1.37 +  locale_t __cloc;
    1.38 +};
    1.39 +
    1.40 +struct _Locale_collate
    1.41 +{
    1.42 +  locale_t __cloc;
    1.43 +};
    1.44 +
    1.45 +struct _Locale_monetary
    1.46 +{
    1.47 +  locale_t __cloc;
    1.48 +};
    1.49 +
    1.50 +struct _Locale_messages
    1.51 +{
    1.52 +  locale_t __cloc;
    1.53 +};
    1.54 +#endif
    1.55 +
    1.56 +void _Locale_init()
    1.57 +{}
    1.58 +
    1.59 +void _Locale_final()
    1.60 +{}
    1.61 +
    1.62 +struct _Locale_ctype *_Locale_ctype_create(const char *nm, struct _Locale_name_hint* hint,
    1.63 +                                           int *__err_code) {
    1.64 +  *__err_code = _STLP_LOC_UNKNOWN_NAME;
    1.65 +  return (struct _Locale_ctype*)newlocale(LC_CTYPE_MASK, nm, NULL);
    1.66 +}
    1.67 +
    1.68 +struct _Locale_codecvt *_Locale_codecvt_create(const char *nm, struct _Locale_name_hint* hint,
    1.69 +                                               int *__err_code) {
    1.70 +  // Glibc do not support multibyte manipulation for the moment, it simply implements "C".
    1.71 +  if (nm[0] == 'C' && nm[1] == 0)
    1.72 +  { return (struct _Locale_codecvt*)0x01; }
    1.73 +  *__err_code = _STLP_LOC_NO_PLATFORM_SUPPORT; return 0;
    1.74 +}
    1.75 +
    1.76 +struct _Locale_numeric *_Locale_numeric_create(const char *nm, struct _Locale_name_hint* hint,
    1.77 +                                               int *__err_code) {
    1.78 +  *__err_code = _STLP_LOC_UNKNOWN_NAME;
    1.79 +  return (struct _Locale_numeric*)newlocale(LC_NUMERIC_MASK, nm, NULL);
    1.80 +}
    1.81 +  
    1.82 +struct _Locale_time *_Locale_time_create(const char *nm, struct _Locale_name_hint* hint,
    1.83 +                                         int *__err_code) {
    1.84 +  *__err_code = _STLP_LOC_UNKNOWN_NAME;
    1.85 +  return (struct _Locale_time*)newlocale(LC_TIME_MASK, nm, NULL);
    1.86 +}
    1.87 +
    1.88 +struct _Locale_collate *_Locale_collate_create(const char *nm, struct _Locale_name_hint* hint,
    1.89 +                                               int *__err_code) {
    1.90 +  *__err_code = _STLP_LOC_UNKNOWN_NAME;
    1.91 +  return (struct _Locale_collate*)newlocale(LC_COLLATE_MASK, nm, NULL);
    1.92 +}
    1.93 +
    1.94 +struct _Locale_monetary *_Locale_monetary_create(const char *nm, struct _Locale_name_hint* hint,
    1.95 +                                                 int *__err_code) {
    1.96 +  *__err_code = _STLP_LOC_UNKNOWN_NAME;
    1.97 +  return (struct _Locale_monetary*)newlocale(LC_MONETARY_MASK, nm, NULL);
    1.98 +}
    1.99 +
   1.100 +struct _Locale_messages *_Locale_messages_create(const char *nm, struct _Locale_name_hint* hint,
   1.101 +                                                 int *__err_code) {
   1.102 +  *__err_code = _STLP_LOC_UNKNOWN_NAME;
   1.103 +  return (struct _Locale_messages*)newlocale(LC_MESSAGES_MASK, nm, NULL);
   1.104 +}
   1.105 +
   1.106 +/*
   1.107 +  try to see locale category LC should be used from environment;
   1.108 +  according POSIX, the order is
   1.109 +  1. LC_ALL
   1.110 +  2. category (LC_CTYPE, LC_NUMERIC, ... )
   1.111 +  3. LANG
   1.112 +  If set nothing, return "C" (this really implementation-specific).
   1.113 +*/
   1.114 +static const char *_Locale_aux_default( const char *LC, char *nm )
   1.115 +{
   1.116 +  char *name = getenv( "LC_ALL" );
   1.117 +
   1.118 +  if ( name != NULL && *name != 0 ) {
   1.119 +    return name;
   1.120 +  }
   1.121 +  name = getenv( LC );
   1.122 +  if ( name != NULL && *name != 0 ) {
   1.123 +    return name;
   1.124 +  }
   1.125 +  name = getenv( "LANG" );
   1.126 +  if ( name != NULL && *name != 0 ) {
   1.127 +    return name;
   1.128 +  }
   1.129 +
   1.130 +  return _C_name;
   1.131 +}
   1.132 +
   1.133 +const char *_Locale_ctype_default( char *nm )
   1.134 +{
   1.135 +  return _Locale_aux_default( "LC_CTYPE", nm );
   1.136 +}
   1.137 +
   1.138 +const char *_Locale_numeric_default( char *nm )
   1.139 +{
   1.140 +  return _Locale_aux_default( "LC_NUMERIC", nm );
   1.141 +}
   1.142 +
   1.143 +const char *_Locale_time_default( char *nm )
   1.144 +{
   1.145 +  return _Locale_aux_default( "LC_TIME", nm );
   1.146 +}
   1.147 +
   1.148 +const char *_Locale_collate_default( char *nm )
   1.149 +{
   1.150 +  return _Locale_aux_default( "LC_COLLATE", nm );
   1.151 +}
   1.152 +
   1.153 +const char *_Locale_monetary_default( char *nm )
   1.154 +{
   1.155 +  return _Locale_aux_default( "LC_MONETARY", nm );
   1.156 +}
   1.157 +
   1.158 +const char *_Locale_messages_default( char *nm )
   1.159 +{
   1.160 +  return _Locale_aux_default( "LC_MESSAGES", nm );
   1.161 +}
   1.162 +
   1.163 +char const*_Locale_ctype_name( const struct _Locale_ctype *__loc, char *buf )
   1.164 +{
   1.165 +  return ((locale_t)__loc)->__names[LC_CTYPE];
   1.166 +}
   1.167 +
   1.168 +char const*_Locale_codecvt_name( const struct _Locale_codecvt *__loc, char *buf )
   1.169 +{
   1.170 +  return _C_name;
   1.171 +}
   1.172 +
   1.173 +char const*_Locale_numeric_name( const struct _Locale_numeric *__loc, char *buf )
   1.174 +{
   1.175 +  return ((locale_t)__loc)->__names[LC_NUMERIC];
   1.176 +}
   1.177 +
   1.178 +char const*_Locale_time_name( const struct _Locale_time *__loc, char *buf )
   1.179 +{
   1.180 +  return ((locale_t)__loc)->__names[LC_TIME];
   1.181 +}
   1.182 +
   1.183 +char const*_Locale_collate_name( const struct _Locale_collate *__loc, char *buf )
   1.184 +{
   1.185 +  return ((locale_t)__loc)->__names[LC_COLLATE];
   1.186 +}
   1.187 +
   1.188 +char const*_Locale_monetary_name( const struct _Locale_monetary *__loc, char *buf )
   1.189 +{
   1.190 +  return ((locale_t)__loc)->__names[LC_MONETARY];
   1.191 +}
   1.192 +
   1.193 +char const*_Locale_messages_name( const struct _Locale_messages *__loc, char *buf )
   1.194 +{
   1.195 +  return ((locale_t)__loc)->__names[LC_MESSAGES];
   1.196 +}
   1.197 +
   1.198 +void _Locale_ctype_destroy( struct _Locale_ctype *__loc )
   1.199 +{ freelocale((locale_t)__loc); }
   1.200 +
   1.201 +void _Locale_codecvt_destroy( struct _Locale_codecvt *__loc )
   1.202 +{}
   1.203 +
   1.204 +void _Locale_numeric_destroy( struct _Locale_numeric *__loc )
   1.205 +{ freelocale((locale_t)__loc); }
   1.206 +
   1.207 +void _Locale_time_destroy( struct _Locale_time *__loc )
   1.208 +{ freelocale((locale_t)__loc); }
   1.209 +
   1.210 +void _Locale_collate_destroy( struct _Locale_collate *__loc )
   1.211 +{ freelocale((locale_t)__loc); }
   1.212 +
   1.213 +void _Locale_monetary_destroy( struct _Locale_monetary *__loc )
   1.214 +{ freelocale((locale_t)__loc); }
   1.215 +
   1.216 +void _Locale_messages_destroy( struct _Locale_messages* __loc )
   1.217 +{ freelocale((locale_t)__loc); }
   1.218 +
   1.219 +/*
   1.220 + * locale loc expected either locale name indeed (platform-specific)
   1.221 + * or string like "LC_CTYPE=LocaleNameForCType;LC_NUMERIC=LocaleNameForNum;"
   1.222 + *
   1.223 + */
   1.224 +
   1.225 +static char const*__Extract_locale_name( const char *loc, const char *category, char *buf )
   1.226 +{
   1.227 +  char *expr;
   1.228 +  size_t len_name;
   1.229 +
   1.230 +  if( loc[0]=='L' && loc[1]=='C' && loc[2]=='_') {
   1.231 +    expr = strstr( (char*)loc, category );
   1.232 +    if ( expr == NULL )
   1.233 +      return NULL; /* Category not found. */
   1.234 +    ++expr;
   1.235 +    len_name = strcspn( expr, ";" );
   1.236 +    len_name = len_name >= _Locale_MAX_SIMPLE_NAME ? _Locale_MAX_SIMPLE_NAME - 1 : len_name;
   1.237 +    strncpy( buf, expr, len_name );
   1.238 +    buf[len_name] = 0;
   1.239 +    return buf;
   1.240 +  }
   1.241 +  return loc;
   1.242 +}
   1.243 +
   1.244 +char const*_Locale_extract_ctype_name(const char *loc, char *buf,
   1.245 +                                      struct _Locale_name_hint* hint, int *__err_code)
   1.246 +{ return __Extract_locale_name( loc, "LC_CTYPE=", buf ); }
   1.247 +
   1.248 +char const*_Locale_extract_numeric_name(const char *loc, char *buf,
   1.249 +                                        struct _Locale_name_hint* hint, int *__err_code)
   1.250 +{ return __Extract_locale_name( loc, "LC_NUMERIC=", buf ); }
   1.251 +
   1.252 +char const*_Locale_extract_time_name(const char *loc, char *buf,
   1.253 +                                     struct _Locale_name_hint* hint, int *__err_code)
   1.254 +{ return __Extract_locale_name( loc, "LC_TIME=", buf ); }
   1.255 +
   1.256 +char const*_Locale_extract_collate_name(const char *loc, char *buf,
   1.257 +                                        struct _Locale_name_hint* hint, int *__err_code)
   1.258 +{ return __Extract_locale_name( loc, "LC_COLLATE=", buf ); }
   1.259 +
   1.260 +char const*_Locale_extract_monetary_name(const char *loc, char *buf,
   1.261 +                                         struct _Locale_name_hint* hint, int *__err_code)
   1.262 +{ return __Extract_locale_name( loc, "LC_MONETARY=", buf ); }
   1.263 +
   1.264 +char const*_Locale_extract_messages_name(const char *loc, char *buf,
   1.265 +                                         struct _Locale_name_hint* hint, int *__err_code)
   1.266 +{ return __Extract_locale_name( loc, "LC_MESSAGES=", buf ); }
   1.267 +
   1.268 +struct _Locale_name_hint* _Locale_get_ctype_hint(struct _Locale_ctype* ctype)
   1.269 +{ return 0; }
   1.270 +struct _Locale_name_hint* _Locale_get_numeric_hint(struct _Locale_numeric* numeric)
   1.271 +{ return 0; }
   1.272 +struct _Locale_name_hint* _Locale_get_time_hint(struct _Locale_time* time)
   1.273 +{ return 0; }
   1.274 +struct _Locale_name_hint* _Locale_get_collate_hint(struct _Locale_collate* collate)
   1.275 +{ return 0; }
   1.276 +struct _Locale_name_hint* _Locale_get_monetary_hint(struct _Locale_monetary* monetary)
   1.277 +{ return 0; }
   1.278 +struct _Locale_name_hint* _Locale_get_messages_hint(struct _Locale_messages* messages)
   1.279 +{ return 0; }
   1.280 +
   1.281 +/* ctype */
   1.282 +
   1.283 +const _Locale_mask_t *_Locale_ctype_table( struct _Locale_ctype *__loc )
   1.284 +{
   1.285 +  /* return table with masks (upper, lower, alpha, etc.) */
   1.286 +  _STLP_STATIC_ASSERT( sizeof(_Locale_mask_t) == sizeof(((locale_t)__loc)->__ctype_b[0]) )
   1.287 +  return ((locale_t)__loc)->__ctype_b;
   1.288 +}
   1.289 +
   1.290 +int _Locale_toupper( struct _Locale_ctype *__loc, int c )
   1.291 +{ return ((locale_t)__loc)->__ctype_toupper[c]; }
   1.292 +
   1.293 +int _Locale_tolower( struct _Locale_ctype *__loc, int c )
   1.294 +{ return ((locale_t)__loc)->__ctype_tolower[c]; }
   1.295 +
   1.296 +#if !defined (_STLP_NO_WCHAR_T)
   1.297 +_Locale_mask_t _WLocale_ctype( struct _Locale_ctype *__loc, wint_t wc, _Locale_mask_t __mask )
   1.298 +{
   1.299 +  _Locale_mask_t ret = 0;
   1.300 +  if ((__mask & _Locale_ALPHA) != 0 && iswalpha_l(wc, (locale_t)__loc))
   1.301 +    ret |= _Locale_ALPHA;
   1.302 +  
   1.303 +  if ((__mask & _Locale_CNTRL) != 0 && iswcntrl_l(wc, (locale_t)__loc))
   1.304 +    ret |= _Locale_CNTRL;
   1.305 +
   1.306 +  if ((__mask & _Locale_DIGIT) != 0 && iswdigit_l(wc, (locale_t)__loc))
   1.307 +    ret |= _Locale_DIGIT;
   1.308 +
   1.309 +  if ((__mask & _Locale_PRINT) != 0 && iswprint_l(wc, (locale_t)__loc)) 
   1.310 +    ret |= _Locale_PRINT;
   1.311 +
   1.312 +  if ((__mask & _Locale_PUNCT) != 0 && iswpunct_l(wc, (locale_t)__loc))
   1.313 +    ret |= _Locale_PUNCT;
   1.314 +
   1.315 +  if ((__mask & _Locale_SPACE) != 0 && iswspace_l(wc, (locale_t)__loc))
   1.316 +    ret |= _Locale_SPACE;
   1.317 +
   1.318 +  if ((__mask & _Locale_XDIGIT) != 0 && iswxdigit_l(wc, (locale_t)__loc))
   1.319 +    ret |= _Locale_XDIGIT;
   1.320 +
   1.321 +  if ((__mask & _Locale_UPPER) != 0 && iswupper_l(wc, (locale_t)__loc))
   1.322 +    ret |= _Locale_UPPER;
   1.323 +
   1.324 +  if ((__mask & _Locale_LOWER) != 0 && iswlower_l(wc, (locale_t)__loc))
   1.325 +    ret |= _Locale_LOWER;
   1.326 +
   1.327 +  return ret;
   1.328 +}
   1.329 +
   1.330 +wint_t _WLocale_tolower( struct _Locale_ctype *__loc, wint_t c )
   1.331 +{
   1.332 +  return towlower_l( c, ((locale_t)__loc) );
   1.333 +}
   1.334 +
   1.335 +wint_t _WLocale_toupper( struct _Locale_ctype *__loc, wint_t c )
   1.336 +{
   1.337 +  return towupper_l( c, ((locale_t)__loc) );
   1.338 +}
   1.339 +#endif
   1.340 +
   1.341 +int _WLocale_mb_cur_max( struct _Locale_codecvt * lcodecvt) { return 1; }
   1.342 +int _WLocale_mb_cur_min( struct _Locale_codecvt * lcodecvt) { return 1; }
   1.343 +int _WLocale_is_stateless( struct _Locale_codecvt * lcodecvt) { return 1; }
   1.344 +
   1.345 +#if !defined (_STLP_NO_WCHAR_T)
   1.346 +size_t _WLocale_mbtowc(struct _Locale_codecvt *lcodecvt,
   1.347 +                       wchar_t *to,
   1.348 +                       const char *from, size_t n,
   1.349 +                       mbstate_t *st)
   1.350 +{ *to = *from; return 1; }
   1.351 +
   1.352 +size_t _WLocale_wctomb(struct _Locale_codecvt *lcodecvt,
   1.353 +                       char *to, size_t n,
   1.354 +                       const wchar_t c,
   1.355 +                       mbstate_t *st)
   1.356 +{ *to = (char)c; return 1; }
   1.357 +#endif
   1.358 +
   1.359 +size_t _WLocale_unshift(struct _Locale_codecvt *lcodecvt,
   1.360 +                        mbstate_t *st,
   1.361 +                        char *buf, size_t n, char ** next)
   1.362 +{ *next = buf; return 0; }
   1.363 +
   1.364 +/* Collate */
   1.365 +int _Locale_strcmp(struct _Locale_collate * __loc,
   1.366 +                   const char *s1, size_t n1,
   1.367 +		   const char *s2, size_t n2) {
   1.368 +  int ret = 0;
   1.369 +  char buf1[64], buf2[64];
   1.370 +  while (n1 > 0 || n2 > 0) {
   1.371 +    size_t bufsize1 = n1 < 63 ? n1 : 63;
   1.372 +    size_t bufsize2 = n2 < 63 ? n2 : 63;
   1.373 +    strncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0;
   1.374 +    strncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0;
   1.375 +
   1.376 +    ret = strcoll_l(buf1, buf2, (locale_t)__loc);
   1.377 +    if (ret != 0) return ret;
   1.378 +    s1 += bufsize1; n1 -= bufsize1;
   1.379 +    s2 += bufsize2; n2 -= bufsize2;
   1.380 +  }
   1.381 +  return ret;
   1.382 +}
   1.383 +
   1.384 +#if !defined (_STLP_NO_WCHAR_T)
   1.385 +int _WLocale_strcmp(struct _Locale_collate *__loc,
   1.386 +                    const wchar_t *s1, size_t n1,
   1.387 +                    const wchar_t *s2, size_t n2) {
   1.388 +  int ret = 0;
   1.389 +  wchar_t buf1[64], buf2[64];
   1.390 +  while (n1 > 0 || n2 > 0) {
   1.391 +    size_t bufsize1 = n1 < 63 ? n1 : 63;
   1.392 +    size_t bufsize2 = n2 < 63 ? n2 : 63;
   1.393 +    wcsncpy(buf1, s1, bufsize1); buf1[bufsize1] = 0;
   1.394 +    wcsncpy(buf2, s2, bufsize2); buf2[bufsize2] = 0;
   1.395 +
   1.396 +    ret = wcscoll_l(buf1, buf2, (locale_t)__loc);
   1.397 +    if (ret != 0) return ret;
   1.398 +    s1 += bufsize1; n1 -= bufsize1;
   1.399 +    s2 += bufsize2; n2 -= bufsize2;
   1.400 +  }
   1.401 +  return ret;
   1.402 +}
   1.403 +
   1.404 +#endif
   1.405 +
   1.406 +size_t _Locale_strxfrm(struct _Locale_collate *__loc,
   1.407 +                       char *dest, size_t dest_n,
   1.408 +                       const char *src, size_t src_n )
   1.409 +{
   1.410 +  const char *real_src;
   1.411 +  char *buf = NULL;
   1.412 +  size_t result;
   1.413 +
   1.414 +  if (src_n == 0)
   1.415 +  {
   1.416 +    if (dest != NULL) dest[0] = 0;
   1.417 +    return 0;
   1.418 +  }
   1.419 +  if (src[src_n] != 0) {
   1.420 +    buf = malloc(src_n + 1);
   1.421 +    strncpy(buf, src, src_n);
   1.422 +    buf[src_n] = 0;
   1.423 +    real_src = buf;
   1.424 +  }
   1.425 +  else
   1.426 +    real_src = src;
   1.427 +  result = strxfrm_l(dest, real_src, dest_n, (locale_t)__loc);
   1.428 +  if (buf != NULL) free(buf);
   1.429 +  return result;
   1.430 +}
   1.431 +
   1.432 +# ifndef _STLP_NO_WCHAR_T
   1.433 +
   1.434 +size_t _WLocale_strxfrm( struct _Locale_collate *__loc,
   1.435 +                        wchar_t *dest, size_t dest_n,
   1.436 +                        const wchar_t *src, size_t src_n )
   1.437 +{
   1.438 +  const wchar_t *real_src;
   1.439 +  wchar_t *buf = NULL;
   1.440 +  size_t result;
   1.441 +
   1.442 +  if (src_n == 0)
   1.443 +  {
   1.444 +    if (dest != NULL) dest[0] = 0;
   1.445 +    return 0;
   1.446 +  }
   1.447 +  if (src[src_n] != 0) {
   1.448 +    buf = malloc((src_n + 1) * sizeof(wchar_t));
   1.449 +    wcsncpy(buf, src, src_n);
   1.450 +    buf[src_n] = 0;
   1.451 +    real_src = buf;
   1.452 +  }
   1.453 +  else
   1.454 +    real_src = src;
   1.455 +  result = wcsxfrm_l(dest, real_src, dest_n, (locale_t)__loc);
   1.456 +  if (buf != NULL) free(buf);
   1.457 +  return result;
   1.458 +}
   1.459 +
   1.460 +# endif
   1.461 +
   1.462 +/* Numeric */
   1.463 +
   1.464 +char _Locale_decimal_point(struct _Locale_numeric *__loc)
   1.465 +{
   1.466 +  return *(nl_langinfo_l(RADIXCHAR, (locale_t)__loc));
   1.467 +}
   1.468 +
   1.469 +char _Locale_thousands_sep(struct _Locale_numeric *__loc)
   1.470 +{
   1.471 +  return *(nl_langinfo_l(THOUSEP, (locale_t)__loc));
   1.472 +}
   1.473 +
   1.474 +const char* _Locale_grouping(struct _Locale_numeric *__loc)
   1.475 +{
   1.476 +  return (_Locale_thousands_sep(__loc) != 0 ) ? (nl_langinfo_l(GROUPING, (locale_t)__loc)) : _empty_str;
   1.477 +}
   1.478 +
   1.479 +const char *_Locale_true(struct _Locale_numeric *__loc)
   1.480 +{
   1.481 +  return nl_langinfo_l(YESSTR, (locale_t)__loc);
   1.482 +}
   1.483 +
   1.484 +const char *_Locale_false(struct _Locale_numeric *__loc)
   1.485 +{
   1.486 +  return nl_langinfo_l(NOSTR, (locale_t)__loc);
   1.487 +}
   1.488 +
   1.489 +#ifndef _STLP_NO_WCHAR_T
   1.490 +wchar_t _WLocale_decimal_point(struct _Locale_numeric *__loc)
   1.491 +{ return (wchar_t)_Locale_decimal_point(__loc); }
   1.492 +wchar_t _WLocale_thousands_sep(struct _Locale_numeric *__loc)
   1.493 +{ return (wchar_t)_Locale_thousands_sep(__loc); }
   1.494 +const wchar_t *_WLocale_true(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize)
   1.495 +{ return _ToWChar(_Locale_true(__loc), buf, bufSize); }
   1.496 +const wchar_t *_WLocale_false(struct _Locale_numeric *__loc, wchar_t *buf, size_t bufSize)
   1.497 +{ return _ToWChar(_Locale_false(__loc), buf, bufSize); }
   1.498 +#endif
   1.499 +
   1.500 +/* Monetary */
   1.501 +
   1.502 +const char *_Locale_int_curr_symbol(struct _Locale_monetary *__loc)
   1.503 +{
   1.504 +  return nl_langinfo_l(INT_CURR_SYMBOL, (locale_t)__loc);
   1.505 +}
   1.506 +
   1.507 +const char *_Locale_currency_symbol(struct _Locale_monetary *__loc)
   1.508 +{
   1.509 +  return nl_langinfo_l(CURRENCY_SYMBOL, (locale_t)__loc);
   1.510 +}
   1.511 +
   1.512 +char _Locale_mon_decimal_point(struct _Locale_monetary * __loc)
   1.513 +{
   1.514 +  return *(nl_langinfo_l(MON_DECIMAL_POINT,(locale_t)__loc));
   1.515 +}
   1.516 +
   1.517 +char _Locale_mon_thousands_sep(struct _Locale_monetary *__loc)
   1.518 +{
   1.519 +  return *(nl_langinfo_l(MON_THOUSANDS_SEP, (locale_t)__loc));
   1.520 +}
   1.521 +
   1.522 +#ifndef _STLP_NO_WCHAR_T
   1.523 +const wchar_t *_WLocale_int_curr_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
   1.524 +{ return _ToWChar(_Locale_int_curr_symbol(__loc), buf, bufSize); }
   1.525 +const wchar_t *_WLocale_currency_symbol(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
   1.526 +{ return _ToWChar(_Locale_currency_symbol(__loc), buf, bufSize); }
   1.527 +wchar_t _WLocale_mon_decimal_point(struct _Locale_monetary * __loc)
   1.528 +{ return (wchar_t)_Locale_mon_decimal_point(__loc); }
   1.529 +wchar_t _WLocale_mon_thousands_sep(struct _Locale_monetary * __loc)
   1.530 +{ return (wchar_t)_Locale_mon_thousands_sep(__loc); }
   1.531 +const wchar_t *_WLocale_positive_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
   1.532 +{ return _ToWChar(_Locale_positive_sign(__loc), buf, bufSize); }
   1.533 +const wchar_t *_WLocale_negative_sign(struct _Locale_monetary *__loc, wchar_t *buf, size_t bufSize)
   1.534 +{ return _ToWChar(_Locale_negative_sign(__loc), buf, bufSize); }
   1.535 +#endif
   1.536 +
   1.537 +const char *_Locale_mon_grouping(struct _Locale_monetary *__loc)
   1.538 +{
   1.539 +  return (_Locale_mon_thousands_sep( __loc ) != 0 ) ? nl_langinfo_l(MON_GROUPING, (locale_t)__loc) : _empty_str;
   1.540 +}
   1.541 +
   1.542 +const char *_Locale_positive_sign(struct _Locale_monetary *__loc)
   1.543 +{
   1.544 +  return nl_langinfo_l(POSITIVE_SIGN, (locale_t)__loc);
   1.545 +}
   1.546 +
   1.547 +const char *_Locale_negative_sign(struct _Locale_monetary *__loc)
   1.548 +{
   1.549 +  return nl_langinfo_l(NEGATIVE_SIGN, (locale_t)__loc);
   1.550 +}
   1.551 +
   1.552 +char _Locale_int_frac_digits(struct _Locale_monetary *__loc)
   1.553 +{
   1.554 +  /* We are forced to manually handled the "C" locale for consistency with
   1.555 +   * the default implementation in STLport. */
   1.556 +  const char* lname = ((locale_t)__loc)->__names[LC_MONETARY];
   1.557 +  if (lname[0] == 'C' && lname[1] == 0)
   1.558 +    return 0;
   1.559 +  return *(nl_langinfo_l(INT_FRAC_DIGITS, (locale_t)__loc));
   1.560 +}
   1.561 +
   1.562 +char _Locale_frac_digits(struct _Locale_monetary *__loc)
   1.563 +{
   1.564 +  /* We are forced to manually handled the "C" locale for consistency with
   1.565 +   * the default implementation in STLport. */
   1.566 +  const char* lname = ((locale_t)__loc)->__names[LC_MONETARY];
   1.567 +  if (lname[0] == 'C' && lname[1] == 0)
   1.568 +    return 0;
   1.569 +  return *(nl_langinfo_l(FRAC_DIGITS, (locale_t)__loc));
   1.570 +}
   1.571 +
   1.572 +/* 1 if currency_symbol precedes a positive value, 0 if succeeds */
   1.573 +int _Locale_p_cs_precedes(struct _Locale_monetary *__loc)
   1.574 +{
   1.575 +  return *(nl_langinfo_l(P_CS_PRECEDES, (locale_t)__loc));
   1.576 +}
   1.577 +
   1.578 +/* 1 if a space separates currency_symbol from a positive value. */
   1.579 +int _Locale_p_sep_by_space(struct _Locale_monetary *__loc)
   1.580 +{
   1.581 +  return *(nl_langinfo_l(P_SEP_BY_SPACE, (locale_t)__loc));
   1.582 +}
   1.583 +
   1.584 +/*
   1.585 + * 0 Parentheses surround the quantity and currency_symbol
   1.586 + * 1 The sign string precedes the quantity and currency_symbol
   1.587 + * 2 The sign string succeeds the quantity and currency_symbol.
   1.588 + * 3 The sign string immediately precedes the currency_symbol.
   1.589 + * 4 The sign string immediately succeeds the currency_symbol.
   1.590 + */
   1.591 +int _Locale_p_sign_posn(struct _Locale_monetary *__loc)
   1.592 +{
   1.593 +  return *(nl_langinfo_l(P_SIGN_POSN, (locale_t)__loc));
   1.594 +}
   1.595 +
   1.596 +/* 1 if currency_symbol precedes a negative value, 0 if succeeds */
   1.597 +int _Locale_n_cs_precedes(struct _Locale_monetary *__loc)
   1.598 +{
   1.599 +  return *(nl_langinfo_l(N_CS_PRECEDES, (locale_t)__loc));
   1.600 +}
   1.601 +
   1.602 +/* 1 if a space separates currency_symbol from a negative value. */
   1.603 +int _Locale_n_sep_by_space(struct _Locale_monetary *__loc)
   1.604 +{
   1.605 +  return *(nl_langinfo_l(N_SEP_BY_SPACE, (locale_t)__loc));
   1.606 +}
   1.607 +
   1.608 +/*
   1.609 + * 0 Parentheses surround the quantity and currency_symbol
   1.610 + * 1 The sign string precedes the quantity and currency_symbol
   1.611 + * 2 The sign string succeeds the quantity and currency_symbol.
   1.612 + * 3 The sign string immediately precedes the currency_symbol.
   1.613 + * 4 The sign string immediately succeeds the currency_symbol.
   1.614 + */
   1.615 +int _Locale_n_sign_posn(struct _Locale_monetary *__loc)
   1.616 +{
   1.617 +  return *(nl_langinfo_l(N_SIGN_POSN, (locale_t)__loc));
   1.618 +}
   1.619 +
   1.620 +
   1.621 +/* Time */
   1.622 +const char *_Locale_full_monthname(struct _Locale_time *__loc, int _m )
   1.623 +{
   1.624 +  return nl_langinfo_l(MON_1 + _m, (locale_t)__loc);
   1.625 +}
   1.626 +
   1.627 +const char *_Locale_abbrev_monthname(struct _Locale_time *__loc, int _m )
   1.628 +{
   1.629 +  return nl_langinfo_l(ABMON_1 + _m, (locale_t)__loc);
   1.630 +}
   1.631 +
   1.632 +const char *_Locale_full_dayofweek(struct _Locale_time *__loc, int _d )
   1.633 +{
   1.634 +  return nl_langinfo_l(DAY_1 + _d, (locale_t)__loc);
   1.635 +}
   1.636 +
   1.637 +const char *_Locale_abbrev_dayofweek(struct _Locale_time *__loc, int _d )
   1.638 +{
   1.639 +  return nl_langinfo_l(ABDAY_1 + _d, (locale_t)__loc);
   1.640 +}
   1.641 +
   1.642 +const char *_Locale_d_t_fmt(struct _Locale_time *__loc)
   1.643 +{
   1.644 +  return nl_langinfo_l(D_T_FMT, (locale_t)__loc);
   1.645 +}
   1.646 +
   1.647 +const char *_Locale_d_fmt(struct _Locale_time *__loc )
   1.648 +{
   1.649 +  return nl_langinfo_l(D_FMT, (locale_t)__loc);
   1.650 +}
   1.651 +
   1.652 +const char *_Locale_t_fmt(struct _Locale_time *__loc )
   1.653 +{
   1.654 +  return nl_langinfo_l(T_FMT, (locale_t)__loc);
   1.655 +}
   1.656 +
   1.657 +const char *_Locale_long_d_t_fmt(struct _Locale_time *__loc )
   1.658 +{
   1.659 +  return nl_langinfo_l(ERA_D_T_FMT, (locale_t)__loc);
   1.660 +}
   1.661 +
   1.662 +const char *_Locale_long_d_fmt(struct _Locale_time *__loc )
   1.663 +{
   1.664 +  return nl_langinfo_l(ERA_D_FMT, (locale_t)__loc);
   1.665 +}
   1.666 +
   1.667 +const char *_Locale_am_str(struct _Locale_time *__loc )
   1.668 +{
   1.669 +  return nl_langinfo_l(AM_STR, (locale_t)__loc);
   1.670 +}
   1.671 +
   1.672 +const char *_Locale_pm_str(struct _Locale_time* __loc )
   1.673 +{
   1.674 +  return nl_langinfo_l(PM_STR, (locale_t)__loc);
   1.675 +}
   1.676 +
   1.677 +#ifndef _STLP_NO_WCHAR_T
   1.678 +const wchar_t *_WLocale_full_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize)
   1.679 +{ return _ToWChar(_Locale_full_monthname(__loc, _m), buf, bufSize); }
   1.680 +const wchar_t *_WLocale_abbrev_monthname(struct _Locale_time *__loc, int _m, wchar_t *buf, size_t bufSize)
   1.681 +{ return _ToWChar(_Locale_abbrev_monthname(__loc, _m), buf, bufSize); }
   1.682 +const wchar_t *_WLocale_full_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize)
   1.683 +{ return _ToWChar(_Locale_full_dayofweek(__loc, _d), buf, bufSize); }
   1.684 +const wchar_t *_WLocale_abbrev_dayofweek(struct _Locale_time *__loc, int _d, wchar_t *buf, size_t bufSize)
   1.685 +{ return _ToWChar(_Locale_abbrev_dayofweek(__loc, _d), buf, bufSize); }
   1.686 +const wchar_t *_WLocale_am_str(struct _Locale_time *__loc, wchar_t *buf, size_t bufSize)
   1.687 +{ return _ToWChar(_Locale_am_str(__loc), buf, bufSize); }
   1.688 +const wchar_t *_WLocale_pm_str(struct _Locale_time* __loc, wchar_t *buf, size_t bufSize)
   1.689 +{ return _ToWChar(_Locale_pm_str(__loc), buf, bufSize); }
   1.690 +#endif
   1.691 +
   1.692 +/* Messages */
   1.693 +
   1.694 +nl_catd_type _Locale_catopen(struct _Locale_messages *__loc, const char *__cat_name )
   1.695 +{
   1.696 +  return catopen( __cat_name, NL_CAT_LOCALE );
   1.697 +}
   1.698 +
   1.699 +void _Locale_catclose(struct _Locale_messages *__loc, nl_catd_type __cat )
   1.700 +{
   1.701 +  catclose( __cat );
   1.702 +}
   1.703 +
   1.704 +const char *_Locale_catgets(struct _Locale_messages *__loc, nl_catd_type __cat,
   1.705 +                            int __setid, int __msgid, const char *dfault)
   1.706 +{
   1.707 +  return catgets( __cat, __setid, __msgid, dfault );
   1.708 +}

mercurial