]> Dogcows Code - chaz/tar/blobdiff - src/tar.c
(struct tar_stat_info): New members is_dumpdir and skipped.
[chaz/tar] / src / tar.c
index a79b956e76e8485827304c1520f336e9c1603534..8e75e7ad421d0fe389b7d21a48add5232ab8d441 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -1,7 +1,7 @@
 /* A tar (tape archiver) program.
 
    Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
-   2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+   2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
    Written by John Gilmore, starting 1985-08-25.
 
@@ -211,6 +211,30 @@ subcommand_string (enum subcommand c)
     }
 }
 
+void
+tar_list_quoting_styles (FILE *fp, char *prefix)
+{
+  int i;
+
+  for (i = 0; quoting_style_args[i]; i++)
+    fprintf (fp, "%s%s\n", prefix, quoting_style_args[i]);
+}
+
+void
+tar_set_quoting_style (char *arg)
+{
+  int i;
+
+  for (i = 0; quoting_style_args[i]; i++)
+    if (strcmp (arg, quoting_style_args[i]) == 0)
+      {
+       set_quoting_style (NULL, i);
+       return;
+      }
+  FATAL_ERROR ((0, 0,
+               _("Unknown quoting style `%s'. Try `%s --quoting-style=help' to get a list."), arg));
+}
+
 \f
 /* Options.  */
 
@@ -221,9 +245,10 @@ enum
   BACKUP_OPTION,
   CHECKPOINT_OPTION,
   CHECK_LINKS_OPTION,
+  DELAY_DIRECTORY_RESTORE_OPTION,
   DELETE_OPTION,
-  EXCLUDE_OPTION,
   EXCLUDE_CACHES_OPTION,
+  EXCLUDE_OPTION,
   FORCE_LOCAL_OPTION,
   GROUP_OPTION,
   HANG_OPTION,
@@ -236,15 +261,17 @@ enum
   MODE_OPTION,
   NEWER_MTIME_OPTION,
   NO_ANCHORED_OPTION,
+  NO_DELAY_DIRECTORY_RESTORE_OPTION,
   NO_IGNORE_CASE_OPTION,
   NO_IGNORE_COMMAND_ERROR_OPTION,
   NO_OVERWRITE_DIR_OPTION,
+  NO_QUOTE_CHARS_OPTION,
   NO_RECURSION_OPTION,
   NO_SAME_OWNER_OPTION,
   NO_SAME_PERMISSIONS_OPTION,
   NO_UNQUOTE_OPTION,
-  NO_WILDCARDS_OPTION,
   NO_WILDCARDS_MATCH_SLASH_OPTION,
+  NO_WILDCARDS_OPTION,
   NULL_OPTION,
   NUMERIC_OWNER_OPTION,
   OCCURRENCE_OPTION,
@@ -255,6 +282,8 @@ enum
   PAX_OPTION,
   POSIX_OPTION,
   PRESERVE_OPTION,
+  QUOTE_CHARS_OPTION,
+  QUOTING_STYLE_OPTION,
   RECORD_SIZE_OPTION,
   RECURSION_OPTION,
   RECURSIVE_UNLINK_OPTION,
@@ -269,16 +298,16 @@ enum
   STRIP_COMPONENTS_OPTION,
   SUFFIX_OPTION,
   TEST_LABEL_OPTION,
-  TO_COMMAND_OPTION,
   TOTALS_OPTION,
+  TO_COMMAND_OPTION,
   UNQUOTE_OPTION,
   USAGE_OPTION,
   USE_COMPRESS_PROGRAM_OPTION,
   UTC_OPTION,
   VERSION_OPTION,
   VOLNO_FILE_OPTION,
-  WILDCARDS_OPTION,
-  WILDCARDS_MATCH_SLASH_OPTION
+  WILDCARDS_MATCH_SLASH_OPTION,
+  WILDCARDS_OPTION
 };
 
 const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION;
