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