From 52996da41c9d430ac4d9a6932634fd12495bb8f2 Mon Sep 17 00:00:00 2001 From: Norihiro Tanaka Date: Wed, 23 Sep 2020 07:33:32 +0900 Subject: [PATCH] grep: fix a bug in the previous commit * src/kwsearch.c (struct kwsearch): Add new member. (Fexecute): Use it. --- src/kwsearch.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/kwsearch.c b/src/kwsearch.c index 1174dbc..820352b 100644 --- a/src/kwsearch.c +++ b/src/kwsearch.c @@ -38,6 +38,9 @@ struct kwsearch char *pattern; size_t size; + /* True when the precision of either -o or --color is required. */ + bool exact; + /* The user's pattern compiled as a regular expression, or null if it has not been compiled. */ void *re; @@ -128,6 +131,7 @@ Fcompile (char *pattern, size_t size, reg_syntax_t ignored, bool exact) kwsearch->words = words; kwsearch->pattern = pattern; kwsearch->size = size; + kwsearch->exact = exact; kwsearch->re = NULL; return kwsearch; } @@ -178,7 +182,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t *match_size, { fgrep_to_grep_pattern (&kwsearch->pattern, &kwsearch->size); kwsearch->re = GEAcompile (kwsearch->pattern, kwsearch->size, - RE_SYNTAX_GREP, !!start_ptr); + RE_SYNTAX_GREP, kwsearch->exact); } return EGexecute (kwsearch->re, buf, size, match_size, start_ptr); } @@ -245,7 +249,7 @@ Fexecute (void *vcp, char const *buf, size_t size, size_t *match_size, fgrep_to_grep_pattern (&kwsearch->pattern, &kwsearch->size); kwsearch->re = GEAcompile (kwsearch->pattern, kwsearch->size, - RE_SYNTAX_GREP, !!start_ptr); + RE_SYNTAX_GREP, kwsearch->exact); } if (beg + len < buf + size) { -- 1.7.1