[evolution] Use the and operator only if there are two conditions



commit 4124ba378b3128ee5f0cb85925559f5fb42cff67
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Wed Sep 8 19:33:39 2010 +0530

    Use the and operator only if there are two conditions

 calendar/gui/e-cal-model.c |   17 ++++++++++++-----
 calendar/gui/gnome-cal.c   |   17 ++++++++++++-----
 2 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index a48fc5d..70d20c3 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -2333,11 +2333,18 @@ redo_queries (ECalModel *model)
 		iso_start = isodate_from_time_t (priv->start);
 		iso_end = isodate_from_time_t (priv->end);
 
-		priv->full_sexp = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\")"
-						   "                           (make-time \"%s\"))"
-						   "     %s)",
-						   iso_start, iso_end,
-						   priv->search_sexp ? priv->search_sexp : "");
+		if (priv->search_sexp) {
+			priv->full_sexp = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\")"
+					"                           (make-time \"%s\"))"
+					"     %s)",
+					iso_start, iso_end,
+					priv->search_sexp ? priv->search_sexp : "");
+		} else {
+			priv->full_sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
+					"                           (make-time \"%s\"))",
+					iso_start, iso_end);
+		}
+
 		g_free (iso_start);
 		g_free (iso_end);
 	} else if (priv->search_sexp) {
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 089167e..e054422 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1009,11 +1009,18 @@ adjust_e_cal_view_sexp (GnomeCalendar *gcal, const gchar *sexp)
 	start = isodate_from_time_t (start_time);
 	end = isodate_from_time_t (end_time);
 
-	new_sexp = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\")"
-				    "                           (make-time \"%s\"))"
-				    "     %s)",
-				    start, end,
-				    sexp);
+	if (sexp) {
+		new_sexp = g_strdup_printf ("(and (occur-in-time-range? (make-time \"%s\")"
+				"                           (make-time \"%s\"))"
+				"     %s)",
+				start, end,
+				sexp);
+	} else {
+		new_sexp = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
+				"                     (make-time \"%s\"))",
+				start, end);
+	}
+
 	g_free (start);
 	g_free (end);
 



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