aboutsummaryrefslogtreecommitdiffstats
path: root/loc.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-06-21 21:23:28 +0200
committerMattias Andrée <maandree@kth.se>2019-06-21 21:23:28 +0200
commit9530053c551fa0e9bad2a0ffda905bb5a9e5e234 (patch)
tree972f82f82c0b14a3a3ca3cb84766c58ca74045e2 /loc.c
parentFix tabulation (diff)
downloadloc-9530053c551fa0e9bad2a0ffda905bb5a9e5e234.tar.gz
loc-9530053c551fa0e9bad2a0ffda905bb5a9e5e234.tar.bz2
loc-9530053c551fa0e9bad2a0ffda905bb5a9e5e234.tar.xz
Fix error handling in the case of 1 file argument4
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--loc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/loc.c b/loc.c
index bd43584..855ad5b 100644
--- a/loc.c
+++ b/loc.c
@@ -163,7 +163,10 @@ main(int argc, char *argv[])
n = count(fd, argv[0]);
close(fd);
}
- printf("%zi\n", n);
+ if (n >= 0)
+ printf("%zi\n", n);
+ else
+ ret = 1;
} else {
if (!(res = calloc(argc, sizeof(struct result))))
fprintf(stderr, "%s: out of memory\n", argv0), exit(1);