]> git.notmuchmail.org Git - notmuch/commitdiff
Merge bugfix for test-suite correctness.
authorCarl Worth <cworth@cworth.org>
Thu, 15 Apr 2010 00:19:42 +0000 (17:19 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 15 Apr 2010 00:19:46 +0000 (17:19 -0700)
The test suite was recently broken, and subsequently fixed (at the
commit that introduced the breakage). This merges that fixup commit:

f1776f8b51013bb66eb21e64c8084ddfe73c3a5c

Makefile
Makefile.local
TODO
compat/Makefile.local
compat/compat.h
compat/have_strcasestr.c [new file with mode: 0644]
compat/strcasestr.c [new file with mode: 0644]
configure
emacs/notmuch.el
lib/Makefile.local

index 076efc79b9532c3e1b80a8ef5b9687456a2fe895..619392d39562aa1f6553e762b91b01106f689061 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,29 @@ all:
 subdirs = compat completion emacs lib
 
 # We make all targets depend on the Makefiles themselves.
-global_deps = Makefile Makefile.local \
+global_deps = Makefile Makefile.config Makefile.local \
        $(subdirs:%=%/Makefile) $(subdirs:%=%/Makefile.local)
 
+# Sub-directory Makefile.local fragments can append to these variables
+# to have directory-specific cflags as necessary.
+
+extra_cflags :=
+extra_cxxflags :=
+
+# Get settings from the output of configure by running it to generate
+# Makefile.config if it doesn't exist yet. And add Makefile.config to
+# our global dependency list.
+include Makefile.config
+Makefile.config: configure
+       @echo ""
+       @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
+       @echo "      but if you want to specify any arguments (such as an alternate prefix"
+       @echo "      into which to install), call ./configure explicitly and then make again."
+       @echo "      See \"./configure --help\" for more details."
+       @echo ""
+       ./configure
+
 # Finally, include all of the Makefile.local fragments where all the
 # real work is done.
-include Makefile.local $(subdirs:%=%/Makefile.local)
+
+include $(subdirs:%=%/Makefile.local) Makefile.local
index 9a1d055bd78822d2d15c3f292eb9ae8379974aed..4a8142f03e6c9810a5d23d046ef5cbac90c74406 100644 (file)
@@ -19,29 +19,13 @@ TAR_FILE=$(PACKAGE)-$(VERSION).tar.gz
 SHA1_FILE=$(TAR_FILE).sha1
 GPG_FILE=$(SHA1_FILE).asc
 
-# Get settings from the output of configure by running it to generate
-# Makefile.config if it doesn't exist yet. And add Makefile.config to
-# our global dependency list.
-include Makefile.config
-global_deps += Makefile.config
-Makefile.config: configure
-       @echo ""
-       @echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
-       @echo "      but if you want to specify any arguments (such as an alternate prefix"
-       @echo "      into which to install), call ./configure explicitly and then make again."
-       @echo "      See \"./configure --help\" for more details."
-       @echo ""
-       ./configure
-
-# Sub-directory Makefile.local fragments can append to these variables
-# to have directory-specific cflags as necessary.
-extra_cflags :=
-extra_cxxflags :=
-
 # Smash together user's values with our extra values
 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags)
 FINAL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(CONFIGURE_CXXFLAGS) $(extra_cflags) $(extra_cxxflags)
 FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Llib -lnotmuch
+ifneq ($(LINKER_RESOLVES_LIBRARY_DEPENDENCIES),1)
+FINAL_NOTMUCH_LDFLAGS += $(CONFIGURE_LDFLAGS)
+endif
 FINAL_LIBNOTMUCH_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS)
 
 .PHONY: all
@@ -193,7 +177,6 @@ clean:
 distclean: clean
 
 notmuch_client_srcs =          \
-       $(notmuch_compat_srcs)  \
        debugger.c              \
        gmime-filter-reply.c    \
        gmime-filter-headers.c  \
@@ -217,10 +200,10 @@ notmuch_client_srcs =             \
 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
 
 notmuch: $(notmuch_client_modules) lib/libnotmuch.a
