Parser/tokenizer.c (tok_nextc): zap tok->buf after freeing;

rest: abort() -> fatal(); small things
This commit is contained in:
Guido van Rossum 1994-12-30 15:46:02 +00:00
parent 66cb311fba
commit 588633daa2
5 changed files with 18 additions and 15 deletions

View File

@ -48,6 +48,7 @@ newgrammar(start)
g->g_start = start;
g->g_ll.ll_nlabels = 0;
g->g_ll.ll_label = NULL;
g->g_accel = 0;
return g;
}
@ -84,6 +85,10 @@ addstate(d)
s = &d->d_state[d->d_nstates++];
s->s_narcs = 0;
s->s_arc = NULL;
s->s_lower = 0;
s->s_upper = 0;
s->s_accel = NULL;
s->s_accept = 0;
return s - d->d_state;
}
@ -139,7 +144,6 @@ findlabel(ll, type, str)
char *str;
{
int i;
label *lb;
for (i = 0; i < ll->ll_nlabels; i++) {
if (ll->ll_label[i].lb_type == type /*&&
@ -147,7 +151,8 @@ findlabel(ll, type, str)
return i;
}
fprintf(stderr, "Label %d/'%s' not found\n", type, str);
abort();
fatal("grammar.c:findlabel()");
/*NOTREACHED*/
}
/* Forward */
@ -158,8 +163,10 @@ translatelabels(g)
grammar *g;
{
int i;
#ifdef DEBUG
printf("Translating labels ...\n");
#endif
/* Don't translate EMPTY */
for (i = EMPTY+1; i < g->g_ll.ll_nlabels; i++)
translabel(g, &g->g_ll.ll_label[i]);

View File

@ -86,10 +86,8 @@ static void
s_pop(s)
register stack *s;
{
if (s_empty(s)) {
fprintf(stderr, "s_pop: parser stack underflow -- FATAL\n");
abort();
}
if (s_empty(s))
fatal("s_pop: parser stack underflow -- FATAL");
s->s_top++;
}

View File

@ -162,7 +162,7 @@ static char REQNFMT[] = "metacompile: less than %d children\n";
#define REQN(i, count) \
if (i < count) { \
fprintf(stderr, REQNFMT, count); \
abort(); \
fatal("REQN"); \
} else
#else
@ -390,7 +390,7 @@ dumpnfa(ll, nf)
/* PART TWO -- CONSTRUCT DFA -- Algorithm 3.1 from [Aho&Ullman 77] */
static int
static void
addclosure(ss, nf, istate)
bitset ss;
nfa *nf;
@ -628,7 +628,7 @@ simplify(xx_nstates, xx_state)
ss_state *xx_state;
{
int changes;
int i, j, k;
int i, j;
do {
changes = 0;

View File

@ -64,7 +64,6 @@ main(argc, argv)
char **argv;
{
grammar *g;
node *n;
FILE *fp;
char *filename;

View File

@ -209,6 +209,7 @@ tok_nextc(tok)
tok->lineno++;
if (buf == NULL) {
free(tok->buf);
tok->buf = NULL;
free(new);
tok->done = E_NOMEM;
return EOF;
@ -309,10 +310,8 @@ tok_backup(tok, c)
register int c;
{
if (c != EOF) {
if (--tok->cur < tok->buf) {
fprintf(stderr, "tok_backup: begin of buffer\n");
abort();
}
if (--tok->cur < tok->buf)
fatal("tok_backup: begin of buffer");
if (*tok->cur != c)
*tok->cur = c;
}