[PATCH] [libcxx] Base __get_classname on char_class_type.

Dan Albert danalbert at google.com
Wed Jul 23 10:40:04 PDT 2014


Hi mclow.lists,

__get_classname() was assuming its char_class_type was ctype_base::mask rather than using regex_traits<_CharT>::char_class_type.

This change allows char_class_type to be defined to something other than ctype_base::mask so that the implementation will still work for platforms with an 8-bit ctype mask (such as Android and OpenBSD).

http://reviews.llvm.org/D4642

Files:
  include/regex
  src/regex.cpp
  test/re/re.traits/lookup_classname.pass.cpp

Index: include/regex
===================================================================
--- include/regex
+++ include/regex
@@ -1192,7 +1192,8 @@
 
 // lookup_classname
 
-ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase);
+regex_traits<char>::char_class_type _LIBCPP_FUNC_VIS
+__get_classname(const char* __s, bool __icase);
 
 template <class _CharT>
 template <class _ForwardIterator>
Index: src/regex.cpp
===================================================================
--- src/regex.cpp
+++ src/regex.cpp
@@ -207,7 +207,7 @@
 struct classnames
 {
     const char* elem_;
-    ctype_base::mask mask_;
+    regex_traits<char>::char_class_type mask_;
 };
 
 #if defined(__clang__)
@@ -254,12 +254,12 @@
     return r;
 }
 
-ctype_base::mask
+regex_traits<char>::char_class_type
 __get_classname(const char* s, bool __icase)
 {
     const classnames* i =
             _VSTD::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp());
-    ctype_base::mask r = 0;
+    regex_traits<char>::char_class_type r = 0;
     if (i != end(ClassNames) && strcmp(s, i->elem_) == 0)
     {
         r = i->mask_;
Index: test/re/re.traits/lookup_classname.pass.cpp
===================================================================
--- test/re/re.traits/lookup_classname.pass.cpp
+++ test/re/re.traits/lookup_classname.pass.cpp
@@ -22,7 +22,9 @@
 
 template <class char_type>
 void
-test(const char_type* A, std::ctype_base::mask expected, bool icase = false)
+test(const char_type* A,
+     typename std::regex_traits<char_type>::char_class_type expected,
+     bool icase = false)
 {
     std::regex_traits<char_type> t;
     typedef forward_iterator<const char_type*> F;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4642.11814.patch
Type: text/x-patch
Size: 1704 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140723/6a1c19c4/attachment.bin>


More information about the cfe-commits mailing list