From ac58aead465ab8bea4223060e61c33eb265e8e85 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 4 Jun 2022 09:55:28 -0700 Subject: [PATCH 2/2] regex-quote: \} -> } in EREs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 | 6 ++++++ lib/regex-quote.c | 2 +- tests/test-regex-quote.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 053fabde2a..ed21be142f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2022-06-04 Paul Eggert + 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 -- 2.34.1