Audit unexpand(1)

I checked the algorithm already a while ago. What was left was a
couple of style-fixes.
This commit is contained in:
FRIGN 2015-03-17 23:45:03 +01:00
parent f6dc69eca3
commit 5af4cdcd60
2 changed files with 8 additions and 6 deletions

2
README
View File

@ -81,7 +81,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
=*| true yes none =*| true yes none
=*| tty yes none =*| tty yes none
=*| uname yes none =*| uname yes none
#* unexpand yes none #*| unexpand yes none
=* uniq yes none =* uniq yes none
=*| unlink yes none =*| unlink yes none
=* uudecode yes none =* uudecode yes none

View File

@ -25,6 +25,7 @@ parselist(const char *s)
eprintf("tablist must be ascending\n"); eprintf("tablist must be ascending\n");
} }
tablist = ereallocarray(tablist, i + 1, sizeof(*tablist)); tablist = ereallocarray(tablist, i + 1, sizeof(*tablist));
return i; return i;
} }
@ -148,18 +149,19 @@ main(int argc, char *argv[])
tablistlen = parselist(tl); tablistlen = parselist(tl);
if (argc == 0) { if (!argc) {
unexpand("<stdin>", stdin); unexpand("<stdin>", stdin);
} else { } else {
for (; argc > 0; argc--, argv++) { for (; *argv; argc--, argv++) {
if (!(fp = fopen(argv[0], "r"))) { if (!(fp = fopen(*argv, "r"))) {
weprintf("fopen %s:", argv[0]); weprintf("fopen %s:", *argv);
ret = 1; ret = 1;
continue; continue;
} }
unexpand(argv[0], fp); unexpand(*argv, fp);
fclose(fp); fclose(fp);
} }
} }
return ret; return ret;
} }