Remove bionic's internal ctype-like inlines.
Bug: http://b/144165498
Test: treehugger
Change-Id: Ifcf352525abc74850053a1a019f90c72e488b71c
diff --git a/libc/bionic/strtol.cpp b/libc/bionic/strtol.cpp
index f6005fa..63ac102 100644
--- a/libc/bionic/strtol.cpp
+++ b/libc/bionic/strtol.cpp
@@ -27,13 +27,12 @@
* SUCH DAMAGE.
*/
+#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h>
-#include <private/bionic_ctype.h>
-
template <typename T, T Min, T Max> T StrToI(const char* nptr, char** endptr, int base) {
// Ensure that base is between 2 and 36 inclusive, or the special value of 0.
if (base < 0 || base == 1 || base > 36) {
@@ -49,7 +48,7 @@
int c;
do {
c = *s++;
- } while (IsSpace(c));
+ } while (isspace(c));
int neg;
if (c == '-') {
neg = 1;
@@ -58,8 +57,7 @@
neg = 0;
if (c == '+') c = *s++;
}
- if ((base == 0 || base == 16) && c == '0' &&
- (*s == 'x' || *s == 'X') && IsXDigit(s[1])) {
+ if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') && isxdigit(s[1])) {
c = s[1];
s += 2;
base = 16;
@@ -74,10 +72,10 @@
int any = 0;
T acc = 0;
for (; ; c = *s++) {
- if (IsDigit(c)) {
+ if (isdigit(c)) {
c -= '0';
- } else if (IsAlpha(c)) {
- c -= IsUpper(c) ? 'A' - 10 : 'a' - 10;
+ } else if (isalpha(c)) {
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
} else {
break;
}
@@ -116,7 +114,7 @@
int c;
do {
c = *s++;
- } while (IsSpace(c));
+ } while (isspace(c));
int neg;
if (c == '-') {
neg = 1;
@@ -125,8 +123,7 @@
neg = 0;
if (c == '+') c = *s++;
}
- if ((base == 0 || base == 16) && c == '0' &&
- (*s == 'x' || *s == 'X') && IsXDigit(s[1])) {
+ if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X') && isxdigit(s[1])) {
c = s[1];
s += 2;
base = 16;
@@ -138,10 +135,10 @@
T acc = 0;
int any = 0;
for (; ; c = *s++) {
- if (IsDigit(c)) {
+ if (isdigit(c)) {
c -= '0';
- } else if (IsAlpha(c)) {
- c -= IsUpper(c) ? 'A' - 10 : 'a' - 10;
+ } else if (isalpha(c)) {
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
} else {
break;
}
diff --git a/libc/private/bionic_ctype.h b/libc/private/bionic_ctype.h
deleted file mode 100644
index 96df974..0000000
--- a/libc/private/bionic_ctype.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef __BIONIC_PRIVATE_BIONIC_CTYPE_H_
-#define __BIONIC_PRIVATE_BIONIC_CTYPE_H_
-
-static inline bool IsAlpha(int ch) {
- return (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
-}
-
-static inline bool IsDigit(int ch) {
- return (ch >= '0' && ch <= '9');
-}
-
-static inline bool IsSpace(int ch) {
- return (ch == ' ') || (ch >= '\t' && ch <= '\r');
-}
-
-static inline bool IsUpper(int ch) {
- return (ch >= 'A' && ch <= 'Z');
-}
-
-static inline bool IsXDigit(int ch) {
- return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f');
-}
-
-#endif
diff --git a/libc/stdio/vfscanf.cpp b/libc/stdio/vfscanf.cpp
index ad20ba4..424c4ef 100644
--- a/libc/stdio/vfscanf.cpp
+++ b/libc/stdio/vfscanf.cpp
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*/
+#include <ctype.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stddef.h>
@@ -41,7 +42,6 @@
#include <wctype.h>
#include "local.h"
-#include <private/bionic_ctype.h>
#include <private/bionic_fortify.h>
#include <platform/bionic/macros.h>
#include <private/bionic_mbstate.h>
@@ -111,8 +111,8 @@
for (;;) {
c = *fmt++;
if (c == 0) return nassigned;
- if (IsSpace(c)) {
- while ((fp->_r > 0 || __srefill(fp) == 0) && IsSpace(*fp->_p)) nread++, fp->_r--, fp->_p++;
+ if (isspace(c)) {
+ while ((fp->_r > 0 || __srefill(fp) == 0) && isspace(*fp->_p)) nread++, fp->_r--, fp->_p++;
continue;
}
if (c != '%') goto literal;
@@ -287,7 +287,7 @@
return EOF;
default: /* compat */
- if (IsUpper(c)) flags |= LONG;
+ if (isupper(c)) flags |= LONG;
c = CT_INT;
base = 10;
break;
@@ -310,7 +310,7 @@
* that suppress this.
*/
if ((flags & NOSKIP) == 0) {
- while (IsSpace(*fp->_p)) {
+ while (isspace(*fp->_p)) {
nread++;
if (--fp->_r > 0) {
fp->_p++;
@@ -431,7 +431,7 @@
wcp = va_arg(ap, wchar_t*);
}
size_t bytes = 0;
- while ((c == CT_CCL || !IsSpace(*fp->_p)) && width != 0) {
+ while ((c == CT_CCL || !isspace(*fp->_p)) && width != 0) {
if (bytes == MB_CUR_MAX) {
fp->_flags |= __SERR;
goto input_failure;