unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: david@tethera.net
To: notmuch@notmuchmail.org
Cc: David Bremner <bremner@debian.org>
Subject: [Patch v8 06/18] util/hex-escape: add a function to check strings unchanged by hex encoding.
Date: Fri, 21 Dec 2012 09:08:15 -0400	[thread overview]
Message-ID: <1356095307-22895-6-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1356095307-22895-1-git-send-email-david@tethera.net>

From: David Bremner <bremner@debian.org>

Initial use case is to recognize input tokens for batch tagging that
need quoting.
---
 util/hex-escape.c |    7 +++++++
 util/hex-escape.h |    8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/util/hex-escape.c b/util/hex-escape.c
index b7e2e07..b601a33 100644
--- a/util/hex-escape.c
+++ b/util/hex-escape.c
@@ -24,6 +24,7 @@
 #include <ctype.h>
 #include "error_util.h"
 #include "hex-escape.h"
+#include "string-util.h"
 
 static const size_t default_buf_size = 1024;
 
@@ -38,6 +39,12 @@ is_output (char c)
     return (strchr (output_charset, c) != NULL);
 }
 
+size_t
+hex_invariant (const char *str, size_t len)
+{
+    return strnspn (str, len, output_charset);
+}
+
 static int
 maybe_realloc (void *ctx, size_t needed, char **out, size_t *out_size)
 {
diff --git a/util/hex-escape.h b/util/hex-escape.h
index 5182042..e7d0b31 100644
--- a/util/hex-escape.h
+++ b/util/hex-escape.h
@@ -38,4 +38,12 @@ hex_decode (void *talloc_ctx, const char *in, char **out,
  */
 hex_status_t
 hex_decode_inplace (char *s);
+
+/*
+ * Calculate the length of the initial segment of str that would not
+ * be changed by hex encoding. Consider at most `len' characters
+ * (bytes) before stopping.
+ */
+size_t
+hex_invariant (const char *str, size_t len);
 #endif
-- 
1.7.10.4

  parent reply	other threads:[~2012-12-21 13:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21 13:08 [Patch v8 01/18] parse_tag_line: use enum for return value david
2012-12-21 13:08 ` [Patch v8 02/18] tag-util: factor out rules for illegal tags, use in parse_tag_line david
2012-12-21 13:08 ` [Patch v8 03/18] notmuch-tag.c: convert to use tag-utils david
2012-12-21 13:08 ` [Patch v8 04/18] notmuch-tag: factor out double quoting routine david
2012-12-21 13:08 ` [Patch v8 05/18] util/string-util: add strnspn david
2012-12-21 13:08 ` david [this message]
2012-12-21 13:08 ` [Patch v8 07/18] unhex_and_quote: new function to quote hex-decoded queries david
2012-12-22 23:36   ` Jani Nikula
2012-12-23  2:59     ` [PATCH] simplify unhex_and_quote david
2012-12-23  8:19       ` Mark Walters
2012-12-21 13:08 ` [Patch v8 08/18] notmuch-restore: move query handling for batch restore to parser david
2012-12-21 13:08 ` [Patch v8 09/18] cli: add support for batch tagging operations to "notmuch tag" david
2012-12-22 22:51   ` Jani Nikula
2012-12-21 13:08 ` [Patch v8 10/18] test/tagging: add test for error messages of tag --batch david
2012-12-21 13:08 ` [Patch v8 11/18] test/tagging: add basic tests for batch tagging functionality david
2012-12-21 13:08 ` [Patch v8 12/18] test/tagging: add tests for exotic tags david
2012-12-21 13:08 ` [Patch v8 13/18] test/tagging: add test for exotic message-ids and batch tagging david
2012-12-21 13:08 ` [Patch v8 14/18] test/tagging: add test for compound queries with " david
2012-12-21 13:08 ` [Patch v8 15/18] notmuch-tag.1: tidy synopsis formatting, reference david
2012-12-21 13:08 ` [Patch v8 16/18] man: document notmuch tag --batch, --input options david
2012-12-21 13:08 ` [Patch v8 17/18] test/tagging: add test for naked punctuation in tags; compare with quoting spaces david
2012-12-21 13:08 ` [Patch v8 18/18] more man fixup david
2012-12-21 13:29 ` [Patch v8 01/18] parse_tag_line: use enum for return value David Bremner
2012-12-22 23:47   ` Jani Nikula
2012-12-22 21:48 ` 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=1356095307-22895-6-git-send-email-david@tethera.net \
    --to=david@tethera.net \
    --cc=bremner@debian.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).