📄 ctype.h
字号:
/* ctype.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.3 */
/* Copyright (C) Codemist Ltd. 1988-1993. */
/* Copyright 1991-1993 ARM Limited. All rights reserved. */
/* version 0.03 */
/*
* RCS $Revision: 1.18 $
* Checkin $Date: 2004/07/09 16:25:45 $
* Revising $Author: wdijkstr $
*/
/*
* ctype.h declares several functions useful for testing and mapping
* characters. In all cases the argument is an int, the value of which shall
* be representable as an unsigned char or shall equal the value of the
* macro EOF. If the argument has any other value, the behaviour is undefined.
*/
#ifndef __ctype_h
#define __ctype_h
#define _ARMABI __declspec(__nothrow)
#define _ARMABI_PURE __declspec(__nothrow) __pure
#ifndef __CTYPE_DECLS
#define __CTYPE_DECLS
#undef __CLIBNS
#ifdef __cplusplus
namespace std {
#define __CLIBNS std::
extern "C" {
#else
#define __CLIBNS
#endif /* __cplusplus */
/* N.B. - keep in step with <ctype.c> */
/*
* __A (alphabetic) is required because characters in some locales
* (e.g. Japanese) can be alphabetic but neither uppercase nor
* lowercase. Unfortunately there wasn't a bit free for this, so
* instead we've defined __A as __N+__X (on the grounds that this
* was a previously unused combination). Hence some of the ctype
* predicates below are slightly less than obvious in
* implementation.
*/
#define __S 1 /* whitespace */
#define __P 2 /* punctuation */
#define __B 4 /* blank */
#define __L 8 /* lower case letter */
#define __U 16 /* upper case letter */
#define __N 32 /* (decimal) digit */
#define __C 64 /* control chars */
#define __X 128 /* A-F and a-f */
#define __A (__N+__X) /* alphabetic */
extern _ARMABI_PURE unsigned char **__rt_ctype_table(void);
#define __ctype (*__CLIBNS __rt_ctype_table())
#ifdef __cplusplus
inline int isalnum(int __c) { return (__ctype[__c] & (__U+__L+__N)); }
#else
#define isalnum(c) (__ctype[c] & (__U+__L+__N))
extern int (isalnum)(int /*c*/);
#endif
/* non-0 iff c is alphabetic or numeric */
#ifdef __cplusplus
inline int isalpha(int __c) { return (__ctype[__c] & (__U+__L+__X)); }
#else
#define isalpha(c) (__ctype[c] & (__U+__L+__X))
extern int (isalpha)(int /*c*/);
#endif
/* non-0 iff c is alphabetic */
#ifdef __cplusplus
inline int iscntrl(int __c) { return (__ctype[__c] & __C); }
#else
#define iscntrl(c) (__ctype[c] & __C)
extern int (iscntrl)(int /*c*/);
#endif
/* non-0 iff c is a control character - in the ASCII locale */
/* this means (c < ' ') || (c > '~') */
/* isdigit must test for the presence of _only_ __N, not just __N at all. */
#ifdef __cplusplus
inline int isdigit(int __c) { return (__ctype[__c] == __N); }
#else
#define isdigit(c) (__ctype[c] == __N)
extern int (isdigit)(int /*c*/);
#endif
/* non-0 iff c is a decimal digit */
#ifdef __cplusplus
inline int isgraph(int __c) {return(__ctype[__c] & (__L+__U+__N+__X+__P));}
#else
#define isgraph(c) (__ctype[c]&(__L+__U+__N+__X+__P))
extern int (isgraph)(int /*c*/);
#endif
/* non-0 iff c is any printing character other than ' ' */
#ifdef __cplusplus
inline int islower(int __c) { return (__ctype[__c] & __L); }
#else
#define islower(c) (__ctype[c] & __L)
extern int (islower)(int /*c*/);
#endif
/* non-0 iff c is a lower-case letter */
#ifdef __cplusplus
inline int isprint(int __c) { return (__ctype[__c] & (__L+__U+__N+__P+__B)); }
#else
#define isprint(c) (__ctype[c] & (__L+__U+__N+__P+__B))
extern int (isprint)(int /*c*/);
#endif
/* non-0 iff c is a printing character - in the ASCII locale */
/* this means 0x20 (space) -> 0x7E (tilde) */
#ifdef __cplusplus
inline int ispunct(int __c) { return (__ctype[__c] & __P); }
#else
#define ispunct(c) (__ctype[c] & __P)
extern int (ispunct)(int /*c*/);
#endif
/* non-0 iff c is a non-space, non-alpha-numeric, printing character */
#ifdef __cplusplus
inline int isspace(int __c) { return (__ctype[__c] & __S); }
#else
#define isspace(c) (__ctype[c] & __S)
extern int (isspace)(int /*c*/);
#endif
/* non-0 iff c is a white-space char: ' ', '\f', '\n', '\r', '\t', '\v'. */
#ifdef __cplusplus
inline int isupper(int __c) { return (__ctype[__c] & __U); }
#else
#define isupper(c) (__ctype[c] & __U)
extern int (isupper)(int /*c*/);
#endif
/* non-0 iff c is an upper-case letter */
/* isxdigit must test for the presence of __N or __X but not both. */
/* This helper function avoids needing to evaluate c twice. */
__inline int __isxdigit_helper(int __t) { return (__t ^ (__t << 2)); }
#ifdef __cplusplus
inline int isxdigit(int __c){return __isxdigit_helper(__ctype[__c]) & __X;}
#else
#define isxdigit(c) (__isxdigit_helper(__ctype[c]) & __X)
extern int (isxdigit)(int /*c*/);
#endif
/* non-0 iff c is a digit, in 'a'..'f', or in 'A'..'F' */
extern int tolower(int /*c*/);
/* if c is an upper-case letter then return the corresponding */
/* lower-case letter, otherwise return c. */
extern int toupper(int /*c*/);
/* if c is an lower-case letter then return the corresponding */
/* upper-case letter, otherwise return c. */
#ifdef __cplusplus
} /* extern "C" */
} /* namespace std */
#endif /* __cplusplus */
#endif /* __CTYPE_DECLS */
#ifdef __cplusplus
#ifndef __CTYPE_NO_EXPORTS
using std::isalnum;
using std::isalpha;
using std::iscntrl;
using std::isdigit;
using std::isgraph;
using std::islower;
using std::isprint;
using std::ispunct;
using std::isspace;
using std::isupper;
using std::isxdigit;
using std::tolower;
using std::toupper;
#endif /* __CTYPE_NO_EXPORTS */
#endif /* __cplusplus */
#endif
/* end of ctype.h */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -