Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 52 / e57217e39505acaeaf0c742bb8fb88a74d1ea4
1 Return-Path: <dmitry.kurochkin@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id BE51E429E4E\r
6         for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 12:37:18 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id l4hAAsjFsKCW for <notmuch@notmuchmail.org>;\r
17         Wed, 14 Dec 2011 12:37:18 -0800 (PST)\r
18 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
19         [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id A4B30429E4D\r
22         for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 12:37:17 -0800 (PST)\r
23 Received: by faaa5 with SMTP id a5so1780547faa.26\r
24         for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 12:37:16 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
27         :message-id:mime-version:content-type;\r
28         bh=AHfH6eUp0sNAMOWaBq7dXPdS2LBpX5CT5QuTf53+kRQ=;\r
29         b=dPQ/RmKcI9/am33Y0t8gWN4sDWQb1mL1ZCy1GC1kA2lYghAmcn28XnEgurYtVcGNes\r
30         FiSGW7mjBEsBIDyW1nNCeX1Lf08n3bYNf91s84Ihkm1CAAkLuOswxlrIadQyV/kTn8Va\r
31         7y6NJoHuKXv8OeGIqwyz7h6xHe9hx/g9UFDTw=\r
32 Received: by 10.180.84.33 with SMTP id v1mr558075wiy.4.1323895036310;\r
33         Wed, 14 Dec 2011 12:37:16 -0800 (PST)\r
34 Received: from localhost ([91.144.186.21])\r
35         by mx.google.com with ESMTPS id fg15sm5766611wbb.7.2011.12.14.12.37.15\r
36         (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Wed, 14 Dec 2011 12:37:15 -0800 (PST)\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
39 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
40 Subject: Re: [Alpha Patch 2/2] test: update dump-restore tests for 8 bit\r
41         characters.\r
42 In-Reply-To: <1323893641-4677-2-git-send-email-david@tethera.net>\r
43 References: <1323808075-7417-7-git-send-email-david@tethera.net>\r
44         <1323893641-4677-1-git-send-email-david@tethera.net>\r
45         <1323893641-4677-2-git-send-email-david@tethera.net>\r
46 User-Agent: Notmuch/0.10.2+96~g74e5ae5 (http://notmuchmail.org) Emacs/23.3.1\r
47         (x86_64-pc-linux-gnu)\r
48 Date: Thu, 15 Dec 2011 00:36:38 +0400\r
49 Message-ID: <87pqfqubzd.fsf@gmail.com>\r
50 MIME-Version: 1.0\r
51 Content-Type: text/plain; charset=us-ascii\r
52 Cc: David Bremner <bremner@debian.org>, pere@hungry.com\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Wed, 14 Dec 2011 20:37:18 -0000\r
66 \r
67 On Wed, 14 Dec 2011 16:14:01 -0400, David Bremner <david@tethera.net> wrote:\r
68 > From: David Bremner <bremner@debian.org>\r
69\r
70 > hex-escape: fix for handling of 8 bit chars\r
71\r
72 > The low level problem was passing negative numbers to sprintf(s,"%x");\r
73 > we fix this and clarify the api for hex_(decode|encode) by making\r
74 > encode go from (unsigned char *) (i.e. 8bit) to (char *) and decode\r
75 > vise-versa.\r
76 \r
77 I did not do a proper review.  But I think the encoder and decoder\r
78 should accept and return the same type, either char* or unsigned char*.\r
79 The decision should be based on what type strings (that would be fed to\r
80 the encoder and decoder) have in notmuch code.  I guess it is char*, so\r
81 the encoder and decoder should take and return char*.  Internally we\r
82 would cast char* to unsigned char*.\r
83 \r
84 Also, I do not like the _octet typedef in hex-escape.c.  Having\r
85 different function parameters in header and .c is confusing.  IMO we\r
86 should either move the typedef to some header, or just use unsigned\r
87 char.\r
88 \r
89 Regards,\r
90   Dmitry\r
91 \r
92 > ---\r
93 >  test/dump-restore |    2 --\r
94 >  test/hex-escaping |    1 -\r
95 >  util/hex-escape.c |   26 +++++++++++++++-----------\r
96 >  util/hex-escape.h |    6 ++++--\r
97 >  4 files changed, 19 insertions(+), 16 deletions(-)\r
98\r
99 > diff --git a/test/dump-restore b/test/dump-restore\r
100 > index eee1773..c5b2e86 100755\r
101 > --- a/test/dump-restore\r
102 > +++ b/test/dump-restore\r
103 > @@ -114,7 +114,6 @@ notmuch dump --format=notmuch > BACKUP\r
104 >  notmuch tag +"$tag1" +"$tag2" +"$tag3" -inbox -unread "*"\r
105 >  \r
106 >  test_begin_subtest 'format=notmuch, round trip with strange tags'\r
107 > -   test_subtest_known_broken\r
108 >     notmuch dump --format=notmuch > EXPECTED.$test_count\r
109 >     notmuch dump --format=notmuch | notmuch restore --format=notmuch\r
110 >     notmuch dump --format=notmuch > OUTPUT.$test_count\r
111 > @@ -122,7 +121,6 @@ test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count\r
112 >  \r
113 >  \r
114 >  test_begin_subtest 'format=notmuch, checking encoded output'\r
115 > -    test_subtest_known_broken\r
116 >      cp /dev/null EXPECTED.$test_count\r
117 >      notmuch dump --format=notmuch -- from:cworth |\\r
118 >        awk "{ print \$1 \" $enc1 $enc2 $enc3\" }" > EXPECTED.$test_count\r
119 > diff --git a/test/hex-escaping b/test/hex-escaping\r
120 > index 2053fb0..daa6446 100755\r
121 > --- a/test/hex-escaping\r
122 > +++ b/test/hex-escaping\r
123 > @@ -19,7 +19,6 @@ $TEST_DIRECTORY/hex-xcode e  < EXPECTED.$test_count |\\r
124 >  test_expect_equal_file EXPECTED.$test_count OUTPUT.$test_count\r
125 >  \r
126 >  test_begin_subtest "round trip 8bit chars"\r
127 > -test_subtest_known_broken\r
128 >  echo '%c3%91%c3%a5%c3%b0%c3%a3%c3%a5%c3%a9-%c3%8f%c3%8a' > EXPECTED.$test_count\r
129 >  $TEST_DIRECTORY/hex-xcode d  < EXPECTED.$test_count |\\r
130 >       $TEST_DIRECTORY/hex-xcode e > OUTPUT.$test_count\r
131 > diff --git a/util/hex-escape.c b/util/hex-escape.c\r
132 > index dcf87cf..565ae99 100644\r
133 > --- a/util/hex-escape.c\r
134 > +++ b/util/hex-escape.c\r
135 > @@ -28,23 +28,24 @@ static const size_t default_buf_size=1024;\r
136 >  static const char* output_charset=\r
137 >      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-_@=.:,";\r
138 >  \r
139 > -static const char escape_char='%';\r
140 > +static const int escape_char = '%';\r
141 >  \r
142 >  static int\r
143 >  is_output (char c) {\r
144 >      return (strchr (output_charset, c) != NULL);\r
145 >  }\r
146 >  \r
147 > +typedef unsigned char _octet;\r
148 >  \r
149 >  static int\r
150 > -maybe_realloc(void *ctx, size_t needed, char **out, size_t *out_size)\r
151 > +maybe_realloc(void *ctx, size_t needed, _octet **out, size_t *out_size)\r
152 >  {\r
153 >      if (*out_size < needed) {\r
154 >  \r
155 >       if (*out == NULL)\r
156 >           *out = talloc_size(ctx,needed);\r
157 >       else\r
158 > -         *out = talloc_realloc(ctx,*out,char,needed);\r
159 > +         *out = talloc_realloc(ctx, *out, _octet, needed);\r
160 >  \r
161 >       if (*out == NULL)\r
162 >           return 0;\r
163 > @@ -56,24 +57,27 @@ maybe_realloc(void *ctx, size_t needed, char **out, size_t *out_size)\r
164 >  \r
165 >  \r
166 >  hex_status_t\r
167 > -hex_encode (void *ctx, const char *in, char **out, size_t *out_size)\r
168 > +hex_encode (void *ctx, const _octet *in, char **out, size_t *out_size)\r
169 >  {\r
170 >  \r
171 > -    const char *p;\r
172 > +    const _octet *p;\r
173 >      char *q;\r
174 >  \r
175 > -    int escape_count=0;\r
176 > +    size_t escape_count = 0;\r
177 > +    size_t len = 0;\r
178 >      size_t needed;\r
179 >  \r
180 > -    for  (p = in; *p; p++)\r
181 > +    for  (p = in; *p; p++) {\r
182 >       escape_count += (! is_output (*p));\r
183 > +     len++;\r
184 > +    }\r
185 >  \r
186 > -    needed = strlen (in) + 2*escape_count + 1;\r
187 > +    needed = len + 2*escape_count + 1;\r
188 >  \r
189 >      if (*out == NULL)\r
190 >       *out_size=0;\r
191 >  \r
192 > -    if (!maybe_realloc (ctx, needed, out, out_size))\r
193 > +    if (!maybe_realloc (ctx, needed, (_octet**)out, out_size))\r
194 >       return HEX_OUT_OF_MEMORY;\r
195 >  \r
196 >      q = *out;\r
197 > @@ -94,12 +98,12 @@ hex_encode (void *ctx, const char *in, char **out, size_t *out_size)\r
198 >  \r
199 >  \r
200 >  hex_status_t\r
201 > -hex_decode (void *ctx, const char *in, char **out, size_t *out_size) {\r
202 > +hex_decode (void *ctx, const char *in, _octet **out, size_t *out_size) {\r
203 >  \r
204 >      char buf[3];\r
205 >  \r
206 >      const char *p;\r
207 > -    char *q;\r
208 > +    _octet *q;\r
209 >  \r
210 >      size_t escape_count = 0;\r
211 >      size_t needed = 0;\r
212 > diff --git a/util/hex-escape.h b/util/hex-escape.h\r
213 > index 98ecbe0..e04aff5 100644\r
214 > --- a/util/hex-escape.h\r
215 > +++ b/util/hex-escape.h\r
216 > @@ -8,8 +8,10 @@ typedef enum hex_status {\r
217 >  } hex_status_t;\r
218 >  \r
219 >  hex_status_t\r
220 > -hex_encode (void *talloc_ctx, const char *in, char **out, size_t *out_size);\r
221 > +hex_encode (void *talloc_ctx, const unsigned char *in, char **out,\r
222 > +         size_t *out_size);\r
223 >  \r
224 >  hex_status_t\r
225 > -hex_decode (void *talloc_ctx, const char *in, char **out, size_t *out_size);\r
226 > +hex_decode (void *talloc_ctx, const char *in, unsigned char **out,\r
227 > +         size_t *out_size);\r
228 >  #endif\r
229 > -- \r
230 > 1.7.7.3\r
231\r
232 > _______________________________________________\r
233 > notmuch mailing list\r
234 > notmuch@notmuchmail.org\r
235 > http://notmuchmail.org/mailman/listinfo/notmuch\r