[evolution-data-server] Bug #654818 crash fix : query conversion to sql



commit 99a56bb8273bc4b5e98bfd7c0dcd41a6a1f9ed6a
Author: Punit Jain <jpunit novell com>
Date:   Tue Sep 6 14:37:33 2011 +0530

    Bug #654818 crash fix : query conversion to sql

 .../libedata-book/e-book-backend-sqlitedb.c        |   32 ++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend-sqlitedb.c b/addressbook/libedata-book/e-book-backend-sqlitedb.c
index 80184ba..206ed87 100644
--- a/addressbook/libedata-book/e-book-backend-sqlitedb.c
+++ b/addressbook/libedata-book/e-book-backend-sqlitedb.c
@@ -1137,6 +1137,37 @@ e_book_backend_sqlitedb_is_summary_query (const gchar *query)
 }
 
 static ESExpResult *
+func_and (ESExp *f, gint argc, struct _ESExpTerm **argv, gpointer data)
+{
+	ESExpResult *r, *r1;
+	GString *string;
+	gint i;
+
+	string = g_string_new("( ");
+	for (i = 0; i < argc; i++) {
+		r1 = e_sexp_term_eval (f, argv[i]);
+
+		if (r1->type != ESEXP_RES_STRING) {
+			e_sexp_result_free (f, r1);
+			continue;
+		}
+		if (r1->value.string && *r1->value.string)
+			g_string_append_printf(string, "%s%s", r1->value.string, ((argc>1) && (i != argc-1)) ?  " AND ":"");
+		e_sexp_result_free (f, r1);
+	}
+	g_string_append(string, " )");
+	r = e_sexp_result_new (f, ESEXP_RES_STRING);
+
+	if (strlen (string->str) == 4)
+		r->value.string = g_strdup("");
+	else
+		r->value.string = string->str;
+	g_string_free (string, FALSE);
+
+	return r;
+}
+
+static ESExpResult *
 func_or (ESExp *f,
          gint argc,
          struct _ESExpTerm **argv,
@@ -1282,6 +1313,7 @@ static struct {
 	ESExpFunc *func;
 	guint immediate :1;
 } symbols[] = {
+	{ "and", (ESExpFunc *) func_and, 1},
 	{ "or", (ESExpFunc *) func_or, 1},
 
 	{ "contains", func_contains, 0 },



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