diff --git a/grep-i18n-speedup.diff b/grep-i18n-speedup.diff new file mode 100644 index 0000000..a45410f --- /dev/null +++ b/grep-i18n-speedup.diff @@ -0,0 +1,74 @@ +--- src/search.c ++++ src/search.c +@@ -140,7 +140,7 @@ kwsmusts (void) + are not single byte character nor the first byte of a multibyte + character. Caller must free the array. */ + static char* +-check_multibyte_string(char const *buf, size_t size) ++check_multibyte_string(char const *buf, size_t size, int case_convert) + { + char *mb_properties = xmalloc(size); + mbstate_t cur_state; +@@ -161,7 +161,7 @@ check_multibyte_string(char const *buf, + We treat it as a single byte character. */ + mbclen = 1; + } +- else if (match_icase) ++ else if (case_convert) + { + if (iswupper((wint_t)wc)) + { +@@ -327,9 +327,9 @@ EXECUTE_FCT(EGexecute) + if (start_ptr) + start_ptr = case_buf + (start_ptr - buf); + buf = case_buf; ++ if (kwset) ++ mb_properties = check_multibyte_string(buf, size, 1); + } +- if (kwset) +- mb_properties = check_multibyte_string(buf, size); + } + #endif /* MBS_SUPPORT */ + +@@ -352,8 +352,13 @@ EXECUTE_FCT(EGexecute) + end = memchr(beg, eol, buflim - beg); + end++; + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1 && mb_properties[beg - buf] == 0) +- continue; ++ if (MB_CUR_MAX > 1) ++ { ++ if (!mb_properties) ++ mb_properties = check_multibyte_string (buf, size, 0); ++ if (mb_properties[beg - buf] == 0) ++ continue; ++ } + #endif + while (beg > buf && beg[-1] != eol) + --beg; +@@ -543,8 +548,8 @@ EXECUTE_FCT(Fexecute) + if (start_ptr) + start_ptr = case_buf + (start_ptr - buf); + buf = case_buf; ++ mb_properties = check_multibyte_string(buf, size, 1); + } +- mb_properties = check_multibyte_string(buf, size); + } + #endif /* MBS_SUPPORT */ + +@@ -554,8 +559,13 @@ EXECUTE_FCT(Fexecute) + if (offset == (size_t) -1) + goto failure; + #ifdef MBS_SUPPORT +- if (MB_CUR_MAX > 1 && mb_properties[offset+beg-buf] == 0) +- continue; /* It is a part of multibyte character. */ ++ if (MB_CUR_MAX > 1) ++ { ++ if (!mb_properties) ++ mb_properties = check_multibyte_string(buf, size, 0); ++ if (mb_properties[offset+beg-buf] == 0) ++ continue; /* It is a part of multibyte character. */ ++ } + #endif /* MBS_SUPPORT */ + beg += offset; + len = kwsmatch.size[0]; diff --git a/grep.changes b/grep.changes index 7cc6bb3..7bdb667 100644 --- a/grep.changes +++ b/grep.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Sep 12 14:32:07 CEST 2007 - schwab@suse.de + +- Allocate MB properties lazily. + ------------------------------------------------------------------- Tue May 15 15:00:53 CEST 2007 - schwab@suse.de diff --git a/grep.spec b/grep.spec index 3f3414e..74b4a83 100644 --- a/grep.spec +++ b/grep.spec @@ -12,14 +12,14 @@ Name: grep BuildRequires: pcre-devel -URL: http://www.gnu.org/software/grep/ -License: GNU General Public License (GPL) +Url: http://www.gnu.org/software/grep/ +License: GPL v2 or later Group: Productivity/Text/Utilities Provides: base:/usr/bin/grep -Autoreqprov: on +AutoReqProv: on PreReq: %{install_info_prereq} Version: 2.5.2 -Release: 3 +Release: 29 Summary: Print lines matching a pattern Source: grep-%{version}.tar.bz2 Patch: grep-%{version}.diff @@ -30,6 +30,7 @@ Patch4: wordmatch.patch Patch5: grep-2.5.1a-mbcset.diff Patch6: xfail-tests.diff Patch7: icase.diff +Patch8: grep-i18n-speedup.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -48,7 +49,7 @@ Authors: Ulrich Drepper %prep -%setup +%setup -q %patch %patch1 %patch2 @@ -57,6 +58,7 @@ Authors: %patch5 %patch6 %patch7 +%patch8 %build %{suse_update_config -f} @@ -96,8 +98,9 @@ ln -sf ../../bin/grep $RPM_BUILD_ROOT/usr/bin/grep %doc %{_mandir}/man1/grep.1.gz %doc %{_infodir}/grep*.gz /usr/share/locale/*/LC_MESSAGES/grep.mo - %changelog +* Wed Sep 12 2007 - schwab@suse.de +- Allocate MB properties lazily. * Tue May 15 2007 - schwab@suse.de - Fix some icase bugs. * Mon May 07 2007 - schwab@suse.de diff --git a/icase.diff b/icase.diff index 8f5c9ae..08f159c 100644 --- a/icase.diff +++ b/icase.diff @@ -1,5 +1,5 @@ ---- src/grep.c.~1.121.~ 2006-08-25 17:43:30.000000000 +0200 -+++ src/grep.c 2007-05-15 14:13:24.000000000 +0200 +--- src/grep.c ++++ src/grep.c @@ -789,28 +789,10 @@ print_line_middle (const char *beg, cons size_t match_offset; const char *cur = beg; @@ -41,9 +41,9 @@ if (only_matching) cur = lim; else if (mid) ---- src/search.c.~1.40.~ 2005-12-12 16:26:59.000000000 +0100 -+++ src/search.c 2007-05-15 14:49:38.000000000 +0200 -@@ -192,11 +192,18 @@ GEAcompile (char const *pattern, size_t +--- src/search.c ++++ src/search.c +@@ -192,11 +192,19 @@ GEAcompile (char const *pattern, size_t const char *sep; size_t total = size; char const *motif = pattern; @@ -54,8 +54,9 @@ - syntax_bits |= RE_ICASE; + if (match_icase +#ifdef MBS_SUPPORT -+ && MB_CUR_MAX == 1) ++ && MB_CUR_MAX == 1 #endif ++ ) + { + int i; + for (i = 0; i < NCHAR; i++) @@ -65,14 +66,15 @@ re_set_syntax (syntax_bits); dfasyntax (syntax_bits, match_icase, eolbyte); -@@ -224,6 +231,11 @@ GEAcompile (char const *pattern, size_t +@@ -224,6 +232,12 @@ GEAcompile (char const *pattern, size_t if (patterns == NULL) error (2, errno, _("memory exhausted")); patterns[pcount] = patterns0; + if (match_icase +#ifdef MBS_SUPPORT -+ && MB_CUR_MAX == 1) ++ && MB_CUR_MAX == 1 +#endif ++ ) + patterns[pcount].regexbuf.translate = translate; if ((err = re_compile_pattern (motif, len,