--- /dev/null
+Return-Path: <dmitry.kurochkin@gmail.com>\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 BE51E429E4E\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 12:37:18 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 l4hAAsjFsKCW for <notmuch@notmuchmail.org>;\r
+ Wed, 14 Dec 2011 12:37:18 -0800 (PST)\r
+Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
+ [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A4B30429E4D\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 12:37:17 -0800 (PST)\r
+Received: by faaa5 with SMTP id a5so1780547faa.26\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 12:37:16 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+ :message-id:mime-version:content-type;\r
+ bh=AHfH6eUp0sNAMOWaBq7dXPdS2LBpX5CT5QuTf53+kRQ=;\r
+ b=dPQ/RmKcI9/am33Y0t8gWN4sDWQb1mL1ZCy1GC1kA2lYghAmcn28XnEgurYtVcGNes\r
+ FiSGW7mjBEsBIDyW1nNCeX1Lf08n3bYNf91s84Ihkm1CAAkLuOswxlrIadQyV/kTn8Va\r
+ 7y6NJoHuKXv8OeGIqwyz7h6xHe9hx/g9UFDTw=\r
+Received: by 10.180.84.33 with SMTP id v1mr558075wiy.4.1323895036310;\r
+ Wed, 14 Dec 2011 12:37:16 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+ by mx.google.com with ESMTPS id fg15sm5766611wbb.7.2011.12.14.12.37.15\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 14 Dec 2011 12:37:15 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [Alpha Patch 2/2] test: update dump-restore tests for 8 bit\r
+ characters.\r
+In-Reply-To: <1323893641-4677-2-git-send-email-david@tethera.net>\r
+References: <1323808075-7417-7-git-send-email-david@tethera.net>\r
+ <1323893641-4677-1-git-send-email-david@tethera.net>\r
+ <1323893641-4677-2-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.10.2+96~g74e5ae5 (http://notmuchmail.org) Emacs/23.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Thu, 15 Dec 2011 00:36:38 +0400\r
+Message-ID: <87pqfqubzd.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Cc: David Bremner <bremner@debian.org>, pere@hungry.com\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: Wed, 14 Dec 2011 20:37:18 -0000\r
+\r
+On Wed, 14 Dec 2011 16:14:01 -0400, David Bremner <david@tethera.net> wrote:\r
+> From: David Bremner <bremner@debian.org>\r
+> \r
+> hex-escape: fix for handling of 8 bit chars\r
+> \r
+> The low level problem was passing negative numbers to sprintf(s,"%x");\r
+> we fix this and clarify the api for hex_(decode|encode) by making\r
+> encode go from (unsigned char *) (i.e. 8bit) to (char *) and decode\r
+> vise-versa.\r
+\r
+I did not do a proper review. But I think the encoder and decoder\r
+should accept and return the same type, either char* or unsigned char*.\r
+The decision should be based on what type strings (that would be fed to\r
+the encoder and decoder) have in notmuch code. I guess it is char*, so\r
+the encoder and decoder should take and return char*. Internally we\r
+would cast char* to unsigned char*.\r
+\r
+Also, I do not like the _octet typedef in hex-escape.c. Having\r
+different function parameters in header and .c is confusing. IMO we\r
+should either move the typedef to some header, or just use unsigned\r
+char.\r
+\r
+Regards,\r
+ Dmitry\r
+\r
+> ---\r
+> test/dump-restore | 2 --\r
+> test/hex-escaping | 1 -\r
+> util/hex-escape.c | 26 +++++++++++++++-----------\r
+> util/hex-escape.h | 6 ++++--\r
+> 4 files changed, 19 insertions(+), 16 deletions(-)\r
+> \r
+> diff --git a/test/dump-restore b/test/dump-restore\r
+> index eee1773..c5b2e86 100755\r
+> --- a/test/dump-restore\r
+> +++ b/test/dump-restore\r
+> @@ -114,7 +114,6 @@ notmuch dump --format=notmuch > BACKUP\r
+> notmuch tag +"$tag1" +"$tag2" +"$tag3" -inbox -unread "*"\r
+> \r
+> test_begin_subtest 'format=notmuch, round trip with strange tags'\r
+> - test_subtest_known_broken\r
+> notmuch dump --format=notmuch > EXPECTED.$test_count\r
+> notmuch dump --format=notmuch | notmuch restore --format=notmuch\r
+> notmuch dump --format=notmuch > OUTPUT.$test_count\r
+> @@ -122,7 +121,6 @@ test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count\r
+> \r
+> \r
+> test_begin_subtest 'format=notmuch, checking encoded output'\r
+> - test_subtest_known_broken\r
+> cp /dev/null EXPECTED.$test_count\r
+> notmuch dump --format=notmuch -- from:cworth |\\r
+> awk "{ print \$1 \" $enc1 $enc2 $enc3\" }" > EXPECTED.$test_count\r
+> diff --git a/test/hex-escaping b/test/hex-escaping\r
+> index 2053fb0..daa6446 100755\r
+> --- a/test/hex-escaping\r
+> +++ b/test/hex-escaping\r
+> @@ -19,7 +19,6 @@ $TEST_DIRECTORY/hex-xcode e < EXPECTED.$test_count |\\r
+> test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count\r
+> \r
+> test_begin_subtest "round trip 8bit chars"\r
+> -test_subtest_known_broken\r
+> echo '%c3%91%c3%a5%c3%b0%c3%a3%c3%a5%c3%a9-%c3%8f%c3%8a' > EXPECTED.$test_count\r
+> $TEST_DIRECTORY/hex-xcode d < EXPECTED.$test_count |\\r
+> $TEST_DIRECTORY/hex-xcode e > OUTPUT.$test_count\r
+> diff --git a/util/hex-escape.c b/util/hex-escape.c\r
+> index dcf87cf..565ae99 100644\r
+> --- a/util/hex-escape.c\r
+> +++ b/util/hex-escape.c\r
+> @@ -28,23 +28,24 @@ static const size_t default_buf_size=1024;\r
+> static const char* output_charset=\r
+> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-_@=.:,";\r
+> \r
+> -static const char escape_char='%';\r
+> +static const int escape_char = '%';\r
+> \r
+> static int\r
+> is_output (char c) {\r
+> return (strchr (output_charset, c) != NULL);\r
+> }\r
+> \r
+> +typedef unsigned char _octet;\r
+> \r
+> static int\r
+> -maybe_realloc(void *ctx, size_t needed, char **out, size_t *out_size)\r
+> +maybe_realloc(void *ctx, size_t needed, _octet **out, size_t *out_size)\r
+> {\r
+> if (*out_size < needed) {\r
+> \r
+> if (*out == NULL)\r
+> *out = talloc_size(ctx,needed);\r
+> else\r
+> - *out = talloc_realloc(ctx,*out,char,needed);\r
+> + *out = talloc_realloc(ctx, *out, _octet, needed);\r
+> \r
+> if (*out == NULL)\r
+> return 0;\r
+> @@ -56,24 +57,27 @@ maybe_realloc(void *ctx, size_t needed, char **out, size_t *out_size)\r
+> \r
+> \r
+> hex_status_t\r
+> -hex_encode (void *ctx, const char *in, char **out, size_t *out_size)\r
+> +hex_encode (void *ctx, const _octet *in, char **out, size_t *out_size)\r
+> {\r
+> \r
+> - const char *p;\r
+> + const _octet *p;\r
+> char *q;\r
+> \r
+> - int escape_count=0;\r
+> + size_t escape_count = 0;\r
+> + size_t len = 0;\r
+> size_t needed;\r
+> \r
+> - for (p = in; *p; p++)\r
+> + for (p = in; *p; p++) {\r
+> escape_count += (! is_output (*p));\r
+> + len++;\r
+> + }\r
+> \r
+> - needed = strlen (in) + 2*escape_count + 1;\r
+> + needed = len + 2*escape_count + 1;\r
+> \r
+> if (*out == NULL)\r
+> *out_size=0;\r
+> \r
+> - if (!maybe_realloc (ctx, needed, out, out_size))\r
+> + if (!maybe_realloc (ctx, needed, (_octet**)out, out_size))\r
+> return HEX_OUT_OF_MEMORY;\r
+> \r
+> q = *out;\r
+> @@ -94,12 +98,12 @@ hex_encode (void *ctx, const char *in, char **out, size_t *out_size)\r
+> \r
+> \r
+> hex_status_t\r
+> -hex_decode (void *ctx, const char *in, char **out, size_t *out_size) {\r
+> +hex_decode (void *ctx, const char *in, _octet **out, size_t *out_size) {\r
+> \r
+> char buf[3];\r
+> \r
+> const char *p;\r
+> - char *q;\r
+> + _octet *q;\r
+> \r
+> size_t escape_count = 0;\r
+> size_t needed = 0;\r
+> diff --git a/util/hex-escape.h b/util/hex-escape.h\r
+> index 98ecbe0..e04aff5 100644\r
+> --- a/util/hex-escape.h\r
+> +++ b/util/hex-escape.h\r
+> @@ -8,8 +8,10 @@ typedef enum hex_status {\r
+> } hex_status_t;\r
+> \r
+> hex_status_t\r
+> -hex_encode (void *talloc_ctx, const char *in, char **out, size_t *out_size);\r
+> +hex_encode (void *talloc_ctx, const unsigned char *in, char **out,\r
+> + size_t *out_size);\r
+> \r
+> hex_status_t\r
+> -hex_decode (void *talloc_ctx, const char *in, char **out, size_t *out_size);\r
+> +hex_decode (void *talloc_ctx, const char *in, unsigned char **out,\r
+> + size_t *out_size);\r
+> #endif\r
+> -- \r
+> 1.7.7.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r