+ if ((options & EXCLUDE_WILDCARDS)
+ && fnmatch_pattern_has_wildcards (pattern, options))
+ {
+ struct exclude_pattern *pat;
+ struct patopts *patopts;
+
+ if (ex->tail && ex->tail->type == exclude_pattern
+ && ((ex->tail->options & EXCLUDE_INCLUDE) ==
+ (options & EXCLUDE_INCLUDE)))
+ seg = ex->tail;
+ else
+ seg = new_exclude_segment (ex, exclude_pattern, options);
+
+ pat = &seg->v.pat;
+ if (pat->exclude_count == pat->exclude_alloc)
+ pat->exclude = x2nrealloc (pat->exclude, &pat->exclude_alloc,
+ sizeof *pat->exclude);
+ patopts = &pat->exclude[pat->exclude_count++];
+ patopts->pattern = pattern;
+ patopts->options = options;
+ }
+ else
+ {
+ char *str, *p;
+#define EXCLUDE_HASH_FLAGS (EXCLUDE_INCLUDE|EXCLUDE_ANCHORED|\
+ FNM_LEADING_DIR|FNM_CASEFOLD)
+ if (ex->tail && ex->tail->type == exclude_hash
+ && ((ex->tail->options & EXCLUDE_HASH_FLAGS) ==
+ (options & EXCLUDE_HASH_FLAGS)))
+ seg = ex->tail;
+ else
+ seg = new_exclude_segment (ex, exclude_hash, options);
+
+ str = xstrdup (pattern);
+ if (options & EXCLUDE_WILDCARDS)
+ unescape_pattern (str);
+ p = hash_insert (seg->v.table, str);
+ if (p != str)
+ free (str);
+ }