Re: [PATCH v2 2/5] util: Function to parse boolean term queries

Subject: Re: [PATCH v2 2/5] util: Function to parse boolean term queries

Date: Wed, 26 Dec 2012 10:31:01 -0400

To: Austin Clements, notmuch@notmuchmail.org

Cc:

From: David Bremner


Austin Clements <amdragon@MIT.EDU> 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.

Thread: