=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/head/head.c,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/head/head.c 2003/06/10 22:20:47 1.11 --- src/usr.bin/head/head.c 2006/10/06 23:44:30 1.12 *************** *** 1,4 **** ! /* $OpenBSD: head.c,v 1.11 2003/06/10 22:20:47 deraadt Exp $ */ /* * Copyright (c) 1980, 1987 Regents of the University of California. --- 1,4 ---- ! /* $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,43 **** #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 $"; #endif /* not lint */ #include --- 37,43 ---- #ifndef lint /*static char sccsid[] = "from: @(#)head.c 5.5 (Berkeley) 6/1/90";*/ ! static char rcsid[] = "$OpenBSD: head.c,v 1.12 2006/10/06 23:44:30 ray Exp $"; #endif /* not lint */ #include *************** *** 62,79 **** long cnt; int ch, firsttime; long linecnt = 10; ! char *inval = NULL, *p = NULL; /* handle obsolete -number syntax */ if (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) { ! linecnt = strtol((p = argv[1] + 1), &inval, 10); argc--; argv++; } while ((ch = getopt (argc, argv, "n:")) != -1) switch (ch) { case 'n': ! linecnt = strtol((p = optarg), &inval, 10); break; default: usage(); --- 62,79 ---- long cnt; int ch, firsttime; long linecnt = 10; ! char *p = NULL; /* handle obsolete -number syntax */ if (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) { ! p = argv[1] + 1; argc--; argv++; } while ((ch = getopt (argc, argv, "n:")) != -1) switch (ch) { case 'n': ! p = optarg; break; default: usage(); *************** *** 81,91 **** 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); } /* setlinebuf(stdout); */ --- 81,91 ---- argc -= optind, argv += optind; if (p) { ! const char *errstr; ! ! linecnt = strtonum(p, 1, LONG_MAX, &errstr); ! if (errstr) ! errx(1, "line count %s: %s", errstr, p); } /* setlinebuf(stdout); */