Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 5c / f3af6e42f3fb7c442ce99540d0d3542520ab24
1 Return-Path: <tomc@caurea.org>\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 839844196F0\r
6         for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 12:00:07 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\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 nXmV+U+-f5wm for <notmuch@notmuchmail.org>;\r
16         Fri, 30 Apr 2010 12:00:06 -0700 (PDT)\r
17 Received: from scotch.caurea.org (ks311007.kimsufi.com [188.165.197.188])\r
18         by olra.theworths.org (Postfix) with ESMTP id 55CAB431FC1\r
19         for <notmuch@notmuchmail.org>; Fri, 30 Apr 2010 12:00:06 -0700 (PDT)\r
20 Received: by scotch.caurea.org (Postfix, from userid 101)\r
21         id B4B69131AB7; Fri, 30 Apr 2010 21:00:26 +0200 (CEST)\r
22 From: Tomas Carnecky <tom@dbservice.com>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [RFC] Add support for the Solaris platform\r
25 Date: Fri, 30 Apr 2010 21:00:24 +0200\r
26 Message-Id: <1272654024-5254-1-git-send-email-tom@dbservice.com>\r
27 X-Mailer: git-send-email 1.7.1\r
28 X-BeenThere: notmuch@notmuchmail.org\r
29 X-Mailman-Version: 2.1.13\r
30 Precedence: list\r
31 List-Id: "Use and development of the notmuch mail system."\r
32         <notmuch.notmuchmail.org>\r
33 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
34         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
35 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
36 List-Post: <mailto:notmuch@notmuchmail.org>\r
37 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
38 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
39         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
40 X-List-Received-Date: Fri, 30 Apr 2010 19:00:07 -0000\r
41 \r
42 Like on Mac OS X, the linker doesn't automatically resolve dependencies.\r
43 \r
44 Signed-off-by: Tomas Carnecky <tom@dbservice.com>\r
45 ---\r
46  Makefile.local     |    2 +-\r
47  configure          |   28 ++++++++++++++------\r
48  lib/Makefile.local |    2 +-\r
49  notmuch-new.c      |   70 ++++++++++++++++++++++++++++++++++++++++++++++------\r
50  4 files changed, 83 insertions(+), 19 deletions(-)\r
51 \r
52 diff --git a/Makefile.local b/Makefile.local\r
53 index 5bb570b..5bc872b 100644\r
54 --- a/Makefile.local\r
55 +++ b/Makefile.local\r
56 @@ -255,7 +255,7 @@ notmuch_client_srcs =               \\r
57  notmuch_client_modules = $(notmuch_client_srcs:.c=.o)\r
58  \r
59  notmuch: $(notmuch_client_modules) lib/libnotmuch.a\r
60 -       $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@\r
61 +       $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_NOTMUCH_LDFLAGS) -o $@\r
62  \r
63  notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)\r
64         $(call quiet,$(FINAL_NOTMUCH_LINKER) $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@\r
65 diff --git a/configure b/configure\r
66 index c522ad8..91e08dd 100755\r
67 --- a/configure\r
68 +++ b/configure\r
69 @@ -257,15 +257,26 @@ else\r
70      have_emacs=0\r
71  fi\r
72  \r
73 -printf "Checking for Mac OS X (for shared library)... "\r
74 +printf "Checking which platform we are on... "\r
75  if [ `uname` = "Darwin" ] ; then\r
76 -    printf "Yes.\n"\r
77 -    mac_os_x=1\r
78 +    printf "Mac OS X.\n"\r
79 +    platform=MACOSX\r
80      linker_resolves_library_dependencies=0\r
81 -else\r
82 -    printf "No.\n"\r
83 -    mac_os_x=0\r
84 +elif [ `uname` = "SunOS" ] ; then\r
85 +    printf "Solaris.\n"\r
86 +    platform=SOLARIS\r
87 +    linker_resolves_library_dependencies=0\r
88 +elif [ `uname` = "Linux" ] ; then\r
89 +    printf "Linux\n"\r
90 +    platform=LINUX\r
91      linker_resolves_library_dependencies=1\r
92 +else\r
93 +    printf "Unknown.\n"\r
94 +    cat <<EOF\r
95 +\r
96 +*** Warning: Unknown platform. Notmuch might or might not build correctly.\r
97 +\r
98 +EOF\r
99  fi\r
100  \r
101  if [ $errors -gt 0 ]; then\r
102 @@ -433,9 +444,8 @@ HAVE_GETLINE = ${have_getline}\r
103  # build its own version)\r
104  HAVE_STRCASESTR = ${have_strcasestr}\r
105  \r
106 -# Whether we are building on OS X.  This will affect how we build the\r
107 -# shared library.\r
108 -MAC_OS_X = ${mac_os_x}\r
109 +# Supported platforms (so far) are: LINUX, MACOSX, SOLARIS\r
110 +PLATFORM = ${platform}\r
111  \r
112  # Whether the linker will automatically resolve the dependency of one\r
113  # library on another (if not, then linking a binary requires linking\r
114 diff --git a/lib/Makefile.local b/lib/Makefile.local\r
115 index 0cc1d39..62f2316 100644\r
116 --- a/lib/Makefile.local\r
117 +++ b/lib/Makefile.local\r
118 @@ -22,7 +22,7 @@ LIBNOTMUCH_VERSION_MINOR = 1\r
119  # simply compatible changes to the implementation).\r
120  LIBNOTMUCH_VERSION_RELEASE = 0\r
121  \r
122 -ifeq ($(MAC_OS_X),1)\r
123 +ifeq ($(PLATFORM),MACOSX)\r
124  LIBRARY_SUFFIX = dylib\r
125  # On OS X, library version numbers go before suffix.\r
126  LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)\r
127 diff --git a/notmuch-new.c b/notmuch-new.c\r
128 index 8818728..aacb5a6 100644\r
129 --- a/notmuch-new.c\r
130 +++ b/notmuch-new.c\r
131 @@ -135,6 +135,62 @@ dirent_sort_strcmp_name (const struct dirent **a, const struct dirent **b)\r
132      return strcmp ((*a)->d_name, (*b)->d_name);\r
133  }\r
134  \r
135 +/* Helper functions to test if a given dirent is of a certain type\r
136 + */\r
137 +static int\r
138 +_is_reg(const char *path, struct dirent *entry)\r
139 +{\r
140 +#ifdef DT_REG\r
141 +    if (entry->d_type == DT_REG)\r
142 +        return 1;\r
143 +#endif\r
144 +\r
145 +    char buffer[PATH_MAX];\r
146 +    snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);\r
147 +\r
148 +    struct stat sbuf;\r
149 +    if (!stat(buffer, &sbuf))\r
150 +        return S_ISREG(sbuf.st_mode);\r
151 +\r
152 +    return 0;\r
153 +}\r
154 +\r
155 +static int\r
156 +_is_dir(const char *path, struct dirent *entry)\r
157 +{\r
158 +#ifdef DT_DIR\r
159 +    if (entry->d_type == DT_DIR)\r
160 +        return 1;\r
161 +#endif\r
162 +\r
163 +    char buffer[PATH_MAX];\r
164 +    snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);\r
165 +\r
166 +    struct stat sbuf;\r
167 +    if (!stat(buffer, &sbuf))\r
168 +        return S_ISDIR(sbuf.st_mode);\r
169 +\r
170 +    return 0;\r
171 +}\r
172 +\r
173 +static int\r
174 +_is_lnk(const char *path, struct dirent *entry)\r
175 +{\r
176 +#ifdef DT_LNK\r
177 +    if (entry->d_type == DT_LNK)\r
178 +        return 1;\r
179 +#endif\r
180 +\r
181 +    char buffer[PATH_MAX];\r
182 +    snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);\r
183 +\r
184 +    struct stat sbuf;\r
185 +    if (!stat(buffer, &sbuf))\r
186 +        return S_ISLNK(sbuf.st_mode);\r
187 +\r
188 +    return 0;\r
189 +}\r
190 +\r
191  /* Test if the directory looks like a Maildir directory.\r
192   *\r
193   * Search through the array of directory entries to see if we can find all\r
194 @@ -143,12 +199,12 @@ dirent_sort_strcmp_name (const struct dirent **a, const struct dirent **b)\r
195   * Return 1 if the directory looks like a Maildir and 0 otherwise.\r
196   */\r
197  static int\r
198 -_entries_resemble_maildir (struct dirent **entries, int count)\r
199 +_entries_resemble_maildir (const char *path, struct dirent **entries, int count)\r
200  {\r
201      int i, found = 0;\r
202  \r
203      for (i = 0; i < count; i++) {\r
204 -       if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)\r
205 +       if (!_is_dir(path, entries[i]))\r
206             continue;\r
207  \r
208         if (strcmp(entries[i]->d_name, "new") == 0 ||\r
209 @@ -261,7 +317,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
210      }\r
211  \r
212      /* Pass 1: Recurse into all sub-directories. */\r
213 -    is_maildir = _entries_resemble_maildir (fs_entries, num_fs_entries);\r
214 +    is_maildir = _entries_resemble_maildir (path, fs_entries, num_fs_entries);\r
215  \r
216      for (i = 0; i < num_fs_entries; i++) {\r
217         if (interrupted)\r
218 @@ -276,9 +332,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
219          * scandir results, then it might be a directory (and if not,\r
220          * then we'll stat and return immediately in the next level of\r
221          * recursion). */\r
222 -       if (entry->d_type != DT_DIR &&\r
223 -           entry->d_type != DT_LNK &&\r
224 -           entry->d_type != DT_UNKNOWN)\r
225 +       if (!_is_dir(path, entry) && !_is_lnk(path, entry))\r
226         {\r
227             continue;\r
228         }\r
229 @@ -356,7 +410,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
230          *\r
231          * In either case, a stat does the trick.\r
232          */\r
233 -       if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {\r
234 +       if (_is_lnk(path, entry)) {\r
235             int err;\r
236  \r
237             next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);\r
238 @@ -372,7 +426,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
239  \r
240             if (! S_ISREG (st.st_mode))\r
241                 continue;\r
242 -       } else if (entry->d_type != DT_REG) {\r
243 +       } else if (!_is_reg(path, entry)) {\r
244             continue;\r
245         }\r
246  \r
247 -- \r
248 1.7.1\r
249 \r