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

Diff for /src/usr.bin/uniq/uniq.c between version 1.32 and 1.33

version 1.32, 2022/01/01 17:44:18 version 1.33, 2022/01/01 18:20:52
Line 35 
Line 35 
   
 #include <ctype.h>  #include <ctype.h>
 #include <err.h>  #include <err.h>
 #include <errno.h>  
 #include <limits.h>  #include <limits.h>
 #include <locale.h>  #include <locale.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   #include <strings.h>
 #include <unistd.h>  #include <unistd.h>
 #include <wchar.h>  #include <wchar.h>
 #include <wctype.h>  #include <wctype.h>
Line 57 
Line 57 
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
           const char *errstr;
         char *p, *prevline, *t, *thisline, *tmp;          char *p, *prevline, *t, *thisline, *tmp;
         size_t prevsize, thissize, tmpsize;          size_t prevsize, thissize, tmpsize;
         ssize_t len;          ssize_t len;
Line 69 
Line 70 
   
         obsolete(argv);          obsolete(argv);
         while ((ch = getopt(argc, argv, "cdf:is:u")) != -1) {          while ((ch = getopt(argc, argv, "cdf:is:u")) != -1) {
                 const char *errstr;  
   
                 switch (ch) {                  switch (ch) {
                 case 'c':                  case 'c':
                         cflag = 1;                          cflag = 1;
Line 81 
Line 80 
                 case 'f':                  case 'f':
                         numfields = strtonum(optarg, 0, LLONG_MAX, &errstr);                          numfields = strtonum(optarg, 0, LLONG_MAX, &errstr);
                         if (errstr)                          if (errstr)
                                 errx(1, "field skip value is %s: %s",                                  errx(1, "fields is %s: %s", errstr, optarg);
                                     errstr, optarg);  
                         break;                          break;
                 case 'i':                  case 'i':
                         iflag = 1;                          iflag = 1;
Line 90 
Line 88 
                 case 's':                  case 's':
                         numchars = strtonum(optarg, 0, LLONG_MAX, &errstr);                          numchars = strtonum(optarg, 0, LLONG_MAX, &errstr);
                         if (errstr)                          if (errstr)
                                 errx(1,                                  errx(1, "chars is %s: %s", errstr, optarg);
                                     "character skip value is %s: %s",  
                                     errstr, optarg);  
                         break;                          break;
                 case 'u':                  case 'u':
                         uflag = 1;                          uflag = 1;
Line 101 
Line 97 
                         usage();                          usage();
                 }                  }
         }          }
   
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
   
Line 129 
Line 124 
                 free(prevline);                  free(prevline);
                 if (ferror(stdin))                  if (ferror(stdin))
                         err(1, "getline");                          err(1, "getline");
                 exit(0);                  return 0;
         }          }
         if (prevline[len - 1] == '\n')          if (prevline[len - 1] == '\n')
                 prevline[len - 1] = '\0';                  prevline[len - 1] = '\0';
Line 173 
Line 168 
         show(prevline);          show(prevline);
         free(prevline);          free(prevline);
   
         exit(0);          return 0;
 }  }
   
 /*  /*
Line 256 
Line 251 
 __dead void  __dead void
 usage(void)  usage(void)
 {  {
         extern char *__progname;          fprintf(stderr,
   
         (void)fprintf(stderr,  
             "usage: %s [-ci] [-d | -u] [-f fields] [-s chars] [input_file [output_file]]\n",              "usage: %s [-ci] [-d | -u] [-f fields] [-s chars] [input_file [output_file]]\n",
             __progname);              getprogname());
         exit(1);          exit(1);
 }  }

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33