[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.21 and 1.22

version 1.21, 2016/03/20 17:14:51 version 1.22, 2021/10/10 15:57:25
Line 48 
Line 48 
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
           const char *errstr;
         FILE    *fp;          FILE    *fp;
         long    cnt;          long    cnt;
         int     ch, firsttime;          int     ch, firsttime;
         long    linecnt = 10;          long    linecnt = 10;
         char    *p = NULL;  
         int     status = 0;          int     status = 0;
   
         if (pledge("stdio rpath", NULL) == -1)          if (pledge("stdio rpath", NULL) == -1)
Line 61 
Line 61 
         /* handle obsolete -number syntax */          /* handle obsolete -number syntax */
         if (argc > 1 && argv[1][0] == '-' &&          if (argc > 1 && argv[1][0] == '-' &&
             isdigit((unsigned char)argv[1][1])) {              isdigit((unsigned char)argv[1][1])) {
                 p = argv[1] + 1;                  linecnt = strtonum(argv[1] + 1, 1, LONG_MAX, &errstr);
                   if (errstr != NULL)
                           errx(1, "count is %s: %s", errstr, argv[1] + 1);
                 argc--;                  argc--;
                 argv++;                  argv++;
         }          }
Line 69 
Line 71 
         while ((ch = getopt(argc, argv, "n:")) != -1) {          while ((ch = getopt(argc, argv, "n:")) != -1) {
                 switch (ch) {                  switch (ch) {
                 case 'n':                  case 'n':
                         p = optarg;                          linecnt = strtonum(optarg, 1, LONG_MAX, &errstr);
                           if (errstr != NULL)
                                   errx(1, "count is %s: %s", errstr, optarg);
                         break;                          break;
                 default:                  default:
                         usage();                          usage();
                 }                  }
         }          }
         argc -= optind, argv += optind;          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);  
         }  
   
         for (firsttime = 1; ; firsttime = 0) {          for (firsttime = 1; ; firsttime = 0) {
                 if (!*argv) {                  if (!*argv) {

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22