summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraiju <aiju@phicode.de>2011-07-13 14:17:09 +0200
committeraiju <aiju@phicode.de>2011-07-13 14:17:09 +0200
commitdb0f050d2b65a5fe329cf9454720420cb2deb721 (patch)
treea018a55765531186d6a5c8eab00f41722d921e97
parentebe8f9460b6a3012c9c75d8479a3e427d5c04977 (diff)
downloadplan9front-db0f050d2b65a5fe329cf9454720420cb2deb721.tar.xz
fixed error handling in p, pr, sed, xd, yacc
-rw-r--r--sys/src/cmd/p.c3
-rw-r--r--sys/src/cmd/pr.c3
-rw-r--r--sys/src/cmd/sed.c5
-rw-r--r--sys/src/cmd/xd.c2
-rw-r--r--sys/src/cmd/yacc.c9
5 files changed, 22 insertions, 0 deletions
diff --git a/sys/src/cmd/p.c b/sys/src/cmd/p.c
index 9bc5cc471..4b3a713e3 100644
--- a/sys/src/cmd/p.c
+++ b/sys/src/cmd/p.c
@@ -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');
diff --git a/sys/src/cmd/pr.c b/sys/src/cmd/pr.c
index 2aff9ab43..1c5b75acf 100644
--- a/sys/src/cmd/pr.c
+++ b/sys/src/cmd/pr.c
@@ -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),
diff --git a/sys/src/cmd/sed.c b/sys/src/cmd/sed.c
index 4fd08b8b5..aa603b4bd 100644
--- a/sys/src/cmd/sed.c
+++ b/sys/src/cmd/sed.c
@@ -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;
}
diff --git a/sys/src/cmd/xd.c b/sys/src/cmd/xd.c
index dcbc2f2f9..e14b741e1 100644
--- a/sys/src/cmd/xd.c
+++ b/sys/src/cmd/xd.c
@@ -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;
diff --git a/sys/src/cmd/yacc.c b/sys/src/cmd/yacc.c
index 75e0d0161..7aef1a281 100644
--- a/sys/src/cmd/yacc.c
+++ b/sys/src/cmd/yacc.c
@@ -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;