grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.6.3-85-gf53baaf


From: Jim Meyering
Subject: grep branch, master, updated. v2.6.3-85-gf53baaf
Date: Fri, 27 Aug 2010 21:05:09 +0000

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  f53baaf7a98c2fbc43eba67a760e62679c53ce50 (commit)
       via  eda8089e09ad421b4bd6cdb21e9eed21d4c01f81 (commit)
       via  2cd3bceac33baa61fda54a3aaa4f5fb266ec10e0 (commit)
      from  565e1ad0e16e11097ceb8ef6402c656bed29db29 (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=f53baaf7a98c2fbc43eba67a760e62679c53ce50


commit f53baaf7a98c2fbc43eba67a760e62679c53ce50
Author: Paolo Bonzini <address@hidden>
Date:   Sun Aug 15 10:54:19 2010 -0400

    dfa: warn on [:space:] and similar
    
    * src/dfa.c (parse_bracket_exp): Warn on regular expressions such as
    [:space:].
    * src/dfa.h (dfawarn): New prototype.
    * src/dfasearch.c (dfawarn): New.
    * NEWS: Document.

diff --git a/NEWS b/NEWS
index 95c2e88..553ec52 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,15 @@ GNU grep NEWS                                    -*- outline 
-*-
   --mmap was meant to be ignored in 2.6.x, but it was instead
   removed by mistake.  [bug introduced in 2.6]
 
+** New features
+
+  grep now will warn for very common regular expression mistakes,
+  such as using [:space:] instead of [[:space:]].  Warnings are
+  disabled by POSIXLY_CORRECT.  They are also disabled when stdout
+  is not a TTY, thus minimizing the chance of extraneous output
+  in a script.  However, the rules for enabling/disabling warnings
+  are experimental and subject to change in future releases.
+
 * Noteworthy changes in release 2.6.3 (2010-04-02) [stable]
 
 ** Bug fixes
diff --git a/src/dfa.c b/src/dfa.c
index 5da59d8..91124b6 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -752,6 +752,13 @@ parse_bracket_exp (void)
   int c, c1, c2;
   charclass ccl;
 
+  /* Used to warn about [:space:].
+     Bit 0 = first character is a colon.
+     Bit 1 = last character is a colon.
+     Bit 2 = includes any other character but a colon.
+     Bit 3 = includes ranges, char/equiv classes or collation elements.  */
+  int colon_warning_state;
+
 #if MBS_SUPPORT
   wint_t wc, wc1, wc2;
 
@@ -790,9 +797,11 @@ parse_bracket_exp (void)
   else
     invert = 0;
 
+  colon_warning_state = (c == ':');
   do
     {
       c1 = EOF; /* mark c1 is not initialized".  */
+      colon_warning_state &= ~2;
 
       /* Note that if we're looking at some other [:...:] construct,
          we just treat it as a bunch of ordinary characters.  We can do
@@ -890,6 +899,7 @@ parse_bracket_exp (void)
                     }
                 }
 #endif
+              colon_warning_state |= 8;
 
               /* Fetch new lookahead character.  */
               FETCH_WC (c1, wc1, _("unbalanced ["));
@@ -975,10 +985,13 @@ parse_bracket_exp (void)
                     setbit_case_fold (c, ccl);
             }
 
+          colon_warning_state |= 8;
           FETCH_WC(c1, wc1, _("unbalanced ["));
           continue;
         }
 
+      colon_warning_state |= (c == ':') ? 2 : 4;
+
 #if MBS_SUPPORT
       /* Build normal characters.  */
       setbit_case_fold (wc, ccl);
@@ -1018,6 +1031,9 @@ parse_bracket_exp (void)
 #endif
          (c = c1) != ']'));
 
