diff options
Diffstat (limited to 'contrib/tar/src/names.c')
-rw-r--r-- | contrib/tar/src/names.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/tar/src/names.c b/contrib/tar/src/names.c index eb17636..2642515 100644 --- a/contrib/tar/src/names.c +++ b/contrib/tar/src/names.c @@ -17,6 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $FreeBSD$ */ + #include "system.h" #include <fnmatch.h> @@ -549,6 +551,7 @@ name_match (const char *path) while (1) { struct name *cursor = namelist; + struct name *tmpnlp; if (!cursor) return ! files_from_option; @@ -572,6 +575,38 @@ name_match (const char *path) nametail = &namelist; } chdir_do (cursor->change_dir); + if (fast_read_option) + { + /* remove the current entry, since we found a match */ + if (namelist->next == NULL) + { + /* the list contains one element */ + free(namelist); + namelist = 0; + nametail = &namelist; + /* set a boolean to decide wether we started with a */ + /* non-empty namelist, that was emptied */ + namelist_freed = 1; + } + else + { + if (cursor == namelist) + { + /* the first element is the one */ + tmpnlp = namelist->next; + free(namelist); + namelist = tmpnlp; + } + else + { + tmpnlp = namelist; + while (tmpnlp->next != cursor) + tmpnlp = tmpnlp->next; + tmpnlp->next = cursor->next; + free(cursor); + } + } + } /* We got a match. */ return 1; |