@@ -428,6 +457,10 @@ static struct argp_option options[] = {
   {"same-order", 0, 0, OPTION_ALIAS, NULL, GRID+1 },
   {"preserve", PRESERVE_OPTION, 0, 0,
    N_("same as both -p and -s"), GRID+1 },
+  {"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, 0, 0,
+   N_("Delay setting modification times and permissions of extracted directories until the end of extraction."), GRID+1 },
+  {"no-delay-directory-restore", NO_DELAY_DIRECTORY_RESTORE_OPTION, 0, 0,
+   N_("Cancel the effect of --delay-directory-restore option."), GRID+1 },
 #undef GRID
 
 #define GRID 60  
@@ -618,6 +651,12 @@ static struct argp_option options[] = {
   {"show-stored-names", SHOW_STORED_NAMES_OPTION, 0, 0,
    N_("When creating archive in verbose mode, list member names as stored in the archive"),
    GRID+1 },
+  {"quoting-style", QUOTING_STYLE_OPTION, N_("STYLE"), 0,
+   N_("Set name quoting style. See below for valid STYLE values."), GRID+1 },
+  {"quote-chars", QUOTE_CHARS_OPTION, N_("STRING"), 0,
+   N_("Additionally quote characters from STRING"), GRID+1 },
+  {"no-quote-chars", NO_QUOTE_CHARS_OPTION, N_("STRING"), 0,
+   N_("Disable quoting for characters from STRING"), GRID+1 },
 #undef GRID
 
 #define GRID 110  
@@ -673,9 +712,10 @@ static void
 show_default_settings (FILE *stream)
 {
   fprintf (stream,
-          "--format=%s -f%s -b%d --rmt-command=%s",
+          "--format=%s -f%s -b%d --quoting-style=%s --rmt-command=%s",
           archive_format_string (DEFAULT_ARCHIVE_FORMAT),
           DEFAULT_ARCHIVE, DEFAULT_BLOCKING,
+          quoting_style_args[DEFAULT_QUOTING_STYLE],
           DEFAULT_RMT_COMMAND);
 #ifdef REMOTE_SHELL
   fprintf (stream, " --rsh-command=%s", REMOTE_SHELL);
@@ -750,7 +790,8 @@ read_name_from_file (FILE *fp, struct obstack *stk)
     {
       if (c == 0)
        {
-         /* We have read a zero separator. The file possibly is zero-separated */
+         /* We have read a zero separator. The file possibly is
+            zero-separated */
          /* FATAL_ERROR((0, 0, N_("file name contains null character"))); */
          return file_list_zero;
        }
@@ -1226,6 +1267,14 @@ parse_opt (int key, char *arg, struct argp_state *state)
        args->version_control_string = arg;
       break;
 
+    case DELAY_DIRECTORY_RESTORE_OPTION:
+      delay_directory_restore_option = true;
+      break;
+
+    case NO_DELAY_DIRECTORY_RESTORE_OPTION:
+      delay_directory_restore_option = false;
+      break;
+      
     case DELETE_OPTION:
       set_subcommand_option (DELETE_SUBCOMMAND);
       break;
@@ -1304,6 +1353,11 @@ parse_opt (int key, char *arg, struct argp_state *state)
       old_files_option = NO_OVERWRITE_DIR_OLD_FILES;
       break;
 
+    case NO_QUOTE_CHARS_OPTION:
+      for (;*arg; arg++)
+       set_char_quoting (NULL, *arg, 0);
+      break;
+      
     case NO_WILDCARDS_OPTION:
       args->exclude_options &= ~ EXCLUDE_WILDCARDS;
       break;
@@ -1352,6 +1406,15 @@ parse_opt (int key, char *arg, struct argp_state *state)
        }
       break;
 
+    case QUOTE_CHARS_OPTION:
+      for (;*arg; arg++)
+       set_char_quoting (NULL, *arg, 1);
+      break;
+
+    case QUOTING_STYLE_OPTION:
+      tar_set_quoting_style (arg);
+      break;
+      
     case PAX_OPTION:
       args->pax_option++;
       xheader_set_option (arg);
@@ -1558,6 +1621,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
       state->flags |= ARGP_NO_EXIT;
       argp_state_help (state, state->out_stream,
                       ARGP_HELP_STD_HELP & ~ARGP_HELP_BUG_ADDR);
+      fprintf (state->out_stream, "\n%s\n\n",
+              _("Valid arguments for --quoting-style options are:"));
+      tar_list_quoting_styles (state->out_stream, "  ");
+      
       fprintf (state->out_stream, _("\n*This* tar defaults to:\n"));
       show_default_settings (state->out_stream);
       fprintf (state->out_stream, "\n");
@@ -1857,7 +1924,8 @@ decode_options (int argc, char **argv)
       if (multi_volume_option)
        USAGE_ERROR ((0, 0, _("Cannot use multi-volume compressed archives")));
       if (subcommand_option == UPDATE_SUBCOMMAND
-         || subcommand_option == APPEND_SUBCOMMAND)
+         || subcommand_option == APPEND_SUBCOMMAND
+         || subcommand_option == DELETE_SUBCOMMAND)
        USAGE_ERROR ((0, 0, _("Cannot update compressed archives")));
       if (subcommand_option == CAT_SUBCOMMAND)
        USAGE_ERROR ((0, 0, _("Cannot concatenate compressed archives")));
@@ -1965,7 +2033,7 @@ main (int argc, char **argv)
 
   exit_status = TAREXIT_SUCCESS;
   filename_terminator = '\n';
-  set_quoting_style (0, escape_quoting_style);
+  set_quoting_style (0, DEFAULT_QUOTING_STYLE);
 
   /* Make sure we have first three descriptors available */
   stdopen ();
This page took 0.027263 seconds and 4 git commands to generate.