grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.25-38-gf13c169


From: Jim Meyering
Subject: grep branch, master, updated. v2.25-38-gf13c169
Date: Tue, 26 Jul 2016 05:58:46 +0000 (UTC)

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  f13c169e13aed279baa00d9ced9d93fe24775493 (commit)
       via  4443fda05ace21b2a2da2d80b09313cc976afe59 (commit)
      from  5a9640cf2a36da39abbda98a4e9aa956d3951f9f (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=f13c169e13aed279baa00d9ced9d93fe24775493


commit f13c169e13aed279baa00d9ced9d93fe24775493
Author: Jim Meyering <address@hidden>
Date:   Sat Jul 16 10:51:31 2016 -0700

    grep: print "filename:lineno:" in invalid-regex diagnostic
    
    Determining the file name and line number is a little tricky because
    of the way the regular expressions are all concatenated onto a newline-
    separated list.  By the time grep would compile regular expressions,
    the <filename,lineno> origin of each regexp was no longer available.
    This patch adds a list of filename,first_lineno pairs, one per input
    source, by which we can then map the ordinal regexp number to a
    filename,lineno pair for the diagnostic.
    
    * src/dfasearch.c (GEAcompile): When diagnosing an invalid regexp
    specified via -f FILE, include the "FILENAME:LINENO: " prefix.
    Also, when there are two or more lines with compilation failures,
    diagnose all of them, rather than stopping after the first.
    * src/grep.h (pattern_file_name): Declare it.
    * src/grep.c: (struct FL_pair): Define type.
    (fl_pair, n_fl_pair_slots, n_pattern_files, patfile_lineno):
    Define globals.
    (fl_add, pattern_file_name): Define functions.
    (main): Call fl_add for each type of the following: -e argument,
    -f argument, command-line-specified (without -e) regexp.
    * tests/filename-lineno.pl: New file.
    * tests/Makefile.am (TESTS): Add it.
    * NEWS (Improvements): Mention this.
    Initially reported by Gunnar Wolf in https://bugs.debian.org/525214
    Forwarded to grep's bug list by Santiago Ruano Rincón as
    http://debbugs.gnu.org/23965

diff --git a/NEWS b/NEWS
index c3e6000..44b6fdf 100644
--- a/NEWS
+++ b/NEWS
@@ -6,12 +6,13 @@ GNU grep NEWS                                    -*- outline 
-*-
 
   grep can be much faster now when standard output is /dev/null.
 
-** Improvements
-
   grep -F is now typically much faster when many patterns are given,
   as it now uses the Aho-Corasick algorithm instead of the
   Commentz-Walter algorithm in that case.
 
+  grep now prints a "FILENAME:LINENO: " prefix when diagnosing an
+  invalid regular expression that was read from an '-f'-specified file.
+
 
 * Noteworthy changes in release 2.25 (2016-04-21) [stable]
 
diff --git a/src/dfasearch.c b/src/dfasearch.c
index fbf0fac..9a523c8 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -135,6 +135,7 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t 
syntax_bits)
      this should be a syntax error.  The same for backref, where the
      backref should be local to each pattern.  */
   char const *p = pattern;
+  bool compilation_failed = false;
   do
     {
       size_t len;
@@ -157,12 +158,25 @@ GEAcompile (char const *pattern, size_t size, 
reg_syntax_t syntax_bits)
       char const *err = re_compile_pattern (p, len,
                                             &(patterns[pcount].regexbuf));
       if (err)
-        error (EXIT_TROUBLE, 0, "%s", err);
+        {
+          /* With patterns specified only on the command line, emit the bare
+             diagnostic.  Otherwise, include a filename:lineno: prefix.  */
+          size_t lineno;
+          char const *pat_filename = pattern_file_name (pcount + 1, &lineno);
+          if (*pat_filename == '\0')
+            error (0, 0, "%s", err);
+          else
+            error (0, 0, "%s:%zu: %s", pat_filename, lineno, err);
+          compilation_failed = true;
+        }
       pcount++;
       p = sep;
     }
   while (p);
 
