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 2/2] Localization problem in regex


On Sat, Aug 24, 2013 at 1:51 AM, Stefan Schweter <stefan@schweter.it> wrote:
> Am Fri, 23 Aug 2013 17:17:41 +0800
> schrieb Tim Shen <timshen91@gmail.com>:
>
>> Inspired by this mail:
>> http://gcc.gnu.org/ml/libstdc++/2013-08/msg00131.html
>>
>> Thanks!
>>
>>
>
> Hi Tim,
>
> I applied the patch + compiled everything - it's working now! Thanks!
>
> But... I found a problem with .imbue():
>
> int main()
> {
>         std::setlocale(LC_ALL, "");
>
>         std::wstring str2 = L"öäü";
>         std::wregex re2;
>         re2.imbue(std::locale(""));
>         re2.assign(L"([[:lower:]]+)");
>         std::wsmatch m2;
>
>         std::wsregex_token_iterator end {};
>
>         for (std::wsregex_token_iterator p{str2.begin(), str2.end(),
> re2, {1}}; p != end; ++p) { std::wcout << *p << std::endl;
>         }
>
>         return 0;
> }
>
> Works fine! But when there's no imbue() call, a Segmentation
> fault occurs.
>
> int main()
> {
>         std::setlocale(LC_ALL, "");
>
>         std::wstring str2 = L"öäü";
>         std::wregex re2;
>         //re2.imbue(std::locale(""));
>         re2.assign(L"([[:lower:]]+)");
>         std::wsmatch m2;
>
>         std::wsregex_token_iterator end {};
>
>         for (std::wsregex_token_iterator p{str2.begin(), str2.end(),
> re2, {1}}; p != end; ++p) { std::wcout << *p << std::endl;
>         }
>
>         return 0;
> }
>
> May be it's better to throw an exception here? Thanks in advance,
>
> Stefan

Fixed.

It's not fully tested. I just run the 28_regex testcases. I'll do a
full test before committing.

Thanks again!

-- 
Tim Shen

Attachment: regex-locale.patch
Description: Binary data


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