aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-18 17:58:36 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-18 17:58:36 +0000
commit674576634753191a3e9acd59a80a7da3cf1a337f (patch)
treeb977cf77b39c9dfd2e79c6649e362e21494fdf21
parenta631e7164299421a8852159ab91137d6f8ffbd7c (diff)
downloadbusybox-w32-674576634753191a3e9acd59a80a7da3cf1a337f.tar.gz
busybox-w32-674576634753191a3e9acd59a80a7da3cf1a337f.tar.bz2
busybox-w32-674576634753191a3e9acd59a80a7da3cf1a337f.zip
tar: fix tar option parsing
-rw-r--r--archival/tar.c43
1 files changed, 25 insertions, 18 deletions
diff --git a/archival/tar.c b/archival/tar.c
index ca59643e5..6e1722bcd 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -760,7 +760,9 @@ int tar_main(int argc, char **argv)
760 const char *tar_filename = "-"; 760 const char *tar_filename = "-";
761 unsigned opt; 761 unsigned opt;
762 int verboseFlag = 0; 762 int verboseFlag = 0;
763#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
763 llist_t *excludes = NULL; 764 llist_t *excludes = NULL;
765#endif
764 766
765 /* Initialise default values */ 767 /* Initialise default values */
766 tar_handle = init_handle(); 768 tar_handle = init_handle();
@@ -773,7 +775,9 @@ int tar_main(int argc, char **argv)
773 "tt:vv:" // count -t,-v 775 "tt:vv:" // count -t,-v
774 "?:" // bail out with usage instead of error return 776 "?:" // bail out with usage instead of error return
775 "X::T::" // cumulative lists 777 "X::T::" // cumulative lists
778#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
776 "\xff::" // cumulative lists for --exclude 779 "\xff::" // cumulative lists for --exclude
780#endif
777 USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd 781 USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
778 USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive 782 USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
779 SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive 783 SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
@@ -788,14 +792,15 @@ int tar_main(int argc, char **argv)
788 USE_FEATURE_TAR_FROM( "T:X:") 792 USE_FEATURE_TAR_FROM( "T:X:")
789 USE_FEATURE_TAR_GZIP( "z" ) 793 USE_FEATURE_TAR_GZIP( "z" )
790 USE_FEATURE_TAR_COMPRESS("Z" ) 794 USE_FEATURE_TAR_COMPRESS("Z" )
791 , 795 , &base_dir // -C dir
792 &base_dir, // -C dir 796 , &tar_filename // -f filename
793 &tar_filename, // -f filename 797 USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
794 USE_FEATURE_TAR_FROM(&(tar_handle->accept),) // T 798 USE_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
795 USE_FEATURE_TAR_FROM(&(tar_handle->reject),) // X 799#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
796 USE_FEATURE_TAR_FROM(&excludes ,) // --exclude 800 , &excludes // --exclude
797 &verboseFlag, // combined count for -t and -v 801#endif
798 &verboseFlag // combined count for -t and -v 802 , &verboseFlag // combined count for -t and -v
803 , &verboseFlag // combined count for -t and -v
799 ); 804 );
800 805
801 if (verboseFlag) tar_handle->action_header = header_verbose_list; 806 if (verboseFlag) tar_handle->action_header = header_verbose_list;
@@ -828,17 +833,19 @@ int tar_main(int argc, char **argv)
828 if (opt & OPT_COMPRESS) 833 if (opt & OPT_COMPRESS)
829 get_header_ptr = get_header_tar_Z; 834 get_header_ptr = get_header_tar_Z;
830 835
831 if (ENABLE_FEATURE_TAR_FROM) { 836#if ENABLE_FEATURE_TAR_FROM
832 tar_handle->reject = append_file_list_to_list(tar_handle->reject); 837 tar_handle->reject = append_file_list_to_list(tar_handle->reject);
833 /* Append excludes to reject */ 838#if ENABLE_FEATURE_TAR_LONG_OPTIONS
834 while (excludes) { 839 /* Append excludes to reject */
835 llist_t *temp = excludes->link; 840 while (excludes) {
836 excludes->link = tar_handle->reject; 841 llist_t *next = excludes->link;
837 tar_handle->reject = excludes; 842 excludes->link = tar_handle->reject;
838 excludes = temp; 843 tar_handle->reject = excludes;
839 } 844 excludes = next;
840 tar_handle->accept = append_file_list_to_list(tar_handle->accept);
841 } 845 }
846#endif
847 tar_handle->accept = append_file_list_to_list(tar_handle->accept);
848#endif
842 849
843 /* Check if we are reading from stdin */ 850 /* Check if we are reading from stdin */
844 if (argv[optind] && *argv[optind] == '-') { 851 if (argv[optind] && *argv[optind] == '-') {