Skip to content

Commit

Permalink
[libc++] ECMAScript IdentityEscape is ambiguous (2584)
Browse files Browse the repository at this point in the history
This patch fixes [[ https://cplusplus.github.io/LWG/issue2584 | 2584 ]]. Now the following works:
    const std::regex r1("\\z");
    assert(std::regex_match("z", r1));

Differential Revision: https://reviews.llvm.org/D66610
  • Loading branch information
zoecarver committed May 7, 2020
1 parent 21e5e17 commit 6d2a66b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions libcxx/include/regex
Expand Up @@ -4438,6 +4438,9 @@ basic_regex<_CharT, _Traits>::__parse_character_class_escape(_ForwardIterator __
__ml->__add_char('_');
++__first;
break;
default:
__ml = __start_matching_list(true);
++__first;
}
}
return __first;
Expand Down
11 changes: 11 additions & 0 deletions libcxx/test/std/re/re.alg/re.alg.match/ecma.pass.cpp
Expand Up @@ -1391,6 +1391,17 @@ int main(int, char**)
assert(m.position(0) == 0);
assert(m.str(0) == s);
}
{
// LWG#2584: identity escapes. Match exact chars/strings.
const std::regex r1("\\z");
assert(std::regex_match("z", r1));

const std::regex r2("\\zz");
assert(std::regex_match("zz", r2));

const std::regex r3("\\zx");
assert(std::regex_match("zx", r3));
}

return 0;
}
Expand Up @@ -32,15 +32,11 @@ static bool error_escape_thrown(const char *pat)
int main(int, char**)
{
assert(error_escape_thrown("[\\a]"));
assert(error_escape_thrown("\\a"));
assert(error_escape_thrown("\\"));

assert(error_escape_thrown("[\\e]"));
assert(error_escape_thrown("\\e"));

assert(error_escape_thrown("[\\c:]"));
assert(error_escape_thrown("\\c:"));
assert(error_escape_thrown("\\c"));
assert(!error_escape_thrown("[\\cA]"));
assert(!error_escape_thrown("\\cA"));

Expand Down
2 changes: 1 addition & 1 deletion libcxx/www/cxx1z_status.html
Expand Up @@ -392,7 +392,7 @@ <h3>Library Working group Issues Status</h3>
<tr><td><a href="https://wg21.link/LWG2569">2569</a></td><td>conjunction and disjunction requirements are too strict</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG2570">2570</a></td><td>[fund.ts.v2] conjunction and disjunction requirements are too strict</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="https://wg21.link/LWG2578">2578</a></td><td>Iterator requirements should reference iterator traits</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG2584">2584</a></td><td><regex> ECMAScript IdentityEscape is ambiguous</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="https://wg21.link/LWG2584">2584</a></td><td><regex> ECMAScript IdentityEscape is ambiguous</td><td>Issaquah</td><td>Complete</td></tr>
<tr><td><a href="https://wg21.link/LWG2587">2587</a></td><td>"Convertible to bool" requirement in conjunction and disjunction</td><td>Issaquah</td><td>Resolved by 2567</td></tr>
<tr><td><a href="https://wg21.link/LWG2588">2588</a></td><td>[fund.ts.v2] "Convertible to bool" requirement in conjunction and disjunction</td><td>Issaquah</td><td></td></tr>
<tr><td><a href="https://wg21.link/LWG2589">2589</a></td><td>match_results can't satisfy the requirements of a container</td><td>Issaquah</td><td>Complete</td></tr>
Expand Down

0 comments on commit 6d2a66b

Please sign in to comment.