Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: TBD

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/locale/wctype.c
          +++ new/usr/src/lib/libc/port/locale/wctype.c
   1    1  /*
        2 + * Copyright 2013 Garrett D'Amore <garrett@damore.org>
   2    3   * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
   3    4   * Copyright (c) 2002 Tim J. Robbins.
   4    5   * All rights reserved.
   5    6   *
   6    7   * Redistribution and use in source and binary forms, with or without
   7    8   * modification, are permitted provided that the following conditions
   8    9   * are met:
   9   10   * 1. Redistributions of source code must retain the above copyright
  10   11   *    notice, this list of conditions and the following disclaimer.
  11   12   * 2. Redistributions in binary form must reproduce the above copyright
↓ open down ↓ 10 lines elided ↑ open up ↑
  22   23   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23   24   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24   25   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25   26   * SUCH DAMAGE.
  26   27   */
  27   28  
  28   29  #include "lint.h"
  29   30  #include <ctype.h>
  30   31  #include <string.h>
  31   32  #include <wctype.h>
       33 +#include <note.h>
       34 +#include <locale.h>
  32   35  #include "_ctype.h"
  33   36  
       37 +/*
       38 + * For now, we don't support locale specific character classes.  This is
       39 + * a capability that needs to be added (locales should be able to define
       40 + * their own character classes.)
       41 + */
  34   42  wctype_t
  35      -wctype(const char *property)
       43 +wctype_l(const char *property, locale_t loc)
  36   44  {
  37   45          static const struct {
  38   46                  const char      *name;
  39   47                  wctype_t         mask;
  40   48          } props[] = {
  41   49                  { "alnum",      _CTYPE_A|_CTYPE_D },
  42   50                  { "alpha",      _CTYPE_A },
  43   51                  { "blank",      _CTYPE_B },
  44   52                  { "cntrl",      _CTYPE_C },
  45   53                  { "digit",      _CTYPE_D },
↓ open down ↓ 4 lines elided ↑ open up ↑
  50   58                  { "space",      _CTYPE_S },
  51   59                  { "upper",      _CTYPE_U },
  52   60                  { "xdigit",     _CTYPE_X },
  53   61                  { "ideogram",   _CTYPE_I },     /* BSD extension */
  54   62                  { "special",    _CTYPE_T },     /* BSD extension */
  55   63                  { "phonogram",  _CTYPE_Q },     /* BSD extension */
  56   64                  { "rune",       -1 },           /* BSD extension */
  57   65                  { NULL,         0 },            /* Default */
  58   66          };
  59   67          int i;
       68 +        _NOTE(ARGUNUSED(loc));
  60   69  
  61   70          i = 0;
  62   71          while (props[i].name != NULL && strcmp(props[i].name, property) != 0)
  63   72                  i++;
  64   73  
  65   74          return (props[i].mask);
       75 +}
       76 +
       77 +wctype_t
       78 +wctype(const char *property)
       79 +{
       80 +        return (wctype_l(property, uselocale(NULL)));
  66   81  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX