* mail/msgset.y: Draft implementation of a proposition
to allow regular implementation. (REGEXP): Passing the address of the pointer instead of the pointer. (INDENT): Likewised. * mail/Makefile.am: Add in EXTRA_DIST msgset.c to force its generation when doing the distribution, having yacc should not be required.
Showing
2 changed files
with
23 additions
and
4 deletions
... | @@ -10,6 +10,8 @@ bin_PROGRAMS = mail | ... | @@ -10,6 +10,8 @@ bin_PROGRAMS = mail |
10 | mail_LDADD = @ARGPLIBS@ ../mailbox/libmailbox.la ../lib/libmailutils.a \ | 10 | mail_LDADD = @ARGPLIBS@ ../mailbox/libmailbox.la ../lib/libmailutils.a \ |
11 | @READLINE_LIBS@ | 11 | @READLINE_LIBS@ |
12 | 12 | ||
13 | EXTRA_DIST = msgset.c | ||
14 | |||
13 | mail_SOURCES = alias.c alt.c cd.c copy.c delete.c dp.c echo.c \ | 15 | mail_SOURCES = alias.c alt.c cd.c copy.c delete.c dp.c echo.c \ |
14 | edit.c eq.c exit.c file.c folders.c followup.c from.c headers.c help.c \ | 16 | edit.c eq.c exit.c file.c folders.c followup.c from.c headers.c help.c \ |
15 | hold.c if.c inc.c list.c mail.c mail.h mailline.c mbox.c msgset.y next.c \ | 17 | hold.c if.c inc.c list.c mail.c mail.h mailline.c mbox.c msgset.y next.c \ | ... | ... |
... | @@ -18,6 +18,9 @@ | ... | @@ -18,6 +18,9 @@ |
18 | %{ | 18 | %{ |
19 | #include <stdio.h> | 19 | #include <stdio.h> |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #ifdef HAVE_REGEXEC | ||
22 | #include <regex.h> | ||
23 | #endif | ||
21 | 24 | ||
22 | #include <xalloc.h> | 25 | #include <xalloc.h> |
23 | #include <mail.h> | 26 | #include <mail.h> |
... | @@ -102,8 +105,7 @@ msgspec : msg | ... | @@ -102,8 +105,7 @@ msgspec : msg |
102 | 105 | ||
103 | msg : REGEXP /* /.../ */ | 106 | msg : REGEXP /* /.../ */ |
104 | { | 107 | { |
105 | util_strupper ($1); | 108 | $$ = msgset_select (select_subject, (void *)$1, 0, 0); |
106 | $$ = msgset_select (select_subject, &$1, 0, 0); | ||
107 | free ($1); | 109 | free ($1); |
108 | } | 110 | } |
109 | | TYPE /* :n, :d, etc */ | 111 | | TYPE /* :n, :d, etc */ |
... | @@ -113,11 +115,11 @@ msg : REGEXP /* /.../ */ | ... | @@ -113,11 +115,11 @@ msg : REGEXP /* /.../ */ |
113 | yyerror ("unknown message type"); | 115 | yyerror ("unknown message type"); |
114 | YYERROR; | 116 | YYERROR; |
115 | } | 117 | } |
116 | $$ = msgset_select (select_type, &$1, 0, 0); | 118 | $$ = msgset_select (select_type, (void *)$1, 0, 0); |
117 | } | 119 | } |
118 | | IDENT /* Sender name */ | 120 | | IDENT /* Sender name */ |
119 | { | 121 | { |
120 | $$ = msgset_select (select_sender, &$1, 0, 0); | 122 | $$ = msgset_select (select_sender, (void *)$1, 0, 0); |
121 | free ($1); | 123 | free ($1); |
122 | } | 124 | } |
123 | ; | 125 | ; |
... | @@ -442,11 +444,26 @@ select_subject (message_t msg, void *closure) | ... | @@ -442,11 +444,26 @@ select_subject (message_t msg, void *closure) |
442 | message_get_header (msg, &hdr); | 444 | message_get_header (msg, &hdr); |
443 | if (header_aget_value (hdr, MU_HEADER_SUBJECT, &subject) == 0) | 445 | if (header_aget_value (hdr, MU_HEADER_SUBJECT, &subject) == 0) |
444 | { | 446 | { |
447 | #ifdef HAVE_REGEXEC | ||
448 | /* Match string against the extended regular expression(ignoring | ||
449 | case) in pattern, treating errors as no match. | ||
450 | Return 1 for match, 0 for no match. | ||
451 | */ | ||
452 | regex_t re; | ||
453 | int status; | ||
454 | if (regcomp (&re, expr, REG_EXTENDED | REG_ICASE) != 0) | ||
455 | return 0; | ||
456 | status = regexec (&re, subject, 0, NULL, 0); | ||
457 | if (status != 0) | ||
458 | return 0; | ||
459 | return status == 0; | ||
460 | #else | ||
445 | int rc; | 461 | int rc; |
446 | util_strupper (subject); | 462 | util_strupper (subject); |
447 | rc = strstr (subject, expr) != NULL; | 463 | rc = strstr (subject, expr) != NULL; |
448 | free (subject); | 464 | free (subject); |
449 | return rc; | 465 | return rc; |
466 | #endif | ||
450 | } | 467 | } |
451 | return 0; | 468 | return 0; |
452 | } | 469 | } | ... | ... |
-
Please register or sign in to post a comment