From: Mark Walters <markwalters1009@gmail.com>
To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2 3/7] util: make sanitize string available in string util for reuse
Date: Sun, 02 Feb 2014 18:24:09 +0000 [thread overview]
Message-ID: <871tzlqsom.fsf@qmul.ac.uk> (raw)
In-Reply-To: <6859d1e9de273e00101c10122cd8ca162cc3a542.1385825425.git.jani@nikula.org>
On Sat, 30 Nov 2013, Jani Nikula <jani@nikula.org> wrote:
> No functional changes.
> ---
> notmuch-search.c | 19 -------------------
> util/string-util.c | 22 ++++++++++++++++++++++
> util/string-util.h | 7 +++++++
> 3 files changed, 29 insertions(+), 19 deletions(-)
>
> diff --git a/notmuch-search.c b/notmuch-search.c
> index 11cd6ee..8b6940a 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -30,25 +30,6 @@ typedef enum {
> OUTPUT_TAGS
> } output_t;
>
> -static char *
> -sanitize_string (const void *ctx, const char *str)
> -{
> - char *out, *loop;
> -
> - if (NULL == str)
> - return NULL;
> -
> - loop = out = talloc_strdup (ctx, str);
> -
> - for (; *loop; loop++) {
> - if (*loop == '\t' || *loop == '\n')
> - *loop = ' ';
> - else if ((unsigned char)(*loop) < 32)
> - *loop = '?';
> - }
> - return out;
> -}
> -
> /* Return two stable query strings that identify exactly the matched
> * and unmatched messages currently in thread. If there are no
> * matched or unmatched messages, the returned buffers will be
> diff --git a/util/string-util.c b/util/string-util.c
> index a5622d7..9e2f728 100644
> --- a/util/string-util.c
> +++ b/util/string-util.c
> @@ -37,6 +37,28 @@ strtok_len (char *s, const char *delim, size_t *len)
> return *len ? s : NULL;
> }
>
> +char *
> +sanitize_string (const void *ctx, const char *str)
> +{
> + char *out, *loop;
> +
> + if (! str)
> + return NULL;
> +
> + out = talloc_strdup (ctx, str);
> + if (! out)
> + return NULL;
> +
> + for (loop = out; *loop; loop++) {
> + if (*loop == '\t' || *loop == '\n')
> + *loop = ' ';
> + else if ((unsigned char)(*loop) < 32)
> + *loop = '?';
> + }
> +
> + return out;
> +}
> +
> static int
> is_unquoted_terminator (unsigned char c)
> {
> diff --git a/util/string-util.h b/util/string-util.h
> index 0194607..228420d 100644
> --- a/util/string-util.h
> +++ b/util/string-util.h
> @@ -19,6 +19,13 @@
>
> char *strtok_len (char *s, const char *delim, size_t *len);
>
> +/* Return a talloced string with str sanitized.
> + *
> + * Whitespace (tabs and newlines) is replaced with spaces,
> + * non-printable characters with question marks.
> + */
A complete triviality but I would prefer "Whitespace characters (tabs
and newlines) are replaced with spaces..." just to emphasise that e.g.
multiple tabs are replaced by multiple spaces.
Best wishes
Mark
> +char *sanitize_string (const void *ctx, const char *str);
> +
> /* Construct a boolean term query with the specified prefix (e.g.,
> * "id") and search term, quoting term as necessary. Specifically, if
> * term contains any non-printable ASCII characters, non-ASCII
> --
> 1.8.4.2
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
next prev parent reply other threads:[~2014-02-02 18:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-30 15:33 [PATCH v2 0/7] lib: replace the message header parser with gmime Jani Nikula
2013-11-30 15:33 ` [PATCH v2 1/7] cli: sanitize tabs and newlines to spaces in notmuch search Jani Nikula
2013-11-30 15:33 ` [PATCH v2 2/7] cli: refactor reply from guessing Jani Nikula
2014-02-02 18:21 ` Mark Walters
2013-11-30 15:33 ` [PATCH v2 3/7] util: make sanitize string available in string util for reuse Jani Nikula
2014-02-02 18:24 ` Mark Walters [this message]
2013-11-30 15:33 ` [PATCH v2 4/7] cli: sanitize the received header before scanning for replies Jani Nikula
2013-11-30 15:33 ` [PATCH v2 5/7] lib: replace the header parser with gmime Jani Nikula
2013-11-30 15:33 ` [PATCH v2 6/7] lib: parse messages only once Jani Nikula
2013-11-30 15:33 ` [PATCH v2 7/7] HACK: fix broken messages in the perf test corpus Jani Nikula
2013-11-30 17:48 ` David Bremner
2014-01-15 18:03 ` [PATCH v2 0/7] lib: replace the message header parser with gmime David Bremner
2014-02-02 13:03 ` Jani Nikula
2014-02-02 18:15 ` Mark Walters
2014-02-02 19:32 ` Jani Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871tzlqsom.fsf@qmul.ac.uk \
--to=markwalters1009@gmail.com \
--cc=jani@nikula.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).