mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
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).
This commit is contained in:
parent
bd193a42a5
commit
4836fd44f0
@ -246,7 +246,8 @@ extern int tar_main(int argc, char **argv)
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
case 'e':
|
||||
if (strcmp(*argv, "xclude")==0) {
|
||||
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||
excludeList=xrealloc( excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = *(++argv);
|
||||
if (excludeList[excludeListSize] == NULL)
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
@ -264,21 +265,21 @@ extern int tar_main(int argc, char **argv)
|
||||
excludeFileName = *(++argv);
|
||||
if (excludeFileName == NULL)
|
||||
error_msg_and_die("Option requires an argument: No file specified\n");
|
||||
fileList = fopen (excludeFileName, "rt");
|
||||
fileList = fopen (excludeFileName, "r");
|
||||
if (! fileList)
|
||||
error_msg_and_die("Exclude file: file not found\n");
|
||||
while (!feof(fileList)) {
|
||||
fscanf(fileList, "%s", file);
|
||||
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
|
||||
strcpy(excludeList[excludeListSize],file);
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
if (file[strlen(file)-1] == '\n')
|
||||
file[strlen(file)-1] = '\0';
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Remove leading "/"s */
|
||||
if (*excludeList[excludeListSize] == '/')
|
||||
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
|
||||
while (*excludeList[excludeListSize] == '/')
|
||||
excludeList[excludeListSize]++;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
}
|
||||
|
||||
fclose(fileList);
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
|
21
tar.c
21
tar.c
@ -246,7 +246,8 @@ extern int tar_main(int argc, char **argv)
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
case 'e':
|
||||
if (strcmp(*argv, "xclude")==0) {
|
||||
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||
excludeList=xrealloc( excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = *(++argv);
|
||||
if (excludeList[excludeListSize] == NULL)
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
@ -264,21 +265,21 @@ extern int tar_main(int argc, char **argv)
|
||||
excludeFileName = *(++argv);
|
||||
if (excludeFileName == NULL)
|
||||
error_msg_and_die("Option requires an argument: No file specified\n");
|
||||
fileList = fopen (excludeFileName, "rt");
|
||||
fileList = fopen (excludeFileName, "r");
|
||||
if (! fileList)
|
||||
error_msg_and_die("Exclude file: file not found\n");
|
||||
while (!feof(fileList)) {
|
||||
fscanf(fileList, "%s", file);
|
||||
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = malloc(sizeof(char) * (strlen(file)+1));
|
||||
strcpy(excludeList[excludeListSize],file);
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
if (file[strlen(file)-1] == '\n')
|
||||
file[strlen(file)-1] = '\0';
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Remove leading "/"s */
|
||||
if (*excludeList[excludeListSize] == '/')
|
||||
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
|
||||
while (*excludeList[excludeListSize] == '/')
|
||||
excludeList[excludeListSize]++;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
}
|
||||
|
||||
fclose(fileList);
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user