]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
SEARCH OR fixes.
authorTimo Sirainen <tss@iki.fi>
Tue, 22 Apr 2003 18:11:35 +0000 (21:11 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 22 Apr 2003 18:11:35 +0000 (21:11 +0300)
--HG--
branch : HEAD

src/lib-storage/index/index-search.c
src/lib-storage/mail-search.c

index 894cf5069f285d257af4f9f7eaab0e7a5da4c4f7..a84c0e3e0d9101c449aecf58ee9ee7f36275826d 100644 (file)
@@ -737,15 +737,17 @@ static int seq_update(const char *set, unsigned int *first_seq,
 static int search_get_sequid(struct index_mailbox *ibox,
                             const struct mail_search_arg *args,
                             unsigned int *first_seq, unsigned int *last_seq,
-                            unsigned int *first_uid, unsigned int *last_uid)
+                            unsigned int *first_uid, unsigned int *last_uid,
+                            int default_all)
 {
        for (; args != NULL; args = args->next) {
                if (args->type == SEARCH_OR || args->type == SEARCH_SUB) {
                        if (!search_get_sequid(ibox, args->value.subargs,
                                               first_seq, last_seq,
-                                              first_uid, last_uid))
+                                              first_uid, last_uid,
+                                              args->type == SEARCH_OR))
                                return FALSE;
-               } if (args->type == SEARCH_SET) {
+               } else if (args->type == SEARCH_SET) {
                        if (!seq_update(args->value.str, first_seq, last_seq,
                                        ibox->synced_messages_count)) {
                                mail_storage_set_error(ibox->box.storage,
@@ -761,7 +763,7 @@ static int search_get_sequid(struct index_mailbox *ibox,
                                                       args->value.str);
                                return FALSE;
                        }
-               } else if (args->type == SEARCH_ALL) {
+               } else if (args->type == SEARCH_ALL || default_all) {
                        /* go through everything */
                        *first_seq = 1;
                        *last_seq = ibox->synced_messages_count;
@@ -859,7 +861,7 @@ static int search_get_uid_range(struct index_mailbox *ibox,
        first_seq = last_seq = 0;
 
        if (!search_get_sequid(ibox, args, &first_seq, &last_seq,
-                              first_uid, last_uid))
+                              first_uid, last_uid, FALSE))
                return -1;
 
        /* seq_update() should make sure that these can't happen */
index 2fa82031ea60fd7885303723e82cb026dae669f2..ce10a32196dc9d3b25d936dae92ac3384b34af24 100644 (file)
@@ -48,7 +48,7 @@ static void search_arg_foreach(struct mail_search_arg *arg,
                i_assert(arg->value.subargs != NULL);
 
                subarg = arg->value.subargs;
-               arg->result = -1;
+               arg->result = 0;
                while (subarg != NULL) {
                        if (subarg->result == -1)
                                search_arg_foreach(subarg, callback, context);
@@ -59,8 +59,8 @@ static void search_arg_foreach(struct mail_search_arg *arg,
                                        arg->result = 1;
                                        break;
                                }
-
-                               arg->result = 0;
+                       } else {
+                               arg->result = -1;
                        }
 
                        subarg = subarg->next;