grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v3.7-75-ge7f8e8e


From: Paul Eggert
Subject: grep branch, master, updated. v3.7-75-ge7f8e8e
Date: Mon, 23 May 2022 15:40:32 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  e7f8e8eb1fd41b308ee10741bbd8068acc1847c2 (commit)
       via  42db5cc8f58620b4c9c58a91c7683279c50503f9 (commit)
      from  a860bd39e384ed6111bc63fe6aabeb7f7120e6d5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e7f8e8eb1fd41b308ee10741bbd8068acc1847c2


commit e7f8e8eb1fd41b308ee10741bbd8068acc1847c2
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon May 23 12:38:42 2022 -0700

    grep: warn about stray backslashes
    
    This papers over a problem reported by Benno Schulenberg and
    Tomasz Dziendzielski <https://bugs.gnu.org/39678> involving
    regular expressions like \a that have unspecified behavior.
    * src/dfasearch.c (dfawarn): Just output a warning.
    Don’t exit, as DFA_CONFUSING_BRACKETS_ERROR now
    does that for us, and we need the ability to warn
    without exiting to diagnose \a etc.
    (GEAcompile): Use new dfa options DFA_CONFUSING_BRACKETS_ERROR and
    DFA_STRAY_BACKSLASH_WARN.

diff --git a/NEWS b/NEWS
index 38ac035..112d85b 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 8f48296..7547a8a 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;
 

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=42db5cc8f58620b4c9c58a91c7683279c50503f9


commit e7f8e8eb1fd41b308ee10741bbd8068acc1847c2
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon May 23 12:38:42 2022 -0700

    grep: warn about stray backslashes
    
    This papers over a problem reported by Benno Schulenberg and
    Tomasz Dziendzielski <https://bugs.gnu.org/39678> involving
    regular expressions like \a that have unspecified behavior.
    * src/dfasearch.c (dfawarn): Just output a warning.
    Don’t exit, as DFA_CONFUSING_BRACKETS_ERROR now
    does that for us, and we need the ability to warn
    without exiting to diagnose \a etc.
    (GEAcompile): Use new dfa options DFA_CONFUSING_BRACKETS_ERROR and
    DFA_STRAY_BACKSLASH_WARN.

diff --git a/NEWS b/NEWS
index 38ac035..112d85b 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 8f48296..7547a8a 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;
 

-----------------------------------------------------------------------

Summary of changes:
 NEWS            | 6 ++++++
 gnulib          | 2 +-
 src/dfasearch.c | 7 ++++---
 3 files changed, 11 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]