]> git.notmuchmail.org Git - notmuch/blobdiff - util/string-util.c
test: Test upgrade to ghost messages feature
[notmuch] / util / string-util.c
index 9e2f728fc6750c586f3effed3ecac5673ea980e0..a90501ee3e70198e652599e6da841ffe95db8f85 100644 (file)
@@ -37,6 +37,14 @@ strtok_len (char *s, const char *delim, size_t *len)
     return *len ? s : NULL;
 }
 
+const char *
+strtok_len_c (const char *s, const char *delim, size_t *len)
+{
+    /* strtok_len is already const-safe, but we can't express both
+     * versions in the C type system. */
+    return strtok_len ((char*)s, delim, len);
+}
+
 char *
 sanitize_string (const void *ctx, const char *str)
 {
@@ -75,10 +83,12 @@ make_boolean_term (void *ctx, const char *prefix, const char *term,
     int need_quoting = 0;
 
     /* Do we need quoting?  To be paranoid, we quote anything
-     * containing a quote, even though it only matters at the
+     * containing a quote or '(', even though these only matter at the
      * beginning, and anything containing non-ASCII text. */
+    if (! term[0])
+       need_quoting = 1;
     for (in = term; *in && !need_quoting; in++)
-       if (is_unquoted_terminator (*in) || *in == '"'
+       if (is_unquoted_terminator (*in) || *in == '"' || *in == '('
            || (unsigned char)*in > 127)
            need_quoting = 1;