From 82dce8f7a8d340a39e08dcc12fb38b8ed254dc64 Mon Sep 17 00:00:00 2001 From: Aurélien Aptel Date: Fri, 19 Jul 2013 18:35:01 +0200 Subject: clitar.c: honor regex flag, emulate old behaviour (and quirks), add tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Aptel [ddiss@samba.org: split from test changes already upstream] Reviewed-by: David Disseldorp Reviewed-by: Andreas Schneider --- source3/client/clitar.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/source3/client/clitar.c b/source3/client/clitar.c index cf31f45c4c..adb0ab4bfa 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -354,9 +354,17 @@ static bool tar_extract_skip_path(struct tar *t, { const bool skip = true; const char *fullpath = archive_entry_pathname(entry); - bool in; + bool in = true; + + if (t->path_list_size <= 0) { + return !skip; + } - in = t->path_list_size > 0 ? tar_path_in_list(t, fullpath, false) : true; + if (t->mode.regex) { + in = mask_match_list(fullpath, t->path_list, t->path_list_size, true); + } else { + in = tar_path_in_list(t, fullpath, false); + } if (t->mode.selection == TAR_EXCLUDE) { in = !in; @@ -405,7 +413,15 @@ static bool tar_create_skip_path(struct tar *t, } /* we are now in exclude mode */ - if (t->path_list_size > 0) { + + /* no matter the selection, no list => include everything */ + if (t->path_list_size <= 0) { + return !skip; + } + + if (t->mode.regex) { + in = mask_match_list(fullpath, t->path_list, t->path_list_size, true); + } else { in = tar_path_in_list(t, fullpath, isdir && !exclude); } -- cgit