Include looks in #9/acid now.
Acid works harder at not falling over.
This commit is contained in:
parent
eaf56db5bc
commit
a8c15b08ca
3 changed files with 26 additions and 6 deletions
|
|
@ -478,6 +478,8 @@ interpret(Node *r, Node *args)
|
||||||
void
|
void
|
||||||
include(Node *r, Node *args)
|
include(Node *r, Node *args)
|
||||||
{
|
{
|
||||||
|
char *file, *libfile;
|
||||||
|
static char buf[1024];
|
||||||
Node res;
|
Node res;
|
||||||
int isave;
|
int isave;
|
||||||
|
|
||||||
|
|
@ -488,7 +490,19 @@ include(Node *r, Node *args)
|
||||||
error("include(string): arg type");
|
error("include(string): arg type");
|
||||||
|
|
||||||
Bflush(bout);
|
Bflush(bout);
|
||||||
pushfile(res.store.u.string->string);
|
|
||||||
|
libfile = nil;
|
||||||
|
file = res.store.u.string->string;
|
||||||
|
if(access(file, AREAD) < 0 && file[0] != '/'){
|
||||||
|
snprint(buf, sizeof buf, "#9/acid/%s", file);
|
||||||
|
libfile = unsharp(buf);
|
||||||
|
if(access(libfile, AREAD) >= 0){
|
||||||
|
strecpy(buf, buf+sizeof buf, libfile);
|
||||||
|
file = buf;
|
||||||
|
}
|
||||||
|
free(libfile);
|
||||||
|
}
|
||||||
|
pushfile(file);
|
||||||
|
|
||||||
isave = interactive;
|
isave = interactive;
|
||||||
interactive = 0;
|
interactive = 0;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ struct IOstack
|
||||||
IOstack *prev;
|
IOstack *prev;
|
||||||
};
|
};
|
||||||
IOstack *lexio;
|
IOstack *lexio;
|
||||||
|
uint nlexio;
|
||||||
|
|
||||||
void
|
void
|
||||||
setacidfile(void)
|
setacidfile(void)
|
||||||
|
|
@ -100,6 +101,9 @@ pushfile(char *file)
|
||||||
Biobuf *b;
|
Biobuf *b;
|
||||||
IOstack *io;
|
IOstack *io;
|
||||||
|
|
||||||
|
if(nlexio > 64)
|
||||||
|
error("too many includes");
|
||||||
|
|
||||||
if(file)
|
if(file)
|
||||||
b = Bopen(file, OREAD);
|
b = Bopen(file, OREAD);
|
||||||
else{
|
else{
|
||||||
|
|
@ -122,6 +126,7 @@ pushfile(char *file)
|
||||||
io->fin = b;
|
io->fin = b;
|
||||||
io->prev = lexio;
|
io->prev = lexio;
|
||||||
lexio = io;
|
lexio = io;
|
||||||
|
nlexio++;
|
||||||
setacidfile();
|
setacidfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,6 +161,7 @@ pushstr(Node *s)
|
||||||
io->ip = io->text;
|
io->ip = io->text;
|
||||||
io->fin = 0;
|
io->fin = 0;
|
||||||
io->prev = lexio;
|
io->prev = lexio;
|
||||||
|
nlexio++;
|
||||||
lexio = io;
|
lexio = io;
|
||||||
setacidfile();
|
setacidfile();
|
||||||
}
|
}
|
||||||
|
|
@ -190,6 +196,7 @@ popio(void)
|
||||||
s = lexio;
|
s = lexio;
|
||||||
lexio = s->prev;
|
lexio = s->prev;
|
||||||
free(s);
|
free(s);
|
||||||
|
nlexio--;
|
||||||
setacidfile();
|
setacidfile();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -197,18 +204,17 @@ popio(void)
|
||||||
int
|
int
|
||||||
Zfmt(Fmt *f)
|
Zfmt(Fmt *f)
|
||||||
{
|
{
|
||||||
int i;
|
char buf[1024], *p;
|
||||||
char buf[1024];
|
|
||||||
IOstack *e;
|
IOstack *e;
|
||||||
|
|
||||||
e = lexio;
|
e = lexio;
|
||||||
if(e) {
|
if(e) {
|
||||||
i = sprint(buf, "%s:%d", e->name, line);
|
p = seprint(buf, buf+sizeof buf, "%s:%d", e->name, line);
|
||||||
while(e->prev) {
|
while(e->prev) {
|
||||||
e = e->prev;
|
e = e->prev;
|
||||||
if(initialising && e->prev == 0)
|
if(initialising && e->prev == 0)
|
||||||
break;
|
break;
|
||||||
i += sprint(buf+i, " [%s:%d]", e->name, e->line);
|
p = seprint(p, buf+sizeof buf, " [%s:%d]", e->name, e->line);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
sprint(buf, "no file:0");
|
sprint(buf, "no file:0");
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ unique(char *buf, Symbol *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(renamed && !quiet)
|
if(renamed && !quiet)
|
||||||
print("\t%s=%s %c/%Z\n", s->name, buf, s->type, s->loc);
|
print("\t%s=%s %c/%L\n", s->name, buf, s->type, s->loc);
|
||||||
if(l == 0)
|
if(l == 0)
|
||||||
l = enter(buf, Tid);
|
l = enter(buf, Tid);
|
||||||
return l;
|
return l;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue