summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2002-11-07 10:23:56 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2002-11-07 10:23:56 (GMT)
commit63d9bc1ed24e7bedcc48db1e312328e9771dc511 (patch) (side-by-side diff)
treecc70ccb355af8b217a89d26a369fe9cc8b33a6d4
parent44986146463782231f0e5152f353f184fd373d91 (diff)
downloadmailutils-63d9bc1ed24e7bedcc48db1e312328e9771dc511.tar.gz
mailutils-63d9bc1ed24e7bedcc48db1e312328e9771dc511.tar.bz2
Added negation of message sets.
`from ! subject:/daily/' outputs all messages whose subject does not contain the word 'daily'.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--mail/msgset.y49
1 files changed, 45 insertions, 4 deletions
diff --git a/mail/msgset.y b/mail/msgset.y
index bb689bc..80de362 100644
--- a/mail/msgset.y
+++ b/mail/msgset.y
@@ -63,7 +63,7 @@ static msgset_t *result;
%token <type> TYPE
%token <string> IDENT REGEXP HEADER BODY
%token <number> NUMBER
-%type <mset> msgset msgspec msg rangeset range partno number
+%type <mset> msgset msgspec msgexpr msg rangeset range partno number
%type <string> header
%%
@@ -102,17 +102,28 @@ input : /* empty */
}
;
-msgset : msgspec
- | msgset ',' msgspec
+msgset : msgexpr
+ | msgset ',' msgexpr
{
$$ = msgset_append ($1, $3);
}
- | msgset msgspec
+ | msgset msgexpr
{
$$ = msgset_append ($1, $2);
}
;
+msgexpr : msgspec
+ | '{' msgset '}'
+ {
+ $$ = $2;
+ }
+ | '!' msgexpr
+ {
+ $$ = msgset_negate ($2);
+ }
+ ;
+
msgspec : msg
| msg '[' rangeset ']'
{
@@ -390,6 +401,36 @@ msgset_append (msgset_t *one, msgset_t *two)
return one;
}
+int
+msgset_member (msgset_t *set, size_t n)
+{
+ for (; set; set = set->next)
+ if (set->msg_part[0] == n)
+ return 1;
+ return 0;
+}
+
+msgset_t *
+msgset_negate (msgset_t *set)
+{
+ size_t i;
+ msgset_t *first = NULL, *last = NULL;
+
+ for (i = 1; i < total; i++)
+ {
+ if (!msgset_member (set, i))
+ {
+ msgset_t *mp = msgset_make_1 (i);
+ if (!first)
+ first = mp;
+ else
+ last->next = mp;
+ last = mp;
+ }
+ }
+ return first;
+}
+
msgset_t *
msgset_range (int low, int high)
{

Return to:

Send suggestions and report system problems to the System administrator.