Tcl Source Code

Check-in [ee7549bebd]
Login

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

Overview
Comment:Cleaner error handling in fixempties().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-4-branch
Files: files | file ages | folders
SHA1: ee7549bebd8a899573c8789e410ec0cb5ab9cffd
User & Date: dgp 2013-03-06 21:51:23
Context
2013-03-08
21:12
Some more ignore-glob settings for msvc, mac, hp .... check-in: 46c1b89e22 user: jan.nijtmans tags: core-8-4-branch
2013-03-06
21:54
Cleaner error handling in fixempties(). check-in: 8577d952c4 user: dgp tags: core-8-5-branch
21:51
Cleaner error handling in fixempties(). check-in: ee7549bebd user: dgp tags: core-8-4-branch
19:25
3604074,3606683 Rewrite of the fixempties() routine (and supporting routines) to completely eliminat... check-in: 8293cc6b1f user: dgp tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/regc_nfa.c.

1270
1271
1272
1273
1274
1275
1276


1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307

			/* Reset the tmp fields as we walk back */
			nexts = s2->tmp;
			s2->tmp = NULL;
		}
		s->tmp = NULL;
	}



	/*
	 * Remove all the EMPTY arcs, since we don't need them anymore.
	 */
	for (s = nfa->states; s != NULL; s = s->next)
		for (a = s->outs; a != NULL; a = nexta) {
			nexta = a->outchain;
			if (a->type == EMPTY)
				freearc(nfa, a);
		}

	/*
	 * And remove any states that have become useless.  (This
	 * cleanup is not very thorough, and would be even less so if we
	 * tried to combine it with the previous step; but cleanup()
	 * will take care of anything we miss.)
	 */
	for (s = nfa->states; s != NULL && !NISERR(); s = nexts) {
		nexts = s->next;
		if ((s->nins == 0 || s->nouts == 0) && !s->flag)
			dropstate(nfa, s);
	}

	if (f != NULL && !NISERR())
		dumpnfa(nfa, f);
}

/*
 - emptyreachable - recursively find all states reachable from s by EMPTY arcs
 * The return value is the last such state found.  Its tmp field links back
 * to the next-to-last such state, and so on back to s, so that all these







>
>

















|





|







1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309

			/* Reset the tmp fields as we walk back */
			nexts = s2->tmp;
			s2->tmp = NULL;
		}
		s->tmp = NULL;
	}
	if (NISERR())
		return;

	/*
	 * Remove all the EMPTY arcs, since we don't need them anymore.
	 */
	for (s = nfa->states; s != NULL; s = s->next)
		for (a = s->outs; a != NULL; a = nexta) {
			nexta = a->outchain;
			if (a->type == EMPTY)
				freearc(nfa, a);
		}

	/*
	 * And remove any states that have become useless.  (This
	 * cleanup is not very thorough, and would be even less so if we
	 * tried to combine it with the previous step; but cleanup()
	 * will take care of anything we miss.)
	 */
	for (s = nfa->states; s != NULL; s = nexts) {
		nexts = s->next;
		if ((s->nins == 0 || s->nouts == 0) && !s->flag)
			dropstate(nfa, s);
	}

	if (f != NULL)
		dumpnfa(nfa, f);
}

/*
 - emptyreachable - recursively find all states reachable from s by EMPTY arcs
 * The return value is the last such state found.  Its tmp field links back
 * to the next-to-last such state, and so on back to s, so that all these