-       $(call quiet,CC $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
+       $(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
 
-notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
-       $(call quiet,CC $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
+notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
+       $(call quiet,CXX $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
 
 notmuch.1.gz: notmuch.1
        gzip --stdout $^ > $@
diff --git a/TODO b/TODO
index f352faf2b19375d6ff2c94c7df5bb82add858146..85ef2f586e2ffa4cbd21671569043c0cb57a4cd5 100644 (file)
--- a/TODO
+++ b/TODO
@@ -36,6 +36,15 @@ Fix i-search to open up invisible citations as necessary.
 Make '=' count from the end rather than from the beginning if more
 than half-way through the buffer.
 
+Fix to automatically wrap long headers (for RFC compliance) before
+sending. This should probably just be fixed in message-mode itself,
+(but perhaps we can have a notmuch-message-mode that layers this on
+top).
+
+Implement Fcc and use it for all messages, (whether a new composition,
+a reply, or a forward). This again may require a notmuch-message-mode
+that extends message-mode.
+
 Emacs saved-search interface
 ----------------------------
 Here's a proposal Carl wrote (id:87einafy4u.fsf@yoom.home.cworth.org):
@@ -138,6 +147,10 @@ Fix to avoid this ugly message:
   notmuch-generated portion of the warning (so that once GMime is
   fixed, this is all silent).
 
+Simplify notmuch-reply to simply print the headers (we have the
+original values) rather than calling GMime (which encodes) and adding
+the confusing gmime-filter-headers.c code (which decodes).
+
 notmuch library
 ---------------
 Add an interface to accept a "key" and a byte stream, rather than a
index 81e6c707d6ad9f2e1ff2c4a3b14aa9829eaa242f..653fc710b68022d9596fc2579ec78e2c435e2a2f 100644 (file)
@@ -3,8 +3,12 @@
 dir := compat
 extra_cflags += -I$(dir)
 
-notmuch_compat_srcs =
+notmuch_compat_srcs :=
 
 ifneq ($(HAVE_GETLINE),1)
 notmuch_compat_srcs += $(dir)/getline.c $(dir)/getdelim.c
 endif
+
+ifneq ($(HAVE_STRCASESTR),1)
+notmuch_compat_srcs += $(dir)/strcasestr.c
+endif
index d639e0f934cec2b91ebab85574f75490fb8f347f..173ef680ceb8d9d9d67833fcd9db6e10ea4382aa 100644 (file)
@@ -38,4 +38,8 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp);
 
 #endif /* !HAVE_GETLINE */
 
+#if !HAVE_STRCASESTR
+char* strcasestr(const char *haystack, const char *needle);
+#endif /* !HAVE_STRCASESTR */
+
 #endif /* NOTMUCH_COMPAT_H */
diff --git a/compat/have_strcasestr.c b/compat/have_strcasestr.c
new file mode 100644 (file)
index 0000000..c0fb762
--- /dev/null
@@ -0,0 +1,10 @@
+#define _GNU_SOURCE
+#include <strings.h>
+
+int main()
+{
+    char *found;
+    const char *haystack, *needle;
+
+    found = strcasestr(haystack, needle);
+}
diff --git a/compat/strcasestr.c b/compat/strcasestr.c
new file mode 100644 (file)
index 0000000..62a3a54
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * slow simplistic reimplementation of strcasestr for systems that
+ * don't include it in their library
+ *
+ * based on a GPL implementation in OpenTTD found under GPL v2
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation, version 2.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+/* Imported into notmuch by Dirk Hohndel - original author unknown. */
+
+#include <string.h>
+
+#include "compat.h"
+
+char *strcasestr(const char *haystack, const char *needle)
+{
+       size_t hay_len = strlen(haystack);
+       size_t needle_len = strlen(needle);
+       while (hay_len >= needle_len) {
+               if (strncasecmp(haystack, needle, needle_len) == 0)
+                   return (char *) haystack;
+
+               haystack++;
+               hay_len--;
+       }
+
+       return NULL;
+}
index 5af7852379f494379a320043e9ebacb515c24ef2..eebe0751bad9b128d18956de30c34e1948484005 100755 (executable)
--- a/configure
+++ b/configure
@@ -234,6 +234,17 @@ else
     have_emacs=0
 fi
 
+printf "Checking for Mac OS X (for shared library)... "
+if [ `uname` = "Darwin" ] ; then
+    printf "Yes.\n"
+    mac_os_x=1
+    linker_resolves_library_dependencies = 0
+else
+    printf "No.\n"
+    mac_os_x=0
+    linker_resolves_library_dependencies = 1
+fi
+
 if [ $errors -gt 0 ]; then
     cat <<EOF
 
@@ -310,6 +321,17 @@ else
 fi
 rm -f compat/have_getline
 
+printf "Checking for strcasestr... "
+if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
+then
+    printf "Yes.\n"
+    have_strcasestr=1
+else
+    printf "No (will use our own instead).\n"
+    have_strcasestr=0
+fi
+rm -f compat/have_strcasestr
+
 cat <<EOF
 
 All required packages were found. You may now run the following
@@ -384,6 +406,19 @@ zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix
 # build its own version)
 HAVE_GETLINE = ${have_getline}
 
+# Whether the strcasestr function is available (if not, then notmuch will
+# build its own version)
+HAVE_STRCASESTR = ${have_strcasestr}
+
+# Whether we are building on OS X.  This will affect how we build the
+# shared library.
+MAC_OS_X = ${mac_os_x}
+
+# Whether the linker will automatically resolve the dependency of one
+# library on another (if not, then linking a binary requires linking
+# directly against both)
+LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
+
 # Flags needed to compile and link against Xapian
 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
 XAPIAN_LDFLAGS = ${xapian_ldflags}
@@ -405,9 +440,10 @@ VALGRIND_CFLAGS = ${valgrind_cflags}
 # Combined flags for compiling and linking against all of the above
 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
                   \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
-                  \$(VALGRIND_CFLAGS)
+                  \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
                     \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
-                    \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)
+                    \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
+                     -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
 EOF
index 517c53a5d3784a5c2d8362f319b2e436ac640d19..be09f424a953c0686f552b7dd012ef5747b3d01a 100644 (file)
@@ -399,10 +399,11 @@ Complete list of currently available key bindings:
 (defun notmuch-search-properties-in-region (property beg end)
   (save-excursion
     (let ((output nil)
-         (last-line (line-number-at-pos end)))
+         (last-line (line-number-at-pos end))
+         (max-line (- (line-number-at-pos (point-max)) 2)))
       (goto-char beg)
       (beginning-of-line)
-      (while (<= (line-number-at-pos) last-line)
+      (while (<= (line-number-at-pos) (min last-line max-line))
        (setq output (cons (get-text-property (point) property) output))
        (forward-line 1))
       output)))
@@ -497,38 +498,39 @@ and will also appear in a buffer named \"*Notmuch errors*\"."
 (defun notmuch-search-get-tags-region (beg end)
   (save-excursion
     (let ((output nil)
-         (last-line (line-number-at-pos end)))
+         (last-line (line-number-at-pos end))
+         (max-line (- (line-number-at-pos (point-max)) 2)))
       (goto-char beg)
-      (while (<= (line-number-at-pos) last-line)
+      (while (<= (line-number-at-pos) (min last-line max-line))
        (setq output (append output (notmuch-search-get-tags)))
        (forward-line 1))
       output)))
 
 (defun notmuch-search-add-tag-thread (tag)
-  (notmuch-call-notmuch-process "tag" (concat "+" tag) (notmuch-search-find-thread-id))
-  (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))
+  (notmuch-search-add-tag-region tag (point) (point)))
 
 (defun notmuch-search-add-tag-region (tag beg end)
   (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))
     (notmuch-call-notmuch-process "tag" (concat "+" tag) search-id-string)
     (save-excursion
-      (let ((last-line (line-number-at-pos end)))
+      (let ((last-line (line-number-at-pos end))
+           (max-line (- (line-number-at-pos (point-max)) 2)))
        (goto-char beg)
-       (while (<= (line-number-at-pos) last-line)
+       (while (<= (line-number-at-pos) (min last-line max-line))
          (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<)))
          (forward-line))))))
 
 (defun notmuch-search-remove-tag-thread (tag)
-  (notmuch-call-notmuch-process "tag" (concat "-" tag) (notmuch-search-find-thread-id))
-  (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))
+  (notmuch-search-remove-tag-region tag (point) (point)))
 
 (defun notmuch-search-remove-tag-region (tag beg end)
   (let ((search-id-string (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or ")))
     (notmuch-call-notmuch-process "tag" (concat "-" tag) search-id-string)
     (save-excursion
-      (let ((last-line (line-number-at-pos end)))
+      (let ((last-line (line-number-at-pos end))
+           (max-line (- (line-number-at-pos (point-max)) 2)))
        (goto-char beg)
-       (while (<= (line-number-at-pos) last-line)
+       (while (<= (line-number-at-pos) (min last-line max-line))
          (notmuch-search-set-tags (delete tag (notmuch-search-get-tags)))
          (forward-line))))))
 
index 0e3a4d15540c547f5186b33836daa0c89aa55aaf..a0920905cb3bd197020a2e0cb63c9f90d11db905 100644 (file)
@@ -22,14 +22,26 @@ LIBNOTMUCH_VERSION_MINOR = 0
 # simply compatible changes to the implementation).
 LIBNOTMUCH_VERSION_RELEASE = 0
 
-LINKER_NAME = libnotmuch.so
+ifeq ($(MAC_OS_X),1)
+LIBRARY_SUFFIX = dylib
+# On OS X, library version numbers go before suffix.
+LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
+SONAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBRARY_SUFFIX)
+LIBNAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE).$(LIBRARY_SUFFIX)
+LIBRARY_LINK_FLAG = -dynamiclib -install_name $(SONAME) -compatibility_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR) -current_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
+else
+LIBRARY_SUFFIX = so
+LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
 SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
 LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
+LIBRARY_LINK_FLAG = -shared -Wl,-soname=$(SONAME)
+endif
 
 dir := lib
 extra_cflags += -I$(dir) -fPIC
 
 libnotmuch_c_srcs =            \
+       $(notmuch_compat_srcs)  \
        $(dir)/libsha1.c        \
        $(dir)/message-file.c   \
        $(dir)/messages.c       \
@@ -51,7 +63,7 @@ $(dir)/libnotmuch.a: $(libnotmuch_modules)
        $(call quiet,AR) rcs $@ $^
 
 $(dir)/$(LIBNAME): $(libnotmuch_modules)
-       $(call quiet,CXX $(CXXFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -shared -Wl,-soname=$(SONAME) -o $@
+       $(call quiet,CXX $(CXXFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@
 
 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
        ln -sf $(LIBNAME) $@