Fix small issue in nl(1)

If fp == NULL we don't want to close it.
This commit is contained in:
FRIGN 2015-04-04 23:09:06 +02:00 committed by sin
parent 11e2d472bf
commit 28c5d560fb

4
nl.c
View File

@ -111,7 +111,7 @@ getlinetype(char *type, regex_t *preg)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
FILE *fp; FILE *fp = NULL;
size_t l, s; size_t l, s;
char *d, *formattype, *formatblit; char *d, *formattype, *formatblit;
@ -195,6 +195,6 @@ main(int argc, char *argv[])
nl(argv[0], fp); nl(argv[0], fp);
} }
return !!(fshut(fp, argv[0]) + fshut(stdin, "<stdin>") + return !!((fp && fshut(fp, argv[0])) + fshut(stdin, "<stdin>") +
fshut(stdout, "<stdout>")); fshut(stdout, "<stdout>"));
} }