fixed error handling in p, pr, sed, xd, yacc
This commit is contained in:
parent
ebe8f9460b
commit
db0f050d2b
|
@ -21,7 +21,9 @@ main(int argc, char *argv[])
|
|||
fprint(2, "p: can't open /dev/cons\n");
|
||||
exits("missing /dev/cons");
|
||||
}
|
||||
Blethal(cons, nil);
|
||||
Binit(&bout, 1, OWRITE);
|
||||
Blethal(&bout, nil);
|
||||
n = 0;
|
||||
while(argc > 1) {
|
||||
--argc; argv++;
|
||||
|
@ -54,6 +56,7 @@ printfile(int f)
|
|||
|
||||
b = malloc(sizeof(Biobuf));
|
||||
Binit(b, f, OREAD);
|
||||
Blethal(b, nil);
|
||||
for(;;){
|
||||
for(i=1; i <= pglen; i++) {
|
||||
s = Brdline(b, '\n');
|
||||
|
|
|
@ -147,6 +147,7 @@ main(int argc, char *argv[])
|
|||
int nfdone = 0;
|
||||
|
||||
Binit(&bout, 1, OWRITE);
|
||||
Blethal(&bout, nil);
|
||||
Files = fstr;
|
||||
for(argc = findopt(argc, argv); argc > 0; --argc, ++argv)
|
||||
if(Multi == 'm') {
|
||||
|
@ -600,6 +601,7 @@ mustopen(char *s, Fils *f)
|
|||
if(f->f_f == 0)
|
||||
cerror("no memory");
|
||||
Binit(f->f_f, 0, OREAD);
|
||||
Blethal(f->f_f, nil);
|
||||
} else
|
||||
if((f->f_f = Bopen(f->f_name = s, OREAD)) == 0) {
|
||||
tmp = ffiler(f->f_name);
|
||||
|
@ -607,6 +609,7 @@ mustopen(char *s, Fils *f)
|
|||
free(tmp);
|
||||
}
|
||||
if(f->f_f != 0) {
|
||||
Blethal(f->f_f, nil);
|
||||
if((f->f_nextc = Bgetrune(f->f_f)) >= 0 || Multi == 'm')
|
||||
return f->f_f;
|
||||
sprint(s = (char*)getspace(strlen(f->f_name) + 1 + EMPTY),
|
||||
|
|
|
@ -207,6 +207,7 @@ main(int argc, char **argv)
|
|||
|
||||
lnum = 0;
|
||||
Binit(&fout, 1, OWRITE);
|
||||
Blethal(&fout, nil);
|
||||
fcode[nfiles++] = &fout;
|
||||
compfl = 0;
|
||||
|
||||
|
@ -610,6 +611,7 @@ open_file(char *name)
|
|||
(fd = create(name, OWRITE, 0666)) < 0)
|
||||
quit("Cannot create %s", name);
|
||||
Binit(bp, fd, OWRITE);
|
||||
Blethal(bp, nil);
|
||||
Bseek(bp, 0, 2);
|
||||
fcode[nfiles++] = bp;
|
||||
return bp;
|
||||
|
@ -688,6 +690,7 @@ newfile(enum PTYPE type, char *name)
|
|||
prog.curr = name;
|
||||
else if ((prog.bp = Bopen(name, OREAD)) == 0)
|
||||
quit("Cannot open pattern-file: %s\n", name);
|
||||
Blethal(prog.bp, nil);
|
||||
prog.type = type;
|
||||
}
|
||||
|
||||
|
@ -1347,6 +1350,7 @@ arout(void)
|
|||
*s = '\0';
|
||||
if((fi = Bopen(buf, OREAD)) == 0)
|
||||
continue;
|
||||
Blethal(fi, nil);
|
||||
while((c = Bgetc(fi)) >= 0)
|
||||
Bputc(&fout, c);
|
||||
Bterm(fi);
|
||||
|
@ -1450,6 +1454,7 @@ opendata(void)
|
|||
Binit(&stdin, 0, OREAD);
|
||||
f = &stdin;
|
||||
}
|
||||
Blethal(f, nil);
|
||||
fhead = fhead->next;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ main(int argc, char *argv[])
|
|||
Arg *ap;
|
||||
|
||||
Binit(&bout, 1, OWRITE);
|
||||
Blethal(&bout, nil);
|
||||
err = 0;
|
||||
ap = 0;
|
||||
while(argc>1 && argv[1][0]=='-' && argv[1][1]){
|
||||
|
@ -205,6 +206,7 @@ xd(char *name, int title)
|
|||
bp = &bin;
|
||||
Binit(bp, fd, OREAD);
|
||||
}
|
||||
Blethal(bp, nil);
|
||||
if(title)
|
||||
xprint("%s\n", name);
|
||||
addr = 0;
|
||||
|
|
|
@ -402,6 +402,7 @@ others(void)
|
|||
finput = Bopen(parser, OREAD);
|
||||
if(finput == 0)
|
||||
error("cannot find parser %s", parser);
|
||||
Blethal(finput, nil);
|
||||
warray("yyr1", levprd, nprod);
|
||||
aryfil(temp1, nprod, 0);
|
||||
PLOOP(1, i)
|
||||
|
@ -481,6 +482,7 @@ others(void)
|
|||
faction = Bopen(actname, OREAD);
|
||||
if(faction == 0)
|
||||
error("cannot reopen action tempfile");
|
||||
Blethal(faction, nil);
|
||||
while((c=Bgetrune(faction)) != Beof)
|
||||
Bputrune(ftable, c);
|
||||
Bterm(faction);
|
||||
|
@ -1217,6 +1219,8 @@ setup(int argc, char *argv[])
|
|||
faction = Bopen(actname = mktemp(tactname), OWRITE);
|
||||
if(ftemp == 0 || faction == 0)
|
||||
error("cannot open temp file");
|
||||
Blethal(ftemp, nil);
|
||||
Blethal(faction, nil);
|
||||
if(argc < 1)
|
||||
error("no input file");
|
||||
infile = argv[0];
|
||||
|
@ -1232,6 +1236,7 @@ setup(int argc, char *argv[])
|
|||
finput = Bopen(infile, OREAD);
|
||||
if(finput == 0)
|
||||
error("cannot open '%s'", argv[0]);
|
||||
Blethal(finput, nil);
|
||||
cnamp = cnames;
|
||||
|
||||
defin(0, "$end");
|
||||
|
@ -2127,6 +2132,7 @@ openup(char *stem, int dflag, int vflag, int ytab, char *ytabc)
|
|||
foutput = Bopen(buf, OWRITE);
|
||||
if(foutput == 0)
|
||||
error("cannot open %s", buf);
|
||||
Blethal(foutput, nil);
|
||||
}
|
||||
if(yydebug) {
|
||||
snprint(buf, sizeof buf, "%s.%s", stem, FILEDEBUG);
|
||||
|
@ -2138,6 +2144,7 @@ openup(char *stem, int dflag, int vflag, int ytab, char *ytabc)
|
|||
fdefine = Bopen(buf, OWRITE);
|
||||
if(fdefine == 0)
|
||||
error("can't create %s", buf);
|
||||
Blethal(fdefine, nil);
|
||||
}
|
||||
if(ytab == 0)
|
||||
snprint(buf, sizeof buf, "%s.%s", stem, OFILE);
|
||||
|
@ -2146,6 +2153,7 @@ openup(char *stem, int dflag, int vflag, int ytab, char *ytabc)
|
|||
ftable = Bopen(buf, OWRITE);
|
||||
if(ftable == 0)
|
||||
error("cannot open table file %s", buf);
|
||||
Blethal(ftable, nil);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2619,6 +2627,7 @@ callopt(void)
|
|||
finput = Bopen(tempname, OREAD);
|
||||
if(finput == 0)
|
||||
error("optimizer cannot open tempfile");
|
||||
Blethal(finput, nil);
|
||||
|
||||
pgo[0] = 0;
|
||||
temp1[0] = 0;
|
||||
|
|
Loading…
Reference in a new issue