Fixed failing hunks.
[rsync/rsync-patches.git] / ignore-case.diff
CommitLineData
992633a5
WD
1This adds the --ignore-case option, which makes rsync compare filenames
2in a case-insensitive manner.
8a524ae0 3
66e2df0e
WD
4--- orig/lib/wildmatch.c 2006-01-03 17:26:02
5+++ lib/wildmatch.c 2006-01-03 17:29:11
992633a5
WD
6@@ -53,6 +53,8 @@
7 #define ISUPPER(c) (ISASCII(c) && isupper(c))
8 #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
9
10+extern int ignore_case;
11+
12 #ifdef WILD_TEST_ITERATIONS
13 int wildmatch_iteration_count;
14 #endif
66e2df0e 15@@ -72,6 +74,8 @@ static int dowild(const uchar *p, const
ffadcb36
WD
16 for ( ; (p_ch = *p) != '\0'; text++, p++) {
17 int matched, special;
18 uchar t_ch, prev_ch;
19+ if (ignore_case && ISUPPER(p_ch))
20+ p_ch = tolower(p_ch);
66e2df0e
WD
21 while ((t_ch = *text) == '\0') {
22 if (*a == NULL) {
23 if (p_ch != '*')
24@@ -288,10 +292,14 @@ static const uchar *trailing_N_elements(
ffadcb36
WD
25 int wildmatch(const char *pattern, const char *text)
26 {
66e2df0e 27 static const uchar *nomore[1]; /* A NULL pointer. */
ffadcb36
WD
28+ int ret;
29 #ifdef WILD_TEST_ITERATIONS
30 wildmatch_iteration_count = 0;
31 #endif
66e2df0e 32- return dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
ffadcb36 33+ force_lower_case = ignore_case;
66e2df0e 34+ ret = dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
ffadcb36 35+ force_lower_case = 0;
66e2df0e 36+ return ret;
ffadcb36
WD
37 }
38
39 /* Match the "pattern" against the forced-to-lower-case "text" string. */
40--- orig/options.c 2005-12-24 07:49:26
edea1111 41+++ options.c 2005-10-14 19:19:18
91f798a7 42@@ -105,6 +105,7 @@ OFF_T max_size = 0;
56208f7b 43 OFF_T min_size = 0;
5f7bb027
WD
44 int ignore_errors = 0;
45 int modify_window = 0;
46+int ignore_case = 0;
47 int blocking_io = -1;
48 int checksum_seed = 0;
f6c3b300 49 int inplace = 0;
91f798a7 50@@ -342,6 +343,7 @@ void usage(enum logcode F)
a7219d20
WD
51 rprintf(F," --include-from=FILE read include patterns from FILE\n");
52 rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
896871f8 53 rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n");
5f7bb027 54+ rprintf(F," --ignore-case ignore case when comparing filenames\n");
2b06a19d 55 rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n");
37da98ae 56 rprintf(F," --port=PORT specify double-colon alternate port number\n");
896871f8 57 rprintf(F," --blocking-io use blocking I/O for the remote shell\n");
91f798a7 58@@ -485,6 +487,7 @@ static struct poptOption long_options[]
edea1111
WD
59 {"only-write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_ONLY_WRITE_BATCH, 0, 0 },
60 {"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
61 {"from0", '0', POPT_ARG_NONE, &eol_nulls, 0, 0, 0},
5f7bb027 62+ {"ignore-case", 0, POPT_ARG_NONE, &ignore_case, 0, 0, 0 },
edea1111
WD
63 {"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 },
64 {"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
65 {"rsh", 'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
ffadcb36 66@@ -1575,6 +1578,9 @@ void server_options(char **args,int *arg
5f7bb027
WD
67 args[ac++] = arg;
68 }
7628f156 69
5f7bb027
WD
70+ if (ignore_case)
71+ args[ac++] = "--ignore-case";
7628f156 72+
afbebe13 73 if (partial_dir && am_sender) {
27a7053c
WD
74 if (partial_dir != partialdir_for_delayupdate) {
75 args[ac++] = "--partial-dir";
91f798a7
WD
76--- orig/t_stub.c 2005-11-12 20:13:05
77+++ t_stub.c 2005-11-12 20:14:28
78@@ -27,6 +27,7 @@
79 **/
80
992633a5 81 int modify_window = 0;
91f798a7 82+int ignore_case = 0;
992633a5 83 int module_id = -1;
56208f7b 84 int relative_paths = 0;
91f798a7
WD
85 int human_readable = 0;
86--- orig/util.c 2005-11-12 20:13:05
87+++ util.c 2005-11-12 20:14:39
88@@ -30,6 +30,7 @@
89 extern int verbose;
90 extern int dry_run;
992633a5 91 extern int module_id;
91f798a7 92+extern int ignore_case;
992633a5 93 extern int modify_window;
56208f7b 94 extern int relative_paths;
91f798a7
WD
95 extern int human_readable;
96@@ -1045,11 +1046,23 @@ int u_strcmp(const char *cs1, const char
5f7bb027
WD
97 {
98 const uchar *s1 = (const uchar *)cs1;
99 const uchar *s2 = (const uchar *)cs2;
8a524ae0 100+
5f7bb027 101+ if (ignore_case) {
992633a5
WD
102+ uchar c1, c2;
103+ while (1) {
104+ c1 = islower(*s1) ? toupper(*s1) : *s1;
105+ c2 = islower(*s2) ? toupper(*s2) : *s2;
106+ if (!c1 || c1 != c2)
107+ break;
108+ s1++, s2++;
5f7bb027 109+ }
992633a5
WD
110
111- while (*s1 && *s2 && (*s1 == *s2)) {
112- s1++; s2++;
113+ return (int)c1 - (int)c2;
114 }
115
116+ while (*s1 && *s1 == *s2)
117+ s1++, s2++;
5f7bb027 118+
992633a5
WD
119 return (int)*s1 - (int)*s2;
120 }
121
66e2df0e 122--- orig/wildtest.c 2006-01-03 17:26:02
992633a5
WD
123+++ wildtest.c 2004-08-13 17:19:34
124@@ -16,6 +16,7 @@ int fnmatch_errors = 0;
125 #endif
126
127 int wildmatch_errors = 0;
128+int ignore_case = 0;
129
130 typedef char bool;
5f7bb027 131