summaryrefslogtreecommitdiffstats
path: root/generic/regcomp.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-03-05 14:01:48 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-03-05 14:01:48 (GMT)
commitd6374c239eef894ece7e7472ada26b15b0abe33e (patch)
tree857140413ec5a4b24bd5e7bbae78bac0830c60d5 /generic/regcomp.c
parent52de2e7cc80ef081b435f17dccc1586121d8c8cd (diff)
downloadtcl-d6374c239eef894ece7e7472ada26b15b0abe33e.zip
tcl-d6374c239eef894ece7e7472ada26b15b0abe33e.tar.gz
tcl-d6374c239eef894ece7e7472ada26b15b0abe33e.tar.bz2
Contributed patch from Tom Lane <tgl@users.sf.net>.
Rewrites parts of the regexp engine to avoid infinite loops.
Diffstat (limited to 'generic/regcomp.c')
-rw-r--r--generic/regcomp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/generic/regcomp.c b/generic/regcomp.c
index b15117b..3dd89d8 100644
--- a/generic/regcomp.c
+++ b/generic/regcomp.c
@@ -121,12 +121,16 @@ static void destroystate(struct nfa *, struct state *);
static void newarc(struct nfa *, int, pcolor, struct state *, struct state *);
static struct arc *allocarc(struct nfa *, struct state *);
static void freearc(struct nfa *, struct arc *);
+static int nonemptyouts(struct state *);
+static int nonemptyins(struct state *);
static struct arc *findarc(struct state *, int, pcolor);
static void cparc(struct nfa *, struct arc *, struct state *, struct state *);
static void moveins(struct nfa *, struct state *, struct state *);
static void copyins(struct nfa *, struct state *, struct state *);
+static void copynonemptyins(struct nfa *, struct state *, struct state *);
static void moveouts(struct nfa *, struct state *, struct state *);
static void copyouts(struct nfa *, struct state *, struct state *);
+static void copynonemptyouts(struct nfa *, struct state *, struct state *);
static void cloneouts(struct nfa *, struct state *, struct state *, struct state *, int);
static void delsub(struct nfa *, struct state *, struct state *);
static void deltraverse(struct nfa *, struct state *, struct state *);
@@ -144,7 +148,8 @@ static int push(struct nfa *, struct arc *);
#define COMPATIBLE 3 /* compatible but not satisfied yet */
static int combine(struct arc *, struct arc *);
static void fixempties(struct nfa *, FILE *);
-static int unempty(struct nfa *, struct arc *);
+static struct state *emptyreachable(struct state *, struct state *);
+static void replaceempty(struct nfa *, struct state *, struct state *);
static void cleanup(struct nfa *);
static void markreachable(struct nfa *, struct state *, struct state *, struct state *);
static void markcanreach(struct nfa *, struct state *, struct state *, struct state *);