Moved the delete-after support into generator.c.
[rsync/rsync.git] / exclude.c
index 9a7a81c..87013ec 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -133,6 +133,19 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
                        listp->debug_type);
        }
 
+       /* This flag also indicates that we're reading a list that
+        * needs to be filtered now, not post-filtered later. */
+       if (xflags & XFLG_ANCHORED2ABS) {
+               uint32 mf = mflags & (MATCHFLG_RECEIVER_SIDE|MATCHFLG_SENDER_SIDE);
+               if (am_sender) {
+                       if (mf == MATCHFLG_RECEIVER_SIDE)
+                               return;
+               } else {
+                       if (mf == MATCHFLG_SENDER_SIDE)
+                               return;
+               }
+       }
+
        if (!(ret = new(struct filter_struct)))
                out_of_memory("add_rule");
        memset(ret, 0, sizeof ret[0]);
@@ -608,9 +621,9 @@ int check_filter(struct filter_list_struct *listp, char *name, int name_is_dir)
 
 #define RULE_STRCMP(s,r) rule_strcmp((s), (r), sizeof (r) - 1)
 
-static const char *rule_strcmp(const char *str, const char *rule, int rule_len)
+static const uchar *rule_strcmp(const uchar *str, const char *rule, int rule_len)
 {
-       if (strncmp(str, rule, rule_len) != 0)
+       if (strncmp((char*)str, rule, rule_len) != 0)
                return NULL;
        if (isspace(str[rule_len]) || str[rule_len] == '_' || !str[rule_len])
                return str + rule_len - 1;
@@ -1021,7 +1034,7 @@ char *get_rule_prefix(int match_flags, const char *pat, int for_xfer,
 {
        static char buf[MAX_RULE_PREFIX+1];
        char *op = buf;
-       int legal_len = for_xfer && protocol_version < 29 ? 1 : MAX_RULE_PREFIX;
+       int legal_len = for_xfer && protocol_version < 29 ? 1 : MAX_RULE_PREFIX-1;
 
        if (match_flags & MATCHFLG_PERDIR_MERGE) {
                if (legal_len == 1)
@@ -1058,10 +1071,10 @@ char *get_rule_prefix(int match_flags, const char *pat, int for_xfer,
            && (!for_xfer || protocol_version >= 29
             || (delete_excluded && am_sender)))
                *op++ = 'r';
-       if (legal_len)
-               *op++ = ' ';
        if (op - buf > legal_len)
                return NULL;
+       if (legal_len)
+               *op++ = ' ';
        *op = '\0';
        if (plen_ptr)
                *plen_ptr = op - buf;