The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/include/ctype.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /* The <ctype.h> header file defines some macros used to identify characters.
    2  * It works by using a table stored in chartab.c. When a character is presented
    3  * to one of these macros, the character is used as an index into the table
    4  * (__ctype) to retrieve a byte.  The relevant bit is then extracted.
    5  */
    6 
    7 #ifndef _CTYPE_H
    8 #define _CTYPE_H
    9 
   10 #ifndef _ANSI_H
   11 #include <ansi.h>
   12 #endif
   13 
   14 extern char     __ctype[];      /* property array defined in chartab.c */
   15 
   16 #define _U              0x01    /* this bit is for upper-case letters [A-Z] */
   17 #define _L              0x02    /* this bit is for lower-case letters [a-z] */
   18 #define _N              0x04    /* this bit is for numbers [0-9] */
   19 #define _S              0x08    /* this bit is for white space \t \n \f etc */
   20 #define _P              0x10    /* this bit is for punctuation characters */
   21 #define _C              0x20    /* this bit is for control characters */
   22 #define _X              0x40    /* this bit is for hex digits [a-f] and [A-F]*/
   23 
   24 /* Function Prototypes (have to go before the macros). */
   25 _PROTOTYPE( int isalnum, (int  _c)  );  /* alphanumeric [a-z], [A-Z], [0-9] */
   26 _PROTOTYPE( int isalpha, (int  _c)  );  /* alphabetic */
   27 _PROTOTYPE( int iscntrl, (int  _c)  );  /* control characters */
   28 _PROTOTYPE( int isdigit, (int  _c)  );  /* digit [0-9] */
   29 _PROTOTYPE( int isgraph, (int  _c)  );  /* graphic character */
   30 _PROTOTYPE( int islower, (int  _c)  );  /* lower-case letter [a-z] */
   31 _PROTOTYPE( int isprint, (int  _c)  );  /* printable character */
   32 _PROTOTYPE( int ispunct, (int  _c)  );  /* punctuation mark */
   33 _PROTOTYPE( int isspace, (int  _c)  );  /* white space sp, \f, \n, \r, \t, \v*/
   34 _PROTOTYPE( int isupper, (int  _c)  );  /* upper-case letter [A-Z] */
   35 _PROTOTYPE( int isxdigit,(int  _c)  );  /* hex digit [0-9], [a-f], [A-F] */
   36 _PROTOTYPE( int tolower, (int  _c)  );  /* convert to lower-case */
   37 _PROTOTYPE( int toupper, (int  _c)  );  /* convert to upper-case */
   38 
   39 /* Macros for identifying character classes. */
   40 #define isalnum(c)      ((__ctype+1)[c]&(_U|_L|_N))
   41 #define isalpha(c)      ((__ctype+1)[c]&(_U|_L))
   42 #define iscntrl(c)      ((__ctype+1)[c]&_C)
   43 #define isgraph(c)      ((__ctype+1)[c]&(_P|_U|_L|_N))
   44 #define ispunct(c)      ((__ctype+1)[c]&_P)
   45 #define isspace(c)      ((__ctype+1)[c]&_S)
   46 #define isxdigit(c)     ((__ctype+1)[c]&(_N|_X))
   47 
   48 #define isdigit(c)      ((unsigned) ((c)-'') < 10)
   49 #define islower(c)      ((unsigned) ((c)-'a') < 26)
   50 #define isupper(c)      ((unsigned) ((c)-'A') < 26)
   51 #define isprint(c)      ((unsigned) ((c)-' ') < 95)
   52 #define isascii(c)      ((unsigned) (c) < 128)
   53 
   54 #endif /* _CTYPE_H */

Cache object: e8e427535fc97ac6d58fe63a6f965223


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.