[evolution-ews/gnome-2-28] Bug #654818 sexp_to_sql_query:
- From: Punit Jain <jpunit src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/gnome-2-28] Bug #654818 sexp_to_sql_query:
- Date: Tue, 6 Sep 2011 09:16:57 +0000 (UTC)
commit d47439279e24581682f3a6ff5445e46ce8a0be09
Author: Punit Jain <jpunit novell com>
Date: Tue Sep 6 14:43:33 2011 +0530
Bug #654818 sexp_to_sql_query:
src/addressbook/e-book-backend-sqlitedb.c | 33 ++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-sqlitedb.c b/src/addressbook/e-book-backend-sqlitedb.c
index 347e3d3..a2fd823 100644
--- a/src/addressbook/e-book-backend-sqlitedb.c
+++ b/src/addressbook/e-book-backend-sqlitedb.c
@@ -907,6 +907,37 @@ 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, gpointer data)
{
ESExpResult *r, *r1;
@@ -932,7 +963,6 @@ func_or (ESExp *f, gint argc, struct _ESExpTerm **argv, gpointer data)
return r;
}
-
typedef enum {
MATCH_CONTAINS,
MATCH_IS,
@@ -1034,6 +1064,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]