+  if (compilation_failed)
+    exit (EXIT_TROUBLE);
+
   /* In the match_words and match_lines cases, we use a different pattern
      for the DFA matcher that will quickly throw out cases that won't work.
      Then if DFA succeeds we do some hairy stuff using the regex matcher
diff --git a/src/grep.c b/src/grep.c
index 302e4d7..a82da61 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -81,6 +81,85 @@ static bool only_matching;
 /* If nonzero, make sure first content char in a line is on a tab stop. */
 static bool align_tabs;
 
+/* See below */
+struct FL_pair
+  {
+    char const *filename;
+    size_t lineno;
+  };
+
+/* A list of lineno,filename pairs corresponding to -f FILENAME
+   arguments. Since we store the concatenation of all patterns in
+   a single array, KEYS, be they from the command line via "-e PAT"
+   or read from one or more -f-specified FILENAMES.  Given this
+   invocation, grep -f <(seq 5) -f <(seq 2) -f <(seq 3) FILE, there
+   will be three entries in LF_PAIR: {1, x} {6, y} {8, z}, where
+   x, y and z are just place-holders for shell-generated names.  */
+static struct FL_pair *fl_pair;
+static size_t n_fl_pair_slots;
+/* Count not only -f-specified files, but also individual -e operands
+   and any command-line argument that serves as a regular expression.  */
+static size_t n_pattern_files;
+
+/* Given the concatenation of all patterns, one per line, be they
+   specified via -e, a lone command-line argument or -f, this is the
+   number of the first line of each entity, in that concatenation.
+   It is advanced by fl_add and, when needed, used in pattern_file_name
+   to derive a file-relative line number.  */
+static uintmax_t patfile_lineno = 1;
+
+/* Return the number of newline bytes in BUF starting at offset BEG
+   and up to and not including offset END.  */
+static size_t _GL_ATTRIBUTE_PURE
+count_nl_bytes (char const *buf, size_t beg, size_t end)
+{
+  char const *p = buf + beg;
+  char const *end_p = buf + end;
+  uintmax_t n = 0;
+  while (true)
+    {
+      p = memchr (p, '\n', end_p - p);
+      if (!p)
+        break;
+      p++;
+      n++;
+    }
+  return n;
+}
+
+/* Append a FILENAME,line-number pair to FL_PAIR.  The line number we save
+   with FILENAME is the initial value of the global PATFILE_LINENO.
+   PATFILE_LINENO is then incremented by the number of newlines in BUF
+   from offset BEG up to but not including offset END.  */
+static void
+fl_add (char const *buf, size_t beg, size_t end, char const *filename)
+{
+  if (n_fl_pair_slots <= n_pattern_files)
+    fl_pair = x2nrealloc (fl_pair, &n_fl_pair_slots, sizeof *fl_pair);
+
+  fl_pair[n_pattern_files].lineno = patfile_lineno;
+  fl_pair[n_pattern_files].filename = filename;
+  n_pattern_files++;
+  patfile_lineno += count_nl_bytes (buf, beg, end);
+}
+
+/* Map the line number, LINENO, of one of the input patterns to the
+   name of the file from which it came.  If it was read from stdin
+   or if it was specified on the command line, return "-".  */
+char const * _GL_ATTRIBUTE_PURE
+pattern_file_name (size_t lineno, size_t *new_lineno)
+{
+  size_t i;
+  for (i = 1; i < n_pattern_files; i++)
+    {
+      if (lineno < fl_pair[i].lineno)
+        break;
+    }
+
+  *new_lineno = lineno - fl_pair[i - 1].lineno + 1;
+  return fl_pair[i - 1].filename;
+}
+
 #if HAVE_ASAN
 /* Record the starting address and length of the sole poisoned region,
    so that we can unpoison it later, just before each following read.  */
@@ -2381,6 +2460,7 @@ main (int argc, char **argv)
         strcpy (&keys[keycc], optarg);
         keycc += cc;
         keys[keycc++] = '\n';
+        fl_add (keys, keycc - cc - 1, keycc, "");
         break;
 
       case 'f':
@@ -2405,6 +2485,7 @@ main (int argc, char **argv)
         /* Append final newline if file ended in non-newline. */
         if (oldcc != keycc && keys[keycc - 1] != '\n')
           keys[keycc++] = '\n';
+        fl_add (keys, oldcc, keycc, xstrdup (optarg));
         break;
 
       case 'h':
@@ -2645,6 +2726,7 @@ main (int argc, char **argv)
       /* A copy must be made in case of an xrealloc() or free() later.  */
       keycc = strlen (argv[optind]);
       keys = xmemdup (argv[optind++], keycc + 1);
+      fl_add (keys, 0, keycc, "");
     }
   else
     usage (EXIT_TROUBLE);
diff --git a/src/grep.h b/src/grep.h
index 75b7ef7..b45992f 100644
--- a/src/grep.h
+++ b/src/grep.h
@@ -30,5 +30,6 @@ extern bool match_lines;      /* -x */
 extern char eolbyte;           /* -z */
 
 extern bool buf_has_encoding_errors (char *, size_t);
+extern char const *pattern_file_name (size_t, size_t *);
 
 #endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 03cfdbb..77502ca 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -99,6 +99,7 @@ TESTS =                                               \
   fedora                                       \
   fgrep-infloop                                        \
   file                                         \
+  filename-lineno.pl                           \
   fmbtest                                      \
   foad1                                                \
   grep-dev-null                                        \
diff --git a/tests/filename-lineno.pl b/tests/filename-lineno.pl
new file mode 100755
index 0000000..3827f4d
--- /dev/null
+++ b/tests/filename-lineno.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+# Prior to 2.26, an invalid regexp in a -f-specified file would elicit
+# a diagnostic like "Unmatched [ or [^", with no indication of the
+# file or line number from which the offending regular expression came.
+# With 2.26, now, each such diagnostic has a "FILENAME:LINENO: " prefix.
+
+# Copyright (C) 2016 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+(my $program_name = $0) =~ s|.*/||;
+
+my $prog = 'grep';
+
+# Turn off localization of executable's output.
address@hidden(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+# There are at least two variants of one diagnostic:
+#   - Unmatched [, [^, [:, [., or [=
+#   - Unmatched [ or [^
+# Transform each to this: "Unmatched [..."
+my $err_subst = {ERR_SUBST => 's/(: Unmatched \[).*/$1.../'};
+
+my @Tests =
+  (
+   # Show that grep now includes filename:lineno in the diagnostic:
+   ['invalid-re', '-f g', {AUX=>{g=>"1\n2\n3\n4[[\n"}}, {EXIT=>2},
+    $err_subst,
+    {ERR => "$prog: g:4: Unmatched [...\n"},
+   ],
+
+   # Show that with two or more errors, grep now prints all diagnostics:
+   ['invalid-re-2-files', '-f g -f h', {EXIT=>2},
+    {AUX=>{g=>"1\n2[[\n3\n4[[\n"}},
+    {AUX=>{h=>"\n\n[[\n"}},
+    $err_subst,
+    {ERR => "$prog: g:2: Unmatched [...\n"
+         . "$prog: g:4: Unmatched [...\n"
+         . "$prog: h:3: Unmatched [...\n"
+    },
+   ],
+
+   # Like the above, but on the other lines.
+   ['invalid-re-2-files2', '-f g -f h', {EXIT=>2},
+    {AUX=>{g=>"1[[\n2\n3[[\n4\n"}},
+    {AUX=>{h=>"[[\n[[\n\n"}},
+    $err_subst,
+    {ERR => "$prog: g:1: Unmatched [...\n"
+         . "$prog: g:3: Unmatched [...\n"
+         . "$prog: h:1: Unmatched [...\n"
+         . "$prog: h:2: Unmatched [...\n"
+    },
+   ],
+
+   # Show that with two '-e'-specified erroneous regexps,
+   # there is no file name or line number.
+   ['invalid-re-2e', '-e "[[" -e "[["', {EXIT=>2},
+    $err_subst,
+    {ERR => "$prog: Unmatched [...\n" x 2},
+   ],
+  );
+
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($program_name, $prog, address@hidden, $save_temps, 
$verbose);
+exit $fail;

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


commit f13c169e13aed279baa00d9ced9d93fe24775493
Author: Jim Meyering <address@hidden>
Date:   Sat Jul 16 10:51:31 2016 -0700

    grep: print "filename:lineno:" in invalid-regex diagnostic
    
    Determining the file name and line number is a little tricky because
    of the way the regular expressions are all concatenated onto a newline-
    separated list.  By the time grep would compile regular expressions,
    the <filename,lineno> origin of each regexp was no longer available.
    This patch adds a list of filename,first_lineno pairs, one per input
    source, by which we can then map the ordinal regexp number to a
    filename,lineno pair for the diagnostic.
    
    * src/dfasearch.c (GEAcompile): When diagnosing an invalid regexp
    specified via -f FILE, include the "FILENAME:LINENO: " prefix.
    Also, when there are two or more lines with compilation failures,
    diagnose all of them, rather than stopping after the first.
    * src/grep.h (pattern_file_name): Declare it.
    * src/grep.c: (struct FL_pair): Define type.
    (fl_pair, n_fl_pair_slots, n_pattern_files, patfile_lineno):
    Define globals.
    (fl_add, pattern_file_name): Define functions.
    (main): Call fl_add for each type of the following: -e argument,
    -f argument, command-line-specified (without -e) regexp.
    * tests/filename-lineno.pl: New file.
    * tests/Makefile.am (TESTS): Add it.
    * NEWS (Improvements): Mention this.
    Initially reported by Gunnar Wolf in https://bugs.debian.org/525214
    Forwarded to grep's bug list by Santiago Ruano Rincón as
    http://debbugs.gnu.org/23965

diff --git a/NEWS b/NEWS
index c3e6000..44b6fdf 100644
--- a/NEWS
+++ b/NEWS
@@ -6,12 +6,13 @@ GNU grep NEWS                                    -*- outline 
-*-
 
   grep can be much faster now when standard output is /dev/null.
 
-** Improvements
-
   grep -F is now typically much faster when many patterns are given,
   as it now uses the Aho-Corasick algorithm instead of the
   Commentz-Walter algorithm in that case.
 
+  grep now prints a "FILENAME:LINENO: " prefix when diagnosing an
+  invalid regular expression that was read from an '-f'-specified file.
+
 
 * Noteworthy changes in release 2.25 (2016-04-21) [stable]
 
diff --git a/src/dfasearch.c b/src/dfasearch.c
index fbf0fac..9a523c8 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -135,6 +135,7 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t 
syntax_bits)
      this should be a syntax error.  The same for backref, where the
      backref should be local to each pattern.  */
   char const *p = pattern;
