Re: [PATCH] emacs: poll: return useful errors when poll fails.
[notmuch-archives.git] / 48 / 21c33247378c00bbb4c5db425f2886974acfae
1 Return-Path: <bremner@tethera.net>\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 01AC3431FBF\r
6         for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 07:08:13 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         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 sR+Ca-s+JqAZ for <notmuch@notmuchmail.org>;\r
16         Sat,  8 Dec 2012 07:08:11 -0800 (PST)\r
17 Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238])\r
18         (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 2117F431FAE\r
21         for <notmuch@notmuchmail.org>; Sat,  8 Dec 2012 07:08:11 -0800 (PST)\r
22 Received: from fctnnbsc30w-142167090129.dhcp-dynamic.fibreop.nb.bellaliant.net\r
23         ([142.167.90.129] helo=zancas.localnet)\r
24         by tesseract.cs.unb.ca with esmtpsa\r
25         (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72)\r
26         (envelope-from <bremner@tethera.net>) id 1ThM0f-0005dJ-AC\r
27         for notmuch@notmuchmail.org; Sat, 08 Dec 2012 11:08:10 -0400\r
28 Received: from bremner by zancas.localnet with local (Exim 4.80)\r
29         (envelope-from <bremner@tethera.net>) id 1ThM0Z-0005GY-Nn\r
30         for notmuch@notmuchmail.org; Sat, 08 Dec 2012 11:08:03 -0400\r
31 From: david@tethera.net\r
32 To: notmuch@notmuchmail.org\r
33 Subject: v4 of Hex Dump/Restore patches\r
34 Date: Sat,  8 Dec 2012 11:07:46 -0400\r
35 Message-Id: <1354979276-20099-1-git-send-email-david@tethera.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 X-Spam_bar: -\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Sat, 08 Dec 2012 15:08:13 -0000\r
51 \r
52 This obsoletes the series at\r
53      \r
54      id:1354843607-17980-1-git-send-email-david@tethera.net\r
55 \r
56 One new patch:\r
57 \r
58 [Patch v4 08/10] test/dump-restore: add test for warning/error\r
59 \r
60 Other changes since the last series are as follows:\r
61 \r
62 commit 16ca0f8126fafd49266ffa02534f2e9b73c03027\r
63 Author: David Bremner <bremner@debian.org>\r
64 Date:   Fri Dec 7 20:19:21 2012 -0400\r
65 \r
66     fixup for test/dump-restore\r
67 \r
68 diff --git a/test/dump-restore b/test/dump-restore\r
69 index 2532cbb..b267792 100755\r
70 --- a/test/dump-restore\r
71 +++ b/test/dump-restore\r
72 @@ -212,7 +212,7 @@ test_expect_equal_file EXPECTED OUTPUT\r
73  \r
74  test_begin_subtest 'roundtripping random message-ids and tags'\r
75  \r
76 -    ${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG}\r
77 +    ${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} \\r
78                         --num-messages=100\r
79  \r
80       notmuch dump --format=batch-tag| \\r
81 \r
82 commit 9d864bd724bd2d2b26b5d52e3e2f28b4fff2046f\r
83 Author: David Bremner <bremner@debian.org>\r
84 Date:   Fri Dec 7 20:32:50 2012 -0400\r
85 \r
86     fixup for tag-util.c: put * in right palce\r
87 \r
88 diff --git a/tag-util.h b/tag-util.h\r
89 index df05d72..6674674 100644\r
90 --- a/tag-util.h\r
91 +++ b/tag-util.h\r
92 @@ -62,8 +62,8 @@ parse_tag_line (void *ctx, char *line,\r
93   * ctx is passed to talloc\r
94   */\r
95  \r
96 -tag_op_list_t\r
97 -*tag_op_list_create (void *ctx);\r
98 +tag_op_list_t *\r
99 +tag_op_list_create (void *ctx);\r
100  \r
101  /*\r
102   * Add a tag operation (delete iff remove == TRUE) to a list.\r
103 \r
104 commit d2cead797981e8992849e1d96ad95177b42290e2\r
105 Author: David Bremner <bremner@debian.org>\r
106 Date:   Fri Dec 7 20:57:52 2012 -0400\r
107 \r
108     fixup for id:87txrxxyzp.fsf@nikula.org\r
109 \r
110 diff --git a/tag-util.c b/tag-util.c\r
111 index 3d54e9e..a927363 100644\r
112 --- a/tag-util.c\r
113 +++ b/tag-util.c\r
114 @@ -24,9 +24,15 @@ parse_tag_line (void *ctx, char *line,\r
115  {\r
116      char *tok = line;\r
117      size_t tok_len = 0;\r
118 -    char *line_for_error = talloc_strdup (ctx, line);\r
119 +    char *line_for_error;\r
120      int ret = 0;\r
121  \r
122 +    line_for_error = talloc_strdup (ctx, line);\r
123 +    if (line_for_error == NULL) {\r
124 +       fprintf (stderr, "Error: out of memory\n");\r
125 +       return -1;\r
126 +    }\r
127 +\r
128      chomp_newline (line);\r
129  \r
130      /* remove leading space */\r
131 @@ -58,7 +64,7 @@ parse_tag_line (void *ctx, char *line,\r
132  \r
133         /* If tag is terminated by NUL, there's no query string. */\r
134         if (*(tok + tok_len) == '\0') {\r
135 -           fprintf (stderr, "no query string: %s\n", line_for_error);\r
136 +           fprintf (stderr, "Warning: no query string: %s\n", line_for_error);\r
137             ret = 1;\r
138             goto DONE;\r
139         }\r
140 @@ -71,19 +77,21 @@ parse_tag_line (void *ctx, char *line,\r
141  \r
142         /* Maybe refuse empty tags. */\r
143         if (! (flags & TAG_FLAG_BE_GENEROUS) && *tag == '\0') {\r
144 -           fprintf (stderr, "Error: empty tag: %s\n", line_for_error);\r
145 +           fprintf (stderr, "Warning: empty tag: %s\n", line_for_error);\r
146 +           ret = 1;\r
147             goto DONE;\r
148         }\r
149  \r
150         /* Decode tag. */\r
151         if (hex_decode_inplace (tag) != HEX_SUCCESS) {\r
152 -           fprintf (stderr, "Hex decoding of tag %s failed\n",\r
153 +           fprintf (stderr, "Warning: Hex decoding of tag %s failed\n",\r
154                      tag);\r
155             ret = 1;\r
156             goto DONE;\r
157         }\r
158  \r
159         if (tag_op_list_append (ctx, tag_ops, tag, remove)) {\r
160 +           /* diagnostics already printed */\r
161             ret = -1;\r
162             goto DONE;\r
163         }\r
164 @@ -98,7 +106,7 @@ parse_tag_line (void *ctx, char *line,\r
165  \r
166      /* tok now points to the query string */\r
167      if (hex_decode_inplace (tok) != HEX_SUCCESS) {\r
168 -       fprintf (stderr, "Hex decoding of query %s failed\n",\r
169 +       fprintf (stderr, "Warning: Hex decoding of query %s failed\n",\r
170                  tok);\r
171         ret = 1;\r
172         goto DONE;\r
173 \r
174 commit 162c20ab6d9b9eef56cb2b966a7144a61557eade\r
175 Author: David Bremner <bremner@debian.org>\r
176 Date:   Sat Dec 8 07:29:56 2012 -0400\r
177 \r
178     fixup for id:87624chmfw.fsf@qmul.ac.uk\r
179     \r
180     update comment\r
181 \r
182 diff --git a/util/string-util.h b/util/string-util.h\r
183 index 696da40..ac7676c 100644\r
184 --- a/util/string-util.h\r
185 +++ b/util/string-util.h\r
186 @@ -3,7 +3,10 @@\r
187  \r
188  #include <string.h>\r
189  \r
190 -/* like strtok(3), but without state, and doesn't modify s. usage pattern:\r
191 +/* like strtok(3), but without state, and doesn't modify s.  Return\r
192 + * value is indicated by pointer and length, not null terminator.\r
193 + *\r
194 + * Usage pattern:\r
195   *\r
196   * const char *tok = input;\r
197   * const char *delim = " \t";\r
198 \r
199 commit 590adeec072f235861154b930bfb10bedbe37e8a\r
200 Author: David Bremner <bremner@debian.org>\r
201 Date:   Sat Dec 8 07:42:44 2012 -0400\r
202 \r
203     fixup for id:8738zghl6d.fsf@qmul.ac.uk\r
204 \r
205 diff --git a/tag-util.c b/tag-util.c\r
206 index a927363..c97d240 100644\r
207 --- a/tag-util.c\r
208 +++ b/tag-util.c\r
209 @@ -98,8 +98,6 @@ parse_tag_line (void *ctx, char *line,\r
210      }\r
211  \r
212      if (tok == NULL) {\r
213 -       fprintf (stderr, "Warning: Ignoring invalid input line: %s\n",\r
214 -                line_for_error);\r
215         ret = 1;\r
216         goto DONE;\r
217      }\r
218 @@ -113,7 +111,13 @@ parse_tag_line (void *ctx, char *line,\r
219      }\r
220  \r
221      *query_string = tok;\r
222 +\r
223    DONE:\r
224 +    if (ret != 0)\r
225 +       fprintf (stderr, "% invalid input line %s\n",\r
226 +                ret == 1 ? "Warning: Ignoring" : "Error: Failing at",\r
227 +                line_for_error);\r
228 +\r
229      talloc_free (line_for_error);\r
230      return ret;\r
231  }\r
232 \r
233 commit 6002e08eb048612f5ef4eab3205a2887e1ab3f02\r
234 Author: David Bremner <bremner@debian.org>\r
235 Date:   Sat Dec 8 07:46:39 2012 -0400\r
236 \r
237     fixup: chomp line before copy\r
238 \r
239 diff --git a/tag-util.c b/tag-util.c\r
240 index c97d240..8e6b1ef 100644\r
241 --- a/tag-util.c\r
242 +++ b/tag-util.c\r
243 @@ -27,14 +27,14 @@ parse_tag_line (void *ctx, char *line,\r
244      char *line_for_error;\r
245      int ret = 0;\r
246  \r
247 +    chomp_newline (line);\r
248 +\r
249      line_for_error = talloc_strdup (ctx, line);\r
250      if (line_for_error == NULL) {\r
251         fprintf (stderr, "Error: out of memory\n");\r
252         return -1;\r
253      }\r
254  \r
255 -    chomp_newline (line);\r
256 -\r
257      /* remove leading space */\r
258      while (*tok == ' ' || *tok == '\t')\r
259         tok++;\r
260 \r
261 commit 9c4878bf0ad0e1f60a45c963998a20635fc234af\r
262 Author: David Bremner <bremner@debian.org>\r
263 Date:   Sat Dec 8 08:36:48 2012 -0400\r
264 \r
265     further fixup for error messages\r
266 \r
267 diff --git a/tag-util.c b/tag-util.c\r
268 index 8e6b1ef..6018d49 100644\r
269 --- a/tag-util.c\r
270 +++ b/tag-util.c\r
271 @@ -41,7 +41,7 @@ parse_tag_line (void *ctx, char *line,\r
272  \r
273      /* Skip empty and comment lines. */\r
274      if (*tok == '\0' || *tok == '#') {\r
275 -       ret = 1;\r
276 +       ret = 2;\r
277         goto DONE;\r
278      }\r
279  \r
280 @@ -55,6 +55,8 @@ parse_tag_line (void *ctx, char *line,\r
281         /* Optional explicit end of tags marker. */\r
282         if (tok_len == 2 && strncmp (tok, "--", tok_len) == 0) {\r
283             tok = strtok_len (tok + tok_len, " ", &tok_len);\r
284 +           if (tok == NULL)\r
285 +               fprintf (stderr, "Warning: no query string: %s\n", line_for_error);\r
286             break;\r
287         }\r
288  \r
289 @@ -113,8 +115,8 @@ parse_tag_line (void *ctx, char *line,\r
290      *query_string = tok;\r
291  \r
292    DONE:\r
293 -    if (ret != 0)\r
294 -       fprintf (stderr, "% invalid input line %s\n",\r
295 +    if ((ret % 2) != 0)\r
296 +       fprintf (stderr, "%s invalid input line %s\n",\r
297                  ret == 1 ? "Warning: Ignoring" : "Error: Failing at",\r
298                  line_for_error);\r
299  \r
300 diff --git a/tag-util.h b/tag-util.h\r
301 index 6674674..1d564f0 100644\r
302 --- a/tag-util.h\r
303 +++ b/tag-util.h\r
304 @@ -45,7 +45,10 @@ typedef enum {\r
305   * Leading and trailing space ' ' is ignored. Empty lines and lines\r
306   * beginning with '#' are ignored.\r
307   *\r
308 - * Returns: 0 for OK, 1 for skipped line, -1 for fatal(ish) error.\r
309 + * Returns:    0       OK,\r
310 + *             1       skipped (invalid) line\r
311 + *             2       skipped (valid)\r
312 + *             -1      fatal(ish) error.\r
313   *\r
314   * Output Parameters:\r
315   *     ops     contains a list of tag operations\r
316 \r
317 commit 6e8a7b30e3980f77724d6005292265d49ad5241a\r
318 Author: David Bremner <bremner@debian.org>\r
319 Date:   Sat Dec 8 08:41:01 2012 -0400\r
320 \r
321     fixup for id:87wqwsg46p.fsf@qmul.ac.uk\r
322 \r
323 diff --git a/notmuch-restore.c b/notmuch-restore.c\r
324 index ceec2d3..44bf88d 100644\r
325 --- a/notmuch-restore.c\r
326 +++ b/notmuch-restore.c\r
327 @@ -56,6 +56,11 @@ tag_message (unused (void *ctx),\r
328      return ret;\r
329  }\r
330  \r
331 +/* Sup dump output is one line per message. We match a sequence of\r
332 + * non-space characters for the message-id, then one or more\r
333 + * spaces, then a list of space-separated tags as a sequence of\r
334 + * characters within literal '(' and ')'. */\r
335 +\r
336  static int\r
337  parse_sup_line (void *ctx, char *line,\r
338                 char **query_str, tag_op_list_t *tag_ops)\r
339 @@ -172,11 +177,6 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
340                  argv[opt_index]);\r
341         return 1;\r
342      }\r
343 -\r
344 -    /* Dump output is one line per message. We match a sequence of\r
345 -     * non-space characters for the message-id, then one or more\r
346 -     * spaces, then a list of space-separated tags as a sequence of\r
347 -     * characters within literal '(' and ')'. */\r
348      char *p;\r
349  \r
350      line_len = getline (&line, &line_size, input);\r
351 \r
352 commit ee198b0d388243f0f43fab1d7ef7acbea5bdb3e6\r
353 Author: David Bremner <bremner@debian.org>\r
354 Date:   Sat Dec 8 08:52:51 2012 -0400\r
355 \r
356     fixup: rewrite confusing for loop as while.\r
357 \r
358 diff --git a/tag-util.c b/tag-util.c\r
359 index 6018d49..b68ea50 100644\r
360 --- a/tag-util.c\r
361 +++ b/tag-util.c\r
362 @@ -157,8 +157,10 @@ makes_changes (notmuch_message_t *message,\r
363         const char *cur_tag = notmuch_tags_get (tags);\r
364         int last_op =  (flags & TAG_FLAG_REMOVE_ALL) ? -1 : 0;\r
365  \r
366 -       /* slight contortions to count down with an unsigned index */\r
367 -       for (i = list->count; i-- > 0; /*nothing*/) {\r
368 +       /* scan backwards to get last operation */\r
369 +       i = list->count;\r
370 +       while (i > 0) {\r
371 +           i--;\r
372             if (strcmp (cur_tag, list->ops[i].tag) == 0) {\r
373                 last_op = list->ops[i].remove ? -1 : 1;\r
374                 break;\r