Audit expand(1)

Not much to do here. Forgot a colon in the manpage and some style-
changes in the code.
This commit is contained in:
FRIGN 2015-03-13 00:37:37 +01:00
parent 9fd4a745f8
commit b12041365d
3 changed files with 11 additions and 9 deletions

2
README
View File

@ -29,7 +29,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
=*| du yes none =*| du yes none
=*| echo yes none =*| echo yes none
=*| env yes none =*| env yes none
#* expand yes none #*| expand yes none
#* expr yes none #* expr yes none
=*| false yes none =*| false yes none
= find yes none = find yes none

View File

@ -1,4 +1,4 @@
.Dd January 25, 2015 .Dd March 13, 2015
.Dt EXPAND 1 .Dt EXPAND 1
.Os sbase .Os sbase
.Sh NAME .Sh NAME
@ -48,4 +48,4 @@ specification.
.Pp .Pp
The The
.Op Fl i .Op Fl i
flag is an extension to that specification flag is an extension to that specification.

View File

@ -27,6 +27,7 @@ parselist(const char *s)
tablist = ereallocarray(tablist, i + 1, sizeof(*tablist)); tablist = ereallocarray(tablist, i + 1, sizeof(*tablist));
/* tab length = 1 for the overflowing case later in the matcher */ /* tab length = 1 for the overflowing case later in the matcher */
tablist[i] = 1; tablist[i] = 1;
return i; return i;
} }
@ -87,8 +88,8 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
FILE *fp; FILE *fp;
int ret = 0;
char *tl = "8"; char *tl = "8";
int ret = 0;
ARGBEGIN { ARGBEGIN {
case 'i': case 'i':
@ -105,18 +106,19 @@ main(int argc, char *argv[])
tablistlen = parselist(tl); tablistlen = parselist(tl);
if (argc == 0) { if (!argc) {
expand("<stdin>", stdin); expand("<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;
} }
expand(argv[0], fp); expand(*argv, fp);
fclose(fp); fclose(fp);
} }
} }
return ret; return ret;
} }