aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-12-04 18:51:09 +0000
committerEric Andersen <andersen@codepoet.org>2000-12-04 18:51:09 +0000
commit8cede00b9eccb077232030723867566ad5685c6f (patch)
treea4f6d4889d8b3e779477ccbabb7de29d80fe0a6f
parentf484e7e65c80e39ec7d9e14bbb1cc2fc2a62ae25 (diff)
downloadbusybox-w32-8cede00b9eccb077232030723867566ad5685c6f.tar.gz
busybox-w32-8cede00b9eccb077232030723867566ad5685c6f.tar.bz2
busybox-w32-8cede00b9eccb077232030723867566ad5685c6f.zip
Patch to add in the -X option and fix the --exclude bug, originally by
Sebastien Huet, and now ported to the latest and greatest by both Arne Bernin <ab@netropol.de> and kent robotti <robotti@metconnect.com>.
-rw-r--r--Config.h2
-rw-r--r--applets/usage.c2
-rw-r--r--archival/tar.c29
-rw-r--r--tar.c29
-rw-r--r--usage.c2
5 files changed, 61 insertions, 3 deletions
diff --git a/Config.h b/Config.h
index 0f31ae16b..e07044690 100644
--- a/Config.h
+++ b/Config.h
@@ -222,7 +222,7 @@
222// Enable support for creation of tar files. 222// Enable support for creation of tar files.
223#define BB_FEATURE_TAR_CREATE 223#define BB_FEATURE_TAR_CREATE
224// 224//
225// Enable support for "--exclude" for excluding files 225// Enable support for "--exclude" and "-X" for excluding files
226#define BB_FEATURE_TAR_EXCLUDE 226#define BB_FEATURE_TAR_EXCLUDE
227// 227//
228//// Enable reverse sort 228//// Enable reverse sort
diff --git a/applets/usage.c b/applets/usage.c
index bab6d21b3..bd2321fbc 100644
--- a/applets/usage.c
+++ b/applets/usage.c
@@ -1218,6 +1218,7 @@ const char tar_usage[] =
1218#endif 1218#endif
1219#if defined BB_FEATURE_TAR_EXCLUDE 1219#if defined BB_FEATURE_TAR_EXCLUDE
1220 "[--exclude File] " 1220 "[--exclude File] "
1221 "[-X File]"
1221#endif 1222#endif
1222 "[-f tarFile] [FILE(s)] ...\n" 1223 "[-f tarFile] [FILE(s)] ...\n"
1223#ifndef BB_FEATURE_TRIVIAL_HELP 1224#ifndef BB_FEATURE_TRIVIAL_HELP
@@ -1234,6 +1235,7 @@ const char tar_usage[] =
1234 "\tO\t\textract to stdout\n" 1235 "\tO\t\textract to stdout\n"
1235#if defined BB_FEATURE_TAR_EXCLUDE 1236#if defined BB_FEATURE_TAR_EXCLUDE
1236 "\texclude\t\tfile to exclude\n" 1237 "\texclude\t\tfile to exclude\n"
1238 "\tX\t\tfile with names to exclude\n"
1237#endif 1239#endif
1238 "\nInformative output:\n" 1240 "\nInformative output:\n"
1239 "\tv\t\tverbosely list files processed\n" 1241 "\tv\t\tverbosely list files processed\n"
diff --git a/archival/tar.c b/archival/tar.c
index 6d8e633b0..7e56fb99a 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -147,6 +147,9 @@ extern int tar_main(int argc, char **argv)
147 char** extractList=NULL; 147 char** extractList=NULL;
148#if defined BB_FEATURE_TAR_EXCLUDE 148#if defined BB_FEATURE_TAR_EXCLUDE
149 int excludeListSize=0; 149 int excludeListSize=0;
150 char *excludeFileName ="-";
151 FILE *fileList;
152 char file[256];
150#endif 153#endif
151 const char *tarName="-"; 154 const char *tarName="-";
152 int listFlag = FALSE; 155 int listFlag = FALSE;
@@ -198,7 +201,7 @@ extern int tar_main(int argc, char **argv)
198 break; 201 break;
199#if defined BB_FEATURE_TAR_EXCLUDE 202#if defined BB_FEATURE_TAR_EXCLUDE
200 case 'e': 203 case 'e':
201 if (strcmp(*argv, "exclude")==0) { 204 if (strcmp(*argv, "xclude")==0) {
202 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 205 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
203 excludeList[excludeListSize] = *(++argv); 206 excludeList[excludeListSize] = *(++argv);
204 if (excludeList[excludeListSize] == NULL) 207 if (excludeList[excludeListSize] == NULL)
@@ -211,6 +214,30 @@ extern int tar_main(int argc, char **argv)
211 stopIt=TRUE; 214 stopIt=TRUE;
212 break; 215 break;
213 } 216 }
217 case 'X':
218 if (*excludeFileName != '-')
219 fatalError("Only one 'X' option allowed\n");
220 excludeFileName = *(++argv);
221 if (excludeFileName == NULL)
222 fatalError("Option requires an argument: No file specified\n");
223 fileList = fopen (excludeFileName, "rt");
224 if (! fileList)
225 fatalError("Exclude file: file not found\n");
226 while (!feof(fileList)) {
227 fscanf(fileList, "%s", file);
228 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
229 excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
230 strcpy(excludeList[excludeListSize],file);
231 /* Remove leading "/"s */
232 if (*excludeList[excludeListSize] == '/')
233 excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
234 /* Tack a NULL onto the end of the list */
235 excludeList[++excludeListSize] = NULL;
236 }
237
238 fclose(fileList);
239 stopIt=TRUE;
240 break;
214#endif 241#endif
215 case '-': 242 case '-':
216 break; 243 break;
diff --git a/tar.c b/tar.c
index 6d8e633b0..7e56fb99a 100644
--- a/tar.c
+++ b/tar.c
@@ -147,6 +147,9 @@ extern int tar_main(int argc, char **argv)
147 char** extractList=NULL; 147 char** extractList=NULL;
148#if defined BB_FEATURE_TAR_EXCLUDE 148#if defined BB_FEATURE_TAR_EXCLUDE
149 int excludeListSize=0; 149 int excludeListSize=0;
150 char *excludeFileName ="-";
151 FILE *fileList;
152 char file[256];
150#endif 153#endif
151 const char *tarName="-"; 154 const char *tarName="-";
152 int listFlag = FALSE; 155 int listFlag = FALSE;
@@ -198,7 +201,7 @@ extern int tar_main(int argc, char **argv)
198 break; 201 break;
199#if defined BB_FEATURE_TAR_EXCLUDE 202#if defined BB_FEATURE_TAR_EXCLUDE
200 case 'e': 203 case 'e':
201 if (strcmp(*argv, "exclude")==0) { 204 if (strcmp(*argv, "xclude")==0) {
202 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 205 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
203 excludeList[excludeListSize] = *(++argv); 206 excludeList[excludeListSize] = *(++argv);
204 if (excludeList[excludeListSize] == NULL) 207 if (excludeList[excludeListSize] == NULL)
@@ -211,6 +214,30 @@ extern int tar_main(int argc, char **argv)
211 stopIt=TRUE; 214 stopIt=TRUE;
212 break; 215 break;
213 } 216 }
217 case 'X':
218 if (*excludeFileName != '-')
219 fatalError("Only one 'X' option allowed\n");
220 excludeFileName = *(++argv);
221 if (excludeFileName == NULL)
222 fatalError("Option requires an argument: No file specified\n");
223 fileList = fopen (excludeFileName, "rt");
224 if (! fileList)
225 fatalError("Exclude file: file not found\n");
226 while (!feof(fileList)) {
227 fscanf(fileList, "%s", file);
228 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
229 excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
230 strcpy(excludeList[excludeListSize],file);
231 /* Remove leading "/"s */
232 if (*excludeList[excludeListSize] == '/')
233 excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
234 /* Tack a NULL onto the end of the list */
235 excludeList[++excludeListSize] = NULL;
236 }
237
238 fclose(fileList);
239 stopIt=TRUE;
240 break;
214#endif 241#endif
215 case '-': 242 case '-':
216 break; 243 break;
diff --git a/usage.c b/usage.c
index bab6d21b3..bd2321fbc 100644
--- a/usage.c
+++ b/usage.c
@@ -1218,6 +1218,7 @@ const char tar_usage[] =
1218#endif 1218#endif
1219#if defined BB_FEATURE_TAR_EXCLUDE 1219#if defined BB_FEATURE_TAR_EXCLUDE
1220 "[--exclude File] " 1220 "[--exclude File] "
1221 "[-X File]"
1221#endif 1222#endif
1222 "[-f tarFile] [FILE(s)] ...\n" 1223 "[-f tarFile] [FILE(s)] ...\n"
1223#ifndef BB_FEATURE_TRIVIAL_HELP 1224#ifndef BB_FEATURE_TRIVIAL_HELP
@@ -1234,6 +1235,7 @@ const char tar_usage[] =
1234 "\tO\t\textract to stdout\n" 1235 "\tO\t\textract to stdout\n"
1235#if defined BB_FEATURE_TAR_EXCLUDE 1236#if defined BB_FEATURE_TAR_EXCLUDE
1236 "\texclude\t\tfile to exclude\n" 1237 "\texclude\t\tfile to exclude\n"
1238 "\tX\t\tfile with names to exclude\n"
1237#endif 1239#endif
1238 "\nInformative output:\n" 1240 "\nInformative output:\n"
1239 "\tv\t\tverbosely list files processed\n" 1241 "\tv\t\tverbosely list files processed\n"