From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sat, 4 Jun 2022 16:55:28 +0000 (-0700)
Subject: regex-quote: \} -> } in EREs
X-Git-Tag: v1.0~2271
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ac58aead465ab8bea4223060e61c33eb265e8e85;p=gnulib.git

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 }.
---

diff --git a/ChangeLog b/ChangeLog
index 053fabde2a..ed21be142f 100644
--- 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
diff --git a/lib/regex-quote.c b/lib/regex-quote.c
index 9b92e98910..41639ea50e 100644
--- a/lib/regex-quote.c
+++ b/lib/regex-quote.c
@@ -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)
diff --git a/tests/test-regex-quote.c b/tests/test-regex-quote.c
index 2282d5f662..918ccd5901 100644
--- a/tests/test-regex-quote.c
+++ b/tests/test-regex-quote.c
@@ -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