The non-anchored --wildcards logic broke full-string matching.

(It matched after every / but when there was one it didn't check
start of string. Oops.)
This commit is contained in:
Rob Landley 2023-04-06 10:48:05 -05:00
parent 51014a26da
commit 24133d5e23
2 changed files with 9 additions and 6 deletions

View File

@ -383,6 +383,7 @@ testing 'without -P' "$TAR --no-recursion -C / /// .. 2>/dev/null | SUM 3" \
# Wildcards: --exclude, include (create/extract * cmdline/recursive)
# --anchored, --wildcards, --wildcards-match-slash
# --no-* versions of each. Span coverage, switching on/off...
#pattern a.c
# abcd dabc a/c da/c
@ -413,6 +414,10 @@ touch sub2/{ephebe,klatch,djelibeybi}
testing 'tsort' '$TAR -c sub2 --sort=name | tar t' \
'sub2/\nsub2/djelibeybi\nsub2/ephebe\nsub2/klatch\n' '' ''
touch file
testing './file bug' 'tar c ./file > tar.tar && tar t ./file < tar.tar' \
'./file\n' '' ''
if false
then
# Sequencing issues that leak implementation details out the interface

View File

@ -194,7 +194,7 @@ static struct double_list *filter(struct double_list *lst, char *name)
{
struct double_list *end = lst;
long long flags = toys.optflags;
char *ss, *last;
char *ss;
if (!lst || !*name) return 0;
@ -211,13 +211,11 @@ static struct double_list *filter(struct double_list *lst, char *name)
// The +1 instead of ++ is in case of conseutive slashes
do {
for (ss = last = name; *ss; ss++) {
if (do_filter(lst->data, name, flags)) return lst;
if (!(flags & FLAG_anchored)) for (ss = name; *ss; ss++) {
if (*ss!='/' || !ss[1]) continue;
if (!(flags & FLAG_anchored)) {
if (do_filter(lst->data, ss+1, flags)) return lst;
} else last = ss+1;
if (do_filter(lst->data, ss+1, flags)) return lst;
}
if (do_filter(lst->data, last, flags)) return lst;
} while (end != (lst = lst->next));
return 0;