+  bool compilation_failed = false;
   do
     {
       size_t len;
@@ -157,12 +158,25 @@ GEAcompile (char const *pattern, size_t size, 
reg_syntax_t syntax_bits)
       char const *err = re_compile_pattern (p, len,
                                             &(patterns[pcount].regexbuf));
       if (err)
-        error (EXIT_TROUBLE, 0, "%s", err);
+        {
+          /* With patterns specified only on the command line, emit the bare
+             diagnostic.  Otherwise, include a filename:lineno: prefix.  */
+          size_t lineno;
+          char const *pat_filename = pattern_file_name (pcount + 1, &lineno);
+          if (*pat_filename == '\0')
+            error (0, 0, "%s", err);
+          else
+            error (0, 0, "%s:%zu: %s", pat_filename, lineno, err);
+          compilation_failed = true;
+        }
       pcount++;
       p = sep;
     }
   while (p);
 
+  if (compilation_failed)
+    exit (EXIT_TROUBLE);
+
   /* In the match_words and match_lines cases, we use a different pattern
      for the DFA matcher that will quickly throw out cases that won't work.
      Then if DFA succeeds we do some hairy stuff using the regex matcher
diff --git a/src/grep.c b/src/grep.c
index 302e4d7..a82da61 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -81,6 +81,85 @@ static bool only_matching;
 /* If nonzero, make sure first content char in a line is on a tab stop. */
 static bool align_tabs;
 
