On 3/1/07, Matt McCutchen <[EMAIL PROTECTED]> wrote:
Oops!  It looks like I fixed only one out of the four cases for rule
matching (only the case that covered *.sys).  Soon I'll send a patch
that fixes all four cases.

Attached is the fix for all four cases in two formats: a metapatch to
ignore-case.diff and an equivalent extra patch to be applied after
ignore-case.diff .

On 3/1/07, Steven Morehouse <[EMAIL PROTECTED]> wrote:
Now the only thing is... I don't know how to patch a patch :(  Sorry, I'm
not very experienced with building from source.  Figuring out how to apply a
patch to rsync's source was easy since the patch begins with instructions...
but your patch doesn't (that I can decipher anyway).  If I understand
correctly, your patch patches the patch that patches the src, right?  Any
tips would be very much appreciated. Thanks.

I made my changes based on the current CVS rsync, but now that I think
of it, you would probably rather have a fixed version of rsync 2.6.9
because the CVS rsync is unstable.  Extra patches are much more likely
to apply correctly to a different version of the software than
metapatches, so I made an extra patch.  Extract rsync 2.6.9, apply
ignore-case.diff according to the instructions, and then apply
ignore-case-filters-extra.diff like this:

patch -p1 <path/to/ignore-case-filters-extra.diff

You should get a harmless warning about an offset of -24 lines.  If
you have trouble with this, you can use the pre-patched source package
I posted here:

http://www.kepreon.com/~matt/private/rsync-2.6.9-ignore-case-filters.tar.bz2

Please reply if you have any questions.

Matt
Index: patches/ignore-case.diff
===================================================================
RCS file: /cvsroot/rsync/patches/ignore-case.diff,v
retrieving revision 1.51
diff -u -r1.51 ignore-case.diff
--- patches/ignore-case.diff	28 Dec 2006 16:11:25 -0000	1.51
+++ patches/ignore-case.diff	1 Mar 2007 20:41:45 -0000
@@ -7,9 +7,37 @@
     ./configure                            (optional if already run)
     make
 
