[BACK]Return to head.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / head

Diff for /src/usr.bin/head/head.c between version 1.11 and 1.12

version 1.11, 2003/06/10 22:20:47 version 1.12, 2006/10/06 23:44:30
Line 62 
Line 62 
         long    cnt;          long    cnt;
         int     ch, firsttime;          int     ch, firsttime;
         long    linecnt = 10;          long    linecnt = 10;
         char    *inval = NULL, *p = NULL;          char    *p = NULL;
   
         /* handle obsolete -number syntax */          /* handle obsolete -number syntax */
         if (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) {          if (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) {
                 linecnt = strtol((p = argv[1] + 1), &inval, 10);                  p = argv[1] + 1;
                 argc--; argv++;                  argc--; argv++;
         }          }
   
         while ((ch = getopt (argc, argv, "n:")) != -1)          while ((ch = getopt (argc, argv, "n:")) != -1)
                 switch (ch) {                  switch (ch) {
                 case 'n':                  case 'n':
                         linecnt = strtol((p = optarg), &inval, 10);                          p = optarg;
                         break;                          break;
                 default:                  default:
                         usage();                          usage();
Line 81 
Line 81 
         argc -= optind, argv += optind;          argc -= optind, argv += optind;
   
         if (p) {          if (p) {
                 if ((linecnt == LONG_MIN || linecnt == LONG_MAX) &&                  const char *errstr;
                     errno == ERANGE)  
                         err(1, "illegal line count -- %s", p);                  linecnt = strtonum(p, 1, LONG_MAX, &errstr);
                 else if (linecnt <= 0 || *inval)                  if (errstr)
                         errx(1, "illegal line count -- %s", p);                          errx(1, "line count %s: %s", errstr, p);
         }          }
   
         /* setlinebuf(stdout); */          /* setlinebuf(stdout); */

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12