+/* See below */
+struct FL_pair
+  {
+    char const *filename;
+    size_t lineno;
+  };
+
+/* A list of lineno,filename pairs corresponding to -f FILENAME
+   arguments. Since we store the concatenation of all patterns in
+   a single array, KEYS, be they from the command line via "-e PAT"
+   or read from one or more -f-specified FILENAMES.  Given this
+   invocation, grep -f <(seq 5) -f <(seq 2) -f <(seq 3) FILE, there
+   will be three entries in LF_PAIR: {1, x} {6, y} {8, z}, where
+   x, y and z are just place-holders for shell-generated names.  */
+static struct FL_pair *fl_pair;
+static size_t n_fl_pair_slots;
+/* Count not only -f-specified files, but also individual -e operands
+   and any command-line argument that serves as a regular expression.  */
+static size_t n_pattern_files;
+
+/* Given the concatenation of all patterns, one per line, be they
+   specified via -e, a lone command-line argument or -f, this is the
+   number of the first line of each entity, in that concatenation.
+   It is advanced by fl_add and, when needed, used in pattern_file_name
+   to derive a file-relative line number.  */
+static uintmax_t patfile_lineno = 1;
+
+/* Return the number of newline bytes in BUF starting at offset BEG
+   and up to and not including offset END.  */
+static size_t _GL_ATTRIBUTE_PURE
+count_nl_bytes (char const *buf, size_t beg, size_t end)
+{
+  char const *p = buf + beg;
+  char const *end_p = buf + end;
+  uintmax_t n = 0;
+  while (true)
+    {
+      p = memchr (p, '\n', end_p - p);
+      if (!p)
+        break;
+      p++;
+      n++;
+    }
+  return n;
+}
+
+/* Append a FILENAME,line-number pair to FL_PAIR.  The line number we save
+   with FILENAME is the initial value of the global PATFILE_LINENO.
+   PATFILE_LINENO is then incremented by the number of newlines in BUF
+   from offset BEG up to but not including offset END.  */
+static void
+fl_add (char const *buf, size_t beg, size_t end, char const *filename)
+{
+  if (n_fl_pair_slots <= n_pattern_files)
+    fl_pair = x2nrealloc (fl_pair, &n_fl_pair_slots, sizeof *fl_pair);
+
+  fl_pair[n_pattern_files].lineno = patfile_lineno;
+  fl_pair[n_pattern_files].filename = filename;
+  n_pattern_files++;
+  patfile_lineno += count_nl_bytes (buf, beg, end);
+}
+
+/* Map the line number, LINENO, of one of the input patterns to the
+   name of the file from which it came.  If it was read from stdin
+   or if it was specified on the command line, return "-".  */
+char const * _GL_ATTRIBUTE_PURE
+pattern_file_name (size_t lineno, size_t *new_lineno)
+{
+  size_t i;
+  for (i = 1; i < n_pattern_files; i++)
+    {
+      if (lineno < fl_pair[i].lineno)
+        break;
+    }
+
+  *new_lineno = lineno - fl_pair[i - 1].lineno + 1;
+  return fl_pair[i - 1].filename;
+}
+
 #if HAVE_ASAN
 /* Record the starting address and length of the sole poisoned region,
    so that we can unpoison it later, just before each following read.  */
@@ -2381,6 +2460,7 @@ main (int argc, char **argv)
         strcpy (&keys[keycc], optarg);
         keycc += cc;
         keys[keycc++] = '\n';
+        fl_add (keys, keycc - cc - 1, keycc, "");
         break;
 
       case 'f':
@@ -2405,6 +2485,7 @@ main (int argc, char **argv)
         /* Append final newline if file ended in non-newline. */
         if (oldcc != keycc && keys[keycc - 1] != '\n')
           keys[keycc++] = '\n';
+        fl_add (keys, oldcc, keycc, xstrdup (optarg));
         break;
 
       case 'h':
@@ -2645,6 +2726,7 @@ main (int argc, char **argv)
       /* A copy must be made in case of an xrealloc() or free() later.  */
       keycc = strlen (argv[optind]);
       keys = xmemdup (argv[optind++], keycc + 1);
+      fl_add (keys, 0, keycc, "");
     }
   else
     usage (EXIT_TROUBLE);
diff --git a/src/grep.h b/src/grep.h
index 75b7ef7..b45992f 100644
--- a/src/grep.h
+++ b/src/grep.h
@@ -30,5 +30,6 @@ extern bool match_lines;      /* -x */
 extern char eolbyte;           /* -z */
 
 extern bool buf_has_encoding_errors (char *, size_t);
+extern char const *pattern_file_name (size_t, size_t *);
 
 #endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 03cfdbb..77502ca 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -99,6 +99,7 @@ TESTS =                                               \
   fedora                                       \
   fgrep-infloop                                        \
   file                                         \
