Re: [evolution-patches] 47765, fix for (match-all (match-all)) bug



Duh, should've tested it.  It didn't work.

This should, and passes the test suite, although i'm not sure how much
it tests match-all.

On Wed, 2003-08-20 at 17:19, Not Zed wrote:
> Didnt get around to testing this because of my head build tree.  i guess
> i should, but in the meantime, someone else can check it too.
> 
> main problem is (match-all (match-all)) the second match-all wasn't
> recognising it was inside a match-all already, so it returned a vector
> when it should've returned a scalar on the current message.
> 
> 
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/camel/ChangeLog,v
retrieving revision 1.1836.2.10
diff -u -3 -r1.1836.2.10 ChangeLog
--- camel/ChangeLog	19 Aug 2003 17:53:28 -0000	1.1836.2.10
+++ camel/ChangeLog	20 Aug 2003 22:09:39 -0000
@@ -1,3 +1,22 @@
+2003-08-20  Not Zed  <NotZed Ximian com>
+
+	** See bug #47765.
+
+	* camel-folder-search.h: Removed match1 member.
+
+	* camel-folder-search.c (camel_folder_search_match_expression):
+	use current directly rather than match1.  This method isn't used
+	anywhere anyway.
+	(search_not): remove match1 stuff.
+	(search_match_all): properly handle the match-all against 1
+	message as a scalar result, not an array result.
+
+2003-07-30  Not Zed  <NotZed Ximian com>
+
+	* providers/imap/camel-imap-provider.c: Added offline_sync, to
+	automatically sync offline folders.  Currently used by the mailer,
+	but will move here eventually.
+
 2003-08-19  Suresh Chandrasekharan <suresh chandrasekharan sun com>
 	
 	* camel-iconv.c: Fix for #46168 'some additional locale aliases
Index: camel/camel-folder-search.c
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-folder-search.c,v
retrieving revision 1.54.4.2
diff -u -3 -r1.54.4.2 camel-folder-search.c
--- camel/camel-folder-search.c	11 Aug 2003 19:09:13 -0000	1.54.4.2
+++ camel/camel-folder-search.c	20 Aug 2003 22:09:39 -0000
@@ -427,7 +427,7 @@
 	GPtrArray *uids;
 	int ret = FALSE;
 
-	search->match1 = (CamelMessageInfo *)info;
+	search->current = (CamelMessageInfo *)info;
 
 	uids = camel_folder_search_execute_expression(search, expr, ex);
 	if (uids) {
@@ -435,7 +435,7 @@
 			ret = TRUE;
 		camel_folder_search_free_result(search, uids);
 	}
-	search->match1 = NULL;
+	search->current = NULL;
 
 	return ret;
 }
@@ -493,14 +493,10 @@
 			r->value.ptrarray = g_ptr_array_new();
 
 			/* not against a single message?*/
-			if (search->match1 || search->current) {
+			if (search->current) {
 				int found = FALSE;
 
-				if (search->match1)
-					uid = camel_message_info_uid(search->match1);
-				else
-					uid = camel_message_info_uid(search->current);
-
+				uid = camel_message_info_uid(search->current);
 				for (i=0;!found && i<v->len;i++) {
 					if (strcmp(uid, v->pdata[i]) == 0)
 						found = TRUE;
@@ -556,32 +552,31 @@
 	if (argc>1) {
 		g_warning("match-all only takes a single argument, other arguments ignored");
 	}
-	r = e_sexp_result_new(f, ESEXP_RES_ARRAY_PTR);
-	r->value.ptrarray = g_ptr_array_new();
-
-	/* we are only matching a single message? */
-	if (search->match1) {
-		search->current = search->match1;
 
+	/* we are only matching a single message?  or already inside a match-all? */
+	if (search->current) {
 		d(printf("matching against 1 message: %s\n", camel_message_info_subject(search->current)));
 
+		r = e_sexp_result_new(f, ESEXP_RES_BOOL);
+		r->value.bool = FALSE;
+
 		if (argc>0) {
 			r1 = e_sexp_term_eval(f, argv[0]);
 			if (r1->type == ESEXP_RES_BOOL) {
-				if (r1->value.bool)
-					g_ptr_array_add(r->value.ptrarray, (char *)camel_message_info_uid(search->current));
+				r->value.bool = r1->value.bool;
 			} else {
 				g_warning("invalid syntax, matches require a single bool result");
 				e_sexp_fatal_error(f, _("(match-all) requires a single bool result"));
 			}
 			e_sexp_result_free(f, r1);
 		} else {
-			g_ptr_array_add(r->value.ptrarray, (char *)camel_message_info_uid(search->current));
+			r->value.bool = TRUE;
 		}
-		search->current = NULL;
-
 		return r;
 	}
+
+	r = e_sexp_result_new(f, ESEXP_RES_ARRAY_PTR);
+	r->value.ptrarray = g_ptr_array_new();
 
 	if (search->summary == NULL) {
 		/* TODO: make it work - e.g. use the folder and so forth for a slower search */
Index: camel/camel-folder-search.h
===================================================================
RCS file: /cvs/gnome/evolution/camel/camel-folder-search.h,v
retrieving revision 1.26
diff -u -3 -r1.26 camel-folder-search.h
--- camel/camel-folder-search.h	14 Feb 2003 21:44:28 -0000	1.26
+++ camel/camel-folder-search.h	20 Aug 2003 22:09:39 -0000
@@ -52,7 +52,6 @@
 	GPtrArray *summary;	/* summary array for current search */
 	GHashTable *summary_hash; /* hashtable of summary items */
 	CamelMessageInfo *current; /* current message info, when searching one by one */
-	CamelMessageInfo *match1; /* message info, when searching a single message only */
 	CamelMimeMessage *current_message; /* cache of current message, if required */
 	CamelIndex *body_index;
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]