libc.src.ctype.isdigit
libc.src.ctype.isgraph
libc.src.ctype.islower
+ libc.src.ctype.isprint
libc.src.ctype.ispunct
+ libc.src.ctype.isspace
libc.src.ctype.isupper
+ libc.src.ctype.isxdigit
# errno.h entrypoints
libc.src.errno.__errno_location
libc.src.ctype.isdigit
libc.src.ctype.isgraph
libc.src.ctype.islower
+ libc.src.ctype.isprint
libc.src.ctype.ispunct
+ libc.src.ctype.isspace
libc.src.ctype.isupper
+ libc.src.ctype.isxdigit
# errno.h entrypoints
libc.src.errno.__errno_location
[ArgSpec<IntType>]
>,
FunctionSpec<
+ "isprint",
+ RetValSpec<IntType>,
+ [ArgSpec<IntType>]
+ >,
+ FunctionSpec<
"ispunct",
RetValSpec<IntType>,
[ArgSpec<IntType>]
>,
FunctionSpec<
+ "isspace",
+ RetValSpec<IntType>,
+ [ArgSpec<IntType>]
+ >,
+ FunctionSpec<
"isupper",
RetValSpec<IntType>,
[ArgSpec<IntType>]
>,
+ FunctionSpec<
+ "isxdigit",
+ RetValSpec<IntType>,
+ [ArgSpec<IntType>]
+ >,
]
>;
)
add_entrypoint_object(
+ isprint
+ SRCS
+ isprint.cpp
+ HDRS
+ isprint.h
+)
+
+add_entrypoint_object(
ispunct
SRCS
ispunct.cpp
)
add_entrypoint_object(
+ isspace
+ SRCS
+ isspace.cpp
+ HDRS
+ isspace.h
+)
+
+add_entrypoint_object(
isupper
SRCS
isupper.cpp
HDRS
isupper.h
)
+
+add_entrypoint_object(
+ isxdigit
+ SRCS
+ isxdigit.cpp
+ HDRS
+ isxdigit.h
+ DEPENDS
+ .ctype_utils
+)
--- /dev/null
+//===-- Implementation of isprint------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/ctype/isprint.h"
+
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+// TODO: Currently restricted to default locale.
+// These should be extended using locale information.
+int LLVM_LIBC_ENTRYPOINT(isprint)(int c) {
+ const unsigned ch = c;
+ return (ch - ' ') < 95;
+}
+
+} // namespace __llvm_libc
--- /dev/null
+//===-- Implementation header for isprint -------------------------*-C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_CTYPE_ISPRINT_H
+#define LLVM_LIBC_SRC_CTYPE_ISPRINT_H
+
+namespace __llvm_libc {
+
+int isprint(int c);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_CTYPE_ISPRINT_H
--- /dev/null
+//===-- Implementation of isspace------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/ctype/isspace.h"
+
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+// TODO: Currently restricted to default locale.
+// These should be extended using locale information.
+int LLVM_LIBC_ENTRYPOINT(isspace)(int c) {
+ const unsigned ch = c;
+ return ch == ' ' || (ch - '\t') < 5;
+}
+
+} // namespace __llvm_libc
--- /dev/null
+//===-- Implementation header for isspace -------------------------*-C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_CTYPE_ISSPACE_H
+#define LLVM_LIBC_SRC_CTYPE_ISSPACE_H
+
+namespace __llvm_libc {
+
+int isspace(int c);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_CTYPE_ISSPACE_H
--- /dev/null
+//===-- Implementation of isxdigit-----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/ctype/isxdigit.h"
+#include "src/ctype/ctype_utils.h"
+
+#include "src/__support/common.h"
+
+namespace __llvm_libc {
+
+// TODO: Currently restricted to default locale.
+// These should be extended using locale information.
+int LLVM_LIBC_ENTRYPOINT(isxdigit)(int c) {
+ const unsigned ch = c;
+ return internal::isdigit(ch) || (ch | 32) - 'a' < 6;
+}
+
+} // namespace __llvm_libc
--- /dev/null
+//===-- Implementation header for isxdigit ------------------------*-C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_CTYPE_ISXDIGIT_H
+#define LLVM_LIBC_SRC_CTYPE_ISXDIGIT_H
+
+namespace __llvm_libc {
+
+int isxdigit(int c);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_CTYPE_ISXDIGIT_H
)
add_libc_unittest(
+ isprint
+ SUITE
+ libc_ctype_unittests
+ SRCS
+ isprint_test.cpp
+ DEPENDS
+ libc.src.ctype.isprint
+)
+
+add_libc_unittest(
ispunct
SUITE
libc_ctype_unittests
)
add_libc_unittest(
+ isspace
+ SUITE
+ libc_ctype_unittests
+ SRCS
+ isspace_test.cpp
+ DEPENDS
+ libc.src.ctype.isspace
+)
+
+add_libc_unittest(
isupper
SUITE
libc_ctype_unittests
DEPENDS
libc.src.ctype.isupper
)
+
+add_libc_unittest(
+ isxdigit
+ SUITE
+ libc_ctype_unittests
+ SRCS
+ isxdigit_test.cpp
+ DEPENDS
+ libc.src.ctype.isxdigit
+)
--- /dev/null
+//===-- Unittests for isprint----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/ctype/isprint.h"
+#include "utils/UnitTest/Test.h"
+
+TEST(IsPrint, DefaultLocale) {
+ for (int ch = 0; ch < 255; ++ch) {
+ if (' ' <= ch && ch <= '~') // A-Z, a-z, 0-9, punctuation, space.
+ EXPECT_NE(__llvm_libc::isprint(ch), 0);
+ else
+ EXPECT_EQ(__llvm_libc::isprint(ch), 0);
+ }
+}
--- /dev/null
+//===-- Unittests for isspace----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/ctype/isspace.h"
+#include "utils/UnitTest/Test.h"
+
+TEST(IsSpace, DefaultLocale) {
+ // Loops through all characters, verifying that space characters
+ // return true and everything else returns false.
+ // Hexadecimal | Symbol
+ // ---------------------------
+ // 0x09 | horizontal tab
+ // 0x0a | line feed
+ // 0x0b | vertical tab
+ // 0x0d | carriage return
+ // 0x20 | space
+ for (int ch = 0; ch < 255; ++ch) {
+ if (ch == 0x20 || (0x09 <= ch && ch <= 0x0d))
+ EXPECT_NE(__llvm_libc::isspace(ch), 0);
+ else
+ EXPECT_EQ(__llvm_libc::isspace(ch), 0);
+ }
+}
--- /dev/null
+//===-- Unittests for isxdigit---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/ctype/isxdigit.h"
+#include "utils/UnitTest/Test.h"
+
+TEST(IsXDigit, DefaultLocale) {
+ for (int ch = 0; ch < 255; ++ch) {
+ if (('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f') ||
+ ('A' <= ch && ch <= 'F'))
+ EXPECT_NE(__llvm_libc::isxdigit(ch), 0);
+ else
+ EXPECT_EQ(__llvm_libc::isxdigit(ch), 0);
+ }
+}