[Patch, libstdc++/77356] Support escape in regex bracket expression

Jonathan Wakely jwakely@redhat.com
Fri Aug 26 10:09:00 GMT 2016


On 24/08/16 12:48 -0700, Tim Shen wrote:
>On Wed, Aug 24, 2016 at 1:41 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
>> On 24/08/16 00:18 -0700, Tim Shen wrote:
>>>
>>> I didn't realized that we can actually escape a dash inside bracket
>>> expression: R"([\-])", in which case the dash should be treated
>>> literally.
>>
>>
>> With this patch applied I no longer get a match for:
>>
>>  regex_match("-", std::regex{"[a-]", std::regex_constants::basic})
>
>Nice catch. I'm surprised that there is no test for it. Added one.
>
>> I wonder if we want to give _S_token_unknown an initializer with a
>> specific value, so it doesn't change whenever we add new tokens.
>>
>> If we use -1 it would change the underlying type of
>> _ScannerBase::_TokenT from unsigned int to signed int, so we should
>> give it a fixed type too:
>>
>>  struct _ScannerBase
>>  {
>>  public:
>>    /// Token types returned from the scanner.
>>    enum _TokenT : unsigned
>>    {
>>      ...
>>      _S_token_unknown = -1u
>
>Done.

OK for trunk, thanks.



More information about the Libstdc++ mailing list