struct nond_on_fs {
int len;
- char name[0];
+ char name[FLEX_ARRAY]; /* more */
};
static struct nond_on_fs **dir;
if (pos >= 0)
return 1;
pos = -pos-1;
- if (pos >= active_nr)
+ if (pos >= active_nr) /* can't */
return 0;
- if (strncmp(active_cache[pos]->name, dirname, len))
- return 0;
- return active_cache[pos]->name[len] == '/';
+ return !strncmp(active_cache[pos]->name, dirname, len);
}
/*
continue;
/* fallthrough */
case DT_DIR:
- if (show_other_directories) {
- if (!dir_exists(fullname, baselen + len))
- break;
- }
memcpy(fullname + baselen + len, "/", 2);
+ len++;
+ if (show_other_directories &&
+ !dir_exists(fullname, baselen + len))
+ break;
read_directory(fullname, fullname,
- baselen + len + 1);
+ baselen + len);
continue;
case DT_REG:
case DT_LNK:
const char *path = ".", *base = "";
int baselen = prefix_len;
- if (baselen)
+ if (baselen) {
path = base = prefix;
+ if (exclude_per_dir) {
+ char *p, *pp = xmalloc(baselen+1);
+ memcpy(pp, prefix, baselen+1);
+ p = pp;
+ while (1) {
+ char save = *p;
+ *p = 0;
+ push_exclude_per_directory(pp, p-pp);
+ *p++ = save;
+ if (!save)
+ break;
+ p = strchr(p, '/');
+ if (p)
+ p++;
+ else
+ p = pp + baselen;
+ }
+ free(pp);
+ }
+ }
read_directory(path, base, baselen);
qsort(dir, nr_dir, sizeof(struct nond_on_fs *), cmp_name);
if (show_others)