libc/newlib/libc/include/ctype.h

95 lines
2.7 KiB
C
Raw Normal View History

2000-02-17 20:39:52 +01:00
#ifndef _CTYPE_H_
#define _CTYPE_H_
#include "_ansi.h"
_BEGIN_STD_C
2000-02-17 20:39:52 +01:00
int _EXFUN(isalnum, (int __c));
int _EXFUN(isalpha, (int __c));
int _EXFUN(iscntrl, (int __c));
int _EXFUN(isdigit, (int __c));
int _EXFUN(isgraph, (int __c));
int _EXFUN(islower, (int __c));
int _EXFUN(isprint, (int __c));
int _EXFUN(ispunct, (int __c));
int _EXFUN(isspace, (int __c));
int _EXFUN(isupper, (int __c));
int _EXFUN(isxdigit,(int __c));
int _EXFUN(tolower, (int __c));
int _EXFUN(toupper, (int __c));
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
int _EXFUN(isblank, (int __c));
#endif
#ifndef __STRICT_ANSI__
2000-02-17 20:39:52 +01:00
int _EXFUN(isascii, (int __c));
int _EXFUN(toascii, (int __c));
* libc/ctype/Makefile.am: Remove _tolower.c and _toupper.c source files. Add a dependency rule for ctype_o to note changes in ctype_iso.h and ctype_cp.h. * libc/ctype/Makefile.in: Regenerate. * libc/ctype/_tolower.c: Remove file. * libc/ctype/_toupper.c: Remove file. * libc/ctype/ctype_.c: Make sure ALLOW_NEGATIVE_CTYPE_INDEX is always defined on Cygwin. (_ctype_b): Don't make `static const' on Cygwin. (ctype_iso.h): Include if _MB_EXTENDED_CHARSETS_ISO is set. (ctype_cp.h): Include if _MB_EXTENDED_CHARSETS_WINDOWS is set. (__ctype_ptr): Drop definition. (__ctype_ptr__): De-constify. Mark as __EXPORT symbol. (_ctype_): Add Cygwin-specifc asm define. (__set_ctype): New function to set __ctype_ptr__ according to current charset. * libc/ctype/ctype_cp.h: New file containing Windows codepage specific character class tables. * libc/ctype/ctype_iso.h: New file containing ISO-8859-x specific character class tables. * libc/ctype/tolower.c (tolower): Reimplement to support any singlebyte charset if one of the extended charsets is enabled. * libc/ctype/toupper.c (toupper): Ditto. * libc/include/ctype.h (_tolower): Define as macro per POSIX. (_toupper): Ditto. (__ctype_ptr__): De-constify. (toupper): Disable macro on systems supporting extended charsets. (tolower): Ditto. * libc/include/sys/config.h (__EXPORT): Define empty if not defined. * libc/locale/locale.c (__mb_cur_max): Mark as __EXPORT symbol. (__set_ctype): Declare unconditionally. (loadlocale): Remove __CYGWIN__ guard around __set_ctype call.
2009-03-31 11:31:38 +02:00
#define _tolower(c) ((unsigned char)(c) - 'A' + 'a')
#define _toupper(c) ((unsigned char)(c) - 'a' + 'A')
2000-02-17 20:39:52 +01:00
#endif
#define _U 01
#define _L 02
#define _N 04
#define _S 010
#define _P 020
#define _C 040
#define _X 0100
#define _B 0200
#ifndef _MB_CAPABLE
_CONST
#endif
* libc/ctype/Makefile.am: Remove _tolower.c and _toupper.c source files. Add a dependency rule for ctype_o to note changes in ctype_iso.h and ctype_cp.h. * libc/ctype/Makefile.in: Regenerate. * libc/ctype/_tolower.c: Remove file. * libc/ctype/_toupper.c: Remove file. * libc/ctype/ctype_.c: Make sure ALLOW_NEGATIVE_CTYPE_INDEX is always defined on Cygwin. (_ctype_b): Don't make `static const' on Cygwin. (ctype_iso.h): Include if _MB_EXTENDED_CHARSETS_ISO is set. (ctype_cp.h): Include if _MB_EXTENDED_CHARSETS_WINDOWS is set. (__ctype_ptr): Drop definition. (__ctype_ptr__): De-constify. Mark as __EXPORT symbol. (_ctype_): Add Cygwin-specifc asm define. (__set_ctype): New function to set __ctype_ptr__ according to current charset. * libc/ctype/ctype_cp.h: New file containing Windows codepage specific character class tables. * libc/ctype/ctype_iso.h: New file containing ISO-8859-x specific character class tables. * libc/ctype/tolower.c (tolower): Reimplement to support any singlebyte charset if one of the extended charsets is enabled. * libc/ctype/toupper.c (toupper): Ditto. * libc/include/ctype.h (_tolower): Define as macro per POSIX. (_toupper): Ditto. (__ctype_ptr__): De-constify. (toupper): Disable macro on systems supporting extended charsets. (tolower): Ditto. * libc/include/sys/config.h (__EXPORT): Define empty if not defined. * libc/locale/locale.c (__mb_cur_max): Mark as __EXPORT symbol. (__set_ctype): Declare unconditionally. (loadlocale): Remove __CYGWIN__ guard around __set_ctype call.
2009-03-31 11:31:38 +02:00
extern __IMPORT char *__ctype_ptr__;
2000-02-17 20:39:52 +01:00
#ifndef __cplusplus
/* These macros are intentionally written in a manner that will trigger
a gcc -Wall warning if the user mistakenly passes a 'char' instead
of an int containing an 'unsigned char'. */
#define isalpha(c) ((__ctype_ptr__+1)[c]&(_U|_L))
#define isupper(c) (((__ctype_ptr__+1)[c]&(_U|_L))==_U)
#define islower(c) (((__ctype_ptr__+1)[c]&(_U|_L))==_L)
#define isdigit(c) ((__ctype_ptr__+1)[c]&_N)
#define isxdigit(c) ((__ctype_ptr__+1)[c]&(_X|_N))
#define isspace(c) ((__ctype_ptr__+1)[c]&_S)
#define ispunct(c) ((__ctype_ptr__+1)[c]&_P)
#define isalnum(c) ((__ctype_ptr__+1)[c]&(_U|_L|_N))
#define isprint(c) ((__ctype_ptr__+1)[c]&(_P|_U|_L|_N|_B))
#define isgraph(c) ((__ctype_ptr__+1)[c]&(_P|_U|_L|_N))
#define iscntrl(c) ((__ctype_ptr__+1)[c]&_C)
#if defined(__GNUC__) && \
(!defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901L)
#define isblank(c) \
__extension__ ({ __typeof__ (c) __c = (c); \
((__ctype_ptr__+1)[__c]&_B) || (__c) == '\t';})
#endif
2000-02-17 20:39:52 +01:00
/* Non-gcc versions will get the library versions, and will be
* libc/ctype/Makefile.am: Remove _tolower.c and _toupper.c source files. Add a dependency rule for ctype_o to note changes in ctype_iso.h and ctype_cp.h. * libc/ctype/Makefile.in: Regenerate. * libc/ctype/_tolower.c: Remove file. * libc/ctype/_toupper.c: Remove file. * libc/ctype/ctype_.c: Make sure ALLOW_NEGATIVE_CTYPE_INDEX is always defined on Cygwin. (_ctype_b): Don't make `static const' on Cygwin. (ctype_iso.h): Include if _MB_EXTENDED_CHARSETS_ISO is set. (ctype_cp.h): Include if _MB_EXTENDED_CHARSETS_WINDOWS is set. (__ctype_ptr): Drop definition. (__ctype_ptr__): De-constify. Mark as __EXPORT symbol. (_ctype_): Add Cygwin-specifc asm define. (__set_ctype): New function to set __ctype_ptr__ according to current charset. * libc/ctype/ctype_cp.h: New file containing Windows codepage specific character class tables. * libc/ctype/ctype_iso.h: New file containing ISO-8859-x specific character class tables. * libc/ctype/tolower.c (tolower): Reimplement to support any singlebyte charset if one of the extended charsets is enabled. * libc/ctype/toupper.c (toupper): Ditto. * libc/include/ctype.h (_tolower): Define as macro per POSIX. (_toupper): Ditto. (__ctype_ptr__): De-constify. (toupper): Disable macro on systems supporting extended charsets. (tolower): Ditto. * libc/include/sys/config.h (__EXPORT): Define empty if not defined. * libc/locale/locale.c (__mb_cur_max): Mark as __EXPORT symbol. (__set_ctype): Declare unconditionally. (loadlocale): Remove __CYGWIN__ guard around __set_ctype call.
2009-03-31 11:31:38 +02:00
slightly slower. These macros are not NLS-aware so they are
disabled if the system supports the extended character sets. */
# if defined(__GNUC__) && !defined (_MB_EXTENDED_CHARSETS_ISO) && !defined (_MB_EXTENDED_CHARSETS_WINDOWS)
2000-02-17 20:39:52 +01:00
# define toupper(c) \
__extension__ ({ __typeof__ (c) __x = (c); \
islower(__x) ? (__x - 'a' + 'A') : __x;})
2000-02-17 20:39:52 +01:00
# define tolower(c) \
__extension__ ({ __typeof__ (c) __x = (c); \
isupper(__x) ? (__x - 'A' + 'a') : __x;})
2000-02-17 20:39:52 +01:00
#endif
#endif /* !__cplusplus */
2000-02-17 20:39:52 +01:00
#ifndef __STRICT_ANSI__
#define isascii(c) ((unsigned)(c)<=0177)
#define toascii(c) ((c)&0177)
#endif
/* For C++ backward-compatibility only. */
extern __IMPORT _CONST char _ctype_[];
_END_STD_C
2000-02-17 20:39:52 +01:00
#endif /* _CTYPE_H_ */