[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.6 and 1.7

version 1.6, 1997/07/19 19:08:28 version 1.7, 1997/08/19 06:32:36
Line 99 
Line 99 
         int ch, bits, cat, decomp, error;          int ch, bits, cat, decomp, error;
         struct compressor *method;          struct compressor *method;
         int exists, isreg, oreg;          int exists, isreg, oreg;
         char *infile, outfile[MAXPATHLEN], suffix[16];          char *infile, outfile[MAXPATHLEN+4], suffix[16];
         char *p;          char *p;
           int rc = 0;
   
         bits = cat = decomp = 0;          bits = cat = decomp = 0;
         p = __progname;          p = __progname;
Line 143 
Line 144 
                         break;                          break;
                 case 'b':                  case 'b':
                         bits = strtol(optarg, &p, 10);                          bits = strtol(optarg, &p, 10);
                           /*
                            * POSIX 1002.3 says 9 <= bits <= 14 for portable
                            * apps, but says the implementation may allow
                            * greater.
                            */
                         if (*p)                          if (*p)
                                 errx(1, "illegal bit count -- %s", optarg);                                  errx(1, "illegal bit count -- %s", optarg);
                         break;                          break;
Line 202 
Line 208 
                 if (*argv != NULL) {                  if (*argv != NULL) {
                         infile = *argv;                          infile = *argv;
                         if (outfile[0] == '\0') {                          if (outfile[0] == '\0') {
                                 if (!decomp && !cat && outfile[0] == '\0')                                  if (!decomp && !cat && outfile[0] == '\0') {
                                         snprintf(outfile, sizeof(outfile), "%s%s",                                          int len;
                                                  infile, method->suffix);                                          char *p;
                                 else if (decomp && !cat) {  
                                           snprintf(outfile, sizeof(outfile),
                                                   "%s%s", infile,
                                                   method->suffix);
   
                                           len = strlen(outfile);
                                           if (len > MAXPATHLEN) {
                                                   errx(1, "pathname%s too long",
                                                           method->suffix);
                                           }
   
                                           p = strrchr(outfile, '/');
                                           if (p == NULL) p = outfile;
                                           len = strlen(p);
                                           if (len > NAME_MAX) {
                                                   errx(1, "filename%s too long",
                                                           method->suffix);
                                           }
                                   } else if (decomp && !cat) {
                                         char *p = strrchr(infile, '.');                                          char *p = strrchr(infile, '.');
                                         if (p != NULL)                                          if (p != NULL)
                                                 for (method = &c_table[0];                                                  for (method = &c_table[0];
Line 258 
Line 282 
                                         fprintf(stderr, "file would grow; "                                          fprintf(stderr, "file would grow; "
                                                      "left unmodified\n");                                                       "left unmodified\n");
                                 error = 1;                                  error = 1;
                                   rc = 2;
                         } else {                          } else {
   
                                 setfile(outfile, &sb);                                  setfile(outfile, &sb);
Line 290 
Line 315 
   
         } while (*argv != NULL);          } while (*argv != NULL);
   
         return (0);          return (rc);
 }  }
   
 int  int

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7