Improved the ABORT logic to allow aborting consecutive "*" wildcards
[rsync/rsync.git] / wildtest.c
index d279fc5..1f7516e 100644 (file)
@@ -3,8 +3,9 @@
 */
 
 #include "rsync.h"
+#include "lib/wildmatch.h"
 
-#define COMPARE_WITH_FNMATCH
+/*#define COMPARE_WITH_FNMATCH*/
 
 #ifdef COMPARE_WITH_FNMATCH
 #include <fnmatch.h>
@@ -23,6 +24,8 @@ beg(int n, const char *text, const char *pattern, bool matches, bool same_as_fnm
 #ifdef COMPARE_WITH_FNMATCH
     bool fn_matched;
     int flags = strstr(pattern, "**")? 0 : FNM_PATHNAME;
+#else
+    same_as_fnmatch = 0; /* Get rid of unused-variable compiler warning. */
 #endif
 
     matched = wildmatch(pattern, text);
@@ -49,6 +52,8 @@ end(int n, const char *text, const char *pattern, bool matches, bool same_as_fnm
 #ifdef COMPARE_WITH_FNMATCH
     bool fn_matched = false;
     int flags = strstr(pattern, "**")? 0 : FNM_PATHNAME;
+#else
+    same_as_fnmatch = 0; /* Get rid of unused-variable compiler warning. */
 #endif
 
     if (strncmp(pattern, "**", 2) == 0) {
@@ -165,10 +170,10 @@ main(int argc, char **argv)
 
     /* Additional tests, including some malformed wildmats. */
     /* TEST, "text",           "pattern",              MATCH?, SAME-AS-FNMATCH? */
-    beg(500, "]",              "[\\-_]",               true,   false);
+    beg(500, "]",              "[\\-_]",               true,   true);
     beg(501, "[",              "[\\-_]",               false,  true);
     beg(502, ".",              "[\\\\-_]",             false,  true);
-    beg(503, "^",              "[\\\\-_]",             true,   false);
+    beg(503, "^",              "[\\\\-_]",             true,   true);
     beg(504, "Z",              "[\\\\-_]",             false,  true);
     beg(505, "\\",             "[\\]]",                false,  true);
     beg(506, "ab",             "a[]b",                 false,  true);
@@ -197,15 +202,15 @@ main(int argc, char **argv)
     beg(529, "[",              "[!]-a]",               true,   true);
     beg(530, "^",              "[a^bc]",               true,   true);
     beg(531, "-b]",            "[a-]b]",               true,   true);
-    beg(532, "\\]",            "[\\]]",                true,   false);
-    beg(533, "\\",             "[\\]",                 true,   false);
-    beg(534, "\\",             "[!\\]",                false,  false); /*FN?*/
-    beg(535, "G",              "[A-\\]",               true,   false);
+    beg(532, "\\]",            "[\\]]",                true,   true);
+    beg(533, "\\",             "[\\]",                 true,   true);
+    beg(534, "\\",             "[!\\]",                false,  true);
+    beg(535, "G",              "[A-\\]",               true,   true);
     beg(536, "aaabbb",         "b*a",                  false,  true);
     beg(537, "aabcaa",         "*ba*",                 false,  true);
     beg(538, ",",              "[,]",                  true,   true);
     beg(539, ",",              "[\\,]",                true,   true);
-    beg(540, "\\",             "[\\,]",                true,   false);
+    beg(540, "\\",             "[\\,]",                true,   true);
     beg(541, "-",              "[,-.]",                true,   true);
     beg(542, "+",              "[,-.]",                false,  true);
     beg(543, "-.]",            "[,-.]",                false,  true);