summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai2000-09-15 22:47:34 +0000
committerMatt Kraai2000-09-15 22:47:34 +0000
commitb2f36af1573f6599f1cd35edfd44c1c2d6048faf (patch)
tree4d3ef37ee5927dde91485605a568faeb58b681df
parent6fc2a7d04da066f40ad91e3a11b6418e76181f86 (diff)
downloadbusybox-b2f36af1573f6599f1cd35edfd44c1c2d6048faf.zip
busybox-b2f36af1573f6599f1cd35edfd44c1c2d6048faf.tar.gz
Updated stdin/stdout treatment to match that of gnu tar.
-rw-r--r--archival/tar.c15
-rw-r--r--tar.c15
2 files changed, 12 insertions, 18 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 3e1a650..7239432 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -133,8 +133,8 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
#ifdef BB_FEATURE_TAR_CREATE
/* Local procedures to save files into a tar file. */
-static int writeTarFile(const char* tarName, int tostdoutFlag,
- int verboseFlag, int argc, char **argv, char** excludeList);
+static int writeTarFile(const char* tarName, int verboseFlag, int argc,
+ char **argv, char** excludeList);
#endif
static struct option longopts[] =
@@ -185,14 +185,11 @@ extern int tar_main(int argc, char **argv)
break;
case 'O':
tostdoutFlag = TRUE;
- tarName = "-";
break;
case 'f':
if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n");
tarName = optarg;
- if (!strcmp(tarName, "-") && createFlag == TRUE)
- tostdoutFlag = TRUE;
break;
#if defined BB_FEATURE_TAR_EXCLUDE
case 'e':
@@ -218,7 +215,7 @@ extern int tar_main(int argc, char **argv)
#ifndef BB_FEATURE_TAR_CREATE
fatalError( "This version of tar was not compiled with tar creation support.\n");
#else
- exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc-optind, &argv[optind], excludeList));
+ exit(writeTarFile(tarName, verboseFlag, argc-optind, &argv[optind], excludeList));
#endif
}
if (listFlag == TRUE || extractFlag == TRUE) {
@@ -922,8 +919,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
return( TRUE);
}
-static int writeTarFile(const char* tarName, int tostdoutFlag,
- int verboseFlag, int argc, char **argv, char** excludeList)
+static int writeTarFile(const char* tarName, int verboseFlag, int argc,
+ char **argv, char** excludeList)
{
int tarFd=-1;
int errorFlag=FALSE;
@@ -936,7 +933,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
fatalError("Cowardly refusing to create an empty archive\n");
/* Open the tar file for writing. */
- if (tostdoutFlag == TRUE)
+ if (strcmp(tarName, "-") == 0)
tbInfo.tarFd = fileno(stdout);
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
diff --git a/tar.c b/tar.c
index 3e1a650..7239432 100644
--- a/tar.c
+++ b/tar.c
@@ -133,8 +133,8 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
#ifdef BB_FEATURE_TAR_CREATE
/* Local procedures to save files into a tar file. */
-static int writeTarFile(const char* tarName, int tostdoutFlag,
- int verboseFlag, int argc, char **argv, char** excludeList);
+static int writeTarFile(const char* tarName, int verboseFlag, int argc,
+ char **argv, char** excludeList);
#endif
static struct option longopts[] =
@@ -185,14 +185,11 @@ extern int tar_main(int argc, char **argv)
break;
case 'O':
tostdoutFlag = TRUE;
- tarName = "-";
break;
case 'f':
if (*tarName != '-')
fatalError( "Only one 'f' option allowed\n");
tarName = optarg;
- if (!strcmp(tarName, "-") && createFlag == TRUE)
- tostdoutFlag = TRUE;
break;
#if defined BB_FEATURE_TAR_EXCLUDE
case 'e':
@@ -218,7 +215,7 @@ extern int tar_main(int argc, char **argv)
#ifndef BB_FEATURE_TAR_CREATE
fatalError( "This version of tar was not compiled with tar creation support.\n");
#else
- exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc-optind, &argv[optind], excludeList));
+ exit(writeTarFile(tarName, verboseFlag, argc-optind, &argv[optind], excludeList));
#endif
}
if (listFlag == TRUE || extractFlag == TRUE) {
@@ -922,8 +919,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
return( TRUE);
}
-static int writeTarFile(const char* tarName, int tostdoutFlag,
- int verboseFlag, int argc, char **argv, char** excludeList)
+static int writeTarFile(const char* tarName, int verboseFlag, int argc,
+ char **argv, char** excludeList)
{
int tarFd=-1;
int errorFlag=FALSE;
@@ -936,7 +933,7 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
fatalError("Cowardly refusing to create an empty archive\n");
/* Open the tar file for writing. */
- if (tostdoutFlag == TRUE)
+ if (strcmp(tarName, "-") == 0)
tbInfo.tarFd = fileno(stdout);
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);