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