[PATCH] D17132: [libcxx] Fix definition of regex_traits::__regex_word on big-endian glibc systems

Daniel Sanders via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 02:10:36 PST 2016


dsanders created this revision.
dsanders added reviewers: mclow.lists, hans.
dsanders added a subscriber: cfe-commits.

On glibc, the bits used for the various character classes is endian dependant
(see _ISbit() in ctypes.h) but __regex_word does not account for this and uses
a spare bit that isn't spare on big-endian. On big-endian, it overlaps with the
bit for graphic characters which causes '-', '@', etc. to be considered a word
character.

Fixed this by defining the value using _ISbit(15) on glibc systems.

Fixes PR26476.

http://reviews.llvm.org/D17132

Files:
  include/regex

Index: include/regex
===================================================================
--- include/regex
+++ include/regex
@@ -976,7 +976,12 @@
     typedef locale                  locale_type;
     typedef ctype_base::mask        char_class_type;
 
+#if defined(__GLIBC__)
+    static const char_class_type __regex_word = static_cast<char_class_type>(_ISbit(15));
+#else
     static const char_class_type __regex_word = 0x80;
+#endif
+
 private:
     locale __loc_;
     const ctype<char_type>* __ct_;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17132.47611.patch
Type: text/x-patch
Size: 505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160211/e960539d/attachment.bin>


More information about the cfe-commits mailing list