+  if (colon_warning_state == 7)
+    dfawarn (_("character class syntax is [[:space:]], not [:space:]"));
+
 #if MBS_SUPPORT
   if (MB_CUR_MAX > 1
       && (!using_utf8()
diff --git a/src/dfa.h b/src/dfa.h
index 0a8ad42..b8f3078 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -90,6 +90,12 @@ extern void dfastate (int, struct dfa *, int []);
 
 /* Error handling. */
 
+/* dfawarn() is called by the regexp routines whenever a regex is compiled
+   that likely doesn't do what the user wanted.  It takes a single
+   argument, a NUL-terminated string describing the situation.  The user
+   must supply a dfawarn.  */
+extern void dfawarn (const char *);
+
 /* dfaerror() is called by the regexp routines whenever an error occurs.  It
    takes a single argument, a NUL-terminated string describing the error.
    The user must supply a dfaerror.  */
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 4ccb6dc..29a1f7e 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -46,6 +46,13 @@ static struct patterns *patterns;
 static size_t pcount;
 
 void
+dfawarn (char const *mesg)
+{
+  if (warnings)
+    error (0, 0, _("warning: %s"), mesg);
+}
+
+void
 dfaerror (char const *mesg)
 {
   error (EXIT_TROUBLE, 0, "%s", mesg);

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


commit f53baaf7a98c2fbc43eba67a760e62679c53ce50
Author: Paolo Bonzini <address@hidden>
Date:   Sun Aug 15 10:54:19 2010 -0400

    dfa: warn on [:space:] and similar
    
    * src/dfa.c (parse_bracket_exp): Warn on regular expressions such as
    [:space:].
    * src/dfa.h (dfawarn): New prototype.
    * src/dfasearch.c (dfawarn): New.
    * NEWS: Document.

diff --git a/NEWS b/NEWS
index 95c2e88..553ec52 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,15 @@ GNU grep NEWS                                    -*- outline 
-*-
   --mmap was meant to be ignored in 2.6.x, but it was instead
   removed by mistake.  [bug introduced in 2.6]
 
+** New features
+
+  grep now will warn for very common regular expression mistakes,
+  such as using [:space:] instead of [[:space:]].  Warnings are
+  disabled by POSIXLY_CORRECT.  They are also disabled when stdout
+  is not a TTY, thus minimizing the chance of extraneous output
+  in a script.  However, the rules for enabling/disabling warnings
+  are experimental and subject to change in future releases.
+
 * Noteworthy changes in release 2.6.3 (2010-04-02) [stable]
 
 ** Bug fixes
diff --git a/src/dfa.c b/src/dfa.c
index 5da59d8..91124b6 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -752,6 +752,13 @@ parse_bracket_exp (void)
   int c, c1, c2;
   charclass ccl;
 
+  /* Used to warn about [:space:].
+     Bit 0 = first character is a colon.
+     Bit 1 = last character is a colon.
+     Bit 2 = includes any other character but a colon.
+     Bit 3 = includes ranges, char/equiv classes or collation elements.  */
+  int colon_warning_state;
+
 #if MBS_SUPPORT
   wint_t wc, wc1, wc2;
 
@@ -790,9 +797,11 @@ parse_bracket_exp (void)
   else
     invert = 0;
 
+  colon_warning_state = (c == ':');
   do
     {
       c1 = EOF; /* mark c1 is not initialized".  */
+      colon_warning_state &= ~2;
 
       /* Note that if we're looking at some other [:...:] construct,
          we just treat it as a bunch of ordinary characters.  We can do
@@ -890,6 +899,7 @@ parse_bracket_exp (void)
                     }
                 }
 #endif
+              colon_warning_state |= 8;
 
               /* Fetch new lookahead character.  */
               FETCH_WC (c1, wc1, _("unbalanced ["));
@@ -975,10 +985,13 @@ parse_bracket_exp (void)
                     setbit_case_fold (c, ccl);
             }
 
+          colon_warning_state |= 8;
           FETCH_WC(c1, wc1, _("unbalanced ["));
           continue;
         }
 
+      colon_warning_state |= (c == ':') ? 2 : 4;
+
 #if MBS_SUPPORT
       /* Build normal characters.  */
       setbit_case_fold (wc, ccl);
@@ -1018,6 +1031,9 @@ parse_bracket_exp (void)
 #endif
          (c = c1) != ']'));
 
