diff --git a/grep-2.5.1-dfa-optional.patch b/grep-2.5.1-dfa-optional.patch index 4bc1272..784eba9 100644 --- a/grep-2.5.1-dfa-optional.patch +++ b/grep-2.5.1-dfa-optional.patch @@ -1,12 +1,13 @@ ---- grep-2.5.1/src/search.c 2004-11-07 20:11:07.437866925 +0000 -+++ grep-2.5.1/src/search.c 2004-11-10 09:40:44.994750111 +0000 -@@ -305,11 +305,33 @@ +--- grep-2.5.1a/src/search.c.dfa-optional 2005-01-07 14:58:45.714869815 +0000 ++++ grep-2.5.1a/src/search.c 2005-01-07 14:58:45.725867716 +0000 +@@ -327,12 +327,34 @@ int backref, start, len; struct kwsmatch kwsm; size_t i, ret_val; + static int use_dfa; + static int use_dfa_checked = 0; #ifdef MBS_SUPPORT + int mb_cur_max = MB_CUR_MAX; mbstate_t mbs; memset (&mbs, '\0', sizeof (mbstate_t)); #endif /* MBS_SUPPORT */ @@ -34,9 +35,9 @@ buflim = buf + size; for (beg = end = buf; end < buflim; beg = end) -@@ -365,7 +387,8 @@ - --beg; - if (kwsm.index < kwset_exact_matches) +@@ -400,7 +422,8 @@ + #endif /* MBS_SUPPORT */ + (kwsm.index < kwset_exact_matches)) goto success_in_beg_and_end; - if (dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1) + if (use_dfa && @@ -44,7 +45,7 @@ continue; } else -@@ -374,7 +397,9 @@ +@@ -409,7 +432,9 @@ #ifdef MBS_SUPPORT size_t bytes_left = 0; #endif /* MBS_SUPPORT */ @@ -55,7 +56,7 @@ if (offset == (size_t) -1) break; /* Narrow down to the line we've found. */ -@@ -416,7 +441,7 @@ +@@ -451,7 +476,7 @@ --beg; } /* Successful, no backreferences encountered! */ diff --git a/grep-2.5.1-egf-speedup.patch b/grep-2.5.1-egf-speedup.patch index 91ed22d..f684555 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.egf-speedup 2004-12-31 15:26:52.187199404 +0000 -+++ grep-2.5.1/src/search.c 2004-12-31 15:28:35.720391036 +0000 +--- grep-2.5.1/src/search.c 2004-12-31 15:28:35.720391036 +0000 ++++ grep-2.5.1a/src/search.c 2005-01-07 14:53:10.308860193 +0000 @@ -18,9 +18,13 @@ /* Written August 1992 by Mike Haertel. */ @@ -118,7 +118,7 @@ if (strcmp (matcher, "awk") == 0) { re_set_syntax (RE_SYNTAX_AWK | (match_icase ? RE_ICASE : 0)); -@@ -350,18 +328,8 @@ +@@ -350,18 +328,9 @@ struct kwsmatch kwsm; size_t i, ret_val; #ifdef MBS_SUPPORT @@ -134,12 +134,13 @@ - if (kwset) - mb_properties = check_multibyte_string(buf, size); - } ++ int mb_cur_max = MB_CUR_MAX; + mbstate_t mbs; + memset (&mbs, '\0', sizeof (mbstate_t)); #endif /* MBS_SUPPORT */ buflim = buf + size; -@@ -373,21 +341,63 @@ +@@ -373,21 +342,63 @@ if (kwset) { /* Find a possible match using the KWset matcher. */ @@ -150,7 +151,7 @@ + size_t offset; +#ifdef MBS_SUPPORT + /* kwsexec doesn't work with match_icase and multibyte input. */ -+ if (match_icase && MB_CUR_MAX > 1) ++ if (match_icase && mb_cur_max > 1) + /* Avoid kwset */ + offset = 0; + else @@ -159,7 +160,7 @@ if (offset == (size_t) -1) goto failure; +#ifdef MBS_SUPPORT -+ if (MB_CUR_MAX > 1 && !using_utf8) ++ if (mb_cur_max > 1 && !using_utf8) + { + bytes_left = offset; + while (bytes_left) @@ -192,7 +193,7 @@ end++; #ifdef MBS_SUPPORT - if (MB_CUR_MAX > 1 && mb_properties[beg - buf] == 0) -+ if (MB_CUR_MAX > 1 && bytes_left) ++ if (mb_cur_max > 1 && bytes_left) continue; -#endif +#endif /* MBS_SUPPORT */ @@ -201,13 +202,13 @@ - if (kwsm.index < kwset_exact_matches) + if ( +#ifdef MBS_SUPPORT -+ !(match_icase && MB_CUR_MAX > 1) && ++ !(match_icase && mb_cur_max > 1) && +#endif /* MBS_SUPPORT */ + (kwsm.index < kwset_exact_matches)) goto success_in_beg_and_end; if (dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1) continue; -@@ -395,13 +405,47 @@ +@@ -395,13 +406,47 @@ else { /* No good fixed strings; start with DFA. */ @@ -219,7 +220,7 @@ break; /* Narrow down to the line we've found. */ +#ifdef MBS_SUPPORT -+ if (MB_CUR_MAX > 1 && !using_utf8) ++ if (mb_cur_max > 1 && !using_utf8) + { + bytes_left = offset; + while (bytes_left) @@ -249,13 +250,13 @@ end = memchr (beg, eol, buflim - beg); end++; +#ifdef MBS_SUPPORT -+ if (MB_CUR_MAX > 1 && bytes_left) ++ if (mb_cur_max > 1 && bytes_left) + continue; +#endif /* MBS_SUPPORT */ while (beg > buf && beg[-1] != eol) --beg; } -@@ -469,15 +513,6 @@ +@@ -469,15 +514,6 @@ } /* for (beg = end ..) */ failure: @@ -271,7 +272,7 @@ return (size_t) -1; success_in_beg_and_end: -@@ -486,24 +521,143 @@ +@@ -486,24 +522,144 @@ /* FALLTHROUGH */ success_in_start_and_len: @@ -301,12 +302,13 @@ static void Fcompile (char const *pattern, size_t size) { ++ int mb_cur_max = MB_CUR_MAX; char const *beg, *lim, *err; + check_utf8 (); +#ifdef MBS_SUPPORT + /* Support -F -i for UTF-8 input. */ -+ if (match_icase && MB_CUR_MAX > 1) ++ if (match_icase && mb_cur_max > 1) + { + mbstate_t mbs; + wchar_t *wcpattern = xmalloc ((size + 1) * sizeof (wchar_t)); @@ -350,7 +352,7 @@ + if (!(fimb_kwset = kwsalloc (NULL))) + error (2, 0, _("memory exhausted")); + -+ starts = xmalloc (MB_CUR_MAX * 3); ++ starts = xmalloc (mb_cur_max * 3); + wcbeg = wcpattern; + do + { @@ -424,7 +426,7 @@ kwsinit (); beg = pattern; do -@@ -522,6 +676,76 @@ +@@ -522,6 +678,76 @@ error (2, 0, err); } @@ -501,7 +503,7 @@ static size_t Fexecute (char const *buf, size_t size, size_t *match_size, int exact) { -@@ -531,80 +755,258 @@ +@@ -531,80 +757,258 @@ struct kwsmatch kwsmatch; size_t ret_val; #ifdef MBS_SUPPORT @@ -803,7 +805,7 @@ end++; while (buf < beg && beg[-1] != eol) --beg; -@@ -613,15 +1015,6 @@ +@@ -613,15 +1017,6 @@ success_in_beg_and_len: *match_size = len; diff --git a/grep.spec b/grep.spec index b33230d..648c654 100644 --- a/grep.spec +++ b/grep.spec @@ -91,6 +91,7 @@ fi %changelog * Fri Jan 7 2005 Tim Waugh +- Cache MB_CUR_MAX value in egf-speedup patch. - Fixed variable shadowing in egf-speedup patch. - Removed redundant (and incorrect) code in prline.