Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 71 / 87593f4d28b80dbb3ef815a43dc383b029d8a1
1 Return-Path: <bremner@pivot.cs.unb.ca>\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 D7208429E2F\r
6         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 11:26:55 -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: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] 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 edrw6pvPP8sx for <notmuch@notmuchmail.org>;\r
16         Wed,  7 Dec 2011 11:26:54 -0800 (PST)\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\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 ED73F429E37\r
21         for <notmuch@notmuchmail.org>; Wed,  7 Dec 2011 11:26:49 -0800 (PST)\r
22 Received: from convex-new.cs.unb.ca ([131.202.13.154])\r
23         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pB7JQhNn021341;\r
24         Wed, 7 Dec 2011 15:26:46 -0400\r
25 Received: from bremner by convex-new.cs.unb.ca with local (Exim 4.72)\r
26         (envelope-from <bremner@pivot.cs.unb.ca>)\r
27         id 1RYN8d-0004Pp-UW; Wed, 07 Dec 2011 15:26:43 -0400\r
28 From: David Bremner <david@tethera.net>\r
29 To: notmuch@notmuchmail.org\r
30 Subject: [PATCH v4 4/5] notmuch-restore: convert to command-line-arguments\r
31 Date: Wed,  7 Dec 2011 15:26:38 -0400\r
32 Message-Id: <1323285999-16870-5-git-send-email-david@tethera.net>\r
33 X-Mailer: git-send-email 1.7.5.4\r
34 In-Reply-To: <1323285999-16870-1-git-send-email-david@tethera.net>\r
35 References: <87iplso9c9.fsf@zancas.localnet>\r
36         <1323285999-16870-1-git-send-email-david@tethera.net>\r
37 Cc: David Bremner <bremner@debian.org>\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: Wed, 07 Dec 2011 19:26:56 -0000\r
51 \r
52 From: David Bremner <bremner@debian.org>\r
53 \r
54 The new argument handling is a bit more concise, and bit more\r
55 flexible.  It allows the input file name to go before the --accumulate\r
56 option.\r
57 ---\r
58  notmuch-restore.c |   37 +++++++++++++++----------------------\r
59  1 files changed, 15 insertions(+), 22 deletions(-)\r
60 \r
61 diff --git a/notmuch-restore.c b/notmuch-restore.c\r
62 index 13b4325..87d9772 100644\r
63 --- a/notmuch-restore.c\r
64 +++ b/notmuch-restore.c\r
65 @@ -18,8 +18,6 @@\r
66   * Author: Carl Worth <cworth@cworth.org>\r
67   */\r
68  \r
69 -#include <getopt.h>\r
70 -\r
71  #include "notmuch-client.h"\r
72  \r
73  int\r
74 @@ -29,12 +27,14 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
75      notmuch_database_t *notmuch;\r
76      notmuch_bool_t synchronize_flags;\r
77      notmuch_bool_t accumulate = FALSE;\r
78 +    char *input_file_name = NULL;\r
79      FILE *input = stdin;\r
80      char *line = NULL;\r
81      size_t line_size;\r
82      ssize_t line_len;\r
83      regex_t regex;\r
84      int rerr;\r
85 +    int opt_index;\r
86  \r
87      config = notmuch_config_open (ctx, NULL, NULL);\r
88      if (config == NULL)\r
89 @@ -47,37 +47,30 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])\r
90  \r
91      synchronize_flags = notmuch_config_get_maildir_synchronize_flags (config);\r
92  \r
93 -    struct option options[] = {\r
94 -       { "accumulate",   no_argument,       0, 'a' },\r
95 -       { 0, 0, 0, 0}\r
96 +    notmuch_opt_desc_t options[] = {\r
97 +       { NOTMUCH_OPT_POSITION, &input_file_name, 0, 0, 0 },\r
98 +       { NOTMUCH_OPT_BOOLEAN,  &accumulate, "accumulate", 'a', 0 },\r
99 +       { 0, 0, 0, 0, 0 }\r
100      };\r
101  \r
102 -    int opt;\r
103 -    do {\r
104 -       opt = getopt_long (argc, argv, "", options, NULL);\r
105 -\r
106 -       switch (opt) {\r
107 -       case 'a':\r
108 -           accumulate = 1;\r
109 -           break;\r
110 -       case '?':\r
111 -           return 1;\r
112 -           break;\r
113 -       }\r
114 +    opt_index = parse_arguments (argc, argv, options, 1);\r
115  \r
116 -    } while (opt != -1);\r
117 +    if (opt_index < 0) {\r
118 +       /* diagnostics already printed */\r
119 +       return 1;\r
120 +    }\r
121  \r
122 -    if (optind < argc) {\r
123 -       input = fopen (argv[optind], "r");\r
124 +    if (input_file_name) {\r
125 +       input = fopen (input_file_name, "r");\r
126         if (input == NULL) {\r
127             fprintf (stderr, "Error opening %s for reading: %s\n",\r
128 -                    argv[optind], strerror (errno));\r
129 +                    input_file_name, strerror (errno));\r
130             return 1;\r
131         }\r
132         optind++;\r
133      }\r
134  \r
135 -    if (optind < argc) {\r
136 +    if (opt_index < argc) {\r
137         fprintf (stderr,\r
138          "Cannot read dump from more than one file: %s\n",\r
139                  argv[optind]);\r
140 -- \r
141 1.7.5.4\r
142 \r