From b678a1801836b49f61f4993c18fc6bc4861b2e08 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 6 Aug 2019 08:04:06 -0400 Subject: formatting of error messages --- head.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/head.c b/head.c index 9f54706..1642186 100644 --- a/head.c +++ b/head.c @@ -37,7 +37,7 @@ static int head(const char *path, int nlines) } if (f == NULL) { - fprintf(stderr, "FIXME: Couldn't open %s: %s\n", path ? path : "stdin", strerror(errno)); + fprintf(stderr, "head: %s: %s\n", path, strerror(errno)); return 1; } @@ -64,12 +64,12 @@ int main(int argc, char **argv) char *end; int c; - while ((c = getopt(argc, argv, ":n:")) != -1) { + while ((c = getopt(argc, argv, "n:")) != -1) { switch (c) { case 'n': lines = strtol(optarg, &end, 10); - if (end != NULL && strlen(end) > 0) { - fprintf(stderr, "head: Invalid number %s\n", optarg); + if (*end != '\0') { + fprintf(stderr, "head: invalid number %s\n", optarg); return 1; } break; -- cgit v1.2.1