changeset 317:79d9a40fbb72 HEAD

Only first search condition was checked.
author Timo Sirainen <tss@iki.fi>
date Wed, 25 Sep 2002 23:24:56 +0300
parents 0c1ff60e55e6
children 6f82f54b8e27
files src/lib-storage/index/index-search.c
diffstat 1 files changed, 16 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-search.c	Wed Sep 25 19:03:23 2002 +0300
+++ b/src/lib-storage/index/index-search.c	Wed Sep 25 23:24:56 2002 +0300
@@ -461,13 +461,6 @@
 		search_text(arg, ctx);
 }
 
-static void search_text_set_unmatched(MailSearchArg *arg,
-				      void *context __attr_unused__)
-{
-	if (arg->type == SEARCH_TEXT || arg->type == SEARCH_BODY)
-		ARG_SET_RESULT(arg, -1);
-}
-
 static void search_arg_match_data(IOBuffer *inbuf, uoff_t max_size,
 				  MailSearchArg *args,
 				  MailSearchForeachFunc search_func)
@@ -554,9 +547,6 @@
 
 		search_arg_match_data(inbuf, rec->body_size, args,
 				      search_text_body);
-
-		/* set the rest as unmatched */
-		mail_search_args_foreach(args, search_text_set_unmatched, NULL);
 	}
 
 	(void)close(inbuf->fd);
@@ -670,8 +660,10 @@
 {
 	SearchIndexContext ctx;
 	MailIndexRecord *rec;
+        MailSearchArg *arg;
 	unsigned int first_seq, last_seq, seq;
 	char num[MAX_LARGEST_T_STRLEN+10];
+	int found;
 
 	if (ibox->synced_messages_count == 0)
 		return;
@@ -691,11 +683,20 @@
 		mail_search_args_foreach(args, search_cached_arg, &ctx);
 		mail_search_args_foreach(args, search_slow_arg, &ctx);
 
-		if (search_arg_match_text(ibox, rec, args) &&
-		    args->result == 1) {
-			i_snprintf(num, sizeof(num), " %u",
-				   uid_result ? rec->uid : seq);
-			io_buffer_send(outbuf, num, strlen(num));
+		if (search_arg_match_text(ibox, rec, args)) {
+			found = TRUE;
+			for (arg = args; arg != NULL; arg = arg->next) {
+				if (arg->result != 1) {
+					found = FALSE;
+					break;
+				}
+			}
+
+			if (found) {
+				i_snprintf(num, sizeof(num), " %u",
+					   uid_result ? rec->uid : seq);
+				io_buffer_send(outbuf, num, strlen(num));
+			}
 		}
 		rec = ibox->index->next(ibox->index, rec);
 	}