]> Savannah Git Hosting - gnulib.git/commitdiff
regex-quote: \} -> } in EREs
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 4 Jun 2022 16:55:28 +0000 (09:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 4 Jun 2022 16:55:57 +0000 (09:55 -0700)
* lib/regex-quote.c (ere_special): Don’t use \} in EREs,
as POSIX says the interpretation is undefined.
* tests/test-regex-quote.c (test_bre, test_ere):
Add tests for }.

ChangeLog
lib/regex-quote.c
tests/test-regex-quote.c

index 053fabde2a5abd33081f9622f83d7285c5aa6338..ed21be142fc8f8b5d9be88532eb19c44582dd949 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2022-06-04  Paul Eggert  <eggert@cs.ucla.edu>
 
+       regex-quote: \} -> } in EREs
+       * lib/regex-quote.c (ere_special): Don’t use \} in EREs,
+       as POSIX says the interpretation is undefined.
+       * tests/test-regex-quote.c (test_bre, test_ere):
+       Add tests for }.
+
        dfa: do not warn about \] and \}
        * lib/dfa.c (lex): Do not warn about \] and \}, since they’re
        surely universally supported even though POSIX says their
index 9b92e9891019aa8795c5d79d7c2de72eb7e9a19a..41639ea50e2449a0087a8d889e70633e392ac88f 100644 (file)
@@ -29,7 +29,7 @@
 static const char bre_special[] = "$^.*[\\";
 
 /* Characters that are special in an ERE.  */
-static const char ere_special[] = "$^.*[\\+?{}()|";
+static const char ere_special[] = "$^.*[\\+?{()|";
 
 struct regex_quote_spec
 regex_quote_spec_posix (int cflags, bool anchored)
index 2282d5f6627525d2b0e32825fac96658d5dea136..918ccd59013cdf0b04d2a5914f8b5ef410acab71 100644 (file)
@@ -79,6 +79,7 @@ test_bre (void)
 {
   check ("aBc", 0, "aBc");
   check ("(foo[$HOME])", 0, "(foo\\[\\$HOME])");
+  check ("(foo{$HOME})", 0, "(foo{\\$HOME})");
 }
 
 static void
@@ -86,6 +87,7 @@ test_ere (void)
 {
   check ("aBc", REG_EXTENDED, "aBc");
   check ("(foo[$HOME])", REG_EXTENDED, "\\(foo\\[\\$HOME]\\)");
+  check ("(foo{$HOME})", REG_EXTENDED, "\\(foo\\{\\$HOME}\\)");
 }
 
 int