This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, libstdc++/64649] Fix regex_traits::lookup_collatename and regex_traits::lookup_classname
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Tim Shen <timshen at google dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 21 Jan 2015 12:12:32 +0000
- Subject: Re: [Patch, libstdc++/64649] Fix regex_traits::lookup_collatename and regex_traits::lookup_classname
- Authentication-results: sourceware.org; auth=none
- References: <CAG4ZjN=a3TG-qANYgtgt_e9vhhMCWxvChQRzcBHHYJrwKLszHg at mail dot gmail dot com> <20150119132329 dot GD3360 at redhat dot com> <CAG4ZjNmZSfX_oDjL1=qWk22inYaAYh9Bg-GYy74kNmVnkExntw at mail dot gmail dot com> <CAG4ZjNnGJg1BidtWci44nt=LvcW7N9DEJHw7o8PQ2++67fijcQ at mail dot gmail dot com> <CAG4ZjNmEtERrMLFhe3QNK2wSpf6N5BWs3D6E05dayYyqUxRz1Q at mail dot gmail dot com>
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?