From: David Bremner Date: Wed, 26 Dec 2012 14:31:01 +0000 (+2000) Subject: Re: [PATCH v2 2/5] util: Function to parse boolean term queries X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=1aa28a068087e6a111957216a9b4598224932044;p=notmuch-archives.git Re: [PATCH v2 2/5] util: Function to parse boolean term queries --- diff --git a/b7/e414dd1a232d7d64c2df8c1d15ae07b1b4671a b/b7/e414dd1a232d7d64c2df8c1d15ae07b1b4671a new file mode 100644 index 000000000..ea1086273 --- /dev/null +++ b/b7/e414dd1a232d7d64c2df8c1d15ae07b1b4671a @@ -0,0 +1,90 @@ +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 4C08B431FAF + for ; Wed, 26 Dec 2012 06:31:11 -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 yOsMGDjee3T5 for ; + Wed, 26 Dec 2012 06:31:10 -0800 (PST) +Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238]) + (using TLSv1 with cipher AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id DAF5A431FAE + for ; Wed, 26 Dec 2012 06:31:10 -0800 (PST) +Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net + ([156.34.82.78] helo=zancas.localnet) + by tesseract.cs.unb.ca with esmtpsa + (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) + (envelope-from ) + id 1Tns0g-0002Tq-WC; Wed, 26 Dec 2012 10:31:07 -0400 +Received: from bremner by zancas.localnet with local (Exim 4.80) + (envelope-from ) + id 1Tns0b-0005y1-Bg; Wed, 26 Dec 2012 10:31:01 -0400 +From: David Bremner +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 2/5] util: Function to parse boolean term queries +In-Reply-To: <1356493723-11085-3-git-send-email-amdragon@mit.edu> +References: <1356493723-11085-1-git-send-email-amdragon@mit.edu> + <1356493723-11085-3-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.14+213~g4af1ac6 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-pc-linux-gnu) +Date: Wed, 26 Dec 2012 10:31:01 -0400 +Message-ID: <87ip7oril6.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: text/plain +X-Spam_bar: - +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: Wed, 26 Dec 2012 14:31:11 -0000 + +Austin Clements writes: + +> + char *out = talloc_strdup (ctx, pos + 1); +> + int closed = 0; +> + /* Find the closing quote and un-double doubled internal +> + * quotes. */ +> + for (pos = *term_out = out; *pos; ) { + +Since you strdup anyway, wouldn't it be easier to understand if pos read +from the input string and out wrote to term_out? Something like +(untested) + +index db01b4b..e4157d0 100644 +--- a/util/string-util.c ++++ b/util/string-util.c +@@ -112,11 +112,12 @@ parse_boolean_term (void *ctx, const char *str, + + /* Implement de-quoting compatible with make_boolean_term. */ + if (*pos == '"') { +- char *out = talloc_strdup (ctx, pos + 1); ++ char *out; + int closed = 0; ++ *term_out= talloc_strdup (ctx, pos + 1); + /* Find the closing quote and un-double doubled internal + * quotes. */ +- for (pos = *term_out = out; *pos; ) { ++ for (out = *term_out; *pos; ) { + if (*pos == '"') { + ++pos; + + +Perhaps the two talloc_strdups can even be unified, but I wouldn't worry +too much about that.