This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, libstdc++/64649] Fix regex_traits::lookup_collatename and regex_traits::lookup_classname


On 19/01/15 18:01 -0800, Tim Shen wrote:
   	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.

OK for trunk, as this is actually fixing a regression (we did narrow
the input range before the last patch for this bug).

--- a/libstdc++-v3/testsuite/28_regex/traits/wchar_t/user_defined.cc
+++ b/libstdc++-v3/testsuite/28_regex/traits/wchar_t/user_defined.cc
@@ -55,8 +55,32 @@ test01()
  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"`kog`"; // chars of "alpha" shifted by 1.

Could this use "digit" instead of "alpha" so it shifts to "chfhs"
instead of something with non-alphabetic characters?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]