/[tar]/tar/src/tar.c
ViewVC logotype

Diff of /tar/src/tar.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.60 by gray, Sun Aug 31 22:45:58 2003 UTC revision 1.61 by gray, Mon Sep 1 17:02:45 2003 UTC
# Line 112  confirm (const char *message_action, con Line 112  confirm (const char *message_action, con
112      return reply == 'y' || reply == 'Y';      return reply == 'y' || reply == 'Y';
113    }    }
114  }  }
115    
116    void
117    set_archive_format (char *name)
118    {
119      static struct fmttab {
120        char *name;
121        enum archive_format fmt;
122      } fmttab[] = {
123        { "v7",      V7_FORMAT },
124        { "oldgnu",  OLDGNU_FORMAT },      
125        { "posix",   POSIX_FORMAT },
126    #if 0 /* not fully supported yet */
127        { "star",    STAR_FORMAT },
128    #endif
129        { "gnu",     GNU_FORMAT },
130        NULL
131      };
132      struct fmttab *p;
133      enum archive_format fmt;
134      
135      for (p = fmttab; p->name; p++)
136        {
137          if (strcmp (p->name, name) == 0)
138            {
139              fmt = p->fmt;
140              break;
141            }
142        }
143    
144      if (archive_format != DEFAULT_FORMAT && archive_format != fmt)
145        USAGE_ERROR ((0, 0, _("Conflicting archive format options")));
146      
147      archive_format = fmt;
148    }
149    
150  /* Options.  */  /* Options.  */
151    
# Line 131  enum Line 165  enum
165    DELETE_OPTION,    DELETE_OPTION,
166    EXCLUDE_OPTION,    EXCLUDE_OPTION,
167    FORCE_LOCAL_OPTION,    FORCE_LOCAL_OPTION,
168      FORMAT_OPTION,
169    GROUP_OPTION,    GROUP_OPTION,
170    IGNORE_CASE_OPTION,    IGNORE_CASE_OPTION,
171    IGNORE_FAILED_READ_OPTION,    IGNORE_FAILED_READ_OPTION,
# Line 197  static struct option long_options[] = Line 232  static struct option long_options[] =
232    {"file", required_argument, 0, 'f'},    {"file", required_argument, 0, 'f'},
233    {"files-from", required_argument, 0, 'T'},    {"files-from", required_argument, 0, 'T'},
234    {"force-local", no_argument, 0, FORCE_LOCAL_OPTION},    {"force-local", no_argument, 0, FORCE_LOCAL_OPTION},
235      {"format", required_argument, 0, FORMAT_OPTION},
236    {"get", no_argument, 0, 'x'},    {"get", no_argument, 0, 'x'},
237    {"group", required_argument, 0, GROUP_OPTION},    {"group", required_argument, 0, GROUP_OPTION},
238    {"gunzip", no_argument, 0, 'z'},    {"gunzip", no_argument, 0, 'z'},
# Line 368  Device blocking:\n\ Line 404  Device blocking:\n\
404        fputs (_("\        fputs (_("\
405  \n\  \n\
406  Archive format selection:\n\  Archive format selection:\n\
407          --format=FMTNAME               create archive of the given format.\n\
408                                         FMTNAME is one of the following:\n\
409                                         v7        old V7 tar format\n\
410                                         oldgnu    GNU format as per tar <= 1.12\n\
411                                         posix     POSIX 1003.1-2001 tar format\n\
412                                         gnu       GNU format\n\
413          --old-archive, --portability   same as --format=v7\n\
414          --posix                        same as --format=posix\n\
415    -V, --label=NAME                   create archive with volume name NAME\n\    -V, --label=NAME                   create archive with volume name NAME\n\
416                PATTERN                at list/extract time, a globbing PATTERN\n\                PATTERN                at list/extract time, a globbing PATTERN\n\
       --old-archive, --portability   write a V7 format archive\n\  
       --posix                        write a POSIX format archive\n\  
417    -j, --bzip2                        filter the archive through bzip2\n\    -j, --bzip2                        filter the archive through bzip2\n\
418    -z, --gzip, --ungzip               filter the archive through gzip\n\    -z, --gzip, --ungzip               filter the archive through gzip\n\
419    -Z, --compress, --uncompress       filter the archive through compress\n\    -Z, --compress, --uncompress       filter the archive through compress\n\
# Line 896  decode_options (int argc, char **argv) Line 938  decode_options (int argc, char **argv)
938          force_local_option = 1;          force_local_option = 1;
939          break;          break;
940    
941          case FORMAT_OPTION:
942            set_archive_format (optarg);
943            break;
944            
945        case INDEX_FILE_OPTION:        case INDEX_FILE_OPTION:
946          index_file_name = optarg;          index_file_name = optarg;
947          break;          break;
# Line 979  decode_options (int argc, char **argv) Line 1025  decode_options (int argc, char **argv)
1025          break;          break;
1026    
1027        case POSIX_OPTION:        case POSIX_OPTION:
1028  #if OLDGNU_COMPATIBILITY          set_archive_format ("posix");
         if (archive_format == DEFAULT_FORMAT)  
           archive_format = GNU_FORMAT;  
         else if (archive_format != GNU_FORMAT)  
           USAGE_ERROR ((0, 0, _("Conflicting archive format options")));  
 #else  
         if (archive_format == DEFAULT_FORMAT)  
           archive_format = POSIX_FORMAT;  
         else if (archive_format != POSIX_FORMAT)  
           USAGE_ERROR ((0, 0, _("Conflicting archive format options")));  
 #endif  
1029          break;          break;
1030    
1031        case PRESERVE_OPTION:        case PRESERVE_OPTION:
# Line 1109  decode_options (int argc, char **argv) Line 1145  decode_options (int argc, char **argv)
1145                  xrealloc (archive_name_array,                  xrealloc (archive_name_array,
1146                            sizeof (const char *) * allocated_archive_names);                            sizeof (const char *) * allocated_archive_names);
1147              }              }
1148            archive_name_array[archive_names++] = buf;            archive_name_array[archive_names++] = strdup (buf);
   
           /* FIXME: How comes this works for many archives when buf is  
              not xstrdup'ed?  */  
