Fixed failing hunks.
[rsync-patches.git] / ignore-case.diff
1 This adds the --ignore-case option, which makes rsync compare filenames
2 in a case-insensitive manner.
3
4 --- orig/lib/wildmatch.c        2005-01-28 21:01:21
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
15 @@ -76,9 +78,19 @@ static int domatch(const uchar *p, const
16             ch = *++p;
17             /* FALLTHROUGH */
18           default:
19 -           if (*text != ch)
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;
32 +               }
33 +           }
34 +           return FALSE;
35           case '?':
36             /* Match anything but '/'. */
37             if (*text == '/')
38 --- orig/options.c      2005-10-15 16:39:46
39 +++ options.c   2005-10-14 19:19:18
40 @@ -102,6 +102,7 @@ OFF_T max_size = 0;
41  OFF_T min_size = 0;
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;
47  int inplace = 0;
48 @@ -334,6 +335,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");
51    rprintf(F," -0, --from0                 all *-from/filter files are delimited by 0s\n");
52 +  rprintf(F,"     --ignore-case           ignore case when comparing filenames\n");
53    rprintf(F,"     --address=ADDRESS       bind address for outgoing socket to daemon\n");
54    rprintf(F,"     --port=PORT             specify double-colon alternate port number\n");
55    rprintf(F,"     --blocking-io           use blocking I/O for the remote shell\n");
56 @@ -471,6 +473,7 @@ static struct poptOption long_options[] 
57    {"only-write-batch", 0,  POPT_ARG_STRING, &batch_name, OPT_ONLY_WRITE_BATCH, 0, 0 },
58    {"files-from",       0,  POPT_ARG_STRING, &files_from, 0, 0, 0 },
59    {"from0",           '0', POPT_ARG_NONE,   &eol_nulls, 0, 0, 0},
60 +  {"ignore-case",      0,  POPT_ARG_NONE,   &ignore_case, 0, 0, 0 },
61    {"numeric-ids",      0,  POPT_ARG_NONE,   &numeric_ids, 0, 0, 0 },
62    {"timeout",          0,  POPT_ARG_INT,    &io_timeout, 0, 0, 0 },
63    {"rsh",             'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
64 @@ -1521,6 +1524,9 @@ void server_options(char **args,int *arg
65                 args[ac++] = arg;
66         }
67  
68 +       if (ignore_case)
69 +               args[ac++] = "--ignore-case";
70 +
71         if (partial_dir && am_sender) {
72                 if (partial_dir != partialdir_for_delayupdate) {
73                         args[ac++] = "--partial-dir";
74 --- orig/t_stub.c       2005-10-16 22:38:39
75 +++ t_stub.c    2005-10-18 08:18:25
76 @@ -29,6 +29,7 @@
77  int modify_window = 0;
78  int module_id = -1;
79  int relative_paths = 0;
80 +int ignore_case = 0;
81  char *partial_dir;
82  struct filter_list_struct server_filter_list;
83  
84 --- orig/util.c 2005-10-16 22:38:40
85 +++ util.c      2005-10-18 08:18:39
86 @@ -32,6 +32,7 @@ extern int dry_run;
87  extern int module_id;
88  extern int modify_window;
89  extern int relative_paths;
90 +extern int ignore_case;
91  extern char *partial_dir;
92  extern struct filter_list_struct server_filter_list;
93  
94 @@ -1044,11 +1045,23 @@ int u_strcmp(const char *cs1, const char
95  {
96         const uchar *s1 = (const uchar *)cs1;
97         const uchar *s2 = (const uchar *)cs2;
98 +       
99 +       if (ignore_case) {
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++;
107 +               }
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++;
116 +
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;
129