diff options
author | dkf <dkf@noemail.net> | 2007-04-19 09:00:53 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2007-04-19 09:00:53 (GMT) |
commit | 6808547fc41733bf2be8bb53ad82d74d485f4837 (patch) | |
tree | 51eae560e8bf56711b6f41a1d3d893a579a4891a /generic/regcomp.c | |
parent | 5f22aad9dbab85f724f5614062894a13cd59c638 (diff) | |
download | tcl-6808547fc41733bf2be8bb53ad82d74d485f4837.zip tcl-6808547fc41733bf2be8bb53ad82d74d485f4837.tar.gz tcl-6808547fc41733bf2be8bb53ad82d74d485f4837.tar.bz2 |
Improve const-correctness of RE compiler
FossilOrigin-Name: cf122e81f894c9291c93945803adce7797118d19
Diffstat (limited to 'generic/regcomp.c')
-rw-r--r-- | generic/regcomp.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/generic/regcomp.c b/generic/regcomp.c index d228879..4137caf 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -52,7 +52,7 @@ static VOID repeat(struct vars *, struct state *, struct state *, int, int); static VOID bracket(struct vars *, struct state *, struct state *); static VOID cbracket(struct vars *, struct state *, struct state *); static VOID brackpart(struct vars *, struct state *, struct state *); -static chr *scanplain(struct vars *); +static const 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 *); @@ -79,7 +79,7 @@ static const char *stid(struct subre *, char *, size_t); /* === regc_lex.c === */ static VOID lexstart(struct vars *); static VOID prefixes(struct vars *); -static VOID lexnest(struct vars *, chr *, chr *); +static VOID lexnest(struct vars *, const chr *, const chr *); static VOID lexword(struct vars *); static int next(struct vars *); static int lexescape(struct vars *); @@ -88,9 +88,9 @@ static int brenext(struct vars *, pchr); static VOID skip(struct vars *); static chr newline(NOPARMS); #ifdef REG_DEBUG -static chr *ch(NOPARMS); +static const chr *ch(NOPARMS); #endif -static chr chrnamed(struct vars *, chr *, chr *, pchr); +static chr chrnamed(struct vars *, const chr *, const chr *, pchr); /* === regc_color.c === */ static VOID initcm(struct vars *, struct colormap *); static VOID freecm(struct colormap *); @@ -176,7 +176,7 @@ static struct cvec *clearcvec(struct cvec *); static VOID addchr(struct cvec *, pchr); static VOID addrange(struct cvec *, pchr, pchr); #ifdef REGEXP_MCCE_ENABLED -static VOID addmcce(struct cvec *, chr *, chr *); +static VOID addmcce(struct cvec *, const chr *, const chr *); #endif static int haschr(struct cvec *, pchr); static struct cvec *getcvec(struct vars *, int, int, int); @@ -185,11 +185,11 @@ static VOID freecvec(struct cvec *); static int nmcces(struct vars *); static int nleaders(struct vars *); static struct cvec *allmcces(struct vars *, struct cvec *); -static celt element(struct vars *, chr *, chr *); +static celt element(struct vars *, const chr *, const chr *); static struct cvec *range(struct vars *, celt, celt, int); static int before(celt, celt); static struct cvec *eclass(struct vars *, celt, int); -static struct cvec *cclass(struct vars *, chr *, chr *, int); +static struct cvec *cclass(struct vars *, const chr *, const chr *, int); static struct cvec *allcases(struct vars *, pchr); static int cmp(const chr *, const chr *, size_t); static int casecmp(const chr *, const chr *, size_t); @@ -199,10 +199,10 @@ static int casecmp(const chr *, const chr *, size_t); /* internal variables, bundled for easy passing around */ struct vars { regex_t *re; - chr *now; /* scan pointer into string */ - chr *stop; /* end of string */ - chr *savenow; /* saved now and stop for "subroutine call" */ - chr *savestop; + const chr *now; /* scan pointer into string */ + const chr *stop; /* end of string */ + const chr *savenow; /* saved now and stop for "subroutine call" */ + const chr *savestop; int err; /* error code (0 if none) */ int cflags; /* copy of compile flags */ int lasttype; /* type of previous token */ @@ -316,7 +316,7 @@ compile( */ v->re = re; - v->now = (chr *)string; + v->now = string; v->stop = v->now + len; v->savenow = v->savestop = NULL; v->err = 0; @@ -374,7 +374,7 @@ compile( leaders(v, v->mcces); #ifdef REGEXP_MCCE_ENABLED /* Function does nothing with NULL pointers */ - addmcce(v->mcces, (chr *)NULL, (chr *)NULL); /* dummy */ + addmcce(v->mcces, (const chr *)NULL, (const chr *)NULL); /* dummy */ #endif } CNOERR(); @@ -1475,7 +1475,7 @@ cbracket( struct arc *ba; /* arc from left, from bracket() */ struct arc *pa; /* MCCE-prototype arc */ color co; - chr *p; + const chr *p; int i; NOERR(); @@ -1564,8 +1564,8 @@ brackpart( celt startc; celt endc; struct cvec *cv; - chr *startp; - chr *endp; + const chr *startp; + const chr *endp; chr c[1]; /* @@ -1672,13 +1672,13 @@ brackpart( - scanplain - scan PLAIN contents of [. etc. * Certain bits of trickery in lex.c know that this code does not try to look * past the final bracket of the [. etc. - ^ static chr *scanplain(struct vars *); + ^ static const chr *scanplain(struct vars *); */ -static chr * /* just after end of sequence */ +static const chr * /* just after end of sequence */ scanplain( struct vars *v) { - chr *endp; + const chr *endp; assert(SEE(COLLEL) || SEE(ECLASS) || SEE(CCLASS)); NEXT(); @@ -1707,7 +1707,7 @@ leaders( struct cvec *cv) { int mcce; - chr *p; + const chr *p; chr leader; struct state *s; struct arc *a; @@ -1773,9 +1773,9 @@ dovec( struct state *rp) { chr ch, from, to; - chr *p; + const 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); @@ -1800,7 +1800,7 @@ dovec( { chr ch, from, to; celt ce; - chr *p; + const chr *p; int i; struct cvec *leads; color co; @@ -1949,7 +1949,7 @@ nextleader( pchr to) { int i; - chr *p; + const chr *p; chr ch; celt it = NOCELT; |