1 This adds the ability to put rules into a filter/include/exclude file
2 in last-match-wins order. All you need to do is to start the file with
9 @@ -76,6 +76,7 @@ static BOOL parent_dirscan = False;
10 static struct filter_struct **mergelist_parents;
11 static int mergelist_cnt = 0;
12 static int mergelist_size = 0;
13 +static int reversing_rules = 0;
15 /* Each filter_list_struct describes a singly-linked list by keeping track
16 * of both the head and tail pointers. The list is slightly unusual in that
17 @@ -244,6 +245,9 @@ static void add_rule(struct filter_list_
19 ret->next = listp->head;
20 listp->head = listp->tail = ret;
21 + } else if (reversing_rules) {
22 + ret->next = listp->head;
25 ret->next = listp->tail->next;
26 listp->tail->next = ret;
27 @@ -970,6 +974,7 @@ void parse_filter_file(struct filter_lis
28 char line[BIGPATHBUFLEN];
29 char *eob = line + sizeof line - 1;
30 int word_split = mflags & MATCHFLG_WORD_SPLIT;
31 + int save_reversing_rules = reversing_rules;
33 if (!fname || !*fname)
35 @@ -1005,6 +1010,7 @@ void parse_filter_file(struct filter_lis
37 dirbuf[dirbuf_len] = '\0';
39 + reversing_rules = 0;
43 @@ -1030,6 +1036,10 @@ void parse_filter_file(struct filter_lis
47 + if (*line == '[' && strcmp(line+1, "last-match]") == 0) {
48 + reversing_rules = 1;
51 /* Skip an empty token and (when line parsing) comments. */
52 if (*line && (word_split || (*line != ';' && *line != '#')))
53 parse_rule(listp, line, mflags, xflags);
54 @@ -1037,6 +1047,7 @@ void parse_filter_file(struct filter_lis
58 + reversing_rules = save_reversing_rules;
61 /* If the "for_xfer" flag is set, the prefix is made compatible with the