>From 0ede35a6cd21093560de8bd9843263ba199abf1f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 7 Sep 2020 17:20:11 -0700 Subject: [PATCH 3/4] Simplify pattern_file_name * src/grep.c (pattern_file_name): Make first argument origin-0, not origin-1, as this simplifies both caller and callee. All uses changed. --- src/dfasearch.c | 2 +- src/grep.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dfasearch.c b/src/dfasearch.c index 2ddab33..256cd39 100644 --- a/src/dfasearch.c +++ b/src/dfasearch.c @@ -164,7 +164,7 @@ regex_compile (struct dfa_comp *dc, char const *p, ptrdiff_t len, /* Emit a filename:lineno: prefix for patterns taken from files. */ size_t pat_lineno; char const *pat_filename - = lineno < 0 ? "" : pattern_file_name (lineno + 1, &pat_lineno); + = lineno < 0 ? "" : pattern_file_name (lineno, &pat_lineno); if (*pat_filename == '\0') error (0, 0, "%s", err); diff --git a/src/grep.c b/src/grep.c index c359ea9..ce2f291 100644 --- a/src/grep.c +++ b/src/grep.c @@ -199,7 +199,7 @@ update_patterns (char *keys, ptrdiff_t dupfree_size, ptrdiff_t size, return dst - keys; } -/* Map LINENO, the origin-1 line number of one of the input patterns, +/* Map LINENO, the origin-0 line number of one of the input patterns, to the name of the file from which it came. Return "-" if it was read from stdin, "" if it was specified on the command line. Set *NEW_LINENO to the origin-1 line number of PATTERN in the file, @@ -207,7 +207,6 @@ update_patterns (char *keys, ptrdiff_t dupfree_size, ptrdiff_t size, char const * _GL_ATTRIBUTE_PURE pattern_file_name (size_t lineno, size_t *new_lineno) { - lineno--; ptrdiff_t i; for (i = 1; i < patlocs_used; i++) if (lineno < patloc[i].lineno) -- 2.17.1