summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-04-19 09:00:54 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-04-19 09:00:54 (GMT)
commitb13067d29f8b9eb7d7d73820b4f14562704a2732 (patch)
tree51eae560e8bf56711b6f41a1d3d893a579a4891a
parentfb49f5dcab8ff9b5198b3616cad010098e1f5674 (diff)
downloadtcl-b13067d29f8b9eb7d7d73820b4f14562704a2732.zip
tcl-b13067d29f8b9eb7d7d73820b4f14562704a2732.tar.gz
tcl-b13067d29f8b9eb7d7d73820b4f14562704a2732.tar.bz2
Improve const-correctness of RE compiler
-rw-r--r--ChangeLog29
-rw-r--r--generic/regc_cvec.c24
-rw-r--r--generic/regc_lex.c38
-rw-r--r--generic/regc_locale.c48
-rw-r--r--generic/regcomp.c48
5 files changed, 97 insertions, 90 deletions
diff --git a/ChangeLog b/ChangeLog
index 77d4181..8e2e607 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,17 +1,23 @@
+2007-04-19 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
+
+ * generic/regcomp.c, generic/regc_cvec.c, generic/regc_lex.c,
+ * generic/regc_locale.c: Improve the const-correctness of the RE
+ compiler.
+
2007-04-18 Miguel Sofer <msofer@users.sf.net>
- * generic/tclExecute.c (INST_LSHIFT): fixed a mistake introduced
- in version 1.266 ('=' became '=='), which effectively turned the
- block that handles native shifts into dead code. This explains why
- the testsuite did not pick this mistake. Rewrote to make the
- intention clear.
+ * generic/tclExecute.c (INST_LSHIFT): fixed a mistake introduced in
+ version 1.266 ('=' became '=='), which effectively turned the block
+ that handles native shifts into dead code. This explains why the
+ testsuite did not pick this mistake. Rewrote to make the intention
+ clear.
2007-04-18 Miguel Sofer <msofer@users.sf.net>
* generic/tclInt.h (TclDecrRefCount): change the order of the
branches, use empty 'if ; else' to handle use in unbraced outer
if/else conditions (as already done in tcl.h)
-
+
2007-04-18 Miguel Sofer <msofer@users.sf.net>
* generic/tclExecute.c: slight changes in Tcl_Obj management.
@@ -19,12 +25,11 @@
2007-04-17 Kevin B. Kenny <kennykb@acm.org>
* library/clock.tcl: Fixed the naming of
- ::tcl::clock::ReadZoneinfoFile because (yoicks!) it was in the
- global namespace.
+ ::tcl::clock::ReadZoneinfoFile because (yoicks!) it was in the global
+ namespace.
* doc/clock.n: Clarified the cases in which legacy time zone is
recognized. [Bug 1656002]
-
-
+
2007-04-17 Miguel Sofer <msofer@users.sf.net>
* generic/tclExecute.c: fixed checkInterp logic [Bug 1702212]
@@ -42,7 +47,7 @@
the [clock] command. [Bug 1690041]
* tests/clock.test: Added rudimentary test cases for unique-prefix
matching of keywords.
-
+
2007-04-14 Miguel Sofer <msofer@users.sf.net>
* generic/tclExecute.c: removed some code at INST_EXPAND_SKTOP that
@@ -54,7 +59,7 @@
OBJ_AT_DEPTH(n) and CURR_DEPTH that remove all direct references to
tosPtr from TEBC (after initialisation and the code at the label
cleanupV_pushObjResultPtr).
-
+
2007-04-11 Miguel Sofer <msofer@users.sf.net>
* generic/tclCompCmds.c: moved all exceptDepth management to the
diff --git a/generic/regc_cvec.c b/generic/regc_cvec.c
index 55d087a..a0a14c2 100644
--- a/generic/regc_cvec.c
+++ b/generic/regc_cvec.c
@@ -28,6 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+/*
+ * Notes:
+ * Only (selected) functions in _this_ file should treat chr* as non-constant.
+ */
/*
- newcvec - allocate a new cvec
@@ -39,14 +44,13 @@ newcvec(
int nranges, /* ... and this many ranges... */
int nmcces) /* ... and this many MCCEs */
{
- size_t n;
- size_t nc;
+ size_t n, nc;
struct cvec *cv;
nc = (size_t)nchrs + (size_t)nmcces*(MAXMCCE+1) + (size_t)nranges*2;
n = sizeof(struct cvec) + (size_t)(nmcces-1)*sizeof(chr *)
+ nc*sizeof(chr);
- cv = (struct cvec *)MALLOC(n);
+ cv = (struct cvec *) MALLOC(n);
if (cv == NULL) {
return NULL;
}
@@ -120,19 +124,17 @@ addrange(
/*
- addmcce - add an MCCE to a cvec
- ^ static VOID addmcce(struct cvec *, chr *, chr *);
+ ^ static VOID addmcce(struct cvec *, const chr *, const chr *);
*/
static void
addmcce(
struct cvec *cv, /* character vector */
- chr *startp, /* beginning of text */
- chr *endp) /* just past end of text */
+ const chr *startp, /* beginning of text */
+ const chr *endp) /* just past end of text */
{
- int len;
- int i;
- chr *s;
- chr *d;
+ int len, i;
+ const chr *s, *d;
if (startp == NULL && endp == NULL) {
return;
@@ -162,7 +164,7 @@ haschr(
pchr c) /* character to test for */
{
int i;
- chr *p;
+ const chr *p;
for (p = cv->chrs, i = cv->nchrs; i > 0; p++, i--) {
if (*p == c) {
diff --git a/generic/regc_lex.c b/generic/regc_lex.c
index cc02e9d..f57779d 100644
--- a/generic/regc_lex.c
+++ b/generic/regc_lex.c
@@ -207,13 +207,13 @@ prefixes(
- lexnest - "call a subroutine", interpolating string at the lexical level
* Note, this is not a very general facility. There are a number of
* implicit assumptions about what sorts of strings can be subroutines.
- ^ static VOID lexnest(struct vars *, chr *, chr *);
+ ^ static VOID lexnest(struct vars *, const chr *, const chr *);
*/
static void
lexnest(
struct vars *v,
- chr *beginp, /* start of interpolation */
- chr *endp) /* one past end of interpolation */
+ const chr *beginp, /* start of interpolation */
+ const chr *endp) /* one past end of interpolation */
{
assert(v->savenow == NULL); /* only one level of nesting */
v->savenow = v->now;
@@ -226,47 +226,47 @@ lexnest(
* string constants to interpolate as expansions of things like \d
*/
-static chr backd[] = { /* \d */
+static const chr backd[] = { /* \d */
CHR('['), CHR('['), CHR(':'),
CHR('d'), CHR('i'), CHR('g'), CHR('i'), CHR('t'),
CHR(':'), CHR(']'), CHR(']')
};
-static chr backD[] = { /* \D */
+static const chr backD[] = { /* \D */
CHR('['), CHR('^'), CHR('['), CHR(':'),
CHR('d'), CHR('i'), CHR('g'), CHR('i'), CHR('t'),
CHR(':'), CHR(']'), CHR(']')
};
-static chr brbackd[] = { /* \d within brackets */
+static const chr brbackd[] = { /* \d within brackets */
CHR('['), CHR(':'),
CHR('d'), CHR('i'), CHR('g'), CHR('i'), CHR('t'),
CHR(':'), CHR(']')
};
-static chr backs[] = { /* \s */
+static const chr backs[] = { /* \s */
CHR('['), CHR('['), CHR(':'),
CHR('s'), CHR('p'), CHR('a'), CHR('c'), CHR('e'),
CHR(':'), CHR(']'), CHR(']')
};
-static chr backS[] = { /* \S */
+static const chr backS[] = { /* \S */
CHR('['), CHR('^'), CHR('['), CHR(':'),
CHR('s'), CHR('p'), CHR('a'), CHR('c'), CHR('e'),
CHR(':'), CHR(']'), CHR(']')
};
-static chr brbacks[] = { /* \s within brackets */
+static const chr brbacks[] = { /* \s within brackets */
CHR('['), CHR(':'),
CHR('s'), CHR('p'), CHR('a'), CHR('c'), CHR('e'),
CHR(':'), CHR(']')
};
-static chr backw[] = { /* \w */
+static const chr backw[] = { /* \w */
CHR('['), CHR('['), CHR(':'),
CHR('a'), CHR('l'), CHR('n'), CHR('u'), CHR('m'),
CHR(':'), CHR(']'), CHR('_'), CHR(']')
};
-static chr backW[] = { /* \W */
+static const chr backW[] = { /* \W */
CHR('['), CHR('^'), CHR('['), CHR(':'),
CHR('a'), CHR('l'), CHR('n'), CHR('u'), CHR('m'),
CHR(':'), CHR(']'), CHR('_'), CHR(']')
};
-static chr brbackw[] = { /* \w within brackets */
+static const chr brbackw[] = { /* \w within brackets */
CHR('['), CHR(':'),
CHR('a'), CHR('l'), CHR('n'), CHR('u'), CHR('m'),
CHR(':'), CHR(']'), CHR('_')
@@ -748,7 +748,7 @@ lexescape(
static chr esc[] = {
CHR('E'), CHR('S'), CHR('C')
};
- chr *save;
+ const chr *save;
assert(v->cflags&REG_ADVF);
@@ -1086,7 +1086,7 @@ static void
skip(
struct vars *v)
{
- chr *start = v->now;
+ const chr *start = v->now;
assert(v->cflags&REG_EXPANDED);
@@ -1128,11 +1128,11 @@ newline(void)
* This helps confine use of CHR to this source file. Beware that the caller
* knows how long the sequence is.
^ #ifdef REG_DEBUG
- ^ static chr *ch(NOPARMS);
+ ^ static const chr *ch(NOPARMS);
^ #endif
*/
#ifdef REG_DEBUG
-static chr *
+static const chr *
ch(void)
{
static chr chstr[] = { CHR('c'), CHR('h'), CHR('\0') };
@@ -1145,13 +1145,13 @@ ch(void)
- chrnamed - return the chr known by a given (chr string) name
* The code is a bit clumsy, but this routine gets only such specialized
* use that it hardly matters.
- ^ static chr chrnamed(struct vars *, chr *, chr *, pchr);
+ ^ static chr chrnamed(struct vars *, const chr *, const chr *, pchr);
*/
static chr
chrnamed(
struct vars *v,
- chr *startp, /* start of name */
- chr *endp, /* just past end of name */
+ const chr *startp, /* start of name */
+ const chr *endp, /* just past end of name */
pchr lastresort) /* what to return if name lookup fails */
{
celt c;
diff --git a/generic/regc_locale.c b/generic/regc_locale.c
index be01dfb..b08c300 100644
--- a/generic/regc_locale.c
+++ b/generic/regc_locale.c
@@ -9,12 +9,12 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: regc_locale.c,v 1.16 2007/04/10 22:01:06 dkf Exp $
+ * RCS: @(#) $Id: regc_locale.c,v 1.17 2007/04/19 09:00:55 dkf Exp $
*/
/* ASCII character-name table */
-static struct cname {
+static const struct cname {
const char *name;
const char code;
} cnames[] = {
@@ -133,7 +133,7 @@ typedef struct crange {
/* Unicode: alphabetic characters */
-static crange alphaRangeTable[] = {
+static const crange alphaRangeTable[] = {
{0x0041, 0x005a}, {0x0061, 0x007a}, {0x00c0, 0x00d6}, {0x00d8, 0x00f6},
{0x00f8, 0x021f}, {0x0222, 0x0233}, {0x0250, 0x02ad}, {0x02b0, 0x02b8},
{0x02bb, 0x02c1}, {0x02e0, 0x02e4}, {0x0388, 0x038a}, {0x038e, 0x03a1},
@@ -181,7 +181,7 @@ static crange alphaRangeTable[] = {
#define NUM_ALPHA_RANGE (sizeof(alphaRangeTable)/sizeof(crange))
-static chr alphaCharTable[] = {
+static const chr alphaCharTable[] = {
0x00aa, 0x00b5, 0x00ba, 0x02d0, 0x02d1, 0x02ee, 0x037a, 0x0386, 0x038c,
0x04c7, 0x04c8, 0x04cb, 0x04cc, 0x04f8, 0x04f9, 0x0559, 0x06d5, 0x06e5,
0x06e6, 0x0710, 0x093d, 0x0950, 0x098f, 0x0990, 0x09b2, 0x09dc, 0x09dd,
@@ -203,7 +203,7 @@ static chr alphaCharTable[] = {
* Unicode: decimal digit characters
*/
-static crange digitRangeTable[] = {
+static const crange digitRangeTable[] = {
{0x0030, 0x0039}, {0x0660, 0x0669}, {0x06f0, 0x06f9}, {0x0966, 0x096f},
{0x09e6, 0x09ef}, {0x0a66, 0x0a6f}, {0x0ae6, 0x0aef}, {0x0b66, 0x0b6f},
{0x0be7, 0x0bef}, {0x0c66, 0x0c6f}, {0x0ce6, 0x0cef}, {0x0d66, 0x0d6f},
@@ -221,7 +221,7 @@ static crange digitRangeTable[] = {
* Unicode: punctuation characters.
*/
-static crange punctRangeTable[] = {
+static const crange punctRangeTable[] = {
{0x0021, 0x0023}, {0x0025, 0x002a}, {0x002c, 0x002f}, {0x005b, 0x005d},
{0x055a, 0x055f}, {0x066a, 0x066d}, {0x0700, 0x070d}, {0x0f04, 0x0f12},
{0x0f3a, 0x0f3d}, {0x104a, 0x104f}, {0x1361, 0x1368}, {0x16eb, 0x16ed},
@@ -233,7 +233,7 @@ static crange punctRangeTable[] = {
#define NUM_PUNCT_RANGE (sizeof(punctRangeTable)/sizeof(crange))
-static chr punctCharTable[] = {
+static const chr punctCharTable[] = {
0x003a, 0x003b, 0x003f, 0x0040, 0x005f, 0x007b, 0x007d, 0x00a1, 0x00ab,
0x00ad, 0x00b7, 0x00bb, 0x00bf, 0x037e, 0x0387, 0x0589, 0x058a, 0x05be,
0x05c0, 0x05c3, 0x05f3, 0x05f4, 0x060c, 0x061b, 0x061f, 0x06d4, 0x0964,
@@ -249,13 +249,13 @@ static chr punctCharTable[] = {
* Unicode: white space characters.
*/
-static crange spaceRangeTable[] = {
+static const crange spaceRangeTable[] = {
{0x0009, 0x000d}, {0x2000, 0x200b}
};
#define NUM_SPACE_RANGE (sizeof(spaceRangeTable)/sizeof(crange))
-static chr spaceCharTable[] = {
+static const chr spaceCharTable[] = {
0x0020, 0x00a0, 0x1680, 0x2028, 0x2029, 0x202f, 0x3000
};
@@ -265,7 +265,7 @@ static chr spaceCharTable[] = {
* Unicode: lowercase characters
*/
-static crange lowerRangeTable[] = {
+static const crange lowerRangeTable[] = {
{0x0061, 0x007a}, {0x00df, 0x00f6}, {0x00f8, 0x00ff}, {0x017e, 0x0180},
{0x0199, 0x019b}, {0x01bd, 0x01bf}, {0x0250, 0x02ad}, {0x03ac, 0x03ce},
{0x03d5, 0x03d7}, {0x03ef, 0x03f3}, {0x0430, 0x045f}, {0x0561, 0x0587},
@@ -278,7 +278,7 @@ static crange lowerRangeTable[] = {
#define NUM_LOWER_RANGE (sizeof(lowerRangeTable)/sizeof(crange))
-static chr lowerCharTable[] = {
+static const chr lowerCharTable[] = {
0x00aa, 0x00b5, 0x00ba, 0x0101, 0x0103, 0x0105, 0x0107, 0x0109, 0x010b,
0x010d, 0x010f, 0x0111, 0x0113, 0x0115, 0x0117, 0x0119, 0x011b, 0x011d,
0x011f, 0x0121, 0x0123, 0x0125, 0x0127, 0x0129, 0x012b, 0x012d, 0x012f,
@@ -327,7 +327,7 @@ static chr lowerCharTable[] = {
* Unicode: uppercase characters.
*/
-static crange upperRangeTable[] = {
+static const crange upperRangeTable[] = {
{0x0041, 0x005a}, {0x00c0, 0x00d6}, {0x00d8, 0x00de}, {0x0189, 0x018b},
{0x018e, 0x0191}, {0x0196, 0x0198}, {0x01b1, 0x01b3}, {0x01f6, 0x01f8},
{0x0388, 0x038a}, {0x0391, 0x03a1}, {0x03a3, 0x03ab}, {0x03d2, 0x03d4},
@@ -340,7 +340,7 @@ static crange upperRangeTable[] = {
#define NUM_UPPER_RANGE (sizeof(upperRangeTable)/sizeof(crange))
-static chr upperCharTable[] = {
+static const chr upperCharTable[] = {
0x0100, 0x0102, 0x0104, 0x0106, 0x0108, 0x010a, 0x010c, 0x010e, 0x0110,
0x0112, 0x0114, 0x0116, 0x0118, 0x011a, 0x011c, 0x011e, 0x0120, 0x0122,
0x0124, 0x0126, 0x0128, 0x012a, 0x012c, 0x012e, 0x0130, 0x0132, 0x0134,
@@ -389,7 +389,7 @@ static chr upperCharTable[] = {
* Unicode: unicode print characters excluding space.
*/
-static crange graphRangeTable[] = {
+static const crange graphRangeTable[] = {
{0x0021, 0x007e}, {0x00a0, 0x011f}, {0x0121, 0x021f}, {0x0222, 0x0233},
{0x0250, 0x02ad}, {0x02b0, 0x02ee}, {0x0300, 0x031f}, {0x0321, 0x034e},
{0x0360, 0x0362}, {0x0384, 0x038a}, {0x038e, 0x03a1}, {0x03a3, 0x03ce},
@@ -511,7 +511,7 @@ static crange graphRangeTable[] = {
#define NUM_GRAPH_RANGE (sizeof(graphRangeTable)/sizeof(crange))
-static chr graphCharTable[] = {
+static const chr graphCharTable[] = {
0x0374, 0x0375, 0x037a, 0x037e, 0x038c, 0x0488, 0x0489, 0x04c7, 0x04c8,
0x04cb, 0x04cc, 0x04f8, 0x04f9, 0x0589, 0x058a, 0x060c, 0x061b, 0x061f,
0x098f, 0x0990, 0x09b2, 0x09bc, 0x09c7, 0x09c8, 0x09d7, 0x09dc, 0x09dd,
@@ -535,7 +535,7 @@ static chr graphCharTable[] = {
* L*), Numbers (N*), Punctuation (P*), Symbols (S*) and Spaces (Zs).
*/
-static crange printRangeTable[] = {
+static const crange printRangeTable[] = {
{0x0020, 0x007E}, {0x00A0, 0x01F5}, {0x01FA, 0x0217}, {0x0250, 0x02A8},
{0x02B0, 0x02DE}, {0x02E0, 0x02E9}, {0x0374, 0x0375}, {0x0384, 0x038A},
{0x038E, 0x03A1}, {0x03A3, 0x03CE}, {0x03D0, 0x03D6}, {0x03E2, 0x03F3},
@@ -593,7 +593,7 @@ static crange printRangeTable[] = {
#define NUM_PRINT_RANGE (sizeof(printRangeTable)/sizeof(crange))
-static chr printCharTable[] = {
+static const chr printCharTable[] = {
0x037A, 0x037E, 0x038C, 0x03DA, 0x03DC, 0x03DE, 0x03E0, 0x0589, 0x05BE,
0x05C0, 0x05C3, 0x060C, 0x061B, 0x061F, 0x06E9, 0x093D, 0x0950, 0x09B2,
0x0A5E, 0x0A8D, 0x0ABD, 0x0AD0, 0x0AE0, 0x0B3D, 0x0B9C, 0x0CDE, 0x0E01,
@@ -649,15 +649,15 @@ allmcces(
/*
- element - map collating-element name to celt
- ^ static celt element(struct vars *, chr *, chr *);
+ ^ static celt element(struct vars *, const chr *, const chr *);
*/
static celt
element(
struct vars *v, /* context */
- chr *startp, /* points to start of name */
- chr *endp) /* points just past end of name */
+ const chr *startp, /* points to start of name */
+ const chr *endp) /* points just past end of name */
{
- struct cname *cn;
+ const struct cname *cn;
size_t len;
Tcl_DString ds;
const char *np;
@@ -818,13 +818,13 @@ eclass(
/*
- cclass - supply cvec for a character class
* Must include case counterparts on request.
- ^ static struct cvec *cclass(struct vars *, chr *, chr *, int);
+ ^ static struct cvec *cclass(struct vars *, const chr *, const chr *, int);
*/
static struct cvec *
cclass(
struct vars *v, /* context */
- chr *startp, /* where the name starts */
- chr *endp, /* just past the end of the name */
+ const chr *startp, /* where the name starts */
+ const chr *endp, /* just past the end of the name */
int cases) /* case-independent? */
{
size_t len;
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;