From: Wayne Davison Date: Fri, 26 Oct 2007 16:53:02 +0000 (+0000) Subject: Fixed problem with anchored filter and an absolute X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/c291d0575962774b449e405c95ae099af4dd7dc6 Fixed problem with anchored filter and an absolute source path with --relative. --- diff --git a/exclude.c b/exclude.c index c329f0d6..b7a00c60 100644 --- a/exclude.c +++ b/exclude.c @@ -518,15 +518,14 @@ void change_local_filter_dir(const char *dname, int dlen, int dir_depth) filt_array[cur_depth] = push_local_filters(dname, dlen); } -static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir) +static int rule_matches(char *fname, struct filter_struct *ex, int name_is_dir) { int slash_handling, str_cnt = 0, anchored_match = 0; int ret_match = ex->match_flags & MATCHFLG_NEGATE ? 0 : 1; char *p, *pattern = ex->pattern; const char *strings[16]; /* more than enough */ + char *name = fname + (*fname == '/'); - if (*name == '/') - name++; if (!*name) return 0; @@ -536,13 +535,13 @@ static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir) * just match the name portion of the path. */ if ((p = strrchr(name,'/')) != NULL) name = p+1; - } else if (ex->match_flags & MATCHFLG_ABS_PATH && *name != '/' + } else if (ex->match_flags & MATCHFLG_ABS_PATH && *fname != '/' && curr_dir_len > module_dirlen + 1) { /* If we're matching against an absolute-path pattern, * we need to prepend our full path info. */ strings[str_cnt++] = curr_dir + module_dirlen + 1; strings[str_cnt++] = "/"; - } else if (ex->match_flags & MATCHFLG_WILD2_PREFIX && *name != '/') { + } else if (ex->match_flags & MATCHFLG_WILD2_PREFIX && *fname != '/') { /* Allow "**"+"/" to match at the start of the string. */ strings[str_cnt++] = "/"; }