- "\xfd::" // cumulative lists for --exclude
- USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
- USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
- SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
- if (ENABLE_FEATURE_TAR_LONG_OPTIONS)
- applet_long_options = tar_long_options;
- opt = getopt32(argc, argv,
- "txC:f:Opvk"
- USE_FEATURE_TAR_CREATE( "ch" )
- USE_FEATURE_TAR_BZIP2( "j" )
- USE_FEATURE_TAR_LZMA( "a" )
- USE_FEATURE_TAR_FROM( "T:X:")
- USE_FEATURE_TAR_GZIP( "z" )
- USE_FEATURE_TAR_COMPRESS("Z" )
- ,
- &base_dir, // -C dir
- &tar_filename, // -f filename
- USE_FEATURE_TAR_FROM(&(tar_handle->accept),) // T
- USE_FEATURE_TAR_FROM(&(tar_handle->reject),) // X
- USE_FEATURE_TAR_FROM(&excludes ) // --exclude
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
+ "\xff::" // cumulative lists for --exclude
+#endif
+ IF_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
+ IF_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
+ IF_NOT_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS
+ applet_long_options = tar_longopts;
+#endif
+#if ENABLE_DESKTOP
+ if (argv[1] && argv[1][0] != '-') {
+ /* Compat:
+ * 1st argument without dash handles options with parameters
+ * differently from dashed one: it takes *next argv[i]*
+ * as paramenter even if there are more chars in 1st argument:
+ * "tar fx TARFILE" - "x" is not taken as f's param
+ * but is interpreted as -x option
+ * "tar -xf TARFILE" - dashed equivalent of the above
+ * "tar -fx ..." - "x" is taken as f's param
+ * getopt32 wouldn't handle 1st command correctly.
+ * Unfortunately, people do use such commands.
+ * We massage argv[1] to work around it by moving 'f'
+ * to the end of the string.
+ * More contrived "tar fCx TARFILE DIR" still fails,
+ * but such commands are much less likely to be used.
+ */
+ char *f = strchr(argv[1], 'f');
+ if (f) {
+ while (f[1] != '\0') {
+ *f = f[1];
+ f++;
+ }
+ *f = 'f';
+ }
+ }
+#endif
+ opt = getopt32(argv,
+ "txC:f:Oopvk"
+ IF_FEATURE_TAR_CREATE( "ch" )
+ IF_FEATURE_SEAMLESS_BZ2( "j" )
+ IF_FEATURE_SEAMLESS_LZMA("a" )
+ IF_FEATURE_TAR_FROM( "T:X:")
+ IF_FEATURE_SEAMLESS_GZ( "z" )
+ IF_FEATURE_SEAMLESS_Z( "Z" )
+ IF_FEATURE_TAR_NOPRESERVE_TIME("m")
+ , &base_dir // -C dir
+ , &tar_filename // -f filename
+ IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
+ IF_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
+ IF_FEATURE_TAR_TO_COMMAND(, &(tar_handle->tar__to_command)) // --to-command
+#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
+ , &excludes // --exclude
+#endif
+ , &verboseFlag // combined count for -t and -v
+ , &verboseFlag // combined count for -t and -v