From 0153035f93d5e537efef9119676e120034ac912b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 3 Jun 2022 18:46:37 -0700 Subject: [PATCH 1/2] dfa: do not warn about \] and \} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lib/dfa.c (lex): Do not warn about \] and \}, since they’re surely universally supported even though POSIX says their interpretation is undefined. --- ChangeLog | 7 +++++++ lib/dfa.c | 2 ++ lib/dfa.h | 6 +++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5fe5e9ee23..053fabde2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2022-06-04 Paul Eggert + + 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 + interpretation is undefined. + 2022-06-03 Paul Eggert regex-quote: \] -> ] in EREs and BREs diff --git a/lib/dfa.c b/lib/dfa.c index bd4c5f0582..4f8367af3f 100644 --- a/lib/dfa.c +++ b/lib/dfa.c @@ -1563,6 +1563,8 @@ lex (struct dfa *dfa) } dfawarn (msg); } + FALLTHROUGH; + case ']': case '}': normal_char: dfa->lex.laststart = false; /* For multibyte character sets, folding is done in atom. Always diff --git a/lib/dfa.h b/lib/dfa.h index 91ec1d809f..043f0e9717 100644 --- a/lib/dfa.h +++ b/lib/dfa.h @@ -79,7 +79,11 @@ enum merely a warning. */ DFA_CONFUSING_BRACKETS_ERROR = 1 << 2, - /* Warn about stray backslashes before ordinary characters. */ + /* Warn about stray backslashes before ordinary characters other + than ] and } which are special because even though POSIX + says \] and \} have undefined interpretation, platforms + reliably ignore those stray backlashes and warning about them + would likely cause more trouble than it's worth. */ DFA_STRAY_BACKSLASH_WARN = 1 << 3, /* Warn about * appearing out of context at the start of an -- 2.34.1