Merge "<ctype.h>: stop using _ctype_." into main am: e253761e14

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2779335

Change-Id: I99943226277d1f4e4d17d1ad6dd0927c9f237337
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-10-09 23:40:50 +00:00 committed by Automerger Merge Worker
commit 01de1a47fa

View file

@ -73,15 +73,6 @@ __BEGIN_DECLS
/** Internal implementation detail. Do not use. */ /** Internal implementation detail. Do not use. */
extern const char* _ctype_; extern const char* _ctype_;
/** Returns true if `ch` is in `[A-Za-z0-9]`. */
__BIONIC_CTYPE_INLINE int isalnum(int __ch) {
// `isalnum(c)` is `isalpha(c) || isdigit(c)`, but there's no obvious way
// to simplify that, and the table lookup is just slightly faster...
// Note that this is unsafe for inputs less than -1 (EOF) or greater than
// 0xff. This is true of other C libraries too.
return (_ctype_[__ch + 1] & (_CTYPE_U|_CTYPE_L|_CTYPE_N));
}
/** Returns true if `ch` is in `[A-Za-z]`. */ /** Returns true if `ch` is in `[A-Za-z]`. */
__BIONIC_CTYPE_INLINE int isalpha(int __ch) { __BIONIC_CTYPE_INLINE int isalpha(int __ch) {
return (__ch >= 'A' && __ch <= 'Z') || (__ch >= 'a' && __ch <= 'z'); return (__ch >= 'A' && __ch <= 'Z') || (__ch >= 'a' && __ch <= 'z');
@ -117,15 +108,6 @@ __BIONIC_CTYPE_INLINE int isprint(int __ch) {
return (__ch >= ' ' && __ch <= '~'); return (__ch >= ' ' && __ch <= '~');
} }
/** Returns true if `ch` is punctuation. */
__BIONIC_CTYPE_INLINE int ispunct(int __ch) {
// `ispunct(c)` is `isgraph(c) && !isalnum(c)`, but there's no obvious way
// to simplify that, and the table lookup is just slightly faster...
// Note that this is unsafe for inputs less than -1 (EOF) or greater than
// 0xff. This is true of other C libraries too.
return (_ctype_[__ch + 1] & _CTYPE_P);
}
/** Returns true if `ch` is in `[ \f\n\r\t\v]`. */ /** Returns true if `ch` is in `[ \f\n\r\t\v]`. */
__BIONIC_CTYPE_INLINE int isspace(int __ch) { __BIONIC_CTYPE_INLINE int isspace(int __ch) {
return __ch == ' ' || (__ch >= '\t' && __ch <= '\r'); return __ch == ' ' || (__ch >= '\t' && __ch <= '\r');
@ -141,6 +123,16 @@ __BIONIC_CTYPE_INLINE int isxdigit(int __ch) {
return (__ch >= '0' && __ch <= '9') || (__ch >= 'a' && __ch <= 'f') || (__ch >= 'A' && __ch <= 'F'); return (__ch >= '0' && __ch <= '9') || (__ch >= 'a' && __ch <= 'f') || (__ch >= 'A' && __ch <= 'F');
} }
/** Returns true if `ch` is in `[A-Za-z0-9]`. */
__BIONIC_CTYPE_INLINE int isalnum(int __ch) {
return isalpha(__ch) || isdigit(__ch);
}
/** Returns true if `ch` is punctuation. */
__BIONIC_CTYPE_INLINE int ispunct(int __ch) {
return isgraph(__ch) && !isalnum(__ch);
}
/** /**
* Returns the corresponding lower-case character if `ch` is upper-case, or undefined otherwise. * Returns the corresponding lower-case character if `ch` is upper-case, or undefined otherwise.
* *