Tcl Source Code

Check-in [8fdd17d1b2]
Login

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

Overview
Comment:merge trunk
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | novem
Files: files | file ages | folders
SHA1: 8fdd17d1b2cd1c8fc6c7b910ccc2ce6991df816e
User & Date: jan.nijtmans 2015-01-26 21:00:15
Context
2015-02-12
17:08
Merge trunk and tzdata2015a from ietf.org check-in: 7e2416a5da user: venkat tags: novem
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
2014-12-23
18:44
merge trunk check-in: 526ce54517 user: dgp tags: novem
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.

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 * 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







|







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 * 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

Changes to generic/tclIO.c.

6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
	     * byte, and we are in TCL_TRANSLATE_AUTO mode, and
	     * when the translation pass was made the INPUT_SAW_CR
	     * flag was set on the channel.  In that case, the
	     * correct behavior is to consume that \n and produce the
	     * empty string.
	     */

	    if (dst[0] == '\n') {
		assert(statePtr->inputTranslation == TCL_TRANSLATE_AUTO);
		assert(dstRead == 1);

		goto consume;
	    }

	    /* Otherwise, reading zero characters indicates there's
	     * something incomplete at the end of the src buffer.
	     * Maybe there were not enough src bytes to decode into







|

<







6194
6195
6196
6197
6198
6199
6200
6201
6202

6203
6204
6205
6206
6207
6208
6209
	     * byte, and we are in TCL_TRANSLATE_AUTO mode, and
	     * when the translation pass was made the INPUT_SAW_CR
	     * flag was set on the channel.  In that case, the
	     * correct behavior is to consume that \n and produce the
	     * empty string.
	     */

	    if (dstRead == 1 && dst[0] == '\n') {
		assert(statePtr->inputTranslation == TCL_TRANSLATE_AUTO);


		goto consume;
	    }

	    /* Otherwise, reading zero characters indicates there's
	     * something incomplete at the end of the src buffer.
	     * Maybe there were not enough src bytes to decode into