2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
14 * Fundamental character types.
16 * CHAR_T An integral type that can hold any character.
17 * ARG_CHAR_T The type of a CHAR_T when passed as an argument using
18 * traditional promotion rules. It should also be able
19 * to be compared against any CHAR_T for equality without
21 * UCHAR_T The shortest unified character type (8-bit clean).
22 * RCHAR_T The character type used by the internal regex engine.
24 * If no integral type can hold a character, don't even try the port.
26 typedef int ARG_CHAR_T;
32 typedef wchar_t CHAR_T;
33 typedef wint_t UCHAR_T;
34 typedef wchar_t RCHAR_T;
39 #define STRTOUL wcstoul
40 #define SPRINTF swprintf
42 #define STRPBRK wcspbrk
43 #define ISBLANK iswblank
44 #define ISCNTRL iswcntrl
45 #define ISDIGIT iswdigit
46 #define ISXDIGIT iswxdigit
47 #define ISGRAPH iswgraph
48 #define ISLOWER iswlower
49 #define ISPRINT iswprint
50 #define ISPUNCT iswpunct
51 #define ISSPACE iswspace
52 #define ISUPPER iswupper
53 #define TOLOWER towlower
54 #define TOUPPER towupper
55 #define STRSET wmemset
57 #define STRRCHR wcsrchr
66 typedef u_char CHAR_T;
67 typedef u_char UCHAR_T;
72 #define STRTOL(a,b,c) (strtol(a,(char**)b,c))
73 #define STRTOUL(a,b,c) (strtoul(a,(char**)b,c))
74 #define SPRINTF snprintf
76 #define STRPBRK strpbrk
77 #define ISBLANK isblank
78 #define ISCNTRL iscntrl
79 #define ISDIGIT isdigit
80 #define ISXDIGIT isxdigit
81 #define ISGRAPH isgraph
82 #define ISLOWER islower
83 #define ISPRINT isprint
84 #define ISPUNCT ispunct
85 #define ISSPACE isspace
86 #define ISUPPER isupper
87 #define TOLOWER tolower
88 #define TOUPPER toupper
91 #define STRRCHR strrchr
101 #if defined(USE_WIDECHAR) && defined(DEBUG)
102 #define MEMCPY wmemcpy
103 #define MEMMOVE wmemmove
104 #define MEMCMP wmemcmp
106 #define MEMCPY(p, t, len) memcpy(p, t, (len) * sizeof(CHAR_T))
107 #define MEMMOVE(p, t, len) memmove(p, t, (len) * sizeof(CHAR_T))
108 #define MEMCMP(p, t, len) memcmp(p, t, (len) * sizeof(CHAR_T))
111 #define SIZE(w) (sizeof(w) / sizeof(*w))
114 * Locale insensitive character category detection.
120 return 'a' <= c && c <= 'z';
126 return 'A' <= c && c <= 'Z';
132 return '0' <= c && c <= '9';
138 return isatoz(c) || isAtoZ(c);
144 return is0to9(c) || isazAZ(c);