summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS6
-rw-r--r--src/dfasearch.c7
2 files changed, 10 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 38ac0353..112d85b0 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,12 @@ GNU grep NEWS -*- outline -*-
release 2.5.3 (2007), now warn that they are obsolescent and should
be replaced by grep -E and grep -F.
+ Regular expressions with stray backslashes now cause warnings, as
+ their unspecified behavior can lead to unexpected results.
+ For example, '\a' and 'a' are not always equivalent
+ <https://bugs.gnu.org/39768>. The warnings are intended as a
+ transition aid; they are likely to be errors in future releases.
+
Regular expressions like [:space:] are now errors even if
POSIXLY_CORRECT is set, since POSIX now allows the GNU behavior.
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 8f48296a..7547a8a3 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -53,10 +53,10 @@ dfaerror (char const *mesg)
die (EXIT_TROUBLE, 0, "%s", mesg);
}
-_Noreturn void
+void
dfawarn (char const *mesg)
{
- dfaerror (mesg);
+ error (0, 0, _("warning: %s"), mesg);
}
/* If the DFA turns out to have some set of fixed strings one of
@@ -196,7 +196,8 @@ GEAcompile (char *pattern, idx_t size, reg_syntax_t syntax_bits,
if (match_icase)
syntax_bits |= RE_ICASE;
- int dfaopts = eolbyte ? 0 : DFA_EOL_NUL;
+ int dfaopts = (DFA_CONFUSING_BRACKETS_ERROR | DFA_STRAY_BACKSLASH_WARN
+ | (eolbyte ? 0 : DFA_EOL_NUL));
dfasyntax (dc->dfa, &localeinfo, syntax_bits, dfaopts);
bool bs_safe = !localeinfo.multibyte | localeinfo.using_utf8;