[hackers] [sbase] Fix small issue in nl(1) || FRIGN

From: <git_AT_suckless.org>
Date: Sun, 5 Apr 2015 10:14:04 +0200 (CEST)

commit 28c5d560fbf5303b0747471d4c5ffab0be7181db
Author: FRIGN <dev_AT_frign.de>
Date: Sat Apr 4 23:09:06 2015 +0200

    Fix small issue in nl(1)
    
    If fp == NULL we don't want to close it.

diff --git a/nl.c b/nl.c
index b84fe32..49c1d10 100644
--- a/nl.c
+++ b/nl.c
_AT_@ -111,7 +111,7 @@ getlinetype(char *type, regex_t *preg)
 int
 main(int argc, char *argv[])
 {
- FILE *fp;
+ FILE *fp = NULL;
         size_t l, s;
         char *d, *formattype, *formatblit;
 
_AT_@ -195,6 +195,6 @@ main(int argc, char *argv[])
                 nl(argv[0], fp);
         }
 
- return !!(fshut(fp, argv[0]) + fshut(stdin, "<stdin>") +
+ return !!((fp && fshut(fp, argv[0])) + fshut(stdin, "<stdin>") +
                   fshut(stdout, "<stdout>"));
 }
Received on Sun Apr 05 2015 - 10:14:04 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 05 2015 - 10:24:10 CEST