From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id A53026DE1BC8 for ; Sat, 25 Feb 2017 08:09:25 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NHJ9khTJJT2I for ; Sat, 25 Feb 2017 08:09:24 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 4AA796DE1B46 for ; Sat, 25 Feb 2017 08:09:24 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cheto-0006DM-0u; Sat, 25 Feb 2017 11:08:44 -0500 Received: (nullmailer pid 22931 invoked by uid 1000); Sat, 25 Feb 2017 16:09:20 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: v5 of nondestructive includes patches Date: Sat, 25 Feb 2017 12:09:10 -0400 Message-Id: <20170225160913.22844-1-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170218150804.26704-1-david@tethera.net> References: <20170218150804.26704-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Feb 2017 16:09:25 -0000 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)