* mail/util.c (util_expand_msglist): Cleanup the expand by pattern
by moving some code in util_strupper(), the comparison must be case insensitive. (util_strupper): Convert the string to uppercase.
Showing
2 changed files
with
26 additions
and
14 deletions
1 | 2001-07-01 Alain Magloire | ||
2 | |||
3 | * mail/util.c (util_expand_msglist): Cleanup the expand by pattern | ||
4 | by moving some code in util_strupper(), the comparison must be | ||
5 | case insensitive. | ||
6 | (util_strupper): Convert the string to uppercase. | ||
7 | |||
1 | 2001-07-01 Sergey Poznyakoff | 8 | 2001-07-01 Sergey Poznyakoff |
2 | * mailbox/attribute.c: set MU_ATTRIBUTE_MODIFIED bit in the underlying | 9 | * mailbox/attribute.c: set MU_ATTRIBUTE_MODIFIED bit in the underlying |
3 | structure when setting the flags. | 10 | structure when setting the flags. | ... | ... |
... | @@ -155,37 +155,30 @@ util_expand_msglist (const int argc, char **argv, int **list) | ... | @@ -155,37 +155,30 @@ util_expand_msglist (const int argc, char **argv, int **list) |
155 | /* All messages with pattern following / in | 155 | /* All messages with pattern following / in |
156 | the subject line, case insensitive */ | 156 | the subject line, case insensitive */ |
157 | int j; | 157 | int j; |
158 | char *pattern; | ||
159 | |||
160 | pattern = strdup (&argv[i][1]); | ||
161 | util_strupper (pattern); | ||
162 | |||
158 | for (j = 1; j <= total; j++) | 163 | for (j = 1; j <= total; j++) |
159 | { | 164 | { |
160 | message_t msg = NULL; | 165 | message_t msg = NULL; |
161 | header_t hdr = NULL; | 166 | header_t hdr = NULL; |
162 | char *subject = NULL; | 167 | char *subject = NULL; |
163 | size_t subjlen; | 168 | size_t subjlen; |
164 | char *pattern; | ||
165 | size_t patlen; | ||
166 | int k; | 169 | int k; |
167 | 170 | ||
168 | mailbox_get_message (mbox, j, &msg); | 171 | mailbox_get_message (mbox, j, &msg); |
169 | message_get_header (msg, &hdr); | 172 | message_get_header (msg, &hdr); |
170 | 173 | ||
171 | header_aget_value (hdr, MU_HEADER_SUBJECT, &subject); | 174 | header_aget_value (hdr, MU_HEADER_SUBJECT, &subject); |
172 | subjlen = (subject) ? strlen (subject) : 0; | 175 | util_strupper (subject); |
173 | for (k = 0; k < subjlen; k++) | ||
174 | subject[k] = toupper ((int)subject[k]); | ||
175 | |||
176 | pattern = strdup (&argv[i][1]); | ||
177 | patlen = (pattern) ? strlen (pattern) : 0; | ||
178 | for (k = 0; k < patlen; k++) | ||
179 | pattern[k] = toupper ((int)pattern[k]); | ||
180 | 176 | ||
181 | if (pattern && subject && strstr (subject, pattern)) | 177 | if (pattern && subject && strstr (subject, pattern)) |
182 | { | ||
183 | current = util_ll_add (current, j); | 178 | current = util_ll_add (current, j); |
184 | } | ||
185 | |||
186 | free (pattern); | ||
187 | free (subject); | 179 | free (subject); |
188 | } | 180 | } |
181 | free (pattern); | ||
189 | } | 182 | } |
190 | else if (argv[i][0] == ':') | 183 | else if (argv[i][0] == ':') |
191 | { | 184 | { |
... | @@ -700,6 +693,18 @@ util_strcat(char **dest, char *str) | ... | @@ -700,6 +693,18 @@ util_strcat(char **dest, char *str) |
700 | } | 693 | } |
701 | } | 694 | } |
702 | 695 | ||
696 | /* Upper case the entire string. Assume it is NULL terminated. */ | ||
697 | void | ||
698 | util_strupper (char *s) | ||
699 | { | ||
700 | if (s) | ||
701 | { | ||
702 | while (s++) | ||
703 | *s = toupper ((int)*s); | ||
704 | } | ||
705 | } | ||
706 | |||
707 | |||
703 | void | 708 | void |
704 | util_escape_percent (char **str) | 709 | util_escape_percent (char **str) |
705 | { | 710 | { | ... | ... |
-
Please register or sign in to post a comment