1 The DFA algorithm is slow with mutlibytes characters.
2 This patch disables the DFA algorithm, but it can be re-enabled by setting
3 the GREP_USE_DFA environment variable.
5 This patch requires 64-egf-speedup.patch
6 --- src/search.c.orig 2005-09-06 22:22:17.000000000 +0200
7 +++ src/search.c 2005-09-06 22:25:41.000000000 +0200
10 int backref, start, len;
13 + static int use_dfa_checked = 0;
16 int mb_cur_max = MB_CUR_MAX;
18 memset (&mbs, '\0', sizeof (mbstate_t));
19 #endif /* MBS_SUPPORT */
21 + if (!use_dfa_checked)
23 + char *grep_use_dfa = getenv ("GREP_USE_DFA");
27 + /* Turn off DFA when processing multibyte input. */
28 + use_dfa = (MB_CUR_MAX == 1);
31 +#endif /* MBS_SUPPORT */
35 + use_dfa = atoi (grep_use_dfa);
38 + use_dfa_checked = 1;
43 for (beg = end = buf; end < buflim; beg = end)
45 #endif /* MBS_SUPPORT */
46 (kwsm.index < kwset_exact_matches))
48 - if (dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1)
50 + dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1)
56 size_t bytes_left = 0;
57 #endif /* MBS_SUPPORT */
58 - size_t offset = dfaexec (&dfa, beg, buflim - beg, &backref);
61 + offset = dfaexec (&dfa, beg, buflim - beg, &backref);
62 if (offset == (size_t) -1)
64 /* Narrow down to the line we've found. */
68 /* Successful, no backreferences encountered! */
70 + if (use_dfa && !backref)