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

Diff for /src/usr.bin/compress/main.c between version 1.71 and 1.72

version 1.71, 2008/02/25 16:53:55 version 1.72, 2008/07/05 21:00:38
Line 93 
Line 93 
 #endif /* SMALL */  #endif /* SMALL */
   
 int permission(const char *);  int permission(const char *);
 __dead void usage(int);  __dead void usage(int, int);
 int docompress(const char *, char *, const struct compressor *,  int docompress(const char *, char *, const struct compressor *,
     int, struct stat *);      int, struct stat *);
 int dodecompress(const char *, char *, const struct compressor *,  int dodecompress(const char *, char *, const struct compressor *,
Line 104 
Line 104 
 void list_stats(const char *, const struct compressor *, struct z_info *);  void list_stats(const char *, const struct compressor *, struct z_info *);
 void verbose_info(const char *, off_t, off_t, u_int32_t);  void verbose_info(const char *, off_t, off_t, u_int32_t);
   
 #define OPTSTRING       "123456789ab:cdfghlLnNOo:qrS:tvV"  
 const struct option longopts[] = {  const struct option longopts[] = {
 #ifndef SMALL  #ifndef SMALL
         { "ascii",      no_argument,            0, 'a' },          { "ascii",      no_argument,            0, 'a' },
Line 140 
Line 139 
         char *p, *infile;          char *p, *infile;
         char outfile[MAXPATHLEN], _infile[MAXPATHLEN], suffix[16];          char outfile[MAXPATHLEN], _infile[MAXPATHLEN], suffix[16];
         char *nargv[512];       /* some estimate based on ARG_MAX */          char *nargv[512];       /* some estimate based on ARG_MAX */
         int bits, ch, error, i, rc, cflag, oflag;          int bits, ch, error, i, rc, cflag, oflag, mode;
           static const char *optstr[3] = {
                   "123456789ab:cdfghlLnNOo:qrS:tvV",
                   "cfhlNno:qrtv",
                   "fghqr"
           };
   
         bits = cflag = oflag = 0;          bits = cflag = oflag = mode = 0;
         storename = -1;          storename = -1;
         p = __progname;          p = __progname;
         if (p[0] == 'g') {          if (p[0] == 'g') {
Line 160 
Line 164 
         if (!strcmp(p, "zcat")) {          if (!strcmp(p, "zcat")) {
                 decomp++;                  decomp++;
                 cflag = 1;                  cflag = 1;
                   mode = MODE_CAT;
         } else {          } else {
                 if (p[0] == 'u' && p[1] == 'n') {                  if (p[0] == 'u' && p[1] == 'n') {
                         p += 2;                          p += 2;
                         decomp++;                          decomp++;
                           mode = MODE_DECOMP;
                 }                  }
   
                 if (strcmp(p, "zip") &&                  if (strcmp(p, "zip") &&
Line 190 
Line 196 
                 argv = nargv;                  argv = nargv;
         }          }
   
         while ((ch = getopt_long(argc, argv, OPTSTRING, longopts, NULL)) != -1)          while ((ch = getopt_long(argc, argv, optstr[mode], longopts, NULL)) != -1)
                 switch(ch) {                  switch(ch) {
                 case '1':                  case '1':
                 case '2':                  case '2':
Line 289 
Line 295 
                         break;                          break;
   
                 case 'h':                  case 'h':
                         usage(0);                          usage(0, mode);
                         break;                          break;
                 default:                  default:
                         usage(1);                          usage(1, mode);
                 }                  }
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
Line 887 
Line 893 
 }  }
   
 __dead void  __dead void
 usage(int status)  usage(int status, int mode)
 {  {
         fprintf(stderr,          switch (mode) {
             "usage: %s [-123456789cdfghLlNnOqrtVv] [-b bits] [-o filename]\n"          case MODE_COMP:
             "\t[-S suffix] [file ...]\n",                  fprintf(stderr, "usage: %s [-123456789cdfghLlNnOqrtVv] "
             __progname);                      "[-b bits] [-o filename] [-S suffix]\n"
                       "       %*s [file ...]\n",
                       __progname, (int)strlen(__progname), "");
                   break;
           case MODE_DECOMP:
                   fprintf(stderr, "usage: %s [-cfhlNnqrtv] [-o filename] "
                       "[file ...]\n", __progname);
                   break;
           case MODE_CAT:
                   fprintf(stderr, "usage: %s [-fghqr] [file ...]\n", __progname);
                   break;
           }
         exit(status);          exit(status);
 }  }

Legend:
Removed from v.1.71  
changed lines
  Added in v.1.72