@@ -470,6 +470,13 @@ void test_gh_5244_atomescape_posix_common(syntax_option_type option) {
470
470
check_atomescape_identityescape (" ^" , option);
471
471
check_atomescape_identityescape (" $" , option);
472
472
473
+ // Even though [ is special, ] is not,
474
+ // so the interpretation of the escape sequence \] is undefined
475
+ // according to the POSIX standard referenced in the C++ standard.
476
+ // But we treat \] as an identity escape in line with
477
+ // more recent versions of the POSIX standard.
478
+ check_atomescape_identityescape (" ]" , option);
479
+
473
480
// Sections on "BRE Special Characters" and "ERE Special Characters":
474
481
// escaping ordinary characters is undefined -> reject
475
482
g_regexTester.should_throw (R"( \B)" , error_escape, option);
@@ -483,9 +490,6 @@ void test_gh_5244_atomescape_posix_common(syntax_option_type option) {
483
490
g_regexTester.should_throw (R"( \W)" , error_escape, option);
484
491
g_regexTester.should_throw (R"( \s)" , error_escape, option);
485
492
g_regexTester.should_throw (R"( \S)" , error_escape, option);
486
-
487
- // while [ is special, ] is not
488
- g_regexTester.should_throw (R"( \])" , error_escape, option);
489
493
}
490
494
491
495
void test_gh_5244_atomescape_posix_not_awk (syntax_option_type option) {
@@ -524,8 +528,6 @@ void test_gh_5244_atomescape_basic_or_grep(syntax_option_type option) {
524
528
}
525
529
526
530
void test_gh_5244_atomescape_extended_egrep_awk (syntax_option_type option) {
527
- test_gh_5244_atomescape_posix_common (option);
528
-
529
531
// check that the parser accepts escaped characters
530
532
// that are only special in extended regexes
531
533
check_atomescape_identityescape (" +" , option);
@@ -557,6 +559,7 @@ void test_gh_5244_atomescape_extended_or_egrep(syntax_option_type option) {
557
559
558
560
void test_gh_5244_atomescape_awk () {
559
561
test_gh_5244_atomescape_extended_egrep_awk (awk);
562
+ test_gh_5244_atomescape_posix_common (awk);
560
563
561
564
// awk-only escapes
562
565
check_atomescape_controlescape (" \a " , " a" , awk);
0 commit comments