summaryrefslogtreecommitdiff
path: root/attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/attr.c b/attr.c
index 097ae87f3c..8985c5c25b 100644
--- a/attr.c
+++ b/attr.c
@@ -564,18 +564,12 @@ static void bootstrap_attr_stack(void)
attr_stack = elem;
}
-static void prepare_attr_stack(const char *path)
+static void prepare_attr_stack(const char *path, int dirlen)
{
struct attr_stack *elem, *info;
- int dirlen, len;
+ int len;
const char *cp;
- cp = strrchr(path, '/');
- if (!cp)
- dirlen = 0;
- else
- dirlen = cp - path;
-
/*
* At the bottom of the attribute stack is the built-in
* set of attribute definitions, followed by the contents
@@ -668,6 +662,10 @@ static int path_matches(const char *pathname, int pathlen,
const char *pattern = pat->pattern;
int prefix = pat->nowildcardlen;
+ if ((pat->flags & EXC_FLAG_MUSTBEDIR) &&
+ ((!pathlen) || (pathname[pathlen-1] != '/')))
+ return 0;
+
if (pat->flags & EXC_FLAG_NODIR) {
return match_basename(basename,
pathlen - (basename - pathname),
@@ -693,7 +691,7 @@ static int fill_one(const char *what, struct match_attr *a, int rem)
if (*n == ATTR__UNKNOWN) {
debug_set(what,
- a->is_macro ? a->u.attr->name : a->u.pattern,
+ a->is_macro ? a->u.attr->name : a->u.pat.pattern,
attr, v);
*n = v;
rem--;
@@ -751,17 +749,26 @@ static int macroexpand_one(int attr_nr, int rem)
static void collect_all_attrs(const char *path)
{
struct attr_stack *stk;
- int i, pathlen, rem;
- const char *basename;
+ int i, pathlen, rem, dirlen;
+ const char *basename, *cp, *last_slash = NULL;
- prepare_attr_stack(path);
+ for (cp = path; *cp; cp++) {
+ if (*cp == '/' && cp[1])
+ last_slash = cp;
+ }
+ pathlen = cp - path;
+ if (last_slash) {
+ basename = last_slash + 1;
+ dirlen = last_slash - path;
+ } else {
+ basename = path;
+ dirlen = 0;
+ }
+
+ prepare_attr_stack(path, dirlen);
for (i = 0; i < attr_nr; i++)
check_all_attr[i].value = ATTR__UNKNOWN;
- basename = strrchr(path, '/');
- basename = basename ? basename + 1 : path;
-
- pathlen = strlen(path);
rem = attr_nr;
for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
rem = fill(path, pathlen, basename, stk, rem);