+  if (colon_warning_state == 7)
+    dfawarn (_("character class syntax is [[:space:]], not [:space:]"));
+
 #if MBS_SUPPORT
   if (MB_CUR_MAX > 1
       && (!using_utf8()
diff --git a/src/dfa.h b/src/dfa.h
index 0a8ad42..b8f3078 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -90,6 +90,12 @@ extern void dfastate (int, struct dfa *, int []);
 
 /* Error handling. */
 
+/* dfawarn() is called by the regexp routines whenever a regex is compiled
+   that likely doesn't do what the user wanted.  It takes a single
+   argument, a NUL-terminated string describing the situation.  The user
+   must supply a dfawarn.  */
+extern void dfawarn (const char *);
+
 /* dfaerror() is called by the regexp routines whenever an error occurs.  It
    takes a single argument, a NUL-terminated string describing the error.
    The user must supply a dfaerror.  */
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 4ccb6dc..29a1f7e 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -46,6 +46,13 @@ static struct patterns *patterns;
 static size_t pcount;
 
 void
+dfawarn (char const *mesg)
+{
+  if (warnings)
+    error (0, 0, _("warning: %s"), mesg);
+}
+
+void
 dfaerror (char const *mesg)
 {
   error (EXIT_TROUBLE, 0, "%s", mesg);

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2cd3bceac33baa61fda54a3aaa4f5fb266ec10e0


commit f53baaf7a98c2fbc43eba67a760e62679c53ce50
Author: Paolo Bonzini <address@hidden>
Date:   Sun Aug 15 10:54:19 2010 -0400

    dfa: warn on [:space:] and similar
    
    * src/dfa.c (parse_bracket_exp): Warn on regular expressions such as
    [:space:].
    * src/dfa.h (dfawarn): New prototype.
    * src/dfasearch.c (dfawarn): New.
    * NEWS: Document.

diff --git a/NEWS b/NEWS
index 95c2e88..553ec52 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,15 @@ GNU grep NEWS                                    -*- outline 
-*-
   --mmap was meant to be ignored in 2.6.x, but it was instead
   removed by mistake.  [bug introduced in 2.6]
 
+** New features
+
+  grep now will warn for very common regular expression mistakes,
+  such as using [:space:] instead of [[:space:]].  Warnings are
+  disabled by POSIXLY_CORRECT.  They are also disabled when stdout
+  is not a TTY, thus minimizing the chance of extraneous output
+  in a script.  However, the rules for enabling/disabling warnings
+  are experimental and subject to change in future releases.
+
 * Noteworthy changes in release 2.6.3 (2010-04-02) [stable]
 
 ** Bug fixes
diff --git a/src/dfa.c b/src/dfa.c
index 5da59d8..91124b6 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -752,6 +752,13 @@ parse_bracket_exp (void)
   int c, c1, c2;
   charclass ccl;
 
+  /* Used to warn about [:space:].
+     Bit 0 = first character is a colon.
+     Bit 1 = last character is a colon.
+     Bit 2 = includes any other character but a colon.
+     Bit 3 = includes ranges, char/equiv classes or collation elements.  */
+  int colon_warning_state;
+
 #if MBS_SUPPORT
   wint_t wc, wc1, wc2;
 
@@ -790,9 +797,11 @@ parse_bracket_exp (void)
   else
     invert = 0;
 
+  colon_warning_state = (c == ':');
   do
     {
       c1 = EOF; /* mark c1 is not initialized".  */
+      colon_warning_state &= ~2;
 
       /* Note that if we're looking at some other [:...:] construct,
          we just treat it as a bunch of ordinary characters.  We can do
@@ -890,6 +899,7 @@ parse_bracket_exp (void)
                     }
                 }
 #endif
+              colon_warning_state |= 8;
 
               /* Fetch new lookahead character.  */
               FETCH_WC (c1, wc1, _("unbalanced ["));
@@ -975,10 +985,13 @@ parse_bracket_exp (void)
                     setbit_case_fold (c, ccl);
             }
 
+          colon_warning_state |= 8;
           FETCH_WC(c1, wc1, _("unbalanced ["));
           continue;
         }
 
+      colon_warning_state |= (c == ':') ? 2 : 4;
+
 #if MBS_SUPPORT
       /* Build normal characters.  */
       setbit_case_fold (wc, ccl);
@@ -1018,6 +1031,9 @@ parse_bracket_exp (void)
 #endif
          (c = c1) != ']'));
 
+  if (colon_warning_state == 7)
+    dfawarn (_("character class syntax is [[:space:]], not [:space:]"));
+
 #if MBS_SUPPORT
   if (MB_CUR_MAX > 1
       && (!using_utf8()
diff --git a/src/dfa.h b/src/dfa.h
index 0a8ad42..b8f3078 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -90,6 +90,12 @@ extern void dfastate (int, struct dfa *, int []);
 
 /* Error handling. */
 
+/* dfawarn() is called by the regexp routines whenever a regex is compiled
+   that likely doesn't do what the user wanted.  It takes a single
+   argument, a NUL-terminated string describing the situation.  The user
+   must supply a dfawarn.  */
+extern void dfawarn (const char *);
+
 /* dfaerror() is called by the regexp routines whenever an error occurs.  It
    takes a single argument, a NUL-terminated string describing the error.
    The user must supply a dfaerror.  */
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 4ccb6dc..29a1f7e 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -46,6 +46,13 @@ static struct patterns *patterns;
 static size_t pcount;
 
 void
+dfawarn (char const *mesg)
+{
+  if (warnings)
+    error (0, 0, _("warning: %s"), mesg);
+}
+
+void
 dfaerror (char const *mesg)
 {
   error (EXIT_TROUBLE, 0, "%s", mesg);

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

Summary of changes:
 NEWS                    |    9 ++++++
 src/dfa.c               |   16 +++++++++++
 src/dfa.h               |    6 ++++
 src/dfasearch.c         |    7 +++++
 src/grep.h              |    2 +
 src/main.c              |   67 ++++++++++++++++++++++++++++++++++++++++-------
 tests/Makefile.am       |    1 +
 tests/warn-char-classes |   46 ++++++++++++++++++++++++++++++++
 8 files changed, 144 insertions(+), 10 deletions(-)
 create mode 100644 tests/warn-char-classes


hooks/post-receive
-- 
grep



reply via email to

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