1149          }          }
1150          break;          break;
1151    
# Line 1138  decode_options (int argc, char **argv) Line 1171  decode_options (int argc, char **argv)
1171        if (subcommand_option == CREATE_SUBCOMMAND)        if (subcommand_option == CREATE_SUBCOMMAND)
1172          {          {
1173            /* GNU Tar <= 1.13 compatibility */            /* GNU Tar <= 1.13 compatibility */
1174            if (archive_format == DEFAULT_FORMAT)            set_archive_format ("v7");
             archive_format = V7_FORMAT;  
           else if (archive_format != V7_FORMAT)  
             USAGE_ERROR ((0, 0, _("Conflicting archive format options")));  
1175          }          }
1176        else        else
1177          {          {
# Line 1179  see the file named COPYING for details." Line 1209  see the file named COPYING for details."
1209    /* Derive option values and check option consistency.  */    /* Derive option values and check option consistency.  */
1210    
1211    if (archive_format == DEFAULT_FORMAT)    if (archive_format == DEFAULT_FORMAT)
1212      {      archive_format = GNU_FORMAT;
 #if OLDGNU_COMPATIBILITY  
       archive_format = OLDGNU_FORMAT;  
 #else  
       archive_format = GNU_FORMAT;  
 #endif  
     }  
1213    
1214    if (archive_format == GNU_FORMAT && getenv ("POSIXLY_CORRECT"))    if (archive_format == GNU_FORMAT && getenv ("POSIXLY_CORRECT"))
1215      archive_format = POSIX_FORMAT;      archive_format = POSIX_FORMAT;
# Line 1411  destroy_stat (struct tar_stat_info *st) Line 1435  destroy_stat (struct tar_stat_info *st)
1435    free (st->gname);    free (st->gname);
1436    memset (st, 0, sizeof (*st));    memset (st, 0, sizeof (*st));
1437  }  }
1438    

Legend:
Removed from v.1.60  
changed lines
  Added in v.1.61

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26