[libcxx] r214201 - Base regex code on char_class_type.

Dan Albert danalbert at google.com
Tue Jul 29 12:23:40 PDT 2014


Author: danalbert
Date: Tue Jul 29 14:23:39 2014
New Revision: 214201

URL: http://llvm.org/viewvc/llvm-project?rev=214201&view=rev
Log:
Base regex code on char_class_type.

__get_classname() and __bracket_expression were assuming that
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).

Modified:
    libcxx/trunk/include/regex
    libcxx/trunk/src/regex.cpp
    libcxx/trunk/test/re/re.traits/lookup_classname.pass.cpp

Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=214201&r1=214200&r2=214201&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Tue Jul 29 14:23:39 2014
@@ -1192,7 +1192,8 @@ regex_traits<_CharT>::__lookup_collatena
 
 // 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>
@@ -2184,8 +2185,8 @@ class __bracket_expression
     vector<pair<string_type, string_type> > __ranges_;
     vector<pair<_CharT, _CharT> > __digraphs_;
     vector<string_type> __equivalences_;
-    ctype_base::mask __mask_;
-    ctype_base::mask __neg_mask_;
+    typename regex_traits<_CharT>::char_class_type __mask_;
+    typename regex_traits<_CharT>::char_class_type __neg_mask_;
     bool __negate_;
     bool __icase_;
     bool __collate_;
@@ -2281,10 +2282,10 @@ public:
     void __add_equivalence(const string_type& __s)
         {__equivalences_.push_back(__s);}
     _LIBCPP_INLINE_VISIBILITY
-    void __add_class(ctype_base::mask __mask)
+    void __add_class(typename regex_traits<_CharT>::char_class_type __mask)
         {__mask_ |= __mask;}
     _LIBCPP_INLINE_VISIBILITY
-    void __add_neg_class(ctype_base::mask __mask)
+    void __add_neg_class(typename regex_traits<_CharT>::char_class_type __mask)
         {__neg_mask_ |= __mask;}
 };
 

Modified: libcxx/trunk/src/regex.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/regex.cpp?rev=214201&r1=214200&r2=214201&view=diff
==============================================================================
--- libcxx/trunk/src/regex.cpp (original)
+++ libcxx/trunk/src/regex.cpp Tue Jul 29 14:23:39 2014
@@ -207,7 +207,7 @@ const collationnames collatenames[] =
 struct classnames
 {
     const char* elem_;
-    ctype_base::mask mask_;
+    regex_traits<char>::char_class_type mask_;
 };
 
 #if defined(__clang__)
@@ -254,12 +254,12 @@ __get_collation_name(const char* s)
     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_;

Modified: libcxx/trunk/test/re/re.traits/lookup_classname.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/re/re.traits/lookup_classname.pass.cpp?rev=214201&r1=214200&r2=214201&view=diff
==============================================================================
--- libcxx/trunk/test/re/re.traits/lookup_classname.pass.cpp (original)
+++ libcxx/trunk/test/re/re.traits/lookup_classname.pass.cpp Tue Jul 29 14:23:39 2014
@@ -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;





More information about the cfe-commits mailing list