From 8f4a4913211b71674b7b75ee47e806ee6ad5bccb Mon Sep 17 00:00:00 2001 From: Norihiro Tanaka Date: Fri, 28 Feb 2014 23:31:33 +0900 Subject: [PATCH] Avoid matching line-by-line for case-insensitive with grep and awk matcher. --- src/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 56ec6b3..3a53ee4 100644 --- a/src/main.c +++ b/src/main.c @@ -355,6 +355,8 @@ int match_words; int match_lines; unsigned char eolbyte; +static char const *matcher; + /* For error messages. */ /* The input file name, or (if standard input) "-" or a --label argument. */ static char const *filename; @@ -1072,7 +1074,9 @@ do_execute (char const *buf, size_t size, size_t *match_size, to struct matcher to split the buffer passed to execute. It would perform the memchr if line-by-line matching is necessary, or just return buf + size otherwise. */ - if (MB_CUR_MAX == 1 || !match_icase) + if (MB_CUR_MAX == 1 || !match_icase + || ! (matcher + && (STREQ (matcher, "fgrep") || STREQ (matcher, "pcre")))) return execute (buf, size, match_size, start_ptr); for (line_next = buf; line_next < buf + size; ) @@ -1643,8 +1647,6 @@ if any error occurs and -q is not given, the exit status is 2.\n")); exit (status); } -static char const *matcher; - /* If M is NULL, initialize the matcher to the default. Otherwise set the matcher to M if available. Exit in case of conflicts or if M is not available. */ -- 1.8.5.2