[PATCH v2 2/5] util: Function to parse boolean term queries
David Bremner
david at tethera.net
Wed Dec 26 06:31:01 PST 2012
Austin Clements <amdragon at 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.
More information about the notmuch
mailing list