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
   1 /*
   2  * CDDL HEADER START



   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */

  22 /*
  23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #pragma ident   "%Z%%M% %I%     %E% SMI"



  28 
  29 #include <ctype.h>




  30 
  31 unsigned char __ctype[129] =

  32 {
  33         0, /* EOF */
  34         _C,     _C,     _C,     _C,     _C,     _C,     _C,     _C,
  35         _C,     _S|_C,  _S|_C,  _S|_C,  _S|_C,  _S|_C,  _C,     _C,
  36         _C,     _C,     _C,     _C,     _C,     _C,     _C,     _C,
  37         _C,     _C,     _C,     _C,     _C,     _C,     _C,     _C,
  38         _S|_B,  _P,     _P,     _P,     _P,     _P,     _P,     _P,
  39         _P,     _P,     _P,     _P,     _P,     _P,     _P,     _P,
  40         _N|_X,  _N|_X,  _N|_X,  _N|_X,  _N|_X,  _N|_X,  _N|_X,  _N|_X,
  41         _N|_X,  _N|_X,  _P,     _P,     _P,     _P,     _P,     _P,
  42         _P,     _U|_X,  _U|_X,  _U|_X,  _U|_X,  _U|_X,  _U|_X,  _U,
  43         _U,     _U,     _U,     _U,     _U,     _U,     _U,     _U,
  44         _U,     _U,     _U,     _U,     _U,     _U,     _U,     _U,
  45         _U,     _U,     _U,     _P,     _P,     _P,     _P,     _P,
  46         _P,     _L|_X,  _L|_X,  _L|_X,  _L|_X,  _L|_X,  _L|_X,  _L,
  47         _L,     _L,     _L,     _L,     _L,     _L,     _L,     _L,
  48         _L,     _L,     _L,     _L,     _L,     _L,     _L,     _L,
  49         _L,     _L,     _L,     _P,     _P,     _P,     _P,     _C,
  50 };


















































   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.














  10  */
  11 
  12 /*
  13  * Copyright 2014 Garrett D'Amore <garrett@damore.org>

  14  */
  15 
  16 /*
  17  * ASCII versions of ctype character classification functions.  This avoids
  18  * pulling in the entire locale framework that is in libc.
  19  */
  20 
  21 int
  22 isdigit(int c)
  23 {
  24         return ((c >= '0' && c <= '9') ? 1 : 0);
  25 }
  26 
  27 int
  28 isupper(int c)
  29 {
  30         return ((c >= 'A' && c <= 'Z') ? 1 : 0);
  31 }
  32 
  33 
  34 int
  35 islower(int c)
  36 {
  37         return ((c >= 'a' && c <= 'z') ? 1 : 0);
  38 }
  39 
  40 int
  41 isspace(int c)
  42 {
  43         return (((c == ' ') || (c == '\t') || (c == '\r') || (c == '\n') ||
  44             (c == '\v') || (c == '\f')) ? 1 : 0);
  45 }
  46 
  47 int
  48 isxdigit(int c)
  49 {
  50         return ((isdigit(c) || (c >= 'A' && c <= 'F') ||
  51             (c >= 'a' && c <= 'f')) ? 1 : 0);
  52 }
  53 
  54 int
  55 isalpha(int c)
  56 {
  57         return ((isupper(c) || islower(c)) ? 1 : 0);
  58 }
  59 
  60 
  61 int
  62 isalnum(int c)
  63 {
  64         return ((isalpha(c) || isdigit(c)) ? 1 : 0);
  65 }
  66 
  67 int
  68 ispunct(int c)
  69 {
  70         return (((c >= '!') && (c <= '/')) ||
  71             ((c >= ':') && (c <= '@')) ||
  72             ((c >= '[') && (c <= '`')) ||
  73             ((c >= '{') && (c <= '~')));
  74 }
  75 
  76 int
  77 iscntrl(int c)
  78 {
  79         return ((c < 0x20) || (c == 0x7f));
  80 }
  81 
  82 int
  83 isprint(int c)
  84 {
  85         /*
  86          * Almost the inverse of iscntrl, but be careful that c > 0x7f
  87          * returns false for everything.
  88          */
  89         return ((c >= ' ') && (c <= '~'));
  90 }
  91 
  92 int
  93 isgraph(int c)
  94 {
  95         /* isgraph is like is print, but excludes <space> */
  96         return ((c >= '!') && (c <= '~'));
  97 }