diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-10-19 06:19:22 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-10-19 06:19:22 +0000 |
commit | c5c1a8a112ebae29862a902e6e511b392c59da74 (patch) | |
tree | 88df433818b25262966b84fa81aecde8b75c8ed1 /archival/tar.c | |
parent | 05fa661123d90b990c146ef6d79da82d798ccd6f (diff) |
Fix exclude/include problem
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/archival/tar.c b/archival/tar.c index df110a149..d8889ae19 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -586,14 +586,10 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag, static const llist_t *append_file_list_to_list(const char *filename, const llist_t *list) { FILE *src_stream = xfopen(filename, "r"); - while(1) { - char *line = get_line_from_file(src_stream); - if (line == NULL) { - break; - } + char *line; + while((line = get_line_from_file(src_stream)) != NULL) { chomp(line); list = add_to_list(list, line); - free(line); } fclose(src_stream); @@ -715,14 +711,10 @@ int tar_main(int argc, char **argv) tar_handle->accept = add_to_list(tar_handle->accept, argv[optind]); optind++; -#ifdef CONFIG_FEATURE_TAR_EXCLUDE - if (tar_handle->reject) { - printf("Reject list\n"); - tar_handle->filter = filter_accept_reject_list; - } else -#endif /* CONFIG_FEATURE_TAR_EXCLUDE */ + } - tar_handle->filter = filter_accept_list; + if ((tar_handle->accept) || (tar_handle->reject)) { + tar_handle->filter = filter_accept_reject_list; } if ((base_dir) && (chdir(base_dir))) { @@ -761,13 +753,18 @@ int tar_main(int argc, char **argv) #endif /* CONFIG_FEATURE_TAR_CREATE */ while (get_header_tar(tar_handle) == EXIT_SUCCESS); - } - /* Skip through list */ - while (tar_handle->accept) { - error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data); - tar_handle->accept = tar_handle->accept->link; + /* Ckeck that every file that should have been extracted was */ + while (tar_handle->accept) { + if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) { + if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) { + error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data); + } + } + tar_handle->accept = tar_handle->accept->link; + } } + #ifdef CONFIG_FEATURE_CLEAN_UP if (tar_handle->src_fd != fileno(stdin)) { close(tar_handle->src_fd); |