From 588633daa2fe7276ae4b0c99723094add0d965ff Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 30 Dec 1994 15:46:02 +0000 Subject: Parser/tokenizer.c (tok_nextc): zap tok->buf after freeing; rest: abort() -> fatal(); small things --- Parser/grammar.c | 13 ++++++++++--- Parser/parser.c | 6 ++---- Parser/pgen.c | 6 +++--- Parser/pgenmain.c | 1 - Parser/tokenizer.c | 7 +++---- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Parser/grammar.c b/Parser/grammar.c index 1285fb3..b422cf5 100644 --- a/Parser/grammar.c +++ b/Parser/grammar.c @@ -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]); diff --git a/Parser/parser.c b/Parser/parser.c index 9167a9d..1b11801 100644 --- a/Parser/parser.c +++ b/Parser/parser.c @@ -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++; } diff --git a/Parser/pgen.c b/Parser/pgen.c index 0232a76..1827477 100644 --- a/Parser/pgen.c +++ b/Parser/pgen.c @@ -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; diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c index 96a3b3c..c93fade 100644 --- a/Parser/pgenmain.c +++ b/Parser/pgenmain.c @@ -64,7 +64,6 @@ main(argc, argv) char **argv; { grammar *g; - node *n; FILE *fp; char *filename; diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 7c25450..baed65d 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -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; } -- cgit v0.12