From 37d7b0a2bfb30d6c1c113029c2b6d2b4e045d145 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 16 Oct 2015 22:39:51 -0700 Subject: [PATCH 4/5] grep: simplify previous change * src/grep.c (main): Simplify recently-changed grep -Fw test. --- src/grep.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/grep.c b/src/grep.c index 0ca0d9a..2c5e09a 100644 --- a/src/grep.c +++ b/src/grep.c @@ -2561,14 +2561,15 @@ main (int argc, char **argv) build_mbclen_cache (); init_easy_encoding (); - /* If fgrep in a multibyte locale, then use grep if either + /* In a unibyte locale, switch from fgrep to grep if + the pattern matches words (where grep is typically faster). + In a multibyte locale, switch from fgrep to grep if either (1) case is ignored (where grep is typically faster), or - (2) the pattern matches words (where grep is typically faster), or - (3) the pattern has an encoding error (where fgrep might not work). */ + (2) the pattern has an encoding error (where fgrep might not work). */ if (compile == Fcompile - && (MB_CUR_MAX > 1 && (match_icase - || contains_encoding_error (keys, keycc))) - || (MB_CUR_MAX == 1 && match_words)) + && (MB_CUR_MAX <= 1 + ? match_words + : match_icase || contains_encoding_error (keys, keycc))) { size_t new_keycc; char *new_keys; -- 2.1.4