[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.4 and 1.5

version 1.4, 1997/07/25 21:05:46 version 1.5, 1997/07/25 22:21:40
Line 56 
Line 56 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   #include <err.h>
   
 #define MAXLINELEN      (8 * 1024)  #define MAXLINELEN      (8 * 1024)
   
 int cflag, dflag, uflag;  int cflag, dflag, uflag;
 int numchars, numfields, repeats;  int numchars, numfields, repeats;
   
 void     err __P((const char *, ...));  
 FILE    *file __P((char *, char *));  FILE    *file __P((char *, char *));
 void     show __P((FILE *, char *));  void     show __P((FILE *, char *));
 char    *skip __P((char *));  char    *skip __P((char *));
Line 94 
Line 94 
                 case 'f':                  case 'f':
                         numfields = strtol(optarg, &p, 10);                          numfields = strtol(optarg, &p, 10);
                         if (numfields < 0 || *p)                          if (numfields < 0 || *p)
                                 err("illegal field skip value: %s", optarg);                                  errx(1, "illegal field skip value: %s", optarg);
                         break;                          break;
                 case 's':                  case 's':
                         numchars = strtol(optarg, &p, 10);                          numchars = strtol(optarg, &p, 10);
                         if (numchars < 0 || *p)                          if (numchars < 0 || *p)
                                 err("illegal character skip value: %s", optarg);                                  errx(1, "illegal character skip value: %s", optarg);
                         break;                          break;
                 case 'u':                  case 'u':
                         uflag = 1;                          uflag = 1;
Line 139 
Line 139 
         prevline = malloc(MAXLINELEN);          prevline = malloc(MAXLINELEN);
         thisline = malloc(MAXLINELEN);          thisline = malloc(MAXLINELEN);
         if (prevline == NULL || thisline == NULL)          if (prevline == NULL || thisline == NULL)
                 err("%s", strerror(errno));                  err(1, "malloc");
   
         if (fgets(prevline, MAXLINELEN, ifp) == NULL)          if (fgets(prevline, MAXLINELEN, ifp) == NULL)
                 exit(0);                  exit(0);
Line 210 
Line 210 
         FILE *fp;          FILE *fp;
   
         if ((fp = fopen(name, mode)) == NULL)          if ((fp = fopen(name, mode)) == NULL)
                 err("%s: %s", name, strerror(errno));                  err(1, name);
         return(fp);          return(fp);
 }  }
   
Line 236 
Line 236 
                  */                   */
                 len = strlen(ap);                  len = strlen(ap);
                 if ((start = p = malloc(len + 3)) == NULL)                  if ((start = p = malloc(len + 3)) == NULL)
                         err("%s", strerror(errno));                          err(1, "malloc");
                 *p++ = '-';                  *p++ = '-';
                 *p++ = ap[0] == '+' ? 's' : 'f';                  *p++ = ap[0] == '+' ? 's' : 'f';
                 (void)strcpy(p, ap + 1);                  (void)strcpy(p, ap + 1);
Line 250 
Line 250 
         (void)fprintf(stderr,          (void)fprintf(stderr,
             "usage: uniq [-c | -du] [-f fields] [-s chars] [input [output]]\n");              "usage: uniq [-c | -du] [-f fields] [-s chars] [input [output]]\n");
         exit(1);          exit(1);
 }  
   
 #ifdef __STDC__  
 #include <stdarg.h>  
 #else  
 #include <varargs.h>  
 #endif  
   
 void  
 #ifdef __STDC__  
 err(const char *fmt, ...)  
 #else  
 err(fmt, va_alist)  
         char *fmt;  
         va_dcl  
 #endif  
 {  
         va_list ap;  
 #ifdef __STDC__  
         va_start(ap, fmt);  
 #else  
         va_start(ap);  
 #endif  
         (void)fprintf(stderr, "uniq: ");  
         (void)vfprintf(stderr, fmt, ap);  
         va_end(ap);  
         (void)fprintf(stderr, "\n");  
         exit(1);  
         /* NOTREACHED */  
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5