From 11bac14cbd5a11d4f9ff646223006879d1a87e51 Mon Sep 17 00:00:00 2001
From: bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Date: Sat, 4 Aug 2001 05:28:29 +0000
Subject: Fix exclude list handling

git-svn-id: svn://busybox.net/trunk/busybox@3210 69ca8d6d-28ef-0310-b511-8ec308f3f277
---
 libbb/unarchive.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

(limited to 'libbb')

diff --git a/libbb/unarchive.c b/libbb/unarchive.c
index 91db2e3b1..0d414a3a8 100644
--- a/libbb/unarchive.c
+++ b/libbb/unarchive.c
@@ -230,24 +230,35 @@ char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers
 	const int extract_function, const char *prefix, char **extract_names)
 {
 	file_header_t *file_entry;
-	int found;
+	int extract_flag;
 	int i;
 	char *buffer = NULL;
 
 	archive_offset = 0;
 	while ((file_entry = get_headers(src_stream)) != NULL) {
-		found = FALSE;
-		if (extract_names == NULL) {
-			found = TRUE;
-		} else {
+		extract_flag = TRUE;
+		if (extract_names != NULL) {
+			int found_flag = FALSE;
 			for(i = 0; extract_names[i] != 0; i++) {
 				if (strcmp(extract_names[i], file_entry->name) == 0) {
-					found = TRUE;
+					found_flag = TRUE;
+					break;
+				}
+			}
+			if (extract_function & extract_exclude_list) {
+				if (found_flag == TRUE) {
+					extract_flag = FALSE;
+				}
+			} else {
+				/* If its not found in the include list dont extract it */
+				if (found_flag == FALSE) {
+					extract_flag = FALSE;
 				}
 			}
+
 		}
 
-		if (found) {
+		if (extract_flag == TRUE) {
 			buffer = extract_archive(src_stream, out_stream, file_entry, extract_function, prefix);
 		} else {
 			/* seek past the data entry */
-- 
cgit v1.2.3-55-g6feb