1 This adds the --ignore-case option, which makes rsync compare filenames
2 in a case-insensitive manner.
4 To use this patch, run these commands for a successful build:
6 patch -p1 <patches/ignore-case.diff
7 ./configure (optional if already run)
12 - Make this code handle multibyte character encodings, and honor the
13 --iconv setting when converting case.
17 @@ -32,6 +32,7 @@ extern int io_error;
18 extern int local_server;
19 extern int prune_empty_dirs;
20 extern int ignore_perishable;
21 +extern int ignore_case;
22 extern int delete_mode;
23 extern int delete_excluded;
24 extern int cvs_exclude;
25 @@ -583,16 +584,17 @@ static int rule_matches(char *name, stru
26 if (litmatch_array(pattern, strings, slash_handling))
28 } else if (anchored_match) {
29 - if (strcmp(name, pattern) == 0)
30 + if ((ignore_case ? strcasecmp(name, pattern)
31 + : strcmp(name, pattern)) == 0)
34 int l1 = strlen(name);
35 int l2 = strlen(pattern);
37 - strcmp(name+(l1-l2),pattern) == 0 &&
38 - (l1==l2 || name[l1-(l2+1)] == '/')) {
40 + && (ignore_case ? strcasecmp(name + (l1-l2), pattern)
41 + : strcmp(name + (l1-l2), pattern)) == 0
42 + && (l1 == l2 || name[l1 - (l2+1)] == '/'))
50 @@ -35,6 +35,7 @@ extern int inc_recurse;
51 extern int do_progress;
52 extern int always_checksum;
54 +extern int ignore_case;
55 extern int ignore_errors;
56 extern int numeric_ids;
58 @@ -2494,6 +2495,7 @@ int f_name_cmp(const struct file_struct
63 enum fnc_state state1, state2;
64 enum fnc_type type1, type2;
65 enum fnc_type t_path = protocol_version >= 29 ? t_PATH : t_ITEM;
66 @@ -2604,7 +2606,15 @@ int f_name_cmp(const struct file_struct
68 return type1 == t_PATH ? 1 : -1;
70 - } while ((dif = (int)*c1++ - (int)*c2++) == 0);
71 + ch1 = CVAL(c1++, 0);
72 + ch2 = CVAL(c2++, 0);
79 + } while ((dif = ch1 - ch2) == 0);
83 --- old/lib/wildmatch.c
84 +++ new/lib/wildmatch.c
86 #define ISUPPER(c) (ISASCII(c) && isupper(c))
87 #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
89 +extern int ignore_case;
91 #ifdef WILD_TEST_ITERATIONS
92 int wildmatch_iteration_count;
94 @@ -72,6 +74,8 @@ static int dowild(const uchar *p, const
95 for ( ; (p_ch = *p) != '\0'; text++, p++) {
98 + if (ignore_case && ISUPPER(p_ch))
99 + p_ch = tolower(p_ch);
100 while ((t_ch = *text) == '\0') {
103 @@ -237,12 +241,21 @@ static int dowild(const uchar *p, const
104 * of "text" and any strings in array "a". */
105 static int doliteral(const uchar *s, const uchar *text, const uchar*const *a)
108 for ( ; *s != '\0'; text++, s++) {
109 while (*text == '\0') {
110 if ((text = *a++) == NULL)
118 + s_ch = tolower(s_ch);
120 + t_ch = tolower(t_ch);
126 @@ -288,10 +301,14 @@ static const uchar *trailing_N_elements(
127 int wildmatch(const char *pattern, const char *text)
129 static const uchar *nomore[1]; /* A NULL pointer. */
131 #ifdef WILD_TEST_ITERATIONS
132 wildmatch_iteration_count = 0;
134 - return dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
135 + force_lower_case = ignore_case;
136 + ret = dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
137 + force_lower_case = 0;
141 /* Match the "pattern" against the forced-to-lower-case "text" string. */
142 @@ -331,12 +348,14 @@ int wildmatch_array(const char *pattern,
146 + force_lower_case = ignore_case;
148 if ((matched = dowild(p, text, a)) != TRUE && where < 0
149 && matched != ABORT_ALL) {
152 if ((text = (uchar*)*a++) == NULL)
157 if (*text++ == '/' && (matched = dowild(p, text, a)) != FALSE
158 @@ -344,6 +363,9 @@ int wildmatch_array(const char *pattern,
163 + force_lower_case = 0;
165 return matched == TRUE;
170 @@ -114,6 +114,7 @@ OFF_T max_size = 0;
172 int ignore_errors = 0;
173 int modify_window = 0;
174 +int ignore_case = 0;
175 int blocking_io = -1;
176 int checksum_seed = 0;
178 @@ -396,6 +397,7 @@ void usage(enum logcode F)
179 rprintf(F," --exclude-from=FILE read exclude patterns from FILE\n");
180 rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n");
181 rprintf(F," --include-from=FILE read include patterns from FILE\n");
182 + rprintf(F," --ignore-case ignore case when comparing filenames\n");
183 rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
184 rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n");
185 rprintf(F," -s, --protect-args no space-splitting; only wildcard special-chars\n");
186 @@ -593,6 +595,8 @@ static struct poptOption long_options[]
187 {"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
188 {"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
189 {"only-write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_ONLY_WRITE_BATCH, 0, 0 },
190 + {"ignore-case", 0, POPT_ARG_VAL, &ignore_case, 1, 0, 0 },
191 + {"no-ignore-case", 0, POPT_ARG_VAL, &ignore_case, 0, 0, 0 },
192 {"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
193 {"from0", '0', POPT_ARG_VAL, &eol_nulls, 1, 0, 0},
194 {"no-from0", 0, POPT_ARG_VAL, &eol_nulls, 0, 0, 0},
195 @@ -1907,6 +1911,9 @@ void server_options(char **args, int *ar
200 + args[ac++] = "--ignore-case";
202 if (partial_dir && am_sender) {
203 if (partial_dir != tmp_partialdir) {
204 args[ac++] = "--partial-dir";
207 @@ -31,6 +31,7 @@ int fnmatch_errors = 0;
210 int wildmatch_errors = 0;
211 +int ignore_case = 0;