--- /dev/null
+Return-Path: <jani@nikula.org>\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 825DB429E4B\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 11:52:18 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 2g2Z9HY8NUl9 for <notmuch@notmuchmail.org>;\r
+ Mon, 3 Feb 2014 11:52:14 -0800 (PST)\r
+Received: from mail-ee0-f45.google.com (mail-ee0-f45.google.com\r
+ [74.125.83.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ F395F431FBC for <notmuch@notmuchmail.org>; Mon, 3 Feb 2014 11:52:06 -0800\r
+ (PST)\r
+Received: by mail-ee0-f45.google.com with SMTP id b15so3782391eek.18\r
+ for <notmuch@notmuchmail.org>; Mon, 03 Feb 2014 11:52:04 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=JwBvHluoJzjtyBf6dvx9NzZqVeYE9ZEAZ90FMAsmkB4=;\r
+ b=UgOkw0rCgZCt7GdkkzOuDAkel8Sxl25xYYQofQY/EJ5JgUf7hWHVP3rAqNUhEyxkp0\r
+ SrHSe6AAvL0JzRV2uSQn8lNAEv28GO61NDzDWjFf8B4i7/UgbJ6bD/meFJzpXv+Zmsd3\r
+ 1lujxDd79TsLcIEfatG8dWHYVpOZ5fknCOmxF5cxyJ1yZmfhZEdLCLgFgvI9s4kOPbB4\r
+ jmZQYGTO8MvrCkMYBNZcHVrcYZxf4wEdmH4Jst1AkUVtX6K7YOkEKSSOrR5zWLKNKiCo\r
+ kMA+qNIYKLw7XQK26NlxIPGBnsWcQ1Y3hENX+0ztSbCMHdgTuRW1ohOvMhsmWRtGB+HH\r
+ FVTQ==\r
+X-Gm-Message-State:\r
+ ALoCoQnVI1apW47ZVS9GBCNYBW9hnT/Ih+34Lqtf2A5DuybPP2nIDXWb6jNu07s8wCTdAZrMNCW5\r
+X-Received: by 10.14.216.3 with SMTP id f3mr5126715eep.66.1391457124479;\r
+ Mon, 03 Feb 2014 11:52:04 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91])\r
+ by mx.google.com with ESMTPSA id d9sm52614741eei.9.2014.02.03.11.52.02\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Mon, 03 Feb 2014 11:52:03 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 3/6] util: make sanitize string available in string util\r
+ for reuse\r
+Date: Mon, 3 Feb 2014 21:51:43 +0200\r
+Message-Id:\r
+ <cc4f0512cb650c53c49c7486f3a579f13791c814.1391456555.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.5.2\r
+In-Reply-To: <cover.1391456555.git.jani@nikula.org>\r
+References: <cover.1391456555.git.jani@nikula.org>\r
+In-Reply-To: <cover.1391456555.git.jani@nikula.org>\r
+References: <cover.1391456555.git.jani@nikula.org>\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, 03 Feb 2014 19:52:18 -0000\r
+\r
+No functional changes.\r
+---\r
+ notmuch-search.c | 19 -------------------\r
+ util/string-util.c | 22 ++++++++++++++++++++++\r
+ util/string-util.h | 7 +++++++\r
+ 3 files changed, 29 insertions(+), 19 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index 0262eb3..bc9be45 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -30,25 +30,6 @@ typedef enum {\r
+ OUTPUT_TAGS\r
+ } output_t;\r
+ \r
+-static char *\r
+-sanitize_string (const void *ctx, const char *str)\r
+-{\r
+- char *out, *loop;\r
+-\r
+- if (NULL == str)\r
+- return NULL;\r
+-\r
+- loop = out = talloc_strdup (ctx, str);\r
+-\r
+- for (; *loop; loop++) {\r
+- if (*loop == '\t' || *loop == '\n')\r
+- *loop = ' ';\r
+- else if ((unsigned char)(*loop) < 32)\r
+- *loop = '?';\r
+- }\r
+- return out;\r
+-}\r
+-\r
+ /* Return two stable query strings that identify exactly the matched\r
+ * and unmatched messages currently in thread. If there are no\r
+ * matched or unmatched messages, the returned buffers will be\r
+diff --git a/util/string-util.c b/util/string-util.c\r
+index a5622d7..9e2f728 100644\r
+--- a/util/string-util.c\r
++++ b/util/string-util.c\r
+@@ -37,6 +37,28 @@ strtok_len (char *s, const char *delim, size_t *len)\r
+ return *len ? s : NULL;\r
+ }\r
+ \r
++char *\r
++sanitize_string (const void *ctx, const char *str)\r
++{\r
++ char *out, *loop;\r
++\r
++ if (! str)\r
++ return NULL;\r
++\r
++ out = talloc_strdup (ctx, str);\r
++ if (! out)\r
++ return NULL;\r
++\r
++ for (loop = out; *loop; loop++) {\r
++ if (*loop == '\t' || *loop == '\n')\r
++ *loop = ' ';\r
++ else if ((unsigned char)(*loop) < 32)\r
++ *loop = '?';\r
++ }\r
++\r
++ return out;\r
++}\r
++\r
+ static int\r
+ is_unquoted_terminator (unsigned char c)\r
+ {\r
+diff --git a/util/string-util.h b/util/string-util.h\r
+index 0194607..8a3ad19 100644\r
+--- a/util/string-util.h\r
++++ b/util/string-util.h\r
+@@ -19,6 +19,13 @@\r
+ \r
+ char *strtok_len (char *s, const char *delim, size_t *len);\r
+ \r
++/* Return a talloced string with str sanitized.\r
++ *\r
++ * Whitespace characters (tabs and newlines) are replaced with spaces,\r
++ * non-printable characters with question marks.\r
++ */\r
++char *sanitize_string (const void *ctx, const char *str);\r
++\r
+ /* Construct a boolean term query with the specified prefix (e.g.,\r
+ * "id") and search term, quoting term as necessary. Specifically, if\r
+ * term contains any non-printable ASCII characters, non-ASCII\r
+-- \r
+1.8.5.2\r
+\r