Tcl Source Code

Check-in [c769b9bb91]
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 | trunk
Files: files | file ages | folders
SHA1: c769b9bb91ec4a8cddbba48832f6d7c248c9dd8a
User & Date: dgp 2013-03-06 21:55:29
Context
2013-03-08
20:57
msvc compiler warning: signed-unsigned mismatch. check-in: 8af2068174 user: jan.nijtmans tags: trunk
2013-03-07
21:30
Work in progress reworking how literals are stored. First effort is replacing the string based loca... check-in: 8de868a03b user: dgp tags: dgp-literal-reform
21:16
Correct unbalanced effect of TclInvalidateCmdLiteral() on the refcounts of literals in the global ta... Closed-Leaf check-in: 03fa2a45da user: dgp tags: bug-3607246
04:44
merge trunk check-in: a9b009d0e5 user: dgp tags: dgp-refactor
2013-03-06
21:55
Cleaner error handling in fixempties(). check-in: c769b9bb91 user: dgp tags: trunk
21:54
Cleaner error handling in fixempties(). check-in: 8577d952c4 user: dgp tags: core-8-5-branch
20:50
3604074,3606683 Rewrite of the fixempties() routine (and supporting routines) to completely eliminat... check-in: 4d7eba11ad user: dgp tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/regc_nfa.c.

1392
1393
1394
1395
1396
1397
1398



1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432

	    /* 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







>
>
>



















|






|







1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435

	    /* 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