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

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

Change-Id: Ia5f94cc1b42a178e4cedcffce130726652bc3b45
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2023-10-10 00:15:05 +00:00 committed by Automerger Merge Worker
commit aba9b2107d

View file

@ -73,15 +73,6 @@ __BEGIN_DECLS
/** Internal implementation detail. Do not use. */
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]`. */
__BIONIC_CTYPE_INLINE int isalpha(int __ch) {
return (__ch >= 'A' && __ch <= 'Z') || (__ch >= 'a' && __ch <= 'z');
@ -117,15 +108,6 @@ __BIONIC_CTYPE_INLINE int isprint(int __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]`. */
__BIONIC_CTYPE_INLINE int isspace(int __ch) {
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');
}
/** 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.
*