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. */
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;
/* Get the next include/exclude arg from the string. The token will not
* be '\0' terminated, so use the returned length to limit the string.
* Also, be sure to add this length to the returned pointer before passing
- * it back to ask for the next token. This routine parses the +/- prefixes
- * and the "!" token unless xflags contains XFLG_WORDS_ONLY. The *flag_ptr
+ * it back to ask for the next token. This routine parses the "!" (list-
+ * clearing) token and (if xflags does NOT contain XFLG_WORDS_ONLY) the
+ * +/- prefixes for overriding the include/exclude mode. The *flag_ptr
* value will also be set to the MATCHFLG_* bits for the current token.
*/
static const char *get_exclude_tok(const char *p, unsigned int *len_ptr,
s += 2;
} else if (xflags & XFLG_DEF_INCLUDE)
mflags |= MATCHFLG_INCLUDE;
+ if (xflags & XFLG_DIRECTORY)
+ mflags |= MATCHFLG_DIRECTORY;
if (xflags & XFLG_WORD_SPLIT) {
const unsigned char *cp = s;
} else
len = strlen(s);
- if (*p == '!' && len == 1 && !(xflags & XFLG_WORDS_ONLY))
+ if (*p == '!' && len == 1)
mflags |= MATCHFLG_CLEAR_LIST;
*len_ptr = len;
{
FILE *fp;
char line[MAXPATHLEN+3]; /* Room for "x " prefix and trailing slash. */
- char *eob = line + MAXPATHLEN - 1;
+ char *eob = line + sizeof line - 1;
int word_split = xflags & XFLG_WORD_SPLIT;
if (!fname || !*fname)