aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-12-13 15:28:48 +0000
committerEric Andersen <andersen@codepoet.org>2000-12-13 15:28:48 +0000
commit4836fd44f037c226e5eee83224cf090406602fae (patch)
treeffa01f7e6af37801d05fe3533006e4ae25199742
parentbd193a42a5624f0a72b5f99d554e9a8d2afc64cc (diff)
downloadbusybox-w32-4836fd44f037c226e5eee83224cf090406602fae.tar.gz
busybox-w32-4836fd44f037c226e5eee83224cf090406602fae.tar.bz2
busybox-w32-4836fd44f037c226e5eee83224cf090406602fae.zip
Patch from Matt Kraai:
The following patch makes the -X option to tar behave like GNU, which reads one file per line. It also prevents the last file from being appended to the list twice (though that has no noticeable impact).
-rw-r--r--archival/tar.c51
-rw-r--r--tar.c51
2 files changed, 52 insertions, 50 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 3a3b7f143..e1beee117 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -246,7 +246,8 @@ extern int tar_main(int argc, char **argv)
246#if defined BB_FEATURE_TAR_EXCLUDE 246#if defined BB_FEATURE_TAR_EXCLUDE
247 case 'e': 247 case 'e':
248 if (strcmp(*argv, "xclude")==0) { 248 if (strcmp(*argv, "xclude")==0) {
249 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 249 excludeList=xrealloc( excludeList,
250 sizeof(char *) * (excludeListSize+2));
250 excludeList[excludeListSize] = *(++argv); 251 excludeList[excludeListSize] = *(++argv);
251 if (excludeList[excludeListSize] == NULL) 252 if (excludeList[excludeListSize] == NULL)
252 error_msg_and_die( "Option requires an argument: No file specified\n"); 253 error_msg_and_die( "Option requires an argument: No file specified\n");
@@ -258,30 +259,30 @@ extern int tar_main(int argc, char **argv)
258 stopIt=TRUE; 259 stopIt=TRUE;
259 break; 260 break;
260 } 261 }
261 case 'X': 262 case 'X':
262 if (*excludeFileName != '-') 263 if (*excludeFileName != '-')
263 error_msg_and_die("Only one 'X' option allowed\n"); 264 error_msg_and_die("Only one 'X' option allowed\n");
264 excludeFileName = *(++argv); 265 excludeFileName = *(++argv);
265 if (excludeFileName == NULL) 266 if (excludeFileName == NULL)
266 error_msg_and_die("Option requires an argument: No file specified\n"); 267 error_msg_and_die("Option requires an argument: No file specified\n");
267 fileList = fopen (excludeFileName, "rt"); 268 fileList = fopen (excludeFileName, "r");
268 if (! fileList) 269 if (! fileList)
269 error_msg_and_die("Exclude file: file not found\n"); 270 error_msg_and_die("Exclude file: file not found\n");
270 while (!feof(fileList)) { 271 while (fgets(file, sizeof(file), fileList) != NULL) {
271 fscanf(fileList, "%s", file); 272 excludeList = xrealloc(excludeList,
272 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 273 sizeof(char *) * (excludeListSize+2));
273 excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1)); 274 if (file[strlen(file)-1] == '\n')
274 strcpy(excludeList[excludeListSize],file); 275 file[strlen(file)-1] = '\0';
275 /* Remove leading "/"s */ 276 excludeList[excludeListSize] = xstrdup(file);
276 if (*excludeList[excludeListSize] == '/') 277 /* Remove leading "/"s */
277 excludeList[excludeListSize] = (excludeList[excludeListSize])+1; 278 while (*excludeList[excludeListSize] == '/')
278 /* Tack a NULL onto the end of the list */ 279 excludeList[excludeListSize]++;
279 excludeList[++excludeListSize] = NULL; 280 /* Tack a NULL onto the end of the list */
280 } 281 excludeList[++excludeListSize] = NULL;
281 282 }
282 fclose(fileList); 283 fclose(fileList);
283 stopIt=TRUE; 284 stopIt=TRUE;
284 break; 285 break;
285#endif 286#endif
286 case '-': 287 case '-':
287 break; 288 break;
diff --git a/tar.c b/tar.c
index 3a3b7f143..e1beee117 100644
--- a/tar.c
+++ b/tar.c
@@ -246,7 +246,8 @@ extern int tar_main(int argc, char **argv)
246#if defined BB_FEATURE_TAR_EXCLUDE 246#if defined BB_FEATURE_TAR_EXCLUDE
247 case 'e': 247 case 'e':
248 if (strcmp(*argv, "xclude")==0) { 248 if (strcmp(*argv, "xclude")==0) {
249 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 249 excludeList=xrealloc( excludeList,
250 sizeof(char *) * (excludeListSize+2));
250 excludeList[excludeListSize] = *(++argv); 251 excludeList[excludeListSize] = *(++argv);
251 if (excludeList[excludeListSize] == NULL) 252 if (excludeList[excludeListSize] == NULL)
252 error_msg_and_die( "Option requires an argument: No file specified\n"); 253 error_msg_and_die( "Option requires an argument: No file specified\n");
@@ -258,30 +259,30 @@ extern int tar_main(int argc, char **argv)
258 stopIt=TRUE; 259 stopIt=TRUE;
259 break; 260 break;
260 } 261 }
261 case 'X': 262 case 'X':
262 if (*excludeFileName != '-') 263 if (*excludeFileName != '-')
263 error_msg_and_die("Only one 'X' option allowed\n"); 264 error_msg_and_die("Only one 'X' option allowed\n");
264 excludeFileName = *(++argv); 265 excludeFileName = *(++argv);
265 if (excludeFileName == NULL) 266 if (excludeFileName == NULL)
266 error_msg_and_die("Option requires an argument: No file specified\n"); 267 error_msg_and_die("Option requires an argument: No file specified\n");
267 fileList = fopen (excludeFileName, "rt"); 268 fileList = fopen (excludeFileName, "r");
268 if (! fileList) 269 if (! fileList)
269 error_msg_and_die("Exclude file: file not found\n"); 270 error_msg_and_die("Exclude file: file not found\n");
270 while (!feof(fileList)) { 271 while (fgets(file, sizeof(file), fileList) != NULL) {
271 fscanf(fileList, "%s", file); 272 excludeList = xrealloc(excludeList,
272 excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2)); 273 sizeof(char *) * (excludeListSize+2));
273 excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1)); 274 if (file[strlen(file)-1] == '\n')
274 strcpy(excludeList[excludeListSize],file); 275 file[strlen(file)-1] = '\0';
275 /* Remove leading "/"s */ 276 excludeList[excludeListSize] = xstrdup(file);
276 if (*excludeList[excludeListSize] == '/') 277 /* Remove leading "/"s */
277 excludeList[excludeListSize] = (excludeList[excludeListSize])+1; 278 while (*excludeList[excludeListSize] == '/')
278 /* Tack a NULL onto the end of the list */ 279 excludeList[excludeListSize]++;
279 excludeList[++excludeListSize] = NULL; 280 /* Tack a NULL onto the end of the list */
280 } 281 excludeList[++excludeListSize] = NULL;
281 282 }
282 fclose(fileList); 283 fclose(fileList);
283 stopIt=TRUE; 284 stopIt=TRUE;
284 break; 285 break;
285#endif 286#endif
286 case '-': 287 case '-':
287 break; 288 break;