summaryrefslogtreecommitdiffstats
path: root/generic/regc_cvec.c
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 /generic/regc_cvec.c
parentfb49f5dcab8ff9b5198b3616cad010098e1f5674 (diff)
downloadtcl-b13067d29f8b9eb7d7d73820b4f14562704a2732.zip
tcl-b13067d29f8b9eb7d7d73820b4f14562704a2732.tar.gz
tcl-b13067d29f8b9eb7d7d73820b4f14562704a2732.tar.bz2
Improve const-correctness of RE compiler
Diffstat (limited to 'generic/regc_cvec.c')
-rw-r--r--generic/regc_cvec.c24
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) {