浏览代码

(time): Do not declare.
(usage): Remove -I as an alias for -T>
(OPTION_STRING): Remove -I.
(decode_options): Dates that look like an absolute path name,
or that start with '.', are presumed to be file names whose
dates are taken.
Remove 'I' as an aliase for 'T'.
Update copyright.

Paul Eggert 24 年之前
父节点
当前提交
d32dfe5d5e
共有 1 个文件被更改,包括 25 次插入15 次删除
  1. 25 15
      src/tar.c

+ 25 - 15
src/tar.c

@@ -1,5 +1,5 @@
 /* A tar (tape archiver) program.
 /* A tar (tape archiver) program.
-   Copyright 1988, 92,93,94,95,96,97,99, 2000 Free Software Foundation, Inc.
+   Copyright 1988,92,93,94,95,96,97,99,2000,2001 Free Software Foundation, Inc.
    Written by John Gilmore, starting 1985-08-25.
    Written by John Gilmore, starting 1985-08-25.
 
 
    This program is free software; you can redistribute it and/or modify it
    This program is free software; you can redistribute it and/or modify it
@@ -26,11 +26,6 @@
 # define SIGCHLD SIGCLD
 # define SIGCHLD SIGCLD
 #endif
 #endif
 
 
-#include <time.h>
-#ifndef time
-time_t time ();
-#endif
-
 /* The following causes "common.h" to produce definitions of all the global
 /* The following causes "common.h" to produce definitions of all the global
    variables, rather than just "extern" declarations of them.  GNU tar does
    variables, rather than just "extern" declarations of them.  GNU tar does
    depend on the system loader to preset all GLOBAL variables to neutral (or
    depend on the system loader to preset all GLOBAL variables to neutral (or
@@ -371,7 +366,7 @@ Archive format selection:\n\
 \n\
 \n\
 Local file selection:\n\
 Local file selection:\n\
   -C, --directory=DIR          change to directory DIR\n\
   -C, --directory=DIR          change to directory DIR\n\
-  -T, -I, --files-from=NAME    get names to extract or create from file NAME\n\
+  -T, --files-from=NAME        get names to extract or create from file NAME\n\
       --null                   -T reads null-terminated names, disable -C\n\
       --null                   -T reads null-terminated names, disable -C\n\
       --exclude=PATTERN        exclude files, given as a globbing PATTERN\n\
       --exclude=PATTERN        exclude files, given as a globbing PATTERN\n\
   -X, --exclude-from=FILE      exclude globbing patterns listed in FILE\n\
   -X, --exclude-from=FILE      exclude globbing patterns listed in FILE\n\
@@ -428,17 +423,18 @@ or a device.  *This* `tar' defaults to `-f%s -b%d'.\n"),
 
 
 /* Parse the options for tar.  */
 /* Parse the options for tar.  */
 
 
-/* Available option letters are DEHJQY and aenqy.  Some are reserved:
+/* Available option letters are DEHIJQY and aenqy.  Some are reserved:
 
 
    e  exit immediately with a nonzero exit status if unexpected errors occur
    e  exit immediately with a nonzero exit status if unexpected errors occur
    E  use extended headers (draft POSIX headers, that is)
    E  use extended headers (draft POSIX headers, that is)
+   I  same as T (for compatibility with Solaris tar)
    n  the archive is quickly seekable, so don't worry about random seeks
    n  the archive is quickly seekable, so don't worry about random seeks
    q  stop after extracting the first occurrence of the named file
    q  stop after extracting the first occurrence of the named file
    y  per-file gzip compression
    y  per-file gzip compression
    Y  per-block gzip compression */
    Y  per-block gzip compression */
 
 
 #define OPTION_STRING \
 #define OPTION_STRING \
-  "-01234567ABC:F:GIK:L:MN:OPRST:UV:WX:Zb:cdf:g:hijklmoprstuvwxz"
+  "-01234567ABC:F:GK:L:MN:OPRST:UV:WX:Zb:cdf:g:hijklmoprstuvwxz"
 
 
 static void
 static void
 set_subcommand_option (enum subcommand subcommand)
 set_subcommand_option (enum subcommand subcommand)
@@ -730,10 +726,25 @@ decode_options (int argc, char **argv)
 	if (newer_mtime_option != TYPE_MINIMUM (time_t))
 	if (newer_mtime_option != TYPE_MINIMUM (time_t))
 	  USAGE_ERROR ((0, 0, _("More than one threshold date")));
 	  USAGE_ERROR ((0, 0, _("More than one threshold date")));
 
 
-	newer_mtime_option = get_date (optarg, 0);
-	if (newer_mtime_option == (time_t) -1)
-	  WARN ((0, 0, _("Substituting %s for unknown date format %s"),
-		 tartime (newer_mtime_option), quote (optarg)));
+	if (FILESYSTEM_PREFIX_LEN (optarg) != 0
+	    || ISSLASH (*optarg)
+	    || *optarg == '.')
+	  {
+	    struct stat st;
+	    if (deref_stat (dereference_option, optarg, &st) != 0)
+	      {
+		stat_error (optarg);
+		USAGE_ERROR ((0, 0, _("Date file not found")));
+	      }
+	    newer_mtime_option = st.st_mtime;
+	  }
+	else
+	  {
+	    newer_mtime_option = get_date (optarg, 0);
+	    if (newer_mtime_option == (time_t) -1)
+	      WARN ((0, 0, _("Substituting %s for unknown date format %s"),
+		     tartime (newer_mtime_option), quote (optarg)));
+	  }
 
 
 	break;
 	break;
 #endif /* not MSDOS */
 #endif /* not MSDOS */
@@ -796,7 +807,6 @@ decode_options (int argc, char **argv)
 	break;
 	break;
 
 
       case 'T':
       case 'T':
-      case 'I': /* for compatibility with Solaris tar */
 	files_from_option = optarg;
 	files_from_option = optarg;
 	break;
 	break;
 
 
@@ -1050,7 +1060,7 @@ decode_options (int argc, char **argv)
   if (show_version)
   if (show_version)
     {
     {
       printf ("tar (GNU %s) %s\n%s\n%s\n%s\n", PACKAGE, VERSION,
       printf ("tar (GNU %s) %s\n%s\n%s\n%s\n", PACKAGE, VERSION,
-	      "Copyright 2000 Free Software Foundation, Inc.",
+	      "Copyright 2001 Free Software Foundation, Inc.",
 	      _("\
 	      _("\
 This program comes with NO WARRANTY, to the extent permitted by law.\n\
 This program comes with NO WARRANTY, to the extent permitted by law.\n\
 You may redistribute it under the terms of the GNU General Public License;\n\
 You may redistribute it under the terms of the GNU General Public License;\n\