summaryrefslogtreecommitdiff
path: root/lib/dfa.c
diff options
context:
space:
mode:
authorNorihiro Tanaka <noritnk@kcn.ne.jp>2019-12-11 12:53:09 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2019-12-11 15:09:38 -0800
commitac92492294ca52fe2596f6353a3fe2800052f676 (patch)
treecc362ef5819a855ec25f5bb16e033f35c652739e /lib/dfa.c
parent76a168b272d371cfba73e89c7d0feeca3bee4c6d (diff)
downloadgnulib-ac92492294ca52fe2596f6353a3fe2800052f676.tar.gz
dfa: separate parse and compile phase
‘dfamust’ must be called after parsing and before tokens are reordered, but both are executed in the compilation phase. Token reordering was introduced in Gnulib commit 2018-10-22T15:01:08Z!noritnk@kcn.ne.jp (5c7a0371823876cca7a1347fa09ca26bbbff0c98). * lib/dfa.c (dfaparse): Change it to global function. (dfacomp): If first argument is NULL, skip parse. * lib/dfa.h: (dfaparse): Add a prototype.
Diffstat (limited to 'lib/dfa.c')
-rw-r--r--lib/dfa.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/dfa.c b/lib/dfa.c
index 329a2092a7..1e125b4d24 100644
--- a/lib/dfa.c
+++ b/lib/dfa.c
@@ -1969,7 +1969,7 @@ regexp (struct dfa *dfa)
/* Main entry point for the parser. S is a string to be parsed, len is the
length of the string, so s can include NUL characters. D is a pointer to
the struct dfa to parse into. */
-static void
+void
dfaparse (char const *s, size_t len, struct dfa *d)
{
d->lex.ptr = s;
@@ -3745,7 +3745,9 @@ dfassbuild (struct dfa *d)
void
dfacomp (char const *s, size_t len, struct dfa *d, bool searchflag)
{
- dfaparse (s, len, d);
+ if (s != NULL)
+ dfaparse (s, len, d);
+
dfassbuild (d);
if (dfa_supported (d))