1 Return-Path: <amdragon@mit.edu>
\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 CA721431FB6
\r
6 for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 21:29:42 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 YGlnSlrBPbQ8 for <notmuch@notmuchmail.org>;
\r
16 Fri, 27 Jul 2012 21:29:40 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 3A49F431FBD
\r
20 for <notmuch@notmuchmail.org>; Fri, 27 Jul 2012 21:29:28 -0700 (PDT)
\r
21 X-AuditID: 1209190c-b7f806d000006b87-71-50136aa76963
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 13.00.27527.7AA63105; Sat, 28 Jul 2012 00:29:28 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6S4TRP1017258;
\r
27 Sat, 28 Jul 2012 00:29:27 -0400
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6S4TK8k027350
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 28 Jul 2012 00:29:22 -0400 (EDT)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1SuyeW-0002Wj-81; Sat, 28 Jul 2012 00:29:20 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH v2 00/13] Convert notmuch show to use structure printers
\r
41 Date: Sat, 28 Jul 2012 00:29:01 -0400
\r
42 Message-Id: <1343449754-9010-1-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10
\r
44 X-Brightmail-Tracker:
\r
45 H4sIAAAAAAAAA+NgFtrBIsWRmVeSWpSXmKPExsUixCmqrLsiSzjA4MIhRou9De2MFqvn8lhc
\r
46 vzmT2eLNynmsDiweO2fdZfdYvGk/m8fhrwtZPJ6tusUcwBLFZZOSmpNZllqkb5fAlXH8wEHG
\r
47 gifiFQd3fmBvYPwm1MXIySEhYCKxseUvG4QtJnHh3nogm4tDSGAfo8TdJ8eZIZwNjBJ3Os8w
\r
48 QjiPmCQO3LjNDuHMZZRoPDSXBaSfTUBDYtv+5YwgtoiAtMTOu7NZQWxmAUeJu78PA83l4BAW
\r
49 8JBYOzkHJMwioCqxd9M6sHJeAXuJRZ82skKcIS/x9H4f2wRG3gWMDKsYZVNyq3RzEzNzilOT
\r
50 dYuTE/PyUot0DfVyM0v0UlNKNzGCA0iSZwfjm4NKhxgFOBiVeHiVrwsFCLEmlhVX5h5ilORg
\r
51 UhLljQoXDhDiS8pPqcxILM6ILyrNSS0+xCjBwawkwrtTECjHm5JYWZValA+TkuZgURLnvZxy
\r
52 019IID2xJDU7NbUgtQgmK8PBoSTBuz0TqFGwKDU9tSItM6cEIc3EwQkynAdo+BqQGt7igsTc
\r
53 4sx0iPwpRkUpcd5JIAkBkERGaR5cLyzCXzGKA70izHsNpIoHmBzgul8BDWYCGmwRLQQyuCQR
\r
54 ISXVwLj1X2fYhBl3j4RuXP9Dge/jJtdwfUm+So95pV2TF8s9NLq7++H3NVK/XG58YZww/Zel
\r
55 PpvAqbYT0usWKicJPd2boVXcx+VqeEC8f8OtJXfNgzXZxXXym2IWf9WumuvqW+c9z7xRU+fP
\r
56 1uzQbZfeJH7tOvg1/K9FzJuaPVN2FEbPswk+tSSEuVGJpTgj0VCLuag4EQAusRsKywIAAA==
\r
57 Cc: tomi.ollila@iki.fi
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.13
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Sat, 28 Jul 2012 04:29:43 -0000
\r
72 This is version 2 of [0]. It adds some comments explaining handling
\r
73 of NUL bytes in strings and moves a few variable assignments closer to
\r
76 [0] id:1343183693-17134-1-git-send-email-amdragon@mit.edu
\r
78 The diff from version 1 follows. (Note that date was already assigned
\r
79 where it was used in version 1, in addition to being assigned at the
\r
80 beginning of format_message_json; hence the diff diff only shows it
\r
83 diff --git a/notmuch-show.c b/notmuch-show.c
\r
84 index f5bc098..3556293 100644
\r
85 --- a/notmuch-show.c
\r
86 +++ b/notmuch-show.c
\r
87 @@ -105,6 +105,8 @@ _get_one_line_summary (const void *ctx, notmuch_message_t *message)
\r
88 from, relative_date, tags);
\r
91 +/* Emit a sequence of key/value pairs for the metadata of message.
\r
92 + * The caller should begin a map before calling this. */
\r
94 format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
96 @@ -113,9 +115,6 @@ format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
98 const char *relative_date;
\r
100 - date = notmuch_message_get_date (message);
\r
101 - relative_date = notmuch_time_relative_date (local, date);
\r
103 sp->map_key (sp, "id");
\r
104 sp->string (sp, notmuch_message_get_message_id (message));
\r
106 @@ -133,6 +132,7 @@ format_message_json (sprinter_t *sp, notmuch_message_t *message)
\r
107 sp->integer (sp, date);
\r
109 sp->map_key (sp, "date_relative");
\r
110 + relative_date = notmuch_time_relative_date (local, date);
\r
111 sp->string (sp, relative_date);
\r
113 sp->map_key (sp, "tags");
\r
114 diff --git a/sprinter-json.c b/sprinter-json.c
\r
115 index 2587ca6..c9b6835 100644
\r
116 --- a/sprinter-json.c
\r
117 +++ b/sprinter-json.c
\r
118 @@ -88,6 +88,11 @@ json_end (struct sprinter *sp)
\r
119 fputc ('\n', spj->stream);
\r
122 +/* This implementation supports embedded NULs as allowed by the JSON
\r
123 + * specification and Unicode. Support for *parsing* embedded NULs
\r
124 + * varies, but is generally not a problem outside of C-based parsers
\r
125 + * (Python's json module and Emacs' json.el take embedded NULs in
\r
128 json_string_len (struct sprinter *sp, const char *val, size_t len)
\r
130 diff --git a/sprinter.h b/sprinter.h
\r
131 index 826a852..5f43175 100644
\r
134 @@ -23,9 +23,11 @@ typedef struct sprinter {
\r
136 void (*end) (struct sprinter *);
\r
138 - /* Print one string/integer/boolean/null element (possibly inside a
\r
139 - * list or map, followed or preceded by separators).
\r
140 - * For string, the char * must be UTF-8 encoded.
\r
141 + /* Print one string/integer/boolean/null element (possibly inside
\r
142 + * a list or map, followed or preceded by separators). For string
\r
143 + * and string_len, the char * must be UTF-8 encoded. string_len
\r
144 + * allows non-terminated strings and strings with embedded NULs
\r
145 + * (though the handling of the latter is format-dependent).
\r
147 void (*string) (struct sprinter *, const char *);
\r
148 void (*string_len) (struct sprinter *, const char *, size_t);
\r