Commit | Line | Data |
---|---|---|
992633a5 WD |
1 | This adds the --ignore-case option, which makes rsync compare filenames |
2 | in a case-insensitive manner. | |
8a524ae0 | 3 | |
a7219d20 | 4 | --- orig/lib/wildmatch.c 2005-01-28 23:01:12 |
992633a5 WD |
5 | +++ lib/wildmatch.c 2004-08-13 16:43:27 |
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 | |
a7219d20 | 15 | @@ -76,9 +78,19 @@ static int domatch(const uchar *p, const |
13bed3dd WD |
16 | ch = *++p; |
17 | /* FALLTHROUGH */ | |
18 | default: | |
19 | - if (*text != ch) | |
992633a5 WD |
20 | - return FALSE; |
21 | - continue; | |
22 | + if (*text == ch) | |
23 | + continue; | |
24 | + if (ignore_case) { | |
25 | + if (ISUPPER(*text)) { | |
26 | + if (tolower(*text) == ch) | |
27 | + continue; | |
28 | + } | |
29 | + else if (ISUPPER(ch)) { | |
30 | + if (*text == tolower(ch)) | |
31 | + continue; | |
13bed3dd | 32 | + } |
13bed3dd | 33 | + } |
992633a5 | 34 | + return FALSE; |
13bed3dd WD |
35 | case '?': |
36 | /* Match anything but '/'. */ | |
992633a5 | 37 | if (*text == '/') |
a7219d20 | 38 | --- orig/options.c 2005-02-01 10:39:22 |
5388f859 | 39 | +++ options.c 2004-10-14 17:22:51 |
a7219d20 | 40 | @@ -97,6 +97,7 @@ int max_delete = 0; |
4c1f2ca5 | 41 | OFF_T max_size = 0; |
5f7bb027 WD |
42 | int ignore_errors = 0; |
43 | int modify_window = 0; | |
44 | +int ignore_case = 0; | |
45 | int blocking_io = -1; | |
46 | int checksum_seed = 0; | |
f6c3b300 | 47 | int inplace = 0; |
a7219d20 WD |
48 | @@ -314,6 +315,7 @@ void usage(enum logcode F) |
49 | rprintf(F," --include-from=FILE read include patterns from FILE\n"); | |
50 | rprintf(F," --files-from=FILE read list of source-file names from FILE\n"); | |
d4e89c6a | 51 | rprintf(F," -0, --from0 all *-from file lists are delimited by nulls\n"); |
5f7bb027 WD |
52 | + rprintf(F," --ignore-case ignore case when comparing filenames\n"); |
53 | rprintf(F," --version print version number\n"); | |
37da98ae | 54 | rprintf(F," --port=PORT specify double-colon alternate port number\n"); |
5388f859 | 55 | rprintf(F," --blocking-io use blocking I/O for the remote shell\n"); |
a7219d20 | 56 | @@ -368,6 +370,7 @@ static struct poptOption long_options[] |
5388f859 WD |
57 | {"include", 0, POPT_ARG_STRING, 0, OPT_INCLUDE, 0, 0 }, |
58 | {"exclude-from", 0, POPT_ARG_STRING, 0, OPT_EXCLUDE_FROM, 0, 0 }, | |
59 | {"include-from", 0, POPT_ARG_STRING, 0, OPT_INCLUDE_FROM, 0, 0 }, | |
5f7bb027 WD |
60 | + {"ignore-case", 0, POPT_ARG_NONE, &ignore_case, 0, 0, 0 }, |
61 | {"safe-links", 0, POPT_ARG_NONE, &safe_symlinks, 0, 0, 0 }, | |
5388f859 | 62 | {"help", 'h', POPT_ARG_NONE, 0, 'h', 0, 0 }, |
5f7bb027 | 63 | {"backup", 'b', POPT_ARG_NONE, &make_backups, 0, 0, 0 }, |
a7219d20 | 64 | @@ -1259,6 +1262,9 @@ void server_options(char **args,int *arg |
5f7bb027 WD |
65 | args[ac++] = arg; |
66 | } | |
7628f156 | 67 | |
5f7bb027 WD |
68 | + if (ignore_case) |
69 | + args[ac++] = "--ignore-case"; | |
7628f156 | 70 | + |
afbebe13 WD |
71 | if (partial_dir && am_sender) { |
72 | args[ac++] = "--partial-dir"; | |
73 | args[ac++] = partial_dir; | |
a7219d20 | 74 | --- orig/t_stub.c 2005-01-25 12:14:14 |
992633a5 WD |
75 | +++ t_stub.c 2004-08-13 17:19:56 |
76 | @@ -28,6 +28,7 @@ | |
77 | ||
78 | int modify_window = 0; | |
79 | int module_id = -1; | |
80 | +int ignore_case = 0; | |
81 | char *partial_dir; | |
4f9b6a01 | 82 | struct filter_list_struct server_filter_list; |
992633a5 | 83 | |
a7219d20 | 84 | --- orig/util.c 2005-01-28 19:08:20 |
992633a5 WD |
85 | +++ util.c 2004-08-13 16:40:34 |
86 | @@ -31,6 +31,7 @@ extern int verbose; | |
87 | extern int dry_run; | |
88 | extern int module_id; | |
89 | extern int modify_window; | |
90 | +extern int ignore_case; | |
91 | extern char *partial_dir; | |
4f9b6a01 | 92 | extern struct filter_list_struct server_filter_list; |
992633a5 | 93 | |
a7219d20 | 94 | @@ -1011,11 +1012,23 @@ int u_strcmp(const char *cs1, const char |
5f7bb027 WD |
95 | { |
96 | const uchar *s1 = (const uchar *)cs1; | |
97 | const uchar *s2 = (const uchar *)cs2; | |
8a524ae0 | 98 | + |
5f7bb027 | 99 | + if (ignore_case) { |
992633a5 WD |
100 | + uchar c1, c2; |
101 | + while (1) { | |
102 | + c1 = islower(*s1) ? toupper(*s1) : *s1; | |
103 | + c2 = islower(*s2) ? toupper(*s2) : *s2; | |
104 | + if (!c1 || c1 != c2) | |
105 | + break; | |
106 | + s1++, s2++; | |
5f7bb027 | 107 | + } |
992633a5 WD |
108 | |
109 | - while (*s1 && *s2 && (*s1 == *s2)) { | |
110 | - s1++; s2++; | |
111 | + return (int)c1 - (int)c2; | |
112 | } | |
113 | ||
114 | + while (*s1 && *s1 == *s2) | |
115 | + s1++, s2++; | |
5f7bb027 | 116 | + |
992633a5 WD |
117 | return (int)*s1 - (int)*s2; |
118 | } | |
119 | ||
120 | --- orig/wildtest.c 2004-02-07 18:40:52 | |
121 | +++ wildtest.c 2004-08-13 17:19:34 | |
122 | @@ -16,6 +16,7 @@ int fnmatch_errors = 0; | |
123 | #endif | |
124 | ||
125 | int wildmatch_errors = 0; | |
126 | +int ignore_case = 0; | |
127 | ||
128 | typedef char bool; | |
5f7bb027 | 129 |