aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar David Bremner <david@tethera.net>2014-06-22 06:53:21 -0300
committerGravatar David Bremner <david@tethera.net>2014-06-22 06:53:21 -0300
commitcc2722ba9e1b2854c5500eb7bb41910478aa8fce (patch)
tree7130e8abf64aae7e133c262c0079ab2afafda9a1
parent9e7bc02530caf94f2eff633129b089d4be26f58a (diff)
parent0c698ef0374b671d3b6a8def2d9c113797ceaec3 (diff)
Merge branch 'release'
Austin's termpos patches and Felipe's zlib.pc workaround
-rw-r--r--compat/.gitignore1
-rw-r--r--compat/gen_zlib_pc.c18
-rwxr-xr-xconfigure9
-rw-r--r--lib/index.cc24
-rw-r--r--lib/message.cc9
-rwxr-xr-xtest/T080-search.sh58
6 files changed, 101 insertions, 18 deletions
diff --git a/compat/.gitignore b/compat/.gitignore
new file mode 100644
index 00000000..107ba17a
--- /dev/null
+++ b/compat/.gitignore
@@ -0,0 +1 @@
+zlib.pc
diff --git a/compat/gen_zlib_pc.c b/compat/gen_zlib_pc.c
new file mode 100644
index 00000000..198a727c
--- /dev/null
+++ b/compat/gen_zlib_pc.c
@@ -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;
+}
diff --git a/configure b/configure
index 9bde2eb7..99ab74dc 100755
--- 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
diff --git a/lib/index.cc b/lib/index.cc
index e1e2a382..1a2e63df 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -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);
}
diff --git a/lib/message.cc b/lib/message.cc
index 9243b769..d0b7351e 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -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;
}
diff --git a/test/T080-search.sh b/test/T080-search.sh
index a7a0b18d..05027fb0 100755
--- a/test/T080-search.sh
+++ b/test/T080-search.sh
@@ -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