Re: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore
authorTomi Ollila <tomi.ollila@iki.fi>
Mon, 31 Dec 2012 22:14:58 +0000 (00:14 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:54 +0000 (09:52 -0800)
2a/4fc5b36ceaf4d3318e7b53d480f1ffbf900100 [new file with mode: 0644]

diff --git a/2a/4fc5b36ceaf4d3318e7b53d480f1ffbf900100 b/2a/4fc5b36ceaf4d3318e7b53d480f1ffbf900100
new file mode 100644 (file)
index 0000000..6e506b4
--- /dev/null
@@ -0,0 +1,158 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 8CC37431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 31 Dec 2012 14:15:08 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id jWwGApP1qoaJ for <notmuch@notmuchmail.org>;\r
+       Mon, 31 Dec 2012 14:15:07 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7A177431FAE\r
+       for <notmuch@notmuchmail.org>; Mon, 31 Dec 2012 14:15:07 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 0B07C10010A;\r
+       Tue,  1 Jan 2013 00:14:59 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v4 0/5] Use Xapian query syntax for batch-tag dump/restore\r
+In-Reply-To: <1356936162-2589-1-git-send-email-amdragon@mit.edu>\r
+References: <1356936162-2589-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.14+216~gd58661f (http://notmuchmail.org) Emacs/24.2.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Tue, 01 Jan 2013 00:14:58 +0200\r
+Message-ID: <m27gnxj2cd.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 31 Dec 2012 22:15:08 -0000\r
+\r
+On Mon, Dec 31 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+\r
+> This obsoletes\r
+>\r
+>   id:1356719189-2837-1-git-send-email-amdragon@mit.edu\r
+>\r
+> This version accepts whitespace before and after boolean terms in\r
+> parse_boolean_term and expands its documentation comment to describe\r
+> what it accepts and how that relates to Xapian and make_boolean_term.\r
+>\r
+> The diff from v3 is below.\r
+\r
+With these changes this looks good to me...\r
+\r
+Tomi\r
+\r
+\r
+>\r
+> diff --git a/util/string-util.c b/util/string-util.c\r
+> index 83b4953..52c7781 100644\r
+> --- a/util/string-util.c\r
+> +++ b/util/string-util.c\r
+> @@ -22,6 +22,8 @@\r
+>  #include "string-util.h"\r
+>  #include "talloc.h"\r
+>  \r
+> +#include <ctype.h>\r
+> +\r
+>  char *\r
+>  strtok_len (char *s, const char *delim, size_t *len)\r
+>  {\r
+> @@ -97,6 +99,14 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,\r
+>      return 0;\r
+>  }\r
+>  \r
+> +static const char*\r
+> +skip_space (const char *str)\r
+> +{\r
+> +    while (*str && isspace (*str))\r
+> +    ++str;\r
+> +    return str;\r
+> +}\r
+> +\r
+>  int\r
+>  parse_boolean_term (void *ctx, const char *str,\r
+>                  char **prefix_out, char **term_out)\r
+> @@ -104,6 +114,7 @@ parse_boolean_term (void *ctx, const char *str,\r
+>      *prefix_out = *term_out = NULL;\r
+>  \r
+>      /* Parse prefix */\r
+> +    str = skip_space (str);\r
+>      const char *pos = strchr (str, ':');\r
+>      if (! pos)\r
+>      goto FAIL;\r
+> @@ -123,6 +134,7 @@ parse_boolean_term (void *ctx, const char *str,\r
+>              if (*pos != '"') {\r
+>                  /* Found the closing quote. */\r
+>                  closed = 1;\r
+> +                pos = skip_space (pos);\r
+>                  break;\r
+>              }\r
+>          }\r
+> @@ -138,11 +150,11 @@ parse_boolean_term (void *ctx, const char *str,\r
+>      /* Check for text after the boolean term. */\r
+>      while (*pos > ' ' && *pos != ')')\r
+>          ++pos;\r
+> -    if (*pos)\r
+> +    if (*skip_space (pos))\r
+>          goto FAIL;\r
+>      /* No trailing text; dup the string so the caller can free\r
+>       * it. */\r
+> -    *term_out = talloc_strdup (ctx, start);\r
+> +    *term_out = talloc_strndup (ctx, start, pos - start);\r
+>      }\r
+>      return 0;\r
+>  \r
+> diff --git a/util/string-util.h b/util/string-util.h\r
+> index 43d49d0..8b9fe50 100644\r
+> --- a/util/string-util.h\r
+> +++ b/util/string-util.h\r
+> @@ -33,12 +33,16 @@ char *strtok_len (char *s, const char *delim, size_t *len);\r
+>  int make_boolean_term (void *talloc_ctx, const char *prefix, const char *term,\r
+>                     char **buf, size_t *len);\r
+>  \r
+> -/* Parse a boolean term query produced by make_boolean_term, returning\r
+> - * the prefix in *prefix_out and the term in *term_out.  *prefix_out\r
+> - * and *term_out will be talloc'd with context ctx.\r
+> +/* Parse a boolean term query consisting of a prefix, a colon, and a\r
+> + * term that may be quoted as described for make_boolean_term.  If the\r
+> + * term is not quoted, then it ends at the first whitespace or close\r
+> + * parenthesis.  str may containing leading or trailing whitespace,\r
+> + * but anything else is considered a parse error.  This is compatible\r
+> + * with anything produced by make_boolean_term, and supports a subset\r
+> + * of the quoting styles supported by Xapian (and hence notmuch).\r
+> + * *prefix_out and *term_out will be talloc'd with context ctx.\r
+>   *\r
+> - * Return: 0 on success, non-zero on parse error (including trailing\r
+> - * data in str).\r
+> + * Return: 0 on success, non-zero on parse error.\r
+>   */\r
+>  int\r
+>  parse_boolean_term (void *ctx, const char *str,\r
+>   \r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r