+  filename-lineno.pl                           \
   fmbtest                                      \
   foad1                                                \
   grep-dev-null                                        \
diff --git a/tests/filename-lineno.pl b/tests/filename-lineno.pl
new file mode 100755
index 0000000..3827f4d
--- /dev/null
+++ b/tests/filename-lineno.pl
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+# Prior to 2.26, an invalid regexp in a -f-specified file would elicit
+# a diagnostic like "Unmatched [ or [^", with no indication of the
+# file or line number from which the offending regular expression came.
+# With 2.26, now, each such diagnostic has a "FILENAME:LINENO: " prefix.
+
+# Copyright (C) 2016 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+(my $program_name = $0) =~ s|.*/||;
+
+my $prog = 'grep';
+
+# Turn off localization of executable's output.
address@hidden(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+
+# There are at least two variants of one diagnostic:
+#   - Unmatched [, [^, [:, [., or [=
+#   - Unmatched [ or [^
+# Transform each to this: "Unmatched [..."
+my $err_subst = {ERR_SUBST => 's/(: Unmatched \[).*/$1.../'};
+
+my @Tests =
+  (
+   # Show that grep now includes filename:lineno in the diagnostic:
+   ['invalid-re', '-f g', {AUX=>{g=>"1\n2\n3\n4[[\n"}}, {EXIT=>2},
+    $err_subst,
+    {ERR => "$prog: g:4: Unmatched [...\n"},
+   ],
+
+   # Show that with two or more errors, grep now prints all diagnostics:
+   ['invalid-re-2-files', '-f g -f h', {EXIT=>2},
+    {AUX=>{g=>"1\n2[[\n3\n4[[\n"}},
+    {AUX=>{h=>"\n\n[[\n"}},
+    $err_subst,
+    {ERR => "$prog: g:2: Unmatched [...\n"
+         . "$prog: g:4: Unmatched [...\n"
+         . "$prog: h:3: Unmatched [...\n"
+    },
+   ],
+
+   # Like the above, but on the other lines.
+   ['invalid-re-2-files2', '-f g -f h', {EXIT=>2},
+    {AUX=>{g=>"1[[\n2\n3[[\n4\n"}},
+    {AUX=>{h=>"[[\n[[\n\n"}},
+    $err_subst,
+    {ERR => "$prog: g:1: Unmatched [...\n"
+         . "$prog: g:3: Unmatched [...\n"
+         . "$prog: h:1: Unmatched [...\n"
+         . "$prog: h:2: Unmatched [...\n"
+    },
+   ],
+
+   # Show that with two '-e'-specified erroneous regexps,
+   # there is no file name or line number.
+   ['invalid-re-2e', '-e "[[" -e "[["', {EXIT=>2},
+    $err_subst,
+    {ERR => "$prog: Unmatched [...\n" x 2},
+   ],
+  );
+
+my $save_temps = $ENV{DEBUG};
+my $verbose = $ENV{VERBOSE};
+
+my $fail = run_tests ($program_name, $prog, address@hidden, $save_temps, 
$verbose);
+exit $fail;

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

Summary of changes:
 NEWS                                  |    5 +-
 configure.ac                          |    7 +
 src/dfasearch.c                       |   16 +-
 src/grep.c                            |   82 +++++
 src/grep.h                            |    1 +
 tests/Coreutils.pm                    |  620 +++++++++++++++++++++++++++++++++
 tests/{dfa-heap-overrun => CuSkip.pm} |   35 +-
 tests/CuTmpdir.pm                     |  111 ++++++
 tests/Makefile.am                     |   25 ++
 tests/filename-lineno.pl              |   80 +++++
 tests/no-perl                         |    6 +
 11 files changed, 974 insertions(+), 14 deletions(-)
 create mode 100644 tests/Coreutils.pm
 copy tests/{dfa-heap-overrun => CuSkip.pm} (52%)
 mode change 100755 => 100644
 create mode 100644 tests/CuTmpdir.pm
 create mode 100755 tests/filename-lineno.pl
 create mode 100644 tests/no-perl


hooks/post-receive
-- 
grep



reply via email to

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