- char *p, full_name[MAXPATHLEN];
- int match_start = 0;
- int ret_match = ex->match_flags & MATCHFLG_NEGATE ? 0 : 1;
- char *pattern = ex->pattern;
+ static int cur_depth = -1;
+ static void *filt_array[MAXPATHLEN/2+1];
+
+ if (!dname) {
+ for ( ; cur_depth >= 0; cur_depth--) {
+ if (filt_array[cur_depth]) {
+ pop_local_filters(filt_array[cur_depth]);
+ filt_array[cur_depth] = NULL;
+ }
+ }
+ return;
+ }
+
+ assert(dir_depth < MAXPATHLEN/2+1);
+
+ for ( ; cur_depth >= dir_depth; cur_depth--) {
+ if (filt_array[cur_depth]) {
+ pop_local_filters(filt_array[cur_depth]);
+ filt_array[cur_depth] = NULL;
+ }
+ }
+
+ cur_depth = dir_depth;
+ filt_array[cur_depth] = push_local_filters(dname, dlen);
+}
+
+static int rule_matches(const char *fname, filter_rule *ex, int name_is_dir)
+{
+ int slash_handling, str_cnt = 0, anchored_match = 0;
+ int ret_match = ex->rflags & FILTRULE_NEGATE ? 0 : 1;
+ char *p, *pattern = ex->pattern;
+ const char *strings[16]; /* more than enough */
+ const char *name = fname + (*fname == '/');