Re: Hi all
[notmuch-archives.git] / 95 / efb4dc7f48c248b0e66ff36f9ad93dde250155
1 Return-Path: <too@guru-group.fi>\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 DFEEC431FC7\r
6         for <notmuch@notmuchmail.org>; Wed, 13 Nov 2013 09:03:14 -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 kQDGE-eCXsEI for <notmuch@notmuchmail.org>;\r
16         Wed, 13 Nov 2013 09:03:09 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 8578A431E62\r
19         for <notmuch@notmuchmail.org>; Wed, 13 Nov 2013 09:02:59 -0800 (PST)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id AAB2F1000E5; Wed, 13 Nov 2013 19:02:50 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH v2 1/5] compact: tidy formatting\r
25 Date: Wed, 13 Nov 2013 19:02:43 +0200\r
26 Message-Id: <1384362167-12740-2-git-send-email-tomi.ollila@iki.fi>\r
27 X-Mailer: git-send-email 1.8.0\r
28 In-Reply-To: <1384362167-12740-1-git-send-email-tomi.ollila@iki.fi>\r
29 References: <1384362167-12740-1-git-send-email-tomi.ollila@iki.fi>\r
30 Cc: tomi.ollila@iki.fi\r
31 X-BeenThere: notmuch@notmuchmail.org\r
32 X-Mailman-Version: 2.1.13\r
33 Precedence: list\r
34 List-Id: "Use and development of the notmuch mail system."\r
35         <notmuch.notmuchmail.org>\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
37         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
39 List-Post: <mailto:notmuch@notmuchmail.org>\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
42         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
43 X-List-Received-Date: Wed, 13 Nov 2013 17:03:15 -0000\r
44 \r
45 Notmuch compact code whitespace changes to match devel/STYLE.\r
46 ---\r
47  lib/database.cc   | 62 ++++++++++++++++++++++++++++---------------------------\r
48  notmuch-compact.c |  4 ++--\r
49  2 files changed, 34 insertions(+), 32 deletions(-)\r
50 \r
51 diff --git a/lib/database.cc b/lib/database.cc\r
52 index a021bf1..3c008d6 100644\r
53 --- a/lib/database.cc\r
54 +++ b/lib/database.cc\r
55 @@ -805,17 +805,19 @@ notmuch_database_close (notmuch_database_t *notmuch)\r
56  }\r
57  \r
58  #if HAVE_XAPIAN_COMPACT\r
59 -static int unlink_cb (const char *path,\r
60 -                     unused (const struct stat *sb),\r
61 -                     unused (int type),\r
62 -                     unused (struct FTW *ftw))\r
63 +static int\r
64 +unlink_cb (const char *path,\r
65 +          unused (const struct stat *sb),\r
66 +          unused (int type),\r
67 +          unused (struct FTW *ftw))\r
68  {\r
69 -    return remove(path);\r
70 +    return remove (path);\r
71  }\r
72  \r
73 -static int rmtree (const char *path)\r
74 +static int\r
75 +rmtree (const char *path)\r
76  {\r
77 -    return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS);\r
78 +    return nftw (path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS);\r
79  }\r
80  \r
81  class NotmuchCompactor : public Xapian::Compactor\r
82 @@ -825,17 +827,17 @@ class NotmuchCompactor : public Xapian::Compactor\r
83  \r
84  public:\r
85      NotmuchCompactor(notmuch_compact_status_cb_t cb, void *closure) :\r
86 -       status_cb(cb), status_closure(closure) { }\r
87 +       status_cb (cb), status_closure (closure) { }\r
88  \r
89      virtual void\r
90      set_status (const std::string &table, const std::string &status)\r
91      {\r
92 -       char* msg;\r
93 +       char *msg;\r
94  \r
95         if (status_cb == NULL)\r
96             return;\r
97  \r
98 -       if (status.length() == 0)\r
99 +       if (status.length () == 0)\r
100             msg = talloc_asprintf (NULL, "compacting table %s", table.c_str());\r
101         else\r
102             msg = talloc_asprintf (NULL, "     %s", status.c_str());\r
103 @@ -844,8 +846,8 @@ public:\r
104             return;\r
105         }\r
106  \r
107 -       status_cb(msg, status_closure);\r
108 -       talloc_free(msg);\r
109 +       status_cb (msg, status_closure);\r
110 +       talloc_free (msg);\r
111      }\r
112  };\r
113  \r
114 @@ -861,8 +863,8 @@ public:\r
115   * compaction process to protect data integrity.\r
116   */\r
117  notmuch_status_t\r
118 -notmuch_database_compact (const char* path,\r
119 -                         const char* backup_path,\r
120 +notmuch_database_compact (const char *path,\r
121 +                         const char *backup_path,\r
122                           notmuch_compact_status_cb_t status_cb,\r
123                           void *closure)\r
124  {\r
125 @@ -876,7 +878,7 @@ notmuch_database_compact (const char* path,\r
126      if (! local)\r
127         return NOTMUCH_STATUS_OUT_OF_MEMORY;\r
128  \r
129 -    ret = notmuch_database_open(path, NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch);\r
130 +    ret = notmuch_database_open (path, NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch);\r
131      if (ret) {\r
132         goto DONE;\r
133      }\r
134 @@ -897,25 +899,25 @@ notmuch_database_compact (const char* path,\r
135      }\r
136  \r
137      if (backup_path != NULL) {\r
138 -       if (stat(backup_path, &statbuf) != -1) {\r
139 +       if (stat (backup_path, &statbuf) != -1) {\r
140             fprintf (stderr, "Backup path already exists: %s\n", backup_path);\r
141             ret = NOTMUCH_STATUS_FILE_ERROR;\r
142             goto DONE;\r
143         }\r
144         if (errno != ENOENT) {\r
145             fprintf (stderr, "Unknown error while stat()ing backup path: %s\n",\r
146 -                    strerror(errno));\r
147 +                    strerror (errno));\r
148             goto DONE;\r
149         }\r
150      }\r
151  \r
152      try {\r
153 -       NotmuchCompactor compactor(status_cb, closure);\r
154 +       NotmuchCompactor compactor (status_cb, closure);\r
155  \r
156 -       compactor.set_renumber(false);\r
157 -       compactor.add_source(xapian_path);\r
158 -       compactor.set_destdir(compact_xapian_path);\r
159 -       compactor.compact();\r
160 +       compactor.set_renumber (false);\r
161 +       compactor.add_source (xapian_path);\r
162 +       compactor.set_destdir (compact_xapian_path);\r
163 +       compactor.compact ();\r
164      } catch (Xapian::InvalidArgumentError e) {\r
165         fprintf (stderr, "Error while compacting: %s\n", e.get_msg().c_str());\r
166         ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;\r
167 @@ -923,33 +925,33 @@ notmuch_database_compact (const char* path,\r
168      }\r
169  \r
170      if (backup_path) {\r
171 -       if (rename(xapian_path, backup_path)) {\r
172 +       if (rename (xapian_path, backup_path)) {\r
173             fprintf (stderr, "Error moving old database out of the way\n");\r
174             ret = NOTMUCH_STATUS_FILE_ERROR;\r
175             goto DONE;\r
176         }\r
177      } else {\r
178 -       rmtree(xapian_path);\r
179 +       rmtree (xapian_path);\r
180      }\r
181  \r
182 -    if (rename(compact_xapian_path, xapian_path)) {\r
183 +    if (rename (compact_xapian_path, xapian_path)) {\r
184         fprintf (stderr, "Error moving compacted database\n");\r
185         ret = NOTMUCH_STATUS_FILE_ERROR;\r
186         goto DONE;\r
187      }\r
188  \r
189 -DONE:\r
190 +  DONE:\r
191      if (notmuch)\r
192         notmuch_database_destroy (notmuch);\r
193  \r
194 -    talloc_free(local);\r
195 +    talloc_free (local);\r
196  \r
197      return ret;\r
198  }\r
199  #else\r
200  notmuch_status_t\r
201 -notmuch_database_compact (unused (const char* path),\r
202 -                         unused (const char* backup_path),\r
203 +notmuch_database_compact (unused (const char *path),\r
204 +                         unused (const char *backup_path),\r
205                           unused (notmuch_compact_status_cb_t status_cb),\r
206                           unused (void *closure))\r
207  {\r
208 @@ -1538,7 +1540,7 @@ _notmuch_database_generate_doc_id (notmuch_database_t *notmuch)\r
209      notmuch->last_doc_id++;\r
210  \r
211      if (notmuch->last_doc_id == 0)\r
212 -       INTERNAL_ERROR ("Xapian document IDs are exhausted.\n");        \r
213 +       INTERNAL_ERROR ("Xapian document IDs are exhausted.\n");\r
214  \r
215      return notmuch->last_doc_id;\r
216  }\r
217 diff --git a/notmuch-compact.c b/notmuch-compact.c\r
218 index 8022dfe..8b820c0 100644\r
219 --- a/notmuch-compact.c\r
220 +++ b/notmuch-compact.c\r
221 @@ -23,7 +23,7 @@\r
222  static void\r
223  status_update_cb (const char *msg, unused (void *closure))\r
224  {\r
225 -    printf("%s\n", msg);\r
226 +    printf ("%s\n", msg);\r
227  }\r
228  \r
229  int\r
230 @@ -49,7 +49,7 @@ notmuch_compact_command (notmuch_config_t *config, int argc, char *argv[])\r
231      ret = notmuch_database_compact (path, backup_path,\r
232                                     quiet ? NULL : status_update_cb, NULL);\r
233      if (ret) {\r
234 -       fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string(ret));\r
235 +       fprintf (stderr, "Compaction failed: %s\n", notmuch_status_to_string (ret));\r
236         return 1;\r
237      }\r
238  \r
239 -- \r
240 1.8.3.1\r
241 \r