diff options
author | Guido van Rossum <guido@python.org> | 1994-12-30 15:46:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-12-30 15:46:02 (GMT) |
commit | 588633daa2fe7276ae4b0c99723094add0d965ff (patch) | |
tree | 531b98a64c67825f81af62a682cacc29707b4b6a | |
parent | 66cb311fba7e824f11964090bce8b6b91f00d2e4 (diff) | |
download | cpython-588633daa2fe7276ae4b0c99723094add0d965ff.zip cpython-588633daa2fe7276ae4b0c99723094add0d965ff.tar.gz cpython-588633daa2fe7276ae4b0c99723094add0d965ff.tar.bz2 |
Parser/tokenizer.c (tok_nextc): zap tok->buf after freeing;
rest: abort() -> fatal(); small things
-rw-r--r-- | Parser/grammar.c | 13 | ||||
-rw-r--r-- | Parser/parser.c | 6 | ||||
-rw-r--r-- | Parser/pgen.c | 6 | ||||
-rw-r--r-- | Parser/pgenmain.c | 1 | ||||
-rw-r--r-- | 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; } |