diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/head/head.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c index d1eaffc040e..f16de6438c2 100644 --- a/usr.bin/head/head.c +++ b/usr.bin/head/head.c @@ -1,4 +1,4 @@ -/* $OpenBSD: head.c,v 1.11 2003/06/10 22:20:47 deraadt Exp $ */ +/* $OpenBSD: head.c,v 1.12 2006/10/06 23:44:30 ray Exp $ */ /* * Copyright (c) 1980, 1987 Regents of the University of California. @@ -37,7 +37,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)head.c 5.5 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$OpenBSD: head.c,v 1.11 2003/06/10 22:20:47 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: head.c,v 1.12 2006/10/06 23:44:30 ray Exp $"; #endif /* not lint */ #include <stdio.h> @@ -62,18 +62,18 @@ main(int argc, char *argv[]) long cnt; int ch, firsttime; long linecnt = 10; - char *inval = NULL, *p = NULL; + char *p = NULL; /* handle obsolete -number syntax */ if (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) { - linecnt = strtol((p = argv[1] + 1), &inval, 10); + p = argv[1] + 1; argc--; argv++; } while ((ch = getopt (argc, argv, "n:")) != -1) switch (ch) { case 'n': - linecnt = strtol((p = optarg), &inval, 10); + p = optarg; break; default: usage(); @@ -81,11 +81,11 @@ main(int argc, char *argv[]) argc -= optind, argv += optind; if (p) { - if ((linecnt == LONG_MIN || linecnt == LONG_MAX) && - errno == ERANGE) - err(1, "illegal line count -- %s", p); - else if (linecnt <= 0 || *inval) - errx(1, "illegal line count -- %s", p); + const char *errstr; + + linecnt = strtonum(p, 1, LONG_MAX, &errstr); + if (errstr) + errx(1, "line count %s: %s", errstr, p); } /* setlinebuf(stdout); */ |