From: Tomi Ollila Date: Mon, 31 Dec 2012 22:14:58 +0000 (+0200) Subject: Re: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=cea16db9414f703f3756887ab661562555aac009;p=notmuch-archives.git Re: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore --- diff --git a/2a/4fc5b36ceaf4d3318e7b53d480f1ffbf900100 b/2a/4fc5b36ceaf4d3318e7b53d480f1ffbf900100 new file mode 100644 index 000000000..6e506b41a --- /dev/null +++ b/2a/4fc5b36ceaf4d3318e7b53d480f1ffbf900100 @@ -0,0 +1,158 @@ +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 8CC37431FAF + for ; Mon, 31 Dec 2012 14:15:08 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 jWwGApP1qoaJ for ; + Mon, 31 Dec 2012 14:15:07 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 7A177431FAE + for ; Mon, 31 Dec 2012 14:15:07 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 0B07C10010A; + Tue, 1 Jan 2013 00:14:59 +0200 (EET) +From: Tomi Ollila +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore +In-Reply-To: <1356936162-2589-1-git-send-email-amdragon@mit.edu> +References: <1356936162-2589-1-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.14+216~gd58661f (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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 22:15:08 -0000 + +On Mon, Dec 31 2012, Austin Clements wrote: + +> 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. + +With these changes this looks good to me... + +Tomi + + +> +> 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, +> +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch