On Mon, 13 May 2002, Dave Dykstra wrote:
> I suggest you go ahead and code it in the way you
> think would be simplest and then we can evaluate it more concretely.

OK.  Here's the simple patch.  It optimizes the loop away if the pattern
starts with "**" (since the loop would be superfluous), but otherwise it
just loops over all the slashes in the name when the pattern is an
unanchored path (i.e. contains at least one interior slash).

I'll post another version where I implemented your suggested
optimization in a moment.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: exclude.c
--- exclude.c   2002/04/11 02:25:53     1.44
+++ exclude.c   2002/05/13 19:43:43
@@ -66,6 +66,8 @@
                            }
                    }
                    ret->fnmatch_flags = 0;
+                   if (strncmp(pattern, "**", 2) == 0)
+                           ret->regular_exp = -1;
            }
        }
 
@@ -110,6 +112,13 @@
        if (ex->regular_exp) {
                if (fnmatch(pattern, name, ex->fnmatch_flags) == 0) {
                        return 1;
+               }
+               if (!match_start && !ex->local && ex->regular_exp > 0) {
+                       while ((name = strchr(name, '/')) != NULL) {
+                               name++;
+                               if (fnmatch(pattern, name, ex->fnmatch_flags) == 0)
+                                       return 1;
+                       }
                }
        } else {
                int l1 = strlen(name);
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---


-- 
To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html

Reply via email to