From: david Date: Fri, 21 Dec 2012 13:08:15 +0000 (+2000) Subject: [Patch v8 06/18] util/hex-escape: add a function to check strings unchanged by hex... X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=22413a5799bf7762c141bd68dc16c6ebdc0472e1;p=notmuch-archives.git [Patch v8 06/18] util/hex-escape: add a function to check strings unchanged by hex encoding. --- diff --git a/59/8fd94f69377c1efa9d547fe0d0bc1b9edaa065 b/59/8fd94f69377c1efa9d547fe0d0bc1b9edaa065 new file mode 100644 index 000000000..80fe186c4 --- /dev/null +++ b/59/8fd94f69377c1efa9d547fe0d0bc1b9edaa065 @@ -0,0 +1,109 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 39B3E431FBD + for ; Fri, 21 Dec 2012 05:08:45 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id O6E5Wu-Re3ij for ; + Fri, 21 Dec 2012 05:08:44 -0800 (PST) +Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238]) + (using TLSv1 with cipher AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 36FF9431FC3 + for ; Fri, 21 Dec 2012 05:08:39 -0800 (PST) +Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net + ([156.34.82.78] helo=zancas.localnet) + by tesseract.cs.unb.ca with esmtpsa + (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) + (envelope-from ) + id 1Tm2L6-0005dc-JS; Fri, 21 Dec 2012 09:08:37 -0400 +Received: from bremner by zancas.localnet with local (Exim 4.80) + (envelope-from ) + id 1Tm2L1-0005yc-4j; Fri, 21 Dec 2012 09:08:31 -0400 +From: david@tethera.net +To: notmuch@notmuchmail.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 +Message-Id: <1356095307-22895-6-git-send-email-david@tethera.net> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1356095307-22895-1-git-send-email-david@tethera.net> +References: <1356095307-22895-1-git-send-email-david@tethera.net> +X-Spam_bar: - +Cc: David Bremner +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 21 Dec 2012 13:08:45 -0000 + +From: David Bremner + +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 + #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 +