Print this page
2964 need POSIX 2008 locale object support

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/locale/none.c
          +++ new/usr/src/lib/libc/port/locale/none.c
   1    1  /*
   2    2   * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
   3    3   * Copyright (c) 2002-2004 Tim J. Robbins. All rights reserved.
   4    4   * Copyright (c) 1993
   5    5   *      The Regents of the University of California.  All rights reserved.
   6    6   *
   7    7   * This code is derived from software contributed to Berkeley by
   8    8   * Paul Borman at Krystal Technologies.
   9    9   *
       10 + * Copyright (c) 2011 The FreeBSD Foundation
       11 + * All rights reserved.
       12 + * Portions of this software were developed by David Chisnall
       13 + * under sponsorship from the FreeBSD Foundation.
       14 + *
  10   15   * Redistribution and use in source and binary forms, with or without
  11   16   * modification, are permitted provided that the following conditions
  12   17   * are met:
  13   18   * 1. Redistributions of source code must retain the above copyright
  14   19   *    notice, this list of conditions and the following disclaimer.
  15   20   * 2. Redistributions in binary form must reproduce the above copyright
  16   21   *    notice, this list of conditions and the following disclaimer in the
  17   22   *    documentation and/or other materials provided with the distribution.
  18   23   * 4. Neither the name of the University nor the names of its contributors
  19   24   *    may be used to endorse or promote products derived from this software
↓ open down ↓ 33 lines elided ↑ open up ↑
  53   58      mbstate_t *_RESTRICT_KYWD);
  54   59  static size_t   _none_wcrtomb(char *_RESTRICT_KYWD, wchar_t,
  55   60      mbstate_t *_RESTRICT_KYWD);
  56   61  static size_t   _none_wcsnrtombs(char *_RESTRICT_KYWD,
  57   62      const wchar_t **_RESTRICT_KYWD,
  58   63      size_t, size_t, mbstate_t *_RESTRICT_KYWD);
  59   64  
  60   65  /* setup defaults */
  61   66  
  62   67  int
  63      -_none_init(_RuneLocale *rl)
       68 +_none_init(struct xlocale_ctype *l, _RuneLocale *rl)
  64   69  {
  65      -        charset_is_ascii = 1;
       70 +        charset_is_ascii = 1;   /* XXX */
  66   71  
  67      -        __mbrtowc = _none_mbrtowc;
  68      -        __mbsinit = _none_mbsinit;
  69      -        __mbsnrtowcs = _none_mbsnrtowcs;
  70      -        __wcrtomb = _none_wcrtomb;
  71      -        __wcsnrtombs = _none_wcsnrtombs;
  72      -        _CurrentRuneLocale = rl;
       72 +        l->__mbrtowc = _none_mbrtowc;
       73 +        l->__mbsinit = _none_mbsinit;
       74 +        l->__mbsnrtowcs = _none_mbsnrtowcs;
       75 +        l->__wcrtomb = _none_wcrtomb;
       76 +        l->__wcsnrtombs = _none_wcsnrtombs;
       77 +        l->runes = rl;
       78 +        /* XXX */
  73   79          return (0);
  74   80  }
  75   81  
  76   82  static int
  77   83  _none_mbsinit(const mbstate_t *unused)
  78   84  {
  79   85          _NOTE(ARGUNUSED(unused));
  80   86  
  81   87          /*
  82   88           * Encoding is not state dependent - we are always in the
↓ open down ↓ 107 lines elided ↑ open up ↑
 190  196  int (*__mbsinit)(const mbstate_t *) = _none_mbsinit;
 191  197  
 192  198  size_t (*__mbsnrtowcs)(wchar_t *_RESTRICT_KYWD, const char **_RESTRICT_KYWD,
 193  199      size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_mbsnrtowcs;
 194  200  
 195  201  size_t (*__wcrtomb)(char *_RESTRICT_KYWD, wchar_t, mbstate_t *_RESTRICT_KYWD) =
 196  202      _none_wcrtomb;
 197  203  
 198  204  size_t (*__wcsnrtombs)(char *_RESTRICT_KYWD, const wchar_t **_RESTRICT_KYWD,
 199  205      size_t, size_t, mbstate_t *_RESTRICT_KYWD) = _none_wcsnrtombs;
      206 +
      207 +struct xlocale_ctype __xlocale_global_ctype = {
      208 +        {{0}, "C"},
      209 +        (_RuneLocale*)&_DefaultRuneLocale,
      210 +        _none_mbrtowc,
      211 +        _none_mbsinit,
      212 +        _none_mbsnrtowcs,
      213 +        _none_wcrtomb,
      214 +        _none_wcsnrtombs,
      215 +        1,      /* __mb_cur_max */
      216 +        256     /* __mb_sb_limit */
      217 +};
      218 +
      219 +const struct xlocale_ctype __xlocale_C_ctype = {
      220 +        {{0}, "C"},
      221 +        (_RuneLocale*)&_DefaultRuneLocale,
      222 +        _none_mbrtowc,
      223 +        _none_mbsinit,
      224 +        _none_mbsnrtowcs,
      225 +        _none_wcrtomb,
      226 +        _none_wcsnrtombs,
      227 +        1,      /* __mb_cur_max */
      228 +        256     /* __mb_sb_limit */
      229 +};
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX