summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--generic/regc_color.c2
-rw-r--r--generic/regc_cvec.c2
-rw-r--r--generic/regcomp.c50
4 files changed, 61 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 66e57ed..ded99e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-09-27 Miguel Sofer <msofer@users.sf.net>
+
+ * generic/regc_color.c (singleton):
+ * generic/regc_cvec.c (addmcce):
+ * generic/regcomp.c (compile, dovec): the static function addmcce does
+ nothing when called with two NULL pointers; the only call is by
+ compile with two NULL pointers (regcomp.c #includes
+ regc_cvec.c).
+ Large parts (all?) the code for mcce (multi character collating
+ element) that we do not use is ifdef'ed out with the macro
+ REGEXP_MCCE_ENABLE.
+ This silences coverity bugs 7, 16, 80
+
2006-09-27 Andreas Kupries <andreask@activestate.com>
* tests/pkg.test: Added test for version comparison at the 32bit
diff --git a/generic/regc_color.c b/generic/regc_color.c
index 2c4d97e..f1f216f 100644
--- a/generic/regc_color.c
+++ b/generic/regc_color.c
@@ -682,6 +682,7 @@ uncolorchain(
a->colorchain = NULL; /* paranoia */
}
+#ifdef REGEXP_MCCE_ENABLED
/*
- singleton - is this character in its own color?
^ static int singleton(struct colormap *, pchr c);
@@ -699,6 +700,7 @@ singleton(
}
return 0;
}
+#endif
/*
- rainbow - add arcs of all full colors (but one) between specified states
diff --git a/generic/regc_cvec.c b/generic/regc_cvec.c
index 1e38476..55d087a 100644
--- a/generic/regc_cvec.c
+++ b/generic/regc_cvec.c
@@ -111,7 +111,7 @@ addrange(
cv->nranges++;
}
-#ifdef REGEXP_ADDMCCE_UNUSED
+#ifdef REGEXP_MCCE_ENABLED
/*
* This static function is currently called from a single spot in regcomp.c,
* with two NULL pointers; in that case it does nothing, so that we define out
diff --git a/generic/regcomp.c b/generic/regcomp.c
index fb159cb..0d6f066 100644
--- a/generic/regcomp.c
+++ b/generic/regcomp.c
@@ -56,7 +56,9 @@ static chr *scanplain(struct vars *);
static VOID leaders(struct vars *, struct cvec *);
static VOID onechr(struct vars *, pchr, struct state *, struct state *);
static VOID dovec(struct vars *, struct cvec *, struct state *, struct state *);
+#ifdef REGEXP_MCCE_ENABLED
static celt nextleader(struct vars *, pchr, pchr);
+#endif
static VOID wordchrs(struct vars *);
static struct subre *subre(struct vars *, int, int, struct state *, struct state *);
static VOID freesubre(struct vars *, struct subre *);
@@ -105,7 +107,9 @@ static VOID subblock(struct vars *, pchr, struct state *, struct state *);
static VOID okcolors(struct nfa *, struct colormap *);
static VOID colorchain(struct colormap *, struct arc *);
static VOID uncolorchain(struct colormap *, struct arc *);
+#ifdef REGEXP_MCCE_ENABLED
static int singleton(struct colormap *, pchr c);
+#endif
static VOID rainbow(struct nfa *, struct colormap *, int, pcolor, struct state *, struct state *);
static VOID colorcomplement(struct nfa *, struct colormap *, int, struct state *, struct state *, struct state *);
#ifdef REG_DEBUG
@@ -171,7 +175,7 @@ static struct cvec *newcvec(int, int, int);
static struct cvec *clearcvec(struct cvec *);
static VOID addchr(struct cvec *, pchr);
static VOID addrange(struct cvec *, pchr, pchr);
-#ifdef REGEXP_ADDMCCE_UNUSED
+#ifdef REGEXP_MCCE_ENABLED
static VOID addmcce(struct cvec *, chr *, chr *);
#endif
static int haschr(struct cvec *, pchr);
@@ -366,7 +370,7 @@ compile(
CNOERR();
v->mcces = allmcces(v, v->mcces);
leaders(v, v->mcces);
-#ifdef REGEXP_ADDMCCE_UNUSED
+#ifdef REGEXP_MCCE_ENABLED
/* Function does nothing with NULL pointers */
addmcce(v->mcces, (chr *)NULL, (chr *)NULL); /* dummy */
#endif
@@ -1754,6 +1758,33 @@ onechr(
^ static VOID dovec(struct vars *, struct cvec *, struct state *,
^ struct state *);
*/
+#ifndef REGEXP_MCCE_ENABLED
+static void
+dovec(
+ struct vars *v,
+ struct cvec *cv,
+ struct state *lp,
+ struct state *rp)
+{
+ chr ch, from, to;
+ chr *p;
+ int i;
+
+ for (p = cv->chrs, i = cv->nchrs; i > 0; p++, i--) {
+ ch = *p;
+ newarc(v->nfa, PLAIN, subcolor(v->cm, ch), lp, rp);
+ }
+
+ for (p = cv->ranges, i = cv->nranges; i > 0; p += 2, i--) {
+ from = *p;
+ to = *(p+1);
+ if (from <= to) {
+ subrange(v, from, to, lp, rp);
+ }
+ }
+
+}
+#else /* REGEXP_MCCE_ENABLED */
static void
dovec(
struct vars *v,
@@ -1765,8 +1796,8 @@ dovec(
celt ce;
chr *p;
int i;
- color co;
struct cvec *leads;
+ color co;
struct arc *a;
struct arc *pa; /* arc in prototype */
struct state *s;
@@ -1791,7 +1822,7 @@ dovec(
} else {
leads = NULL;
}
-
+
/*
* First, get the ordinary characters out of the way.
*/
@@ -1832,7 +1863,15 @@ dovec(
}
}
- if ((leads == NULL || leads->nchrs == 0) && cv->nmcces == 0) {
+ /* *** WARNING ***
+ *
+ * This was buggy, check before enabling: the original version would cause
+ * a segfault at the loopinit below if (leads==NULL && cv->nmcces!=0)
+ * Possibly just a problem with parens? The original condition was
+ * ((leads == NULL || leads->nchrs == 0) && cv->nmcces == 0)
+ */
+
+ if (leads == NULL || (leads->nchrs == 0 && cv->nmcces == 0)) {
return;
}
@@ -1922,6 +1961,7 @@ nextleader(
}
return it;
}
+#endif
/*
- wordchrs - set up word-chr list for word-boundary stuff, if needed