A minor improvement in check_one_exclude().
authorWayne Davison <wayned@samba.org>
Tue, 10 Aug 2004 18:15:33 +0000 (18:15 +0000)
committerWayne Davison <wayned@samba.org>
Tue, 10 Aug 2004 18:15:33 +0000 (18:15 +0000)
exclude.c

index d02c462..a9dee7b 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -115,10 +115,13 @@ void clear_exclude_list(struct exclude_list_struct *listp)
 static int check_one_exclude(char *name, struct exclude_struct *ex,
                              int name_is_dir)
 {
-       char *p;
+       char *p, full_name[MAXPATHLEN];
        int match_start = 0;
        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. */
@@ -126,15 +129,12 @@ static int check_one_exclude(char *name, struct exclude_struct *ex,
                if ((p = strrchr(name,'/')) != NULL)
                        name = p+1;
        }
-       else if (ex->match_flags & MATCHFLG_ABS_PATH && *name != '/') {
-               static char full_name[MAXPATHLEN];
-               int plus = curr_dir[1] == '\0'? 1 : 0;
-               pathjoin(full_name, sizeof full_name, curr_dir+plus, name);
+       else if (ex->match_flags & MATCHFLG_ABS_PATH && *name != '/'
+           && curr_dir[1]) {
+               pathjoin(full_name, sizeof full_name, curr_dir + 1, name);
                name = full_name;
        }
 
-       if (!name[0]) return 0;
-
        if (ex->match_flags & MATCHFLG_DIRECTORY && !name_is_dir)
                return 0;