- More improvements to egf-speedup patch (bug #138076).
This commit is contained in:
parent
6f2e162151
commit
9fa0ec14fd
@ -1,5 +1,5 @@
|
||||
--- grep-2.5.1/src/search.c.egf-speedup 2004-11-04 10:42:45.000000000 +0000
|
||||
+++ grep-2.5.1/src/search.c 2004-11-04 11:12:44.688292744 +0000
|
||||
--- grep-2.5.1/src/search.c.egf-speedup 2004-11-04 14:34:20.883140606 +0000
|
||||
+++ grep-2.5.1/src/search.c 2004-11-04 14:53:29.991266613 +0000
|
||||
@@ -70,9 +70,6 @@
|
||||
call the regexp matcher at all. */
|
||||
static int kwset_exact_matches;
|
||||
@ -79,30 +79,34 @@
|
||||
#endif /* MBS_SUPPORT */
|
||||
|
||||
buflim = buf + size;
|
||||
@@ -376,15 +322,34 @@
|
||||
@@ -373,18 +319,42 @@
|
||||
if (kwset)
|
||||
{
|
||||
/* Find a possible match using the KWset matcher. */
|
||||
+#ifdef MBS_SUPPORT
|
||||
+ size_t bytes_left = 0;
|
||||
+#endif /* MBS_SUPPORT */
|
||||
size_t offset = kwsexec (kwset, beg, buflim - beg, &kwsm);
|
||||
if (offset == (size_t) -1)
|
||||
goto failure;
|
||||
+#ifdef MBS_SUPPORT
|
||||
+ if (MB_CUR_MAX > 1)
|
||||
+ {
|
||||
+ size_t n = offset;
|
||||
+ while (n)
|
||||
+ bytes_left = offset;
|
||||
+ while (bytes_left)
|
||||
+ {
|
||||
+ size_t len = mbrlen (beg, n, &mbs);
|
||||
+ size_t len = mbrlen (beg, bytes_left, &mbs);
|
||||
+ if (len == (size_t) -1 || len == (size_t) -2 || len == 0)
|
||||
+ {
|
||||
+ /* Incomplete character. */
|
||||
+ memset (&mbs, '\0', sizeof (mbstate_t));
|
||||
+ beg += n;
|
||||
+ beg += bytes_left;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ beg += len;
|
||||
+ n -= len;
|
||||
+ bytes_left -= len;
|
||||
+ }
|
||||
+ if (n)
|
||||
+ continue;
|
||||
+ }
|
||||
+ else
|
||||
+#endif /* MBS_SUPPORT */
|
||||
@ -111,44 +115,58 @@
|
||||
run it through DFA. */
|
||||
end = memchr(beg, eol, buflim - beg);
|
||||
end++;
|
||||
-#ifdef MBS_SUPPORT
|
||||
#ifdef MBS_SUPPORT
|
||||
- if (MB_CUR_MAX > 1 && mb_properties[beg - buf] == 0)
|
||||
- continue;
|
||||
+ if (MB_CUR_MAX > 1 && bytes_left)
|
||||
continue;
|
||||
-#endif
|
||||
+#endif /* MBS_SUPPORT */
|
||||
while (beg > buf && beg[-1] != eol)
|
||||
--beg;
|
||||
if (kwsm.index < kwset_exact_matches)
|
||||
@@ -399,6 +364,29 @@
|
||||
@@ -395,13 +365,41 @@
|
||||
else
|
||||
{
|
||||
/* No good fixed strings; start with DFA. */
|
||||
+#ifdef MBS_SUPPORT
|
||||
+ size_t bytes_left = 0;
|
||||
+#endif /* MBS_SUPPORT */
|
||||
size_t offset = dfaexec (&dfa, beg, buflim - beg, &backref);
|
||||
if (offset == (size_t) -1)
|
||||
break;
|
||||
/* Narrow down to the line we've found. */
|
||||
+#ifdef MBS_SUPPORT
|
||||
+ if (MB_CUR_MAX > 1)
|
||||
+ {
|
||||
+ size_t n = offset;
|
||||
+ while (n)
|
||||
+ bytes_left = offset;
|
||||
+ while (bytes_left)
|
||||
+ {
|
||||
+ size_t len = mbrlen (beg, n, &mbs);
|
||||
+ size_t len = mbrlen (beg, bytes_left, &mbs);
|
||||
+ if (len == (size_t) -1 || len == (size_t) -2 || len == 0)
|
||||
+ {
|
||||
+ /* Incomplete character. */
|
||||
+ memset (&mbs, '\0', sizeof (mbstate_t));
|
||||
+ beg += n;
|
||||
+ beg += bytes_left;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ beg += len;
|
||||
+ n -= len;
|
||||
+ bytes_left -= len;
|
||||
+ }
|
||||
+ if (n)
|
||||
+ continue;
|
||||
+ }
|
||||
+ else
|
||||
+#endif /* MBS_SUPPORT */
|
||||
beg += offset;
|
||||
end = memchr (beg, eol, buflim - beg);
|
||||
end++;
|
||||
@@ -469,15 +457,6 @@
|
||||
+#ifdef MBS_SUPPORT
|
||||
+ if (MB_CUR_MAX > 1 && bytes_left)
|
||||
+ continue;
|
||||
+#endif /* MBS_SUPPORT */
|
||||
while (beg > buf && beg[-1] != eol)
|
||||
--beg;
|
||||
}
|
||||
@@ -469,15 +467,6 @@
|
||||
} /* for (beg = end ..) */
|
||||
|
||||
failure:
|
||||
@ -164,7 +182,7 @@
|
||||
return (size_t) -1;
|
||||
|
||||
success_in_beg_and_end:
|
||||
@@ -486,15 +465,6 @@
|
||||
@@ -486,15 +475,6 @@
|
||||
/* FALLTHROUGH */
|
||||
|
||||
success_in_start_and_len:
|
||||
@ -180,7 +198,7 @@
|
||||
*match_size = len;
|
||||
return start;
|
||||
}
|
||||
@@ -531,17 +501,8 @@
|
||||
@@ -531,17 +511,8 @@
|
||||
struct kwsmatch kwsmatch;
|
||||
size_t ret_val;
|
||||
#ifdef MBS_SUPPORT
|
||||
@ -200,7 +218,7 @@
|
||||
#endif /* MBS_SUPPORT */
|
||||
|
||||
for (beg = buf; beg <= buf + size; ++beg)
|
||||
@@ -550,8 +511,28 @@
|
||||
@@ -550,8 +521,28 @@
|
||||
if (offset == (size_t) -1)
|
||||
goto failure;
|
||||
#ifdef MBS_SUPPORT
|
||||
@ -208,54 +226,54 @@
|
||||
- continue; /* It is a part of multibyte character. */
|
||||
+ if (MB_CUR_MAX > 1)
|
||||
+ {
|
||||
+ size_t n = offset;
|
||||
+ while (n)
|
||||
+ size_t bytes_left = offset;
|
||||
+ while (bytes_left)
|
||||
+ {
|
||||
+ size_t len = mbrlen (beg, n, &mbs);
|
||||
+ size_t len = mbrlen (beg, bytes_left, &mbs);
|
||||
+ if (len == (size_t) -1 || len == (size_t) -2 || len == 0)
|
||||
+ {
|
||||
+ /* Incomplete character. */
|
||||
+ memset (&mbs, '\0', sizeof (mbstate_t));
|
||||
+ beg += n;
|
||||
+ beg += bytes_left;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ beg += len;
|
||||
+ n -= len;
|
||||
+ bytes_left -= len;
|
||||
+ }
|
||||
+
|
||||
+ if (n)
|
||||
+ if (bytes_left)
|
||||
+ continue;
|
||||
+ }
|
||||
+ else
|
||||
#endif /* MBS_SUPPORT */
|
||||
beg += offset;
|
||||
len = kwsmatch.size[0];
|
||||
@@ -587,6 +568,31 @@
|
||||
@@ -587,6 +578,31 @@
|
||||
if (offset == -1) {
|
||||
break; /* Try a different anchor. */
|
||||
}
|
||||
+#ifdef MBS_SUPPORT
|
||||
+ if (MB_CUR_MAX > 1)
|
||||
+ {
|
||||
+ size_t n = offset;
|
||||
+ while (n)
|
||||
+ size_t bytes_left = offset;
|
||||
+ while (bytes_left)
|
||||
+ {
|
||||
+ size_t len = mbrlen (beg, n, &mbs);
|
||||
+ size_t len = mbrlen (beg, bytes_left, &mbs);
|
||||
+ if (len == (size_t) -1 || len == (size_t) -2 ||
|
||||
+ len == 0)
|
||||
+ {
|
||||
+ /* Incomplete character. */
|
||||
+ memset (&mbs, '\0', sizeof (mbstate_t));
|
||||
+ beg += n;
|
||||
+ beg += bytes_left;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ beg += len;
|
||||
+ n -= len;
|
||||
+ bytes_left -= len;
|
||||
+ }
|
||||
+
|
||||
+ if (n)
|
||||
+ if (bytes_left)
|
||||
+ break; /* Try a different anchor. */
|
||||
+ }
|
||||
+ else
|
||||
@ -263,7 +281,7 @@
|
||||
beg += offset;
|
||||
len = kwsmatch.size[0];
|
||||
}
|
||||
@@ -597,20 +603,30 @@
|
||||
@@ -597,20 +613,30 @@
|
||||
}
|
||||
|
||||
failure:
|
||||
@ -303,7 +321,7 @@
|
||||
while (buf < beg && beg[-1] != eol)
|
||||
--beg;
|
||||
len = end - beg;
|
||||
@@ -618,15 +634,6 @@
|
||||
@@ -618,15 +644,6 @@
|
||||
|
||||
success_in_beg_and_len:
|
||||
*match_size = len;
|
||||
|
@ -1,7 +1,7 @@
|
||||
Summary: The GNU versions of grep pattern matching utilities.
|
||||
Name: grep
|
||||
Version: 2.5.1
|
||||
Release: 33
|
||||
Release: 34
|
||||
License: GPL
|
||||
Group: Applications/Text
|
||||
Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.bz2
|
||||
@ -81,6 +81,9 @@ fi
|
||||
%{_mandir}/*/*
|
||||
|
||||
%changelog
|
||||
* Thu Nov 4 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-34
|
||||
- More improvements to egf-speedup patch (bug #138076).
|
||||
|
||||
* Thu Nov 4 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-33
|
||||
- Small improvements to egf-speedup patch.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user