aboutsummaryrefslogtreecommitdiff
path: root/tar.c
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-12-13 15:28:48 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2000-12-13 15:28:48 +0000
commit179c1041c4169c5331da22d16745f71bd8de6930 (patch)
treeffa01f7e6af37801d05fe3533006e4ae25199742 /tar.c
parent76093f071417169382722f3d327849ec4ac9596b (diff)
downloadbusybox-w32-179c1041c4169c5331da22d16745f71bd8de6930.tar.gz
busybox-w32-179c1041c4169c5331da22d16745f71bd8de6930.tar.bz2
busybox-w32-179c1041c4169c5331da22d16745f71bd8de6930.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). git-svn-id: svn://busybox.net/trunk/busybox@1444 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'tar.c')
-rw-r--r--tar.c51
1 files changed, 26 insertions, 25 deletions
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;