]> git.cworth.org Git - notmuch/commitdiff
Merge branch 'release'
authorDavid Bremner <david@tethera.net>
Sun, 22 Jun 2014 09:53:21 +0000 (06:53 -0300)
committerDavid Bremner <david@tethera.net>
Sun, 22 Jun 2014 09:53:21 +0000 (06:53 -0300)
Austin's termpos patches and Felipe's zlib.pc workaround

compat/.gitignore [new file with mode: 0644]
compat/gen_zlib_pc.c [new file with mode: 0644]
configure
lib/index.cc
lib/message.cc
test/T080-search.sh

diff --git a/compat/.gitignore b/compat/.gitignore
new file mode 100644 (file)
index 0000000..107ba17
--- /dev/null
@@ -0,0 +1 @@
+zlib.pc
diff --git a/compat/gen_zlib_pc.c b/compat/gen_zlib_pc.c
new file mode 100644 (file)
index 0000000..198a727
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <zlib.h>
+
+static const char *template =
+       "prefix=/usr\n"
+       "exec_prefix=${prefix}\n"
+       "libdir=${exec_prefix}/lib\n"
+       "\n"
+       "Name: zlib\n"
+       "Description: zlib compression library\n"
+       "Version: %s\n"
+       "Libs: -lz\n";
+
+int main(void)
+{
+       printf(template, ZLIB_VERSION);
+       return 0;
+}
index 9bde2eb72b0e6811505391b0c759a9345f38313a..99ab74dcfb97c515a8c2b96ffd7d75f551652e0c 100755 (executable)
--- a/configure
+++ b/configure
@@ -340,6 +340,15 @@ else
     errors=$((errors + 1))
 fi
 
+if ! pkg-config --exists zlib; then
+  ${CC} ${zlib_cflags} -o compat/gen_zlib_pc \
+         "$srcdir"/compat/gen_zlib_pc.c ${zlib_ldflags} > /dev/null 2>&1 &&
+  compat/gen_zlib_pc > compat/zlib.pc &&
+  PKG_CONFIG_PATH="$PKG_CONFIG_PATH":compat &&
+  export PKG_CONFIG_PATH
+  rm -f compat/gen_zlib_pc
+fi
+
 printf "Checking for zlib (>= 1.2.5.2)... "
 have_zlib=0
 if pkg-config --atleast-version=1.2.5.2 zlib; then
index e1e2a3828f024988d59b8d28d9524a4a0ba99f28..1a2e63df58e45a2f163f7ca61ab6a7740032314a 100644 (file)
@@ -231,26 +231,22 @@ _index_address_mailbox (notmuch_message_t *message,
                        InternetAddress *address)
 {
     InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
-    const char *name, *addr;
+    const char *name, *addr, *combined;
     void *local = talloc_new (message);
 
     name = internet_address_get_name (address);
     addr = internet_address_mailbox_get_addr (mailbox);
 
-    /* In the absence of a name, we'll strip the part before the @
-     * from the address. */
-    if (! name) {
-       const char *at;
+    /* Combine the name and address and index them as a phrase. */
+    if (name && addr)
+       combined = talloc_asprintf (local, "%s %s", name, addr);
+    else if (name)
+       combined = name;
+    else
+       combined = addr;
 
-       at = strchr (addr, '@');
-       if (at)
-           name = talloc_strndup (local, addr, at - addr);
-    }
-
-    if (name)
-       _notmuch_message_gen_terms (message, prefix_name, name);
-    if (addr)
-       _notmuch_message_gen_terms (message, prefix_name, addr);
+    if (combined)
+       _notmuch_message_gen_terms (message, prefix_name, combined);
 
     talloc_free (local);
 }
index 9243b769d2b0b77ffae9858b22e5af8cccf3774d..d0b7351e71796ad2e288a018cbc5ef00ff4fcb67 100644 (file)
@@ -1023,16 +1023,21 @@ _notmuch_message_gen_terms (notmuch_message_t *message,
        return NOTMUCH_PRIVATE_STATUS_NULL_POINTER;
 
     term_gen->set_document (message->doc);
-    term_gen->set_termpos (message->termpos);
 
     if (prefix_name) {
        const char *prefix = _find_prefix (prefix_name);
 
+       term_gen->set_termpos (message->termpos);
        term_gen->index_text (text, 1, prefix);
-       message->termpos = term_gen->get_termpos ();
+       /* Create a gap between this an the next terms so they don't
+        * appear to be a phrase. */
+       message->termpos = term_gen->get_termpos () + 100;
     }
 
+    term_gen->set_termpos (message->termpos);
     term_gen->index_text (text);
+    /* Create a term gap, as above. */
+    message->termpos = term_gen->get_termpos () + 100;
 
     return NOTMUCH_PRIVATE_STATUS_SUCCESS;
 }
index a7a0b18d2e48d21f09890aca61cc63f3eb8bd2f6..05027fb0fee0bfbc7b1548421220e860bef1144d 100755 (executable)
@@ -59,7 +59,15 @@ test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] searchbyfrom@example.
 
 test_begin_subtest "Search by from: (name)"
 add_message '[subject]="search by from (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]="Search By From Name <test@example.com>"'
-output=$(notmuch search from:"Search By From Name" | notmuch_search_sanitize)
+output=$(notmuch search 'from:"Search By From Name"' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
+
+test_begin_subtest "Search by from: (name and address)"
+output=$(notmuch search 'from:"Search By From Name <test@example.com>"' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
+
+test_begin_subtest "Search by from: without prefix (name and address)"
+output=$(notmuch search '"Search By From Name <test@example.com>"' | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
 
 test_begin_subtest "Search by to: (address)"
@@ -69,7 +77,15 @@ test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; s
 
 test_begin_subtest "Search by to: (name)"
 add_message '[subject]="search by to (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[to]="Search By To Name <test@example.com>"'
-output=$(notmuch search to:"Search By To Name" | notmuch_search_sanitize)
+output=$(notmuch search 'to:"Search By To Name"' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
+
+test_begin_subtest "Search by to: (name and adress)"
+output=$(notmuch search 'to:"Search By To Name <test@example.com>"' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
+
+test_begin_subtest "Search by to: without prefix (name and adress)"
+output=$(notmuch search '"Search By To Name <test@example.com>"' | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
 
 test_begin_subtest "Search by subject: (phrase)"
@@ -129,4 +145,42 @@ add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12
 output=$(notmuch search "bödý" | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)"
 
+
+cat <<EOF > ${MAIL_DIR}/termpos
+From: Source <source@example.com>
+To: Dest <dest@example.com>
+Subject: part overlap test
+Date: Sat, 01 January 2000 00:00:00 +0000
+Message-ID: <termpos>
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="==-=="
+
+--==-==
+Content-Type: text/plain
+
+a b c
+
+--==-==
+Content-Type: text/plain
+
+x y z
+
+--==-==--
+EOF
+notmuch new > /dev/null
+
+test_begin_subtest "headers do not have adjacent term positions"
+# Regression test for a bug where term positions for non-prefixed
+# terms weren't updated
+output=$(notmuch search id:termpos and '"com dest"')
+test_expect_equal "$output" ""
+
+test_begin_subtest "parts have non-overlapping term positions"
+output=$(notmuch search id:termpos and '"a y c"')
+test_expect_equal "$output" ""
+
+test_begin_subtest "parts do not have adjacent term positions"
+output=$(notmuch search id:termpos and '"c x"')
+test_expect_equal "$output" ""
+
 test_done