[cfe-commits] [libcxx] r134787 - in /libcxx/trunk: include/__config src/locale.cpp

Sean Hunt scshunt at csclub.uwaterloo.ca
Fri Jul 8 20:40:04 PDT 2011


Author: coppro
Date: Fri Jul  8 22:40:04 2011
New Revision: 134787

URL: http://llvm.org/viewvc/llvm-project?rev=134787&view=rev
Log:
Don't assume that wctype produces a nice mask on all platforms. On
glibc, for instance, it's a const char *.

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=134787&r1=134786&r2=134787&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Jul  8 22:40:04 2011
@@ -289,4 +289,8 @@
 #define _LIBCPP_STABLE_APPLE_ABI
 #endif
 
+#ifdef __APPLE__
+#define _LIBCPP_WCTYPE_IS_MASK
+#endif
+
 #endif  // _LIBCPP_CONFIG

Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=134787&r1=134786&r2=134787&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Fri Jul  8 22:40:04 2011
@@ -1114,7 +1114,21 @@
 bool
 ctype_byname<wchar_t>::do_is(mask m, char_type c) const
 {
+#ifdef _LIBCPP_WCTYPE_IS_MASK
     return static_cast<bool>(iswctype_l(c, m, __l));
+#else
+    if (m & space && !iswspace_l(c, __l)) return false;
+    if (m & print && !iswprint_l(c, __l)) return false;
+    if (m & cntrl && !iswcntrl_l(c, __l)) return false;
+    if (m & upper && !iswupper_l(c, __l)) return false;
+    if (m & lower && !iswlower_l(c, __l)) return false;
+    if (m & alpha && !iswalpha_l(c, __l)) return false;
+    if (m & digit && !iswdigit_l(c, __l)) return false;
+    if (m & punct && !iswpunct_l(c, __l)) return false;
+    if (m & xdigit && !iswxdigit_l(c, __l)) return false;
+    if (m & blank && !iswblank_l(c, __l)) return false;
+    return true;
+#endif
 }
 
 const wchar_t*
@@ -1154,8 +1168,24 @@
 ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
 {
     for (; low != high; ++low)
+    {
+#ifdef _LIBCPP_WCTYPE_IS_MASK
         if (iswctype_l(*low, m, __l))
             break;
+#else
+        if (m & space && !iswspace_l(*low, __l)) continue;
+        if (m & print && !iswprint_l(*low, __l)) continue;
+        if (m & cntrl && !iswcntrl_l(*low, __l)) continue;
+        if (m & upper && !iswupper_l(*low, __l)) continue;
+        if (m & lower && !iswlower_l(*low, __l)) continue;
+        if (m & alpha && !iswalpha_l(*low, __l)) continue;
+        if (m & digit && !iswdigit_l(*low, __l)) continue;
+        if (m & punct && !iswpunct_l(*low, __l)) continue;
+        if (m & xdigit && !iswxdigit_l(*low, __l)) continue;
+        if (m & blank && !iswblank_l(*low, __l)) continue;
+        break;
+#endif
+    }
     return low;
 }
 
@@ -1163,8 +1193,24 @@
 ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
 {
     for (; low != high; ++low)
+    {
+#ifdef _LIBCPP_WCTYPE_IS_MASK
         if (!iswctype_l(*low, m, __l))
             break;
+#else
+        if (m & space && iswspace_l(*low, __l)) continue;
+        if (m & print && iswprint_l(*low, __l)) continue;
+        if (m & cntrl && iswcntrl_l(*low, __l)) continue;
+        if (m & upper && iswupper_l(*low, __l)) continue;
+        if (m & lower && iswlower_l(*low, __l)) continue;
+        if (m & alpha && iswalpha_l(*low, __l)) continue;
+        if (m & digit && iswdigit_l(*low, __l)) continue;
+        if (m & punct && iswpunct_l(*low, __l)) continue;
+        if (m & xdigit && iswxdigit_l(*low, __l)) continue;
+        if (m & blank && iswblank_l(*low, __l)) continue;
+        break;
+#endif
+    }
     return low;
 }
 





More information about the cfe-commits mailing list