]> git.cworth.org Git - notmuch/commitdiff
Merge remote branch 'amdragon/search-perf-3'
authorCarl Worth <cworth@cworth.org>
Thu, 10 Mar 2011 19:05:49 +0000 (11:05 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 10 Mar 2011 19:05:49 +0000 (11:05 -0800)
14 files changed:
Makefile
Makefile.local
bindings/go/cmds/notmuch-addrlookup.go
bindings/ruby/.gitignore [new file with mode: 0644]
compat/Makefile.local
completion/Makefile.local
configure
emacs/Makefile.local
lib/Makefile.local
notmuch-search.c
test/json
test/notmuch-test
test/search-insufficient-from-quoting [new file with mode: 0755]
test/test-lib.sh

index 7549b40d171fdde519697e5fe3d67de307ddbf20..4ca74a3ff25a223140d6022fa1d5769393f53bd0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ extra_cxxflags :=
 # Makefile.config if it doesn't exist yet. And add Makefile.config to
 # our global dependency list.
 include Makefile.config
-Makefile.config: configure
+Makefile.config: $(srcdir)/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"
index 38ead11dd8dde9d3e6cba828e4addb8315a38e37..50bba640aa66bbfdce01099ee75ff20d58f6bb6e 100644 (file)
@@ -12,7 +12,7 @@ PACKAGE=notmuch
 
 IS_GIT=$(shell if [ -d .git ] ; then echo yes ; else echo no; fi)
 
-VERSION:=$(shell cat version)
+VERSION:=$(shell cat ${srcdir}/version)
 ifneq ($(MAKECMDGOALS),release)
 ifneq ($(MAKECMDGOALS),release-message)
 ifeq ($(IS_GIT),yes)
@@ -81,7 +81,7 @@ dist: $(TAR_FILE)
 # targets in the case of parallel invocation of make (-j).
 #
 # We carefully ensure that our VERSION variable is passed down to any
-# sub-ordinate make invocations (which won't otherwhise know that they
+# sub-ordinate make invocations (which won't otherwise know that they
 # are part of the release and need to take the version from the
 # version file).
 .PHONY: release
index a72e5301a38aca2b2ca8850f6f3966b7758a6354..16958e502e4e1979ef962908729d7ae222f23cf0 100644 (file)
@@ -11,7 +11,6 @@ import "sort"
 
 // 3rd-party imports
 import "notmuch"
-//import "github.com/jteeuwen/go-pkg-ini/ini"
 import "github.com/kless/goconfig/config"
 
 type mail_addr_freq struct {
@@ -189,7 +188,7 @@ func new_address_matcher() *address_matcher {
        }
 
        if cfg,err = config.ReadDefault(path.Join(home, ".notmuch-config")); err != nil {
-               log.Exitf("error loading config file:",err)
+               log.Fatalf("error loading config file:",err)
        }
 
        db_path,_ := cfg.String("database", "path")
diff --git a/bindings/ruby/.gitignore b/bindings/ruby/.gitignore
new file mode 100644 (file)
index 0000000..fa25752
--- /dev/null
@@ -0,0 +1,6 @@
+# .gitignore for bindings/ruby
+
+# Generated files
+Makefile
+mkmf.log
+notmuch.so
index 653fc710b68022d9596fc2579ec78e2c435e2a2f..504eb7157cc281e8c9c5483ca42637f0740476b4 100644 (file)
@@ -1,7 +1,7 @@
 # -*- makefile -*-
 
 dir := compat
-extra_cflags += -I$(dir)
+extra_cflags += -I$(srcdir)/$(dir)
 
 notmuch_compat_srcs :=
 
index 755b0f7e9ba2d81af4fda1ee7e5cc2022f998c42..dfc12713301dc7891008e0000a3e26db78519557 100644 (file)
@@ -5,8 +5,8 @@ dir := completion
 # The dir variable will be re-assigned to later, so we can't use it
 # directly in any shell commands. Instead we save its value in other,
 # private variables that we can use in the commands.
-bash_script := $(dir)/notmuch-completion.bash
-zsh_script := $(dir)/notmuch-completion.zsh
+bash_script := $(srcdir)/$(dir)/notmuch-completion.bash
+zsh_script := $(srcdir)/$(dir)/notmuch-completion.zsh
 
 install: install-$(dir)
 
index 3d1efb0bf7b84116c1fbdf70c4f3eec9dbf3b201..157ecf39086b08a62fa55760fa964d44ad80574b 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,26 @@
 #! /bin/sh
 
+srcdir=$(dirname "$0")
+
+# For a non-srcdir configure invocation (such as ../configure), create
+# the directory structure and copy Makefiles.
+if [ "$srcdir" != "." ]; then
+
+    for dir in . $(grep "^subdirs *=" "$srcdir"/Makefile | sed -e "s/subdirs *= *//"); do
+       mkdir -p "$dir"
+       cp "$srcdir"/"$dir"/Makefile.local "$dir"
+       cp "$srcdir"/"$dir"/Makefile "$dir"
+    done
+
+    # Easiest way to get the test suite to work is to just copy the
+    # whole thing into the build directory.
+    cp -a "$srcdir"/test/* test
+
+    # Emacs only likes to generate compiled files next to the .el files
+    # by default so copy these as well (which is not ideal0.
+    cp -a "$srcdir"/emacs/*.el emacs
+fi
+
 # Set several defaults (optionally specified by the user in
 # environemnt variables)
 CC=${CC:-gcc}
@@ -424,7 +445,7 @@ EOF
 fi
 
 printf "Checking for getline... "
-if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1
+if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_getline=1
@@ -435,7 +456,7 @@ fi
 rm -f compat/have_getline
 
 printf "Checking for strcasestr... "
-if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
+if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
 then
     printf "Yes.\n"
     have_strcasestr=1
@@ -508,6 +529,24 @@ cat > Makefile.config <<EOF
 # changes, (and this could happen by simply calling "make" if the
 # configure script is updated).
 
+srcdir = ${srcdir}
+
+# We use vpath directives (rather than the VPATH variable) since the
+# VPATH variable matches targets as well as prerequisites, (which is
+# not useful since then a target left-over from a srcdir build would
+# cause a target to not be built in the non-srcdir build).
+#
+# Also, we don't use a single "vpath % \$(srcdir)" here because we
+# don't want the vpath to trigger for our emacs lisp compilation,
+# (unless we first find a way to convince emacs to build the .elc
+# target in a directory other than the directory of the .el
+# prerequisite). In the meantime, we're actually copying in the .el
+# files, (which is quite ugly).
+vpath %.c \$(srcdir)
+vpath %.cc \$(srcdir)
+vpath %.1 \$(srcdir)
+vpath Makefile.% \$(srcdir)
+
 # The C compiler to use
 CC = ${CC}
 
index 1c4166feca88d86164bc088d790685522f7f1062..1c09d87aa8f33c2dd453392c2b7a15a346ae29d2 100644 (file)
@@ -15,9 +15,9 @@ emacs_sources := \
        $(dir)/coolj.el
 
 emacs_images := \
-       $(dir)/notmuch-logo.png
+       $(srcdir)/$(dir)/notmuch-logo.png
 
-emacs_bytecode := $(subst .el,.elc,$(emacs_sources))
+emacs_bytecode = $(emacs_sources:.el=.elc)
 
 %.elc: %.el
        $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
index f4b2c7b9603b383ee8ad39b14d36771f130358ea..d02a515cb7116ac84506508a39089c17412114b3 100644 (file)
@@ -45,7 +45,7 @@ endif
 endif
 
 dir := lib
-extra_cflags += -I$(dir) -fPIC
+extra_cflags += -I$(srcdir)/$(dir) -fPIC
 
 libnotmuch_c_srcs =            \
        $(notmuch_compat_srcs)  \
@@ -85,13 +85,13 @@ install: install-$(dir)
 # but cannot be used reliably within commands, so copy its value to a
 # variable that is not reused.
 lib := $(dir)
-install-$(dir):
+install-$(dir): $(dir)/$(LIBNAME)
        mkdir -p "$(DESTDIR)$(libdir)/"
        install -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
        ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(SONAME)"
        ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(LINKER_NAME)"
        mkdir -p "$(DESTDIR)$(includedir)"
-       install -m0644 "$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
+       install -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
        $(LIBRARY_INSTALL_POST_COMMAND)
 
 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
index a91b23110d240b755064bec12f0b2d28cd8affe0..8b901210ddaab31a4cacd4c4f1a883b80ecb4c8a 100644 (file)
@@ -72,7 +72,7 @@ static const search_format_t format_text = {
                "%s", " ",
            ")", "\n",
        "",
-    "\n",
+    "",
 };
 
 static void
@@ -182,15 +182,15 @@ do_search_threads (const search_format_t *format,
     if (threads == NULL)
        return 1;
 
+    fputs (format->results_start, stdout);
+
     for (;
         notmuch_threads_valid (threads);
         notmuch_threads_move_to_next (threads))
     {
        int first_tag = 1;
 
-       if (first_thread)
-           fputs (format->results_start, stdout);
-       else
+       if (! first_thread)
            fputs (format->item_sep, stdout);
 
        thread = notmuch_threads_get (threads);
@@ -236,8 +236,7 @@ do_search_threads (const search_format_t *format,
        notmuch_thread_destroy (thread);
     }
 
-    if (! first_thread)
-       fputs (format->results_end, stdout);
+    fputs (format->results_end, stdout);
 
     return 0;
 }
@@ -255,15 +254,15 @@ do_search_messages (const search_format_t *format,
     if (messages == NULL)
        return 1;
 
+    fputs (format->results_start, stdout);
+
     for (;
         notmuch_messages_valid (messages);
         notmuch_messages_move_to_next (messages))
     {
        message = notmuch_messages_get (messages);
 
-       if (first_message)
-           fputs (format->results_start, stdout);
-       else
+       if (! first_message)
            fputs (format->item_sep, stdout);
 
        if (output == OUTPUT_FILES) {
@@ -281,8 +280,7 @@ do_search_messages (const search_format_t *format,
 
     notmuch_messages_destroy (messages);
 
-    if (! first_message)
-       fputs (format->results_end, stdout);
+    fputs (format->results_end, stdout);
 
     return 0;
 }
@@ -310,15 +308,15 @@ do_search_tags (notmuch_database_t *notmuch,
     if (tags == NULL)
        return 1;
 
+    fputs (format->results_start, stdout);
+
     for (;
         notmuch_tags_valid (tags);
         notmuch_tags_move_to_next (tags))
     {
        tag = notmuch_tags_get (tags);
 
-       if (first_tag)
-           fputs (format->results_start, stdout);
-       else
+       if (! first_tag)
            fputs (format->item_sep, stdout);
 
        format->item_id (tags, "", tag);
@@ -331,8 +329,7 @@ do_search_tags (notmuch_database_t *notmuch,
     if (messages)
        notmuch_messages_destroy (messages);
 
-    if (! first_tag)
-       fputs (format->results_end, stdout);
+    fputs (format->results_end, stdout);
 
     return 0;
 }
index 7fe2a27a8d6479bfd32c0d03b1c68b23ff7bf26f..307cd1e6c927e3c655b273076c55e5ec436d2d06 100755 (executable)
--- a/test/json
+++ b/test/json
@@ -39,4 +39,8 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",
 \"subject\": \"json-search-utf8-body-sübjéct\",
 \"tags\": [\"inbox\", \"unread\"]}]"
 
+test_begin_subtest "Search returning no messages"
+output=$(notmuch search --format=json "this string had better not match any messages" | notmuch_search_sanitize)
+test_expect_equal "$output" "[]"
+
 test_done
index 9d77c0fa172559e187f4216afceee0e41823a2e8..e3e04476f7bc11f2ffe7809fc784a5949456d8f5 100755 (executable)
@@ -23,6 +23,7 @@ TESTS="
   search-output
   search-by-folder
   search-position-overlap-bug
+  search-insufficient-from-quoting
   json
   thread-naming
   raw
diff --git a/test/search-insufficient-from-quoting b/test/search-insufficient-from-quoting
new file mode 100755 (executable)
index 0000000..6c858a8
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+test_description='messages with unquoted . in name'
+. ./test-lib.sh
+
+add_message \
+  '[from]="Some.Name for Someone <bugs@quoting.com>"' \
+  '[subject]="This message needs more quoting on the From line"'
+
+add_message \
+  '[from]="\"Some.Name for Someone\" <bugs@quoting.com>"' \
+  '[subject]="This message has necessary quoting in place"'
+
+add_message \
+  '[from]="No.match Here <filler@mail.com>"' \
+  '[subject]="This message needs more quoting on the From line"'
+
+add_message \
+  '[from]="\"No.match Here\" <filler@mail.com>"' \
+  '[subject]="This message has necessary quoting in place"'
+
+
+test_begin_subtest "Search by first name"
+output=$(notmuch search from:Some.Name | notmuch_search_sanitize)
+test_expect_equal_failure "$output" "thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message needs more quoting on the From line (inbox unread)
+thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message has necessary quoting in place (inbox unread)"
+
+test_begin_subtest "Search by last name:"
+output=$(notmuch search from:Someone | notmuch_search_sanitize)
+test_expect_equal_failure "$output" "thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message needs more quoting on the From line (inbox unread)
+thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message has necessary quoting in place (inbox unread)"
+
+test_begin_subtest "Search by address:"
+output=$(notmuch search from:bugs@quoting.com | notmuch_search_sanitize)
+test_expect_equal_failure "$output" "thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message needs more quoting on the From line (inbox unread)
+thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message has necessary quoting in place (inbox unread)"
+
+test_begin_subtest "Search for all messages:"
+output=$(notmuch search '*' | notmuch_search_sanitize)
+test_expect_equal_failure "$output" "thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message needs more quoting on the From line (inbox unread)
+thread:XXX   2001-01-05 [1/1] Some.Name for Someone; This message has necessary quoting in place (inbox unread)
+thread:XXX   2001-01-05 [1/1] No.match Here; This message needs more quoting on the From line (inbox unread)
+thread:XXX   2001-01-05 [1/1] No.match Here; This message has necessary quoting in place (inbox unread)"
+
+test_done
index d1794265fd33a0e4893ef9c306bba421effc4702..f53617258ae8bfca73642de89b7d39eadad03354 100755 (executable)
@@ -351,8 +351,11 @@ ${additional_headers}"
 ${additional_headers}"
     fi
 
+    # Note that in the way we're setting it above and using it below,
+    # `additional_headers' will also serve as the header / body separator
+    # (empty line in between).
 
-cat <<EOF >"$gen_msg_filename"
+    cat <<EOF >"$gen_msg_filename"
 From: ${template[from]}
 To: ${template[to]}
 Message-Id: <${gen_msg_id}>