diff options
author | rsc <devnull@localhost> | 2004-04-21 05:34:37 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2004-04-21 05:34:37 +0000 |
commit | a8c15b08ca39ae9fa8d50f9e338d341c09fa57dd (patch) | |
tree | ffe19f2f3aaebc2dfe03d32d1614082aa9f85e8f /src/cmd/acid/lex.c | |
parent | eaf56db5bc78cfec908db84dc792c53ac8ffb90e (diff) | |
download | plan9port-a8c15b08ca39ae9fa8d50f9e338d341c09fa57dd.tar.gz plan9port-a8c15b08ca39ae9fa8d50f9e338d341c09fa57dd.tar.bz2 plan9port-a8c15b08ca39ae9fa8d50f9e338d341c09fa57dd.zip |
Include looks in #9/acid now.
Acid works harder at not falling over.
Diffstat (limited to 'src/cmd/acid/lex.c')
-rw-r--r-- | src/cmd/acid/lex.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/cmd/acid/lex.c b/src/cmd/acid/lex.c index bbfb47b1..d978407f 100644 --- a/src/cmd/acid/lex.c +++ b/src/cmd/acid/lex.c @@ -76,6 +76,7 @@ struct IOstack IOstack *prev; }; IOstack *lexio; +uint nlexio; void setacidfile(void) @@ -100,6 +101,9 @@ pushfile(char *file) Biobuf *b; IOstack *io; + if(nlexio > 64) + error("too many includes"); + if(file) b = Bopen(file, OREAD); else{ @@ -122,6 +126,7 @@ pushfile(char *file) io->fin = b; io->prev = lexio; lexio = io; + nlexio++; setacidfile(); } @@ -156,6 +161,7 @@ pushstr(Node *s) io->ip = io->text; io->fin = 0; io->prev = lexio; + nlexio++; lexio = io; setacidfile(); } @@ -190,6 +196,7 @@ popio(void) s = lexio; lexio = s->prev; free(s); + nlexio--; setacidfile(); return 1; } @@ -197,18 +204,17 @@ popio(void) int Zfmt(Fmt *f) { - int i; - char buf[1024]; + char buf[1024], *p; IOstack *e; e = lexio; if(e) { - i = sprint(buf, "%s:%d", e->name, line); + p = seprint(buf, buf+sizeof buf, "%s:%d", e->name, line); while(e->prev) { e = e->prev; if(initialising && e->prev == 0) break; - i += sprint(buf+i, " [%s:%d]", e->name, e->line); + p = seprint(p, buf+sizeof buf, " [%s:%d]", e->name, e->line); } } else sprint(buf, "no file:0"); |