summaryrefslogtreecommitdiffstats
path: root/abs/core/grep/10-dfa-optional.patch
diff options
context:
space:
mode:
authorJames Meyer <James.meyer@operamail.com>2008-10-02 03:19:12 (GMT)
committerJames Meyer <James.meyer@operamail.com>2008-10-02 03:19:12 (GMT)
commit0e2532d4e8f4eed5e047f1db54d5c03ba849ec0a (patch)
treec0aa2c0b53c317be87eacfcb77b63f53f1f415e7 /abs/core/grep/10-dfa-optional.patch
downloadlinhes_pkgbuild-0e2532d4e8f4eed5e047f1db54d5c03ba849ec0a.zip
linhes_pkgbuild-0e2532d4e8f4eed5e047f1db54d5c03ba849ec0a.tar.gz
linhes_pkgbuild-0e2532d4e8f4eed5e047f1db54d5c03ba849ec0a.tar.bz2
initial import
Diffstat (limited to 'abs/core/grep/10-dfa-optional.patch')
-rw-r--r--abs/core/grep/10-dfa-optional.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/abs/core/grep/10-dfa-optional.patch b/abs/core/grep/10-dfa-optional.patch
new file mode 100644
index 0000000..784eba9
--- /dev/null
+++ b/abs/core/grep/10-dfa-optional.patch
@@ -0,0 +1,67 @@
+--- 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 */
+
++ if (!use_dfa_checked)
++ {
++ char *grep_use_dfa = getenv ("GREP_USE_DFA");
++ if (!grep_use_dfa)
++ {
++#ifdef MBS_SUPPORT
++ /* Turn off DFA when processing multibyte input. */
++ use_dfa = (MB_CUR_MAX == 1);
++#else
++ use_dfa = 1;
++#endif /* MBS_SUPPORT */
++ }
++ else
++ {
++ use_dfa = atoi (grep_use_dfa);
++ }
++
++ use_dfa_checked = 1;
++ }
++
+ buflim = buf + size;
+
+ for (beg = end = buf; end < buflim; beg = end)
+@@ -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 &&
++ dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1)
+ continue;
+ }
+ else
+@@ -409,7 +432,9 @@
+ #ifdef MBS_SUPPORT
+ size_t bytes_left = 0;
+ #endif /* MBS_SUPPORT */
+- size_t offset = dfaexec (&dfa, beg, buflim - beg, &backref);
++ size_t offset = 0;
++ if (use_dfa)
++ offset = dfaexec (&dfa, beg, buflim - beg, &backref);
+ if (offset == (size_t) -1)
+ break;
+ /* Narrow down to the line we've found. */
+@@ -451,7 +476,7 @@
+ --beg;
+ }
+ /* Successful, no backreferences encountered! */
+- if (!backref)
++ if (use_dfa && !backref)
+ goto success_in_beg_and_end;
+ }
+ else