+--- old/exclude.c
++++ new/exclude.c
+@@ -38,6 +38,7 @@ extern int cvs_exclude;
+ extern int sanitize_paths;
+ extern int protocol_version;
+ extern int module_id;
++extern int ignore_case;
+ 
+ extern char curr_dir[];
+ extern unsigned int curr_dir_len;
+@@ -580,13 +581,15 @@ static int rule_matches(char *name, stru
+ 		if (litmatch_array(pattern, strings, slash_handling))
+ 			return ret_match;
+ 	} else if (anchored_match) {
+-		if (strcmp(name, pattern) == 0)
++		if ((ignore_case ? strcasecmp(name, pattern)
++		    : strcmp(name, pattern)) == 0)
+ 			return ret_match;
+ 	} else {
+ 		int l1 = strlen(name);
+ 		int l2 = strlen(pattern);
+ 		if (l2 <= l1 &&
+-		    strcmp(name+(l1-l2),pattern) == 0 &&
++		    (ignore_case ? strcasecmp(name+(l1-l2),pattern)
++		    	: strcmp(name+(l1-l2),pattern)) == 0 &&
+ 		    (l1==l2 || name[l1-(l2+1)] == '/')) {
+ 			return ret_match;
+ 		}
 --- old/flist.c
 +++ new/flist.c
-@@ -34,6 +34,7 @@ extern int incremental;
+@@ -33,6 +33,7 @@ extern int inc_recurse;
  extern int do_progress;
  extern int always_checksum;
  extern int module_id;
@@ -17,7 +45,7 @@
  extern int ignore_errors;
  extern int numeric_ids;
  extern int recurse;
-@@ -2161,7 +2162,7 @@ int f_name_cmp(struct file_struct *f1, s
+@@ -2169,7 +2170,7 @@ int f_name_cmp(struct file_struct *f1, s
  	if (type1 != type2)
  		return type1 == t_PATH ? 1 : -1;
  
@@ -26,7 +54,7 @@
  		if (!*c1) {
  			switch (state1) {
  			case s_DIR:
-@@ -2224,7 +2225,16 @@ int f_name_cmp(struct file_struct *f1, s
+@@ -2232,7 +2233,16 @@ int f_name_cmp(struct file_struct *f1, s
  			if (type1 != type2)
  				return type1 == t_PATH ? 1 : -1;
  		}
@@ -64,7 +92,22 @@
  	while ((t_ch = *text) == '\0') {
  	    if (*a == NULL) {
  		if (p_ch != '*')
-@@ -288,10 +292,14 @@ static const uchar *trailing_N_elements(
+@@ -242,7 +246,13 @@ static int doliteral(const uchar *s, con
+ 	    if ((text = *a++) == NULL)
+ 		return FALSE;
+ 	}
+-	if (*text != *s)
++	uchar s_ch = *s;
++	if (ignore_case && ISUPPER(s_ch))
++	    s_ch = tolower(s_ch);
++	uchar t_ch = *text;
++	if (force_lower_case && ISUPPER(t_ch))
++	    t_ch = tolower(t_ch);
++	if (t_ch != s_ch)
+ 	    return FALSE;
+     }
+ 
+@@ -288,10 +298,14 @@ static const uchar *trailing_N_elements(
  int wildmatch(const char *pattern, const char *text)
  {
      static const uchar *nomore[1]; /* A NULL pointer. */
@@ -80,9 +123,25 @@
  }
  
  /* Match the "pattern" against the forced-to-lower-case "text" string. */
+@@ -323,6 +337,7 @@ int wildmatch_array(const char *pattern,
+ #ifdef WILD_TEST_ITERATIONS
+     wildmatch_iteration_count = 0;
+ #endif
++    force_lower_case = ignore_case;
+ 
+     if (where > 0)
+ 	text = trailing_N_elements(&a, where);
+@@ -344,6 +359,7 @@ int wildmatch_array(const char *pattern,
+ 		break;
+ 	}
+     }
++    force_lower_case = 0;
+     return matched == TRUE;
+ }
+ 
 --- old/options.c
 +++ new/options.c
-@@ -111,6 +111,7 @@ OFF_T max_size = 0;
+@@ -110,6 +110,7 @@ OFF_T max_size = 0;
  OFF_T min_size = 0;
  int ignore_errors = 0;
  int modify_window = 0;
@@ -90,7 +149,7 @@
  int blocking_io = -1;
  int checksum_seed = 0;
  int inplace = 0;
-@@ -358,6 +359,7 @@ void usage(enum logcode F)
+@@ -357,6 +358,7 @@ void usage(enum logcode F)
    rprintf(F,"     --include-from=FILE     read include patterns from FILE\n");
    rprintf(F,"     --files-from=FILE       read list of source-file names from FILE\n");
    rprintf(F," -0, --from0                 all *-from/filter files are delimited by 0s\n");
@@ -98,7 +157,7 @@
    rprintf(F,"     --address=ADDRESS       bind address for outgoing socket to daemon\n");
    rprintf(F,"     --port=PORT             specify double-colon alternate port number\n");
    rprintf(F,"     --sockopts=OPTIONS      specify custom TCP options\n");
-@@ -523,6 +525,7 @@ static struct poptOption long_options[] 
+@@ -522,6 +524,7 @@ static struct poptOption long_options[] 
    {"only-write-batch", 0,  POPT_ARG_STRING, &batch_name, OPT_ONLY_WRITE_BATCH, 0, 0 },
    {"files-from",       0,  POPT_ARG_STRING, &files_from, 0, 0, 0 },
    {"from0",           '0', POPT_ARG_NONE,   &eol_nulls, 0, 0, 0},
@@ -106,7 +165,7 @@
    {"numeric-ids",      0,  POPT_ARG_NONE,   &numeric_ids, 0, 0, 0 },
    {"timeout",          0,  POPT_ARG_INT,    &io_timeout, 0, 0, 0 },
    {"rsh",             'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
-@@ -1704,6 +1707,9 @@ void server_options(char **args,int *arg
+@@ -1703,6 +1706,9 @@ void server_options(char **args,int *arg
  		args[ac++] = arg;
  	}
  
@@ -118,7 +177,7 @@
  			args[ac++] = "--partial-dir";
 --- old/wildtest.c
 +++ new/wildtest.c
-@@ -32,6 +32,7 @@ int fnmatch_errors = 0;
+@@ -31,6 +31,7 @@ int fnmatch_errors = 0;
  #endif
  
  int wildmatch_errors = 0;
--- old/exclude.c
+++ new/exclude.c
@@ -38,6 +38,7 @@ extern int cvs_exclude;
 extern int sanitize_paths;
 extern int protocol_version;
 extern int module_id;
+extern int ignore_case;
 
 extern char curr_dir[];
 extern unsigned int curr_dir_len;
@@ -580,13 +581,15 @@ static int rule_matches(char *name, stru
 		if (litmatch_array(pattern, strings, slash_handling))
 			return ret_match;
 	} else if (anchored_match) {
-		if (strcmp(name, pattern) == 0)
+		if ((ignore_case ? strcasecmp(name, pattern)
+		    : strcmp(name, pattern)) == 0)
 			return ret_match;
 	} else {
 		int l1 = strlen(name);
 		int l2 = strlen(pattern);
 		if (l2 <= l1 &&
-		    strcmp(name+(l1-l2),pattern) == 0 &&
+		    (ignore_case ? strcasecmp(name+(l1-l2),pattern)
+		    	: strcmp(name+(l1-l2),pattern)) == 0 &&
 		    (l1==l2 || name[l1-(l2+1)] == '/')) {
 			return ret_match;
 		}
--- old/lib/wildmatch.c
+++ new/lib/wildmatch.c
@@ -246,7 +246,13 @@ static int doliteral(const uchar *s, con
 	    if ((text = *a++) == NULL)
 		return FALSE;
 	}
-	if (*text != *s)
+	uchar s_ch = *s;
+	if (ignore_case && ISUPPER(s_ch))
+	    s_ch = tolower(s_ch);
+	uchar t_ch = *text;
+	if (force_lower_case && ISUPPER(t_ch))
+	    t_ch = tolower(t_ch);
+	if (t_ch != s_ch)
 	    return FALSE;
     }
 
@@ -331,6 +337,7 @@ int wildmatch_array(const char *pattern,
 #ifdef WILD_TEST_ITERATIONS
     wildmatch_iteration_count = 0;
 #endif
+    force_lower_case = ignore_case;
 
     if (where > 0)
 	text = trailing_N_elements(&a, where);
@@ -352,6 +359,7 @@ int wildmatch_array(const char *pattern,
 		break;
 	}
     }
+    force_lower_case = 0;
     return matched == TRUE;
 }
 
-- 
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to