Tcl Source Code

Check-in [fd1317ae18]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix [df08482b04]: Double defined INFINITY in regguts.h
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fd1317ae1809d4540ef2bbf3d5950c2f06bd1df9
User & Date: jan.nijtmans 2015-01-26 20:56:01
References
2015-01-26
20:58 Closed ticket [df08482b04]: Double defined INFINITY in regguts.h plus 7 other changes artifact: d54a7f8020 user: jan.nijtmans
Context
2015-01-29
17:48
Protect against extension variable resolvers that fail to play by the post-Var Reform rules. check-in: 9fff408391 user: dgp tags: trunk
2015-01-26
21:00
merge trunk check-in: 8fdd17d1b2 user: jan.nijtmans tags: novem
20:56
Fix [df08482b04]: Double defined INFINITY in regguts.h check-in: fd1317ae18 user: jan.nijtmans tags: trunk
20:47
Fix [df08482b04]: Double defined INFINITY in regguts.h check-in: 4087cc2323 user: jan.nijtmans tags: core-8-5-branch
2015-01-02
22:43
merge mark check-in: 690300420f user: dgp tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/regcomp.c.

992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
    /*
     * ...and an atom may be followed by a quantifier.
     */

    switch (v->nexttype) {
    case '*':
	m = 0;
	n = INFINITY;
	qprefer = (v->nextvalue) ? LONGER : SHORTER;
	NEXT();
	break;
    case '+':
	m = 1;
	n = INFINITY;
	qprefer = (v->nextvalue) ? LONGER : SHORTER;
	NEXT();
	break;
    case '?':
	m = 0;
	n = 1;
	qprefer = (v->nextvalue) ? LONGER : SHORTER;
	NEXT();
	break;
    case '{':
	NEXT();
	m = scannum(v);
	if (EAT(',')) {
	    if (SEE(DIGIT)) {
		n = scannum(v);
	    } else {
		n = INFINITY;
	    }
	    if (m > n) {
		ERR(REG_BADBR);
		return;
	    }

	    /*







|





|
















|







992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
    /*
     * ...and an atom may be followed by a quantifier.
     */

    switch (v->nexttype) {
    case '*':
	m = 0;
	n = DUPINF;
	qprefer = (v->nextvalue) ? LONGER : SHORTER;
	NEXT();
	break;
    case '+':
	m = 1;
	n = DUPINF;
	qprefer = (v->nextvalue) ? LONGER : SHORTER;
	NEXT();
	break;
    case '?':
	m = 0;
	n = 1;
	qprefer = (v->nextvalue) ? LONGER : SHORTER;
	NEXT();
	break;
    case '{':
	NEXT();
	m = scannum(v);
	if (EAT(',')) {
	    if (SEE(DIGIT)) {
		n = scannum(v);
	    } else {
		n = DUPINF;
	    }
	    if (m > n) {
		ERR(REG_BADBR);
		return;
	    }

	    /*
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
    } else {
	/*
	 * Turn x{m,n} into x{m-1,n-1}x, with capturing parens in only second
	 * x
	 */

	dupnfa(v->nfa, atom->begin, atom->end, s, atom->begin);
	assert(m >= 1 && m != INFINITY && n >= 1);
	repeat(v, s, atom->begin, m-1, (n == INFINITY) ? n : n-1);
	f = COMBINE(qprefer, atom->flags);
	t = subre(v, '.', f, s, atom->end);	/* prefix and atom */
	NOERR();
	t->left = subre(v, '=', PREF(f), s, atom->begin);
	NOERR();
	t->right = atom;
	*atomp = t;







|
|







1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
    } else {
	/*
	 * Turn x{m,n} into x{m-1,n-1}x, with capturing parens in only second
	 * x
	 */

	dupnfa(v->nfa, atom->begin, atom->end, s, atom->begin);
	assert(m >= 1 && m != DUPINF && n >= 1);
	repeat(v, s, atom->begin, m-1, (n == DUPINF) ? n : n-1);
	f = COMBINE(qprefer, atom->flags);
	t = subre(v, '.', f, s, atom->end);	/* prefix and atom */
	NOERR();
	t->left = subre(v, '=', PREF(f), s, atom->begin);
	NOERR();
	t->right = atom;
	*atomp = t;
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
    struct state *rp,
    int m,
    int n)
{
#define	SOME		2
#define	INF		3
#define	PAIR(x, y)	((x)*4 + (y))
#define	REDUCE(x)	( ((x) == INFINITY) ? INF : (((x) > 1) ? SOME : (x)) )
    const int rm = REDUCE(m);
    const int rn = REDUCE(n);
    struct state *s, *s2;

    switch (PAIR(rm, rn)) {
    case PAIR(0, 0):		/* empty string */
	delsub(v->nfa, lp, rp);







|







1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
    struct state *rp,
    int m,
    int n)
{
#define	SOME		2
#define	INF		3
#define	PAIR(x, y)	((x)*4 + (y))
#define	REDUCE(x)	( ((x) == DUPINF) ? INF : (((x) > 1) ? SOME : (x)) )
    const int rm = REDUCE(m);
    const int rn = REDUCE(n);
    struct state *s, *s2;

    switch (PAIR(rm, rn)) {
    case PAIR(0, 0):		/* empty string */
	delsub(v->nfa, lp, rp);
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
	fprintf(f, " UNUSED");
    }
    if (t->subno != 0) {
	fprintf(f, " (#%d)", t->subno);
    }
    if (t->min != 1 || t->max != 1) {
	fprintf(f, " {%d,", t->min);
	if (t->max != INFINITY) {
	    fprintf(f, "%d", t->max);
	}
	fprintf(f, "}");
    }
    if (nfapresent) {
	fprintf(f, " %ld-%ld", (long)t->begin->no, (long)t->end->no);
    }







|







2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
	fprintf(f, " UNUSED");
    }
    if (t->subno != 0) {
	fprintf(f, " (#%d)", t->subno);
    }
    if (t->min != 1 || t->max != 1) {
	fprintf(f, " {%d,", t->min);
	if (t->max != DUPINF) {
	    fprintf(f, "%d", t->max);
	}
	fprintf(f, "}");
    }
    if (nfapresent) {
	fprintf(f, " %ld-%ld", (long)t->begin->no, (long)t->end->no);
    }

Changes to generic/regexec.c.

1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
    stop = end - len;

    /*
     * Count occurrences.
     */

    i = 0;
    for (p = begin; p <= stop && (i < max || max == INFINITY); p += len) {
	if (v->g->compare(paren, p, len) != 0) {
	    break;
	}
	i++;
    }
    MDEBUG(("cbackref found %d\n", i));

    /*
     * And sort it out.
     */

    if (p != end) {		/* didn't consume all of it */
	return REG_NOMATCH;
    }
    if (min <= i && (i <= max || max == INFINITY)) {
	return REG_OKAY;
    }
    return REG_NOMATCH;		/* out of range */
}

/*
 - complicatedAlternationDissect - determine alternative subexpression matches (w.







|














|







1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
    stop = end - len;

    /*
     * Count occurrences.
     */

    i = 0;
    for (p = begin; p <= stop && (i < max || max == DUPINF); p += len) {
	if (v->g->compare(paren, p, len) != 0) {
	    break;
	}
	i++;
    }
    MDEBUG(("cbackref found %d\n", i));

    /*
     * And sort it out.
     */

    if (p != end) {		/* didn't consume all of it */
	return REG_NOMATCH;
    }
    if (min <= i && (i <= max || max == DUPINF)) {
	return REG_OKAY;
    }
    return REG_NOMATCH;		/* out of range */
}

/*
 - complicatedAlternationDissect - determine alternative subexpression matches (w.

Changes to generic/regguts.h.

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 * misc
 */

#define	NOTREACHED	0
#define	xxx		1

#define	DUPMAX	_POSIX2_RE_DUP_MAX
#define	INFINITY	(DUPMAX+1)

#define	REMAGIC	0xfed7		/* magic number for main struct */

/*
 * debugging facilities
 */
#ifdef REG_DEBUG







|







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 * misc
 */

#define	NOTREACHED	0
#define	xxx		1

#define	DUPMAX	_POSIX2_RE_DUP_MAX
#define	DUPINF	(DUPMAX+1)

#define	REMAGIC	0xfed7		/* magic number for main struct */

/*
 * debugging facilities
 */
#ifdef REG_DEBUG