v5 of nondestructive includes patches

Subject:v5 of nondestructive includes patches

Date:Sat, 25 Feb 2017 12:09:10 -0400

To:David Bremner ,notmuch@notmuchmail.org

Cc:

From:David Bremner


More or less by blind luck, it turns out the need for a status return
from notmuch_query_add_tag_exclude is somewhat mitigated by the lazy
query parsing introduced in patch 2/3. In particular the query is not
marked parsed, and later attempts to parse it will report the error.

interdiff follows, only whitespace and comments from v4, except adding
a setting of exception_reported

diff --git a/lib/query.cc b/lib/query.cc
index c0a1cdf8..2c6a4ba6 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -130,9 +130,9 @@ _notmuch_query_ensure_parsed (notmuch_query_t *query)
 	*  something searchable.
 	*/
 
-	for (Xapian::TermIterator t = query->xapian_query.get_terms_begin();
-	     t != query->xapian_query.get_terms_end(); ++t)
-	    query->terms.insert(*t);
+	for (Xapian::TermIterator t = query->xapian_query.get_terms_begin ();
+	     t != query->xapian_query.get_terms_end (); ++t)
+	    query->terms.insert (*t);
 
 	query->parsed = TRUE;
 
@@ -143,6 +143,7 @@ _notmuch_query_ensure_parsed (notmuch_query_t *query)
 	_notmuch_database_log_append (query->notmuch,
 			       "Query string was: %s\n",
 			       query->query_string);
+	query->notmuch->exception_reported = TRUE;
 
 	return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
     }
@@ -181,8 +182,16 @@ notmuch_query_add_tag_exclude (notmuch_query_t *query, const char *tag)
     char *term;
 
     status = _notmuch_query_ensure_parsed (query);
+    /* The following is not ideal error handling, but to avoid
+     * breaking the ABI, we can live with it for now. In particular at
+     * least in the notmuch CLI, any syntax error in the query is
+     * caught in a later call to _notmuch_query_ensure_parsed with a
+     * better error path.
+     *
+     * TODO: add status return to this function.
+     */
     if (status)
-	return; /* XXX report error */
+	return;
 
     term = talloc_asprintf (query, "%s%s", _find_prefix ("tag"), tag);
     if (query->terms.count(term) != 0)

Thread: