1 Return-Path: <tomi.ollila@nixu.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 3E668429E26
\r
6 for <notmuch@notmuchmail.org>; Mon, 12 Dec 2011 03:30:03 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id RaH+Pqj7Iwmz for <notmuch@notmuchmail.org>;
\r
16 Mon, 12 Dec 2011 03:30:00 -0800 (PST)
\r
17 Received: from mail-gw3.nixu.fi (mail-gw3.nixu.fi [193.209.237.7])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 55D86429E25
\r
21 for <notmuch@notmuchmail.org>; Mon, 12 Dec 2011 03:30:00 -0800 (PST)
\r
22 Received: from pps.filterd (mail-gw3 [127.0.0.1])
\r
23 by mail-gw3.nixu.fi (8.14.4/8.14.4) with SMTP id pBCBSQBj020852;
\r
24 Mon, 12 Dec 2011 13:29:46 +0200
\r
25 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
26 by mail-gw3.nixu.fi with ESMTP id 114cs0stgy-1
\r
27 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
28 Mon, 12 Dec 2011 13:29:46 +0200
\r
29 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
30 by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id
\r
31 pBCBTjeM004007; Mon, 12 Dec 2011 13:29:45 +0200
\r
32 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
33 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
\r
34 Subject: Re: [PATCH] util/hex-escape.[ch]: encoding/decoding strings into
\r
35 restricted character set
\r
36 In-Reply-To: <1323620384-16043-1-git-send-email-david@tethera.net>
\r
37 References: <1323620384-16043-1-git-send-email-david@tethera.net>
\r
38 User-Agent: Notmuch/0.10.2+93~g631d290 (http://notmuchmail.org) Emacs/23.3.1
\r
40 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
41 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
42 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
43 Date: Mon, 12 Dec 2011 13:29:45 +0200
\r
44 Message-ID: <yf6ty56m3iu.fsf@taco2.nixu.fi>
\r
46 Content-Type: text/plain; charset=us-ascii
\r
47 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.5.7110,
\r
48 1.0.211, 0.0.0000 definitions=2011-12-12_02:2011-12-12, 2011-12-12,
\r
49 1970-01-01 signatures=0
\r
50 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
\r
51 ipscore=0 suspectscore=0
\r
52 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0
\r
54 scancount=1 engine=6.0.2-1012030000 definitions=main-1112120054
\r
55 Cc: David Bremner <bremner@debian.org>
\r
56 X-BeenThere: notmuch@notmuchmail.org
\r
57 X-Mailman-Version: 2.1.13
\r
59 List-Id: "Use and development of the notmuch mail system."
\r
60 <notmuch.notmuchmail.org>
\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
64 List-Post: <mailto:notmuch@notmuchmail.org>
\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
68 X-List-Received-Date: Mon, 12 Dec 2011 11:30:03 -0000
\r
70 On Sun, 11 Dec 2011 12:19:44 -0400, David Bremner <david@tethera.net> wrote:
\r
71 > From: David Bremner <bremner@debian.org>
\r
73 > The character set is chosen to be suitable for pathnames, and the same
\r
74 > as that used by contrib/nmbug. The new encoded/decoded strings are
\r
75 > allocated using talloc.
\r
77 > This isn't urgent, but it is useful for a couple projects I have
\r
78 > brewing (nmbug compatible dump/restore and tag logging), so I thought
\r
79 > I would get some feedback on it.
\r
82 > util/Makefile.local | 4 +-
\r
83 > util/hex-escape.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++
\r
84 > util/hex-escape.h | 10 +++++
\r
85 > 3 files changed, 122 insertions(+), 2 deletions(-)
\r
86 > create mode 100644 util/hex-escape.c
\r
87 > create mode 100644 util/hex-escape.h
\r
89 Like Dmitry mentioned, Makefile.local change in separate patch after
\r
90 hex-escape additions.
\r
92 > diff --git a/util/hex-escape.c b/util/hex-escape.c
\r
93 > new file mode 100644
\r
94 > index 0000000..c294bb5
\r
96 > +++ b/util/hex-escape.c
\r
101 > +escapes_needed (const char *str){
\r
103 Opening { in separate line, like in all other source files.
\r
105 > + int escapes = 0;
\r
108 > + if (index (HEX_NO_ESCAPE, *str) == NULL)
\r
110 strchr() instead of index()
\r
112 And, like Dmitry mentioned, static const char _hex_no_escape[] = "...";
\r
118 > + return escapes;
\r
122 > +hex_encode (void *ctx, const char *str) {
\r
123 > + char *newstr = talloc_size (ctx, strlen (str)+3*escapes_needed (str)+1);
\r
125 Consistent spacing, like Dmitry mentioned (I compared with
\r
126 _optimize_tag_query () in notmuch-tag.c ).
\r
129 > + char *out = newstr;
\r
132 > + if (index (HEX_NO_ESCAPE, *str)) {
\r
134 ... if (strchr ( _hex_no_escape, *str) != NULL) {
\r
138 > +inline static int
\r
139 > +_digit (char c) {
\r
141 Maybe _hexdigit () ?
\r
143 > + if ('0' <= c && c <= '9')
\r
144 > + return c - '0';
\r
146 > + if ('A' <= c && c <= 'F')
\r
147 > + return c - 'A';
\r
149 > + if ('a' <= c && c <= 'f')
\r
150 > + return c - 'a';
\r
152 Fix this (or change to sscanf) like Dmitry mentioned
\r
153 (c - 'A' + 10 and c - 'a' + 10)
\r
156 > + INTERNAL_ERROR ("Illegal hex digit %c", c);
\r
158 Is this too heavy ? -- but there may not be alternative.
\r