diff options
| author | donal.k.fellows@manchester.ac.uk <dkf> | 2007-04-19 09:00:54 (GMT) |
|---|---|---|
| committer | donal.k.fellows@manchester.ac.uk <dkf> | 2007-04-19 09:00:54 (GMT) |
| commit | 1646eafa9876a0346cfa76d245e2c86d850d84f9 (patch) | |
| tree | 51eae560e8bf56711b6f41a1d3d893a579a4891a /generic/regc_cvec.c | |
| parent | d0b1f44339726b9f3a5fbcaec5daf31e04df8e5d (diff) | |
| download | tcl-1646eafa9876a0346cfa76d245e2c86d850d84f9.zip tcl-1646eafa9876a0346cfa76d245e2c86d850d84f9.tar.gz tcl-1646eafa9876a0346cfa76d245e2c86d850d84f9.tar.bz2 | |
Improve const-correctness of RE compiler
Diffstat (limited to 'generic/regc_cvec.c')
| -rw-r--r-- | generic/regc_cvec.c | 24 |
1 files changed, 13 insertions, 11 deletions
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) { |
