[PATCH][libcxx] regex/awk does not handle 3-char octal escapes correctly

William Fisher william.w.fisher at gmail.com
Fri Jun 28 17:31:24 PDT 2013


This patch fixes a bug where the regex parser doesn't advance the pointer
after reading the third character of an octal escape (in awk mode).

That is, regex{"\\141", awk} results in the regular expression /a1/ instead
of just /a/.

Here is the test case:

```
#include <regex>
#include <cassert>

int main()
{
    using std::regex_constants::awk;

    assert(std::regex_match("\4", std::regex{"\\4", awk}));
    assert(std::regex_match("\41", std::regex{"\\41", awk}));
    assert(std::regex_match("\141", std::regex{"\\141", awk}));
    assert(std::regex_match("\1411", std::regex{"\\1411", awk}));
}
```

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130628/e8fecdac/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: octal_escape.patch
Type: application/octet-stream
Size: 872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130628/e8fecdac/attachment.obj>


More information about the cfe-commits mailing list