diff: continue after i/o errors when diffing many files

This commit is contained in:
Russ Cox 2007-11-05 11:09:39 -05:00
parent e84044be84
commit eb5d2a54d5
2 changed files with 13 additions and 5 deletions

View file

@ -19,8 +19,10 @@ scandir(char *name)
int nitems;
int fd, n;
if ((fd = open(name, OREAD)) < 0)
panic(2, "can't open %s\n", name);
if ((fd = open(name, OREAD)) < 0){
panic(mflag ? 0 : 2, "can't open %s\n", name);
return nil;
}
cp = 0;
nitems = 0;
if((n = dirreadall(fd, &db)) > 0){
@ -63,6 +65,8 @@ diffdir(char *f, char *t, int level)
dt = scandir(t);
dirf = df;
dirt = dt;
if(df == nil || dt == nil)
goto Out;
while (*df || *dt) {
from = *df;
to = *dt;
@ -99,9 +103,10 @@ diffdir(char *f, char *t, int level)
diff(fb, tb, level+1);
df++; dt++;
}
for (df = dirf; *df; df++)
Out:
for (df = dirf; df && *df; df++)
FREE(*df);
for (dt = dirt; *dt; dt++)
for (dt = dirt; dt && *dt; dt++)
FREE(*dt);
FREE(dirf);
FREE(dirt);

View file

@ -183,7 +183,9 @@ main(int argc, char *argv[])
char *p;
int i;
Dir *fsb, *tsb;
extern int _p9usepwlibrary;
_p9usepwlibrary = 0;
Binit(&stdout, 1, OWRITE);
progname = *argv;
while (--argc && (*++argv)[0] == '-' && (*argv)[1]) {
@ -208,6 +210,7 @@ main(int argc, char *argv[])
case 'r':
rflag = 1;
mflag = 1;
break;
case 'm':