From 8443e177c3b2bfc939b1e3cb921f6f5978a5112c Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Dec 16 2004 17:15:31 +0000 Subject: - Bypass kwset matching when ignoring case and processing multibyte input (bug #143079). --- diff --git a/grep-2.5.1-egf-speedup.patch b/grep-2.5.1-egf-speedup.patch index ab840af..87e4dee 100644 --- a/grep-2.5.1-egf-speedup.patch +++ b/grep-2.5.1-egf-speedup.patch @@ -1,5 +1,5 @@ ---- grep-2.5.1/src/search.c 2004-12-14 15:08:58.985159277 +0000 -+++ grep-2.5.1/src/search.c 2004-12-14 15:55:21.257729918 +0000 +--- grep-2.5.1/src/search.c 2004-12-14 15:55:21.257729918 +0000 ++++ grep-2.5.1/src/search.c 2004-12-16 16:53:01.110921088 +0000 @@ -39,6 +39,9 @@ #ifdef HAVE_LIBPCRE # include @@ -125,14 +125,23 @@ #endif /* MBS_SUPPORT */ buflim = buf + size; -@@ -373,18 +337,48 @@ +@@ -373,18 +337,56 @@ if (kwset) { /* Find a possible match using the KWset matcher. */ +- size_t offset = kwsexec (kwset, beg, buflim - beg, &kwsm); +#ifdef MBS_SUPPORT + size_t bytes_left = 0; +#endif /* MBS_SUPPORT */ - size_t offset = kwsexec (kwset, beg, buflim - beg, &kwsm); ++ size_t offset; ++ /* kwsexec doesn't work with match_icase and multibyte input. */ ++#ifdef MBS_SUPPORT ++ if (match_icase && MB_CUR_MAX > 1) ++ /* Avoid kwset */ ++ offset = 0; ++ else ++#endif /* MBS_SUPPORT */ ++ offset = kwsexec (kwset, beg, buflim - beg, &kwsm); if (offset == (size_t) -1) goto failure; +#ifdef MBS_SUPPORT @@ -176,7 +185,7 @@ while (beg > buf && beg[-1] != eol) --beg; if (kwsm.index < kwset_exact_matches) -@@ -395,13 +389,47 @@ +@@ -395,13 +397,47 @@ else { /* No good fixed strings; start with DFA. */ @@ -224,7 +233,7 @@ while (beg > buf && beg[-1] != eol) --beg; } -@@ -469,15 +497,6 @@ +@@ -469,15 +505,6 @@ } /* for (beg = end ..) */ failure: @@ -240,7 +249,7 @@ return (size_t) -1; success_in_beg_and_end: -@@ -486,15 +505,6 @@ +@@ -486,15 +513,6 @@ /* FALLTHROUGH */ success_in_start_and_len: @@ -256,7 +265,7 @@ *match_size = len; return start; } -@@ -504,6 +514,7 @@ +@@ -504,6 +522,7 @@ { char const *beg, *lim, *err; @@ -264,7 +273,7 @@ kwsinit (); beg = pattern; do -@@ -531,17 +542,8 @@ +@@ -531,17 +550,8 @@ struct kwsmatch kwsmatch; size_t ret_val; #ifdef MBS_SUPPORT @@ -284,7 +293,7 @@ #endif /* MBS_SUPPORT */ for (beg = buf; beg <= buf + size; ++beg) -@@ -550,8 +552,33 @@ +@@ -550,8 +560,33 @@ if (offset == (size_t) -1) goto failure; #ifdef MBS_SUPPORT @@ -320,7 +329,7 @@ #endif /* MBS_SUPPORT */ beg += offset; len = kwsmatch.size[0]; -@@ -587,6 +614,36 @@ +@@ -587,6 +622,36 @@ if (offset == -1) { break; /* Try a different anchor. */ } @@ -357,7 +366,7 @@ beg += offset; len = kwsmatch.size[0]; } -@@ -597,19 +654,31 @@ +@@ -597,19 +662,31 @@ } failure: @@ -397,7 +406,7 @@ end++; while (buf < beg && beg[-1] != eol) --beg; -@@ -618,15 +687,6 @@ +@@ -618,15 +695,6 @@ success_in_beg_and_len: *match_size = len;