[libcxx-commits] [libcxx] 20acf6d - [libcxx] Check _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE first in __locale

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 11 12:33:06 PST 2020


Author: Xiang Xiao
Date: 2020-11-11T15:32:59-05:00
New Revision: 20acf6d5882014e733ac9a5f97de2791b9a851c5

URL: https://github.com/llvm/llvm-project/commit/20acf6d5882014e733ac9a5f97de2791b9a851c5
DIFF: https://github.com/llvm/llvm-project/commit/20acf6d5882014e733ac9a5f97de2791b9a851c5.diff

LOG: [libcxx] Check _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE first in __locale

This is consistent with what's done in locale.cpp, and it ensures that
we get the default rune table whenever _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
is defined, regardless of the actual platform.

Differential Revision: https://reviews.llvm.org/D91074

Added: 
    

Modified: 
    libcxx/include/__locale

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__locale b/libcxx/include/__locale
index ed48bfb9ae66..d4f3cda08c98 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -397,7 +397,26 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
 class _LIBCPP_TYPE_VIS ctype_base
 {
 public:
-#if defined(__GLIBC__)
+#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
+    typedef unsigned long mask;
+    static const mask space  = 1<<0;
+    static const mask print  = 1<<1;
+    static const mask cntrl  = 1<<2;
+    static const mask upper  = 1<<3;
+    static const mask lower  = 1<<4;
+    static const mask alpha  = 1<<5;
+    static const mask digit  = 1<<6;
+    static const mask punct  = 1<<7;
+    static const mask xdigit = 1<<8;
+    static const mask blank  = 1<<9;
+#if defined(__BIONIC__)
+    // Historically this was a part of regex_traits rather than ctype_base. The
+    // historical value of the constant is preserved for ABI compatibility.
+    static const mask __regex_word = 0x8000;
+#else
+    static const mask __regex_word = 1<<10;
+#endif // defined(__BIONIC__)
+#elif defined(__GLIBC__)
     typedef unsigned short mask;
     static const mask space  = _ISspace;
     static const mask print  = _ISprint;
@@ -486,24 +505,7 @@ public:
 # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
 # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
 #else
-    typedef unsigned long mask;
-    static const mask space  = 1<<0;
-    static const mask print  = 1<<1;
-    static const mask cntrl  = 1<<2;
-    static const mask upper  = 1<<3;
-    static const mask lower  = 1<<4;
-    static const mask alpha  = 1<<5;
-    static const mask digit  = 1<<6;
-    static const mask punct  = 1<<7;
-    static const mask xdigit = 1<<8;
-    static const mask blank  = 1<<9;
-#if defined(__BIONIC__)
-    // Historically this was a part of regex_traits rather than ctype_base. The
-    // historical value of the constant is preserved for ABI compatibility.
-    static const mask __regex_word = 0x8000;
-#else
-    static const mask __regex_word = 1<<10;
-#endif // defined(__BIONIC__)
+# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?
 #endif
     static const mask alnum  = alpha | digit;
     static const mask graph  = alnum | punct;


        


More information about the libcxx-commits mailing list