(struct argp_option options): Fixed definition
of -a option. (print_header): Last header was never seen.
Showing
1 changed file
with
15 additions
and
9 deletions
... | @@ -41,8 +41,8 @@ static struct argp_option options[] = | ... | @@ -41,8 +41,8 @@ static struct argp_option options[] = |
41 | { "folder", 'f', "FOLDER", 0, "Folder to use", 1 }, | 41 | { "folder", 'f', "FOLDER", 0, "Folder to use", 1 }, |
42 | { "no-header", 'n', 0, 0, "Exclude all headers", 1 }, | 42 | { "no-header", 'n', 0, 0, "Exclude all headers", 1 }, |
43 | { "form-feeds", 'p', 0, 0, "Output formfeeds between messages", 1 }, | 43 | { "form-feeds", 'p', 0, 0, "Output formfeeds between messages", 1 }, |
44 | { "show-all-match", 'a', "PATTERN", 0, | 44 | { "show-all-match", 'a', NULL, 0, |
45 | "Print all messages matching PATTERN", 1 }, | 45 | "Print all messages matching pattern, not just the first", 1 }, |
46 | {0, 0, 0, 0} | 46 | {0, 0, 0, 0} |
47 | }; | 47 | }; |
48 | 48 | ||
... | @@ -162,16 +162,17 @@ print_header (message_t message, int no_header, int all_headers, | ... | @@ -162,16 +162,17 @@ print_header (message_t message, int no_header, int all_headers, |
162 | 162 | ||
163 | header_get_field_count (header, &count); | 163 | header_get_field_count (header, &count); |
164 | 164 | ||
165 | for (i = 1; i < count; i++) | 165 | for (i = 1; i <= count; i++) |
166 | { | 166 | { |
167 | char *name = NULL; | 167 | char *name = NULL; |
168 | char *value = NULL; | 168 | char *value = NULL; |
169 | char *token = strdup (weedlist); | 169 | char *weedcopy = strdup (weedlist); |
170 | char *p = token; | 170 | char *token, *s; |
171 | 171 | ||
172 | header_aget_field_name (header, i, &name); | 172 | header_aget_field_name (header, i, &name); |
173 | header_aget_field_value (header, i, &value); | 173 | header_aget_field_value (header, i, &value); |
174 | for (; (token = strtok (token, delim)) != NULL; token = NULL) | 174 | for (token = strtok_r (weedcopy, delim, &s); token; |
175 | token = strtok_r (NULL, delim, &s)) | ||
175 | { | 176 | { |
176 | if (string_starts_with (name, token)) | 177 | if (string_starts_with (name, token)) |
177 | { | 178 | { |
... | @@ -182,7 +183,7 @@ print_header (message_t message, int no_header, int all_headers, | ... | @@ -182,7 +183,7 @@ print_header (message_t message, int no_header, int all_headers, |
182 | } | 183 | } |
183 | free (value); | 184 | free (value); |
184 | free (name); | 185 | free (name); |
185 | free (p); | 186 | free (weedcopy); |
186 | } | 187 | } |
187 | putchar ('\n'); | 188 | putchar ('\n'); |
188 | } | 189 | } |
... | @@ -253,7 +254,12 @@ main (int argc, char **argv) | ... | @@ -253,7 +254,12 @@ main (int argc, char **argv) |
253 | status = mailbox_open (mbox, MU_STREAM_READ); | 254 | status = mailbox_open (mbox, MU_STREAM_READ); |
254 | if (status != 0) | 255 | if (status != 0) |
255 | { | 256 | { |
256 | fprintf (stderr, "mailbox open - %s\n", mu_errstring(status)); | 257 | url_t url = NULL; |
258 | |||
259 | mailbox_get_url (mbox, &url); | ||
260 | fprintf (stderr, "can't open mailbox %s: %s\n", | ||
261 | url_to_string (url), | ||
262 | mu_errstring(status)); | ||
257 | exit (2); | 263 | exit (2); |
258 | } | 264 | } |
259 | 265 | ||
... | @@ -261,7 +267,7 @@ main (int argc, char **argv) | ... | @@ -261,7 +267,7 @@ main (int argc, char **argv) |
261 | weedlist = "Date To Cc Subject From Apparently-"; | 267 | weedlist = "Date To Cc Subject From Apparently-"; |
262 | 268 | ||
263 | /* Build an array containing the message number. */ | 269 | /* Build an array containing the message number. */ |
264 | argc -= optind; | 270 | argc -= index; |
265 | if (argc > 0) | 271 | if (argc > 0) |
266 | msglist (mbox, show_all, argc, &argv[index], &set, &n); | 272 | msglist (mbox, show_all, argc, &argv[index], &set, &n); |
267 | 273 | ... | ... |
-
Please register or sign in to post a comment