From f3b63eaf2b45ca81bea5aba15a3aa5bc62714e18 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Tue, 1 Jan 2013 01:42:37 +1900 Subject: [PATCH] [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore --- 0a/f2adbce1025ccdc5133c8d18855072f021c71b | 167 ++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 0a/f2adbce1025ccdc5133c8d18855072f021c71b diff --git a/0a/f2adbce1025ccdc5133c8d18855072f021c71b b/0a/f2adbce1025ccdc5133c8d18855072f021c71b new file mode 100644 index 000000000..6b72772f7 --- /dev/null +++ b/0a/f2adbce1025ccdc5133c8d18855072f021c71b @@ -0,0 +1,167 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A56B4431FBD + for ; Sun, 30 Dec 2012 22:42:52 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id jg16oMcRxCXj for ; + Sun, 30 Dec 2012 22:42:52 -0800 (PST) +Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU + [18.9.25.15]) + by olra.theworths.org (Postfix) with ESMTP id DD7EA431FAF + for ; Sun, 30 Dec 2012 22:42:51 -0800 (PST) +X-AuditID: 1209190f-b7f016d000000e07-ae-50e133eb6114 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id 9B.5C.03591.BE331E05; Mon, 31 Dec 2012 01:42:51 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBV6goqc026112; + Mon, 31 Dec 2012 01:42:50 -0500 +Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net + [76.21.105.205]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBV6gkKq009878 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Mon, 31 Dec 2012 01:42:48 -0500 (EST) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1TpZ5B-0000id-Ou; Mon, 31 Dec 2012 01:42:45 -0500 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore +Date: Mon, 31 Dec 2012 01:42:37 -0500 +Message-Id: <1356936162-2589-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFtrPIsWRmVeSWpSXmKPExsUixG6nrvva+GGAwZw54hY3WrsZLZqmO1us + nstjcf3mTGaLNyvnsTqweuycdZfd4/DXhSwet+6/Zvd4tuoWs8eWQ++ZA1ijuGxSUnMyy1KL + 9O0SuDI6vu5jKjgvUXF391fWBsb/Ql2MnBwSAiYSm9dOZIawxSQu3FvP1sXIwSEksI9RYrlB + FyMXkLmBUeJ0z01GkBohgYtMEje31kAk5jJK3Fx6jg0kwSagIbFt/3KwIhEBaYmdd2ezgtjM + AnESKy8tZgexhQW8JG59nwq2jEVAVWLJyZ1MIDavgL3E7IeHmSCOUJTofjaBbQIj7wJGhlWM + sim5Vbq5iZk5xanJusXJiXl5qUW6Jnq5mSV6qSmlmxhB4cQpyb+D8dtBpUOMAhyMSjy8HEwP + A4RYE8uKK3MPMUpyMCmJ8j40AgrxJeWnVGYkFmfEF5XmpBYfYpTgYFYS4X2rBZTjTUmsrEot + yodJSXOwKInzXk256S8kkJ5YkpqdmlqQWgSTleHgUJLgLQYZKliUmp5akZaZU4KQZuLgBBnO + AzS8GqSGt7ggMbc4Mx0if4pRUUqcNxEkIQCSyCjNg+uFxfsrRnGgV4R5p4NU8QBTBVz3K6DB + TECDtRgegAwuSURISTUwSoumpRU8al7W9vaYf3LZqq83p1gYOiY9bzvl/VZCqz1Ea17w+k1X + y2o6JH49ezf326/tXUoaMqd7nNdv+f76t+eTZgNN1V6HX4qWWyY8eXfDuW1PKuspswtP4781 + 7E/LslPkk9n110U59mvCkgcfPp28X7le+LyIbGk8l5Bm1yvfnDtMU+e9UWIpzkg01GIuKk4E + AJrCHQrSAgAA +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Mon, 31 Dec 2012 06:42:52 -0000 + +This obsoletes + + id:1356719189-2837-1-git-send-email-amdragon@mit.edu + +This version accepts whitespace before and after boolean terms in +parse_boolean_term and expands its documentation comment to describe +what it accepts and how that relates to Xapian and make_boolean_term. + +The diff from v3 is below. + +diff --git a/util/string-util.c b/util/string-util.c +index 83b4953..52c7781 100644 +--- a/util/string-util.c ++++ b/util/string-util.c +@@ -22,6 +22,8 @@ + #include "string-util.h" + #include "talloc.h" + ++#include ++ + char * + strtok_len (char *s, const char *delim, size_t *len) + { +@@ -97,6 +99,14 @@ make_boolean_term (void *ctx, const char *prefix, const char *term, + return 0; + } + ++static const char* ++skip_space (const char *str) ++{ ++ while (*str && isspace (*str)) ++ ++str; ++ return str; ++} ++ + int + parse_boolean_term (void *ctx, const char *str, + char **prefix_out, char **term_out) +@@ -104,6 +114,7 @@ parse_boolean_term (void *ctx, const char *str, + *prefix_out = *term_out = NULL; + + /* Parse prefix */ ++ str = skip_space (str); + const char *pos = strchr (str, ':'); + if (! pos) + goto FAIL; +@@ -123,6 +134,7 @@ parse_boolean_term (void *ctx, const char *str, + if (*pos != '"') { + /* Found the closing quote. */ + closed = 1; ++ pos = skip_space (pos); + break; + } + } +@@ -138,11 +150,11 @@ parse_boolean_term (void *ctx, const char *str, + /* Check for text after the boolean term. */ + while (*pos > ' ' && *pos != ')') + ++pos; +- if (*pos) ++ if (*skip_space (pos)) + goto FAIL; + /* No trailing text; dup the string so the caller can free + * it. */ +- *term_out = talloc_strdup (ctx, start); ++ *term_out = talloc_strndup (ctx, start, pos - start); + } + return 0; + +diff --git a/util/string-util.h b/util/string-util.h +index 43d49d0..8b9fe50 100644 +--- a/util/string-util.h ++++ b/util/string-util.h +@@ -33,12 +33,16 @@ char *strtok_len (char *s, const char *delim, size_t *len); + int make_boolean_term (void *talloc_ctx, const char *prefix, const char *term, + char **buf, size_t *len); + +-/* Parse a boolean term query produced by make_boolean_term, returning +- * the prefix in *prefix_out and the term in *term_out. *prefix_out +- * and *term_out will be talloc'd with context ctx. ++/* Parse a boolean term query consisting of a prefix, a colon, and a ++ * term that may be quoted as described for make_boolean_term. If the ++ * term is not quoted, then it ends at the first whitespace or close ++ * parenthesis. str may containing leading or trailing whitespace, ++ * but anything else is considered a parse error. This is compatible ++ * with anything produced by make_boolean_term, and supports a subset ++ * of the quoting styles supported by Xapian (and hence notmuch). ++ * *prefix_out and *term_out will be talloc'd with context ctx. + * +- * Return: 0 on success, non-zero on parse error (including trailing +- * data in str). ++ * Return: 0 on success, non-zero on parse error. + */ + int + parse_boolean_term (void *ctx, const char *str, + + -- 2.26.2