>From c11a949328b90aca3398f730a50eab35033f0334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 13 Oct 2010 19:06:07 +0700 Subject: [PATCH 3/3] excluded_from_list: support EXC_FLAG_STARSTAR if that flag is set, try to match all full pathname, then skip one directory and try again until it completely fails. --- dir.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dir.c b/dir.c index 241fbce..11c3e7d 100644 --- a/dir.c +++ b/dir.c @@ -417,9 +417,23 @@ int excluded_from_list(const char *pathname, if (el->nr) { for (i = el->nr - 1; 0 <= i; i--) { struct exclude *x = el->excludes[i]; - int to_exclude = excluded_from_list_1(pathname, pathlen, basename, x, dtype); - if (to_exclude != -1) - return to_exclude; + const char *new_pathname = pathname; + int new_pathlen = pathlen; + + while (1) { + int to_exclude = excluded_from_list_1(new_pathname, new_pathlen, basename, x, dtype); + if (to_exclude != -1) + return to_exclude; + if (x->flags & EXC_FLAG_STARSTAR) { + const char *p = strchr(new_pathname, '/'); + if (p) { + new_pathlen -= p - new_pathname - 1; + new_pathname = p + 1; + continue; + } + } + break; + } } } return -1; /* undecided */ -- 1.7.0.2.445.gcbdb3