2004-11-10 09:42:35 +00:00
|
|
|
--- 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
|
2004-11-08 09:14:38 +00:00
|
|
|
@@ -305,11 +305,33 @@
|
2004-11-05 18:09:53 +00:00
|
|
|
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
|
|
|
|
mbstate_t mbs;
|
|
|
|
memset (&mbs, '\0', sizeof (mbstate_t));
|
|
|
|
#endif /* MBS_SUPPORT */
|
|
|
|
|
|
|
|
+ if (!use_dfa_checked)
|
|
|
|
+ {
|
2004-11-08 09:14:38 +00:00
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+
|
2004-11-05 18:09:53 +00:00
|
|
|
+ use_dfa_checked = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
buflim = buf + size;
|
|
|
|
|
|
|
|
for (beg = end = buf; end < buflim; beg = end)
|
2004-11-08 09:14:38 +00:00
|
|
|
@@ -365,7 +387,8 @@
|
2004-11-05 18:09:53 +00:00
|
|
|
--beg;
|
|
|
|
if (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
|
2004-11-08 09:14:38 +00:00
|
|
|
@@ -374,7 +397,9 @@
|
2004-11-05 18:09:53 +00:00
|
|
|
#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. */
|
2004-11-10 09:42:35 +00:00
|
|
|
@@ -416,7 +441,7 @@
|
|
|
|
--beg;
|
|
|
|
}
|
|
|
|
/* Successful, no backreferences encountered! */
|
|
|
|
- if (!backref)
|
|
|
|
+ if (use_dfa && !backref)
|
|
|
|
goto success_in_beg_and_end;
|
|
|
|
}
|
|
|
|
else
|