+2015-01-22 Tim Shen <timshen@google.com>
+
+ PR libstdc++/64649
+ * include/bits/regex.tcc (regex_traits<>::lookup_collatename,
+ regex_traits<>::lookup_classname): Correctly narrow input chars.
+ * testsuite/28_regex/traits/wchar_t/user_defined.cc: New testcase.
+
2015-01-21 Jonathan Wakely <jwakely@redhat.com>
* config/abi/pre/gnu.ver: Use [jmy] for size_t parameters.
"DEL",
};
- string __s(__first, __last);
+ string __s;
+ for (; __first != __last; ++__first)
+ __s += __fctyp.narrow(*__first, 0);
+
for (const auto& __it : __collatenames)
if (__s == __it)
return string_type(1, __fctyp.widen(
};
string __s;
- for (auto __cur = __first; __cur != __last; ++__cur)
- __s += __fctyp.narrow(__fctyp.tolower(*__cur), '?');
+ for (; __first != __last; ++__first)
+ __s += __fctyp.narrow(__fctyp.tolower(*__first), 0);
for (const auto& __it : __classnames)
if (__s == __it.first)
VERIFY(!regex_match(L"\u2029", re));
}
+struct MyCtype : std::ctype<wchar_t>
+{
+ char
+ do_narrow(wchar_t c, char dflt) const override
+ {
+ if (c >= 256)
+ return dflt;
+ return ((char)c)+1;
+ }
+};
+
+void
+test02()
+{
+ std::locale loc(std::locale(), new MyCtype);
+ std::regex_traits<wchar_t> traits;
+ traits.imbue(loc);
+ wchar_t wch = L'p';
+ VERIFY(traits.lookup_collatename(&wch, &wch+1) == L"q");
+ std::wstring ws = L"chfhs"; // chars of "digit" shifted by 1.
+ VERIFY(traits.lookup_classname(ws.begin(), ws.end()) != 0);
+}
+
int main()
{
test01();
+ test02();
return 0;
}