2 * Character classification and conversion
3 * Copyright (C) 2000 Lineo, Inc.
4 * Written by Erik Andersen
5 * This file is part of the uClibc C library and is distributed
6 * under the GNU Library General Public License.
8 * not C-locale only code
9 * written by Vladimir Oleynik (c) vodz@usa.net
10 * and Manuel Novoa III <mnovoa3@bellsouth.net>
11 * used ideas is part of the GNU C Library.
20 return (c > 0 && c <= 0x7f);
28 return (c >= '0' && c <= '9');
42 #if !__UCLIBC_HAS_LOCALE__
48 return (isupper(c) || islower(c));
56 return (isalpha(c) || isdigit(c));
64 return ((c >= 0) && ((c <= 0x1f) || (c == 0x7f)));
72 return (c > ' ' && isprint(c));
80 return (c >= 'a' && c <= 'z');
88 return (c >= ' ' && c <= '~');
96 return ((c > ' ' && c <= '~') && !isalnum(c));
104 return (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||
105 c == '\t' || c == '\v');
113 return (c >= 'A' && c <= 'Z');
121 return (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
129 return (isdigit(c) || (c >= 'a' && c <= 'f'));
137 return (isdigit(c) || (c >= 'A' && c <= 'F'));
145 return (isupper(c) ? (c - 'A' + 'a') : (c));
153 return (islower(c) ? (c - 'a' + 'A') : (c));
157 #else /* __UCLIBC_HAS_LOCALE__ == 1 */
162 #define _UC_ISCTYPE(c, type) \
163 ((c != -1) && ((_uc_ctype_b[(int)((unsigned char)c)] & type) != 0))
165 #define _UC_ISCTYPE2(c, type, type2) \
166 ((c != -1) && ((_uc_ctype_b[(int)((unsigned char)c)] & type) == type2))
171 /* startup setlocale(LC_TYPE, "C"); */
174 const unsigned char *_uc_ctype_b = _uc_ctype_b_C;
175 const unsigned char *_uc_ctype_trans = _uc_ctype_b_C+LOCALE_BUF_SIZE/2;
177 #endif /* L_ctype_C */
183 return _UC_ISCTYPE(c, ISalpha);
191 return _UC_ISCTYPE(c, (ISalpha|ISxdigit));
199 return _UC_ISCTYPE(c, IScntrl);
207 return _UC_ISCTYPE2(c, (ISprint|ISspace), ISprint);
215 return _UC_ISCTYPE(c, ISlower);
223 return _UC_ISCTYPE(c, ISprint);
231 return _UC_ISCTYPE(c, ISpunct);
239 return _UC_ISCTYPE(c, ISspace);
247 return _UC_ISCTYPE(c, ISupper);
255 return _UC_ISCTYPE(c, ISxdigit);
263 return _UC_ISCTYPE2(c, (ISxdigit|ISupper), ISxdigit);
271 return _UC_ISCTYPE2(c, (ISxdigit|ISlower), ISxdigit);
279 if((c < CHAR_MIN) || (c > UCHAR_MAX))
282 return _uc_ctype_trans[(int)((unsigned char)c)];
292 if((c < CHAR_MIN) || (c > UCHAR_MAX))
295 return _uc_ctype_trans[(int)((unsigned char)c)];