| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 | /* ctype.c * Character classification and conversion * Copyright (C) 2000 Lineo, Inc. * Written by Erik Andersen * This file is part of the uClibc C library and is distributed * under the GNU Library General Public License. * * not C-locale only code * written by Vladimir Oleynik (c) vodz@usa.net * and Manuel Novoa III <mnovoa3@bellsouth.net> * used ideas is part of the GNU C Library. */#include <ctype.h>#ifdef L_isasciiintisascii( int c ){    return (c > 0 && c <= 0x7f);}#endif#ifdef L_isdigitintisdigit( int c ){    return (c >= '0' && c <= '9');}#endif#ifdef L_toasciiinttoascii( int c ){    return (c & 0x7f);}#endif/* locale depended */#ifndef __UCLIBC_HAS_LOCALE__#ifdef L_isalphaintisalpha( int c ){    return (isupper(c) || islower(c));}#endif#ifdef L_isalnumintisalnum( int c ){    return (isalpha(c) || isdigit(c));}#endif#ifdef L_iscntrlintiscntrl( int c ){    return ((c >= 0) && ((c <= 0x1f) || (c == 0x7f)));}#endif#ifdef L_isgraphintisgraph( int c ){    return (c > ' ' && isprint(c));}#endif#ifdef L_islowerintislower( int c ){    return (c >=  'a' && c <= 'z');}#endif#ifdef L_isprintintisprint( int c ){    return (c >= ' ' && c <= '~');}#endif#ifdef L_ispunctintispunct( int c ){    return ((c > ' ' && c <= '~') && !isalnum(c));}#endif#ifdef L_isspaceintisspace( int c ){    return (c == ' ' || c == '\f' || c == '\n' || c == '\r' ||	    c == '\t' || c == '\v');}#endif#ifdef L_isupperintisupper( int c ){    return (c >=  'A' && c <= 'Z');}#endif#ifdef L_isxdigitintisxdigit( int c ){    return (isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));}#endif#ifdef L_isxlowerintisxlower( int c ){    return (isdigit(c) || (c >= 'a' && c <= 'f'));}#endif#ifdef L_isxupperintisxupper( int c ){    return (isdigit(c) || (c >= 'A' && c <= 'F'));}#endif#ifdef L_tolowerinttolower( int c ){    return (isupper(c) ? (c - 'A' + 'a') : (c));}#endif#ifdef L_toupperinttoupper( int c ){    return (islower(c) ? (c - 'a' + 'A') : (c));}#endif#else   /* __UCLIBC_HAS_LOCALE__ */#include <limits.h>#include "./ctype.h"#define _UC_ISCTYPE(c, type) \((c != -1) && ((_uc_ctype_b[(int)((unsigned char)c)] & type) != 0))#define _UC_ISCTYPE2(c, type, type2) \((c != -1) && ((_uc_ctype_b[(int)((unsigned char)c)] & type) == type2))#ifdef L_ctype_C/* startup setlocale(LC_TYPE, "C"); */#include "ctype_C.c"const unsigned char *_uc_ctype_b     = _uc_ctype_b_C;const unsigned char *_uc_ctype_trans = _uc_ctype_b_C+LOCALE_BUF_SIZE/2;#endif  /* L_ctype_C */#ifdef L_isalphaintisalpha( int c ){    return _UC_ISCTYPE(c, ISalpha);}#endif#ifdef L_isalnumintisalnum( int c ){    return _UC_ISCTYPE(c, (ISalpha|ISxdigit));}#endif#ifdef L_iscntrlintiscntrl( int c ){    return _UC_ISCTYPE(c, IScntrl);}#endif#ifdef L_isgraphintisgraph( int c ){    return _UC_ISCTYPE2(c, (ISprint|ISspace), ISprint);}#endif#ifdef L_islowerintislower( int c ){    return _UC_ISCTYPE(c, ISlower);}#endif#ifdef L_isprintintisprint( int c ){    return _UC_ISCTYPE(c, ISprint);}#endif#ifdef L_ispunctintispunct( int c ){    return _UC_ISCTYPE(c, ISpunct);}#endif#ifdef L_isspaceintisspace( int c ){    return _UC_ISCTYPE(c, ISspace);}#endif#ifdef L_isupperintisupper( int c ){    return _UC_ISCTYPE(c, ISupper);}#endif#ifdef L_isxdigitintisxdigit( int c ){    return _UC_ISCTYPE(c, ISxdigit);}#endif#ifdef L_isxlowerintisxlower( int c ){    return _UC_ISCTYPE2(c, (ISxdigit|ISupper), ISxdigit);}#endif#ifdef L_isxupperintisxupper( int c ){    return _UC_ISCTYPE2(c, (ISxdigit|ISlower), ISxdigit);}#endif#ifdef L_tolowerinttolower( int c ){    if((c < CHAR_MIN) || (c > UCHAR_MAX))		return c;    if(isupper(c))		return _uc_ctype_trans[(int)((unsigned char)c)];    else		return c;}#endif#ifdef L_toupperinttoupper( int c ){    if((c < CHAR_MIN) || (c > UCHAR_MAX))		return c;    if(islower(c))		return _uc_ctype_trans[(int)((unsigned char)c)];    else		return c;}#endif#endif
 |