[libcxx-commits] [PATCH] D118851: [SystemZ]:[z/OS]:[libcxx]: fix isascii function to work for z/OS
Nancy Wang via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Feb 11 14:12:09 PST 2022
NancyWang2222 updated this revision to Diff 408048.
NancyWang2222 marked an inline comment as done.
NancyWang2222 added a comment.
change function name and return type
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118851/new/
https://reviews.llvm.org/D118851
Files:
libcxx/include/__locale
libcxx/include/charconv
Index: libcxx/include/charconv
===================================================================
--- libcxx/include/charconv
+++ libcxx/include/charconv
@@ -93,6 +93,12 @@
#include <__debug>
+#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# include <cctype>
+#else
+# include <locale>
+#endif
+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
@@ -426,6 +432,22 @@
return {__r.ptr, errc::result_out_of_range};
}
+template <typename _Tp>
+inline _LIBCPP_INLINE_VISIBILITY int __alphabetical_index(_Tp __c) {
+# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
+ if ('a' <= __c && __c <= 'i')
+ return __c - 'a';
+ else if ('j' <= __c && __c <= 'r')
+ return __c - 'j' + 9;
+ else if ('s' <= __c && __c <= 'z')
+ return __c - 's' + 18;
+ else
+ return 27;
+# else
+ return __c - 'a';
+# endif
+ }
+
template <typename _Tp>
inline _LIBCPP_INLINE_VISIBILITY bool
__in_pattern(_Tp __c)
@@ -449,10 +471,9 @@
return {'0' <= __c && __c < '0' + __base, __c - '0'};
else if (__in_pattern(__c))
return {true, __c - '0'};
- else if ('a' <= __c && __c < 'a' + __base - 10)
- return {true, __c - 'a' + 10};
- else
- return {'A' <= __c && __c < 'A' + __base - 10, __c - 'A' + 10};
+ __c = _VSTD::tolower(__c);
+ return {'a' <= __c && __alphabetical_index(__c) < __base - 10,
+ __alphabetical_index(__c) + 10};
}
template <typename _It, typename _Tp, typename _Fn, typename... _Ts>
Index: libcxx/include/__locale
===================================================================
--- libcxx/include/__locale
+++ libcxx/include/__locale
@@ -14,7 +14,9 @@
#include <__config>
#include <cctype>
#include <cstdint>
-#include <locale.h>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# include <locale.h>
+#endif
#include <memory>
#include <mutex>
#include <string>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118851.408048.patch
Type: text/x-patch
Size: 1892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220211/fe8073ae/attachment-0001.bin>
More information about the libcxx-commits
mailing list