summaryrefslogtreecommitdiff
path: root/exclude.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2005-12-24 08:00:12 +0000
committerWayne Davison <wayned@samba.org>2005-12-24 08:00:12 +0000
commit770de8994e165c0025966e10eff4caff915bb436 (patch)
tree43648a62d631236bd9f60772b520735e7709b17b /exclude.c
parent37cf7b41919f8a920513e2c8c232d20f6fed2ebb (diff)
downloadrsync-770de8994e165c0025966e10eff4caff915bb436.tar.gz
- Renamed match_start -> anchored_match.
- Twiddled one comment and added another. - Twiddled the placement of two else statements.
Diffstat (limited to 'exclude.c')
-rw-r--r--exclude.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/exclude.c b/exclude.c
index 5bca3cc2..b7c5492c 100644
--- a/exclude.c
+++ b/exclude.c
@@ -493,22 +493,23 @@ void pop_local_filters(void *mem)
static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
{
char *p, full_name[MAXPATHLEN];
- int match_start = 0;
+ int anchored_match = 0;
int ret_match = ex->match_flags & MATCHFLG_NEGATE ? 0 : 1;
char *pattern = ex->pattern;
if (!*name)
return 0;
- /* If the pattern does not have any slashes AND it does not have
- * a "**" (which could match a slash), then we just match the
- * name portion of the path. */
if (!ex->u.slash_cnt && !(ex->match_flags & MATCHFLG_WILD2)) {
+ /* If the pattern does not have any slashes AND it does
+ * not have a "**" (which could match a slash), then we
+ * 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 && *name != '/'
&& curr_dir_len > module_dirlen + 1) {
+ /* If we're matching against an absolute-path pattern,
+ * we need to prepend our full path info. */
pathjoin(full_name, sizeof full_name,
curr_dir + module_dirlen + 1, name);
name = full_name;
@@ -518,7 +519,7 @@ static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
return !ret_match;
if (*pattern == '/') {
- match_start = 1;
+ anchored_match = 1;
pattern++;
if (*name == '/')
name++;
@@ -527,7 +528,7 @@ static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
if (ex->match_flags & MATCHFLG_WILD) {
/* A non-anchored match with an infix slash and no "**"
* needs to match the last slash_cnt+1 name elements. */
- if (!match_start && ex->u.slash_cnt
+ if (!anchored_match && ex->u.slash_cnt
&& !(ex->match_flags & MATCHFLG_WILD2)) {
int cnt = ex->u.slash_cnt + 1;
for (p = name + strlen(name) - 1; p >= name; p--) {
@@ -544,8 +545,7 @@ static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
* pattern at the root. */
if (pattern[2] == '/' && wildmatch(pattern+3, name))
return ret_match;
- }
- else if (!match_start && ex->match_flags & MATCHFLG_WILD2) {
+ } else if (!anchored_match && ex->match_flags & MATCHFLG_WILD2) {
/* A non-anchored match with an infix or trailing "**"
* (but not a prefixed "**") needs to try matching
* after every slash. */
@@ -555,7 +555,7 @@ static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
return ret_match;
}
}
- } else if (match_start) {
+ } else if (anchored_match) {
if (strcmp(name,pattern) == 0)
return ret_match;
} else {