diff --git a/man/mu-view.1 b/man/mu-view.1 index f7b62387..7d672fb5 100644 --- a/man/mu-view.1 +++ b/man/mu-view.1 @@ -25,10 +25,9 @@ any). instead of displaying the full message, output a summary based upon the first lines of the message. -\fB\-\-separate\fR -add an ascii \\014 (0x0c, or \fIform-feed\fR) between messages when displaying -multiple messages. - +\fB\-\-terminator\fR +terminate messaages with a \\f (\fIform-feed\fR) characters when displaying +them. This is useful when you want to further process them. .SH BUGS diff --git a/src/mu-cmd.c b/src/mu-cmd.c index 89a53197..e873870e 100644 --- a/src/mu-cmd.c +++ b/src/mu-cmd.c @@ -34,7 +34,7 @@ #include "mu-contacts.h" #include "mu-runtime.h" -#define VIEW_SEPARATOR '\f' /* form-feed */ +#define VIEW_TERMINATOR '\f' /* form-feed */ static void @@ -196,8 +196,8 @@ mu_cmd_view (MuConfig *opts) if (rv != MU_EXITCODE_OK) break; /* add a separator between two messages? */ - if (opts->params[i+1] && opts->separate) - g_print ("%c", VIEW_SEPARATOR); + if (opts->terminator) + g_print ("%c", VIEW_TERMINATOR); } return rv; diff --git a/src/mu-config.c b/src/mu-config.c index 4fb9b78f..76d05eaf 100644 --- a/src/mu-config.c +++ b/src/mu-config.c @@ -245,8 +245,8 @@ config_options_group_view (MuConfig *opts) GOptionEntry entries[] = { {"summary", 0, 0, G_OPTION_ARG_NONE, &opts->summary, "only show a short summary of the message (false)", NULL}, - {"separate", 0, 0, G_OPTION_ARG_NONE, &opts->separate, - "separate messages with ascii-0x07 (form-feed)", NULL}, + {"terminate", 0, 0, G_OPTION_ARG_NONE, &opts->terminator, + "terminate messages with ascii-0x07 (\\f, form-feed)", NULL}, {NULL, 0, 0, 0, NULL, NULL, NULL} }; diff --git a/src/mu-config.h b/src/mu-config.h index 361b8b16..ff05fefe 100644 --- a/src/mu-config.h +++ b/src/mu-config.h @@ -108,9 +108,9 @@ struct _MuConfig { * messages */ /* options for view */ - gboolean separate; /* add separator between - * multiple messages in mu - * view */ + gboolean terminator; /* add separator \f between + * multiple messages in mu + * view */ /* output to a maildir with symlinks */ char *linksdir; /* maildir to output symlinks */ diff --git a/src/mu-msg-fields.c b/src/mu-msg-fields.c index 71b12359..072a26b2 100644 --- a/src/mu-msg-fields.c +++ b/src/mu-msg-fields.c @@ -212,7 +212,7 @@ static const MuMsgField FIELD_DATA[] = { MU_MSG_FIELD_TYPE_STRING_LIST, "tag", 'x', 'X', FLAG_GMIME | FLAG_XAPIAN_TERM | FLAG_XAPIAN_PREFIX_ONLY | - FLAG_NORMALIZE + FLAG_NORMALIZE | FLAG_XAPIAN_ESCAPE } }; diff --git a/src/mu-store.cc b/src/mu-store.cc index dc356d94..284efbb7 100644 --- a/src/mu-store.cc +++ b/src/mu-store.cc @@ -407,6 +407,9 @@ add_terms_values_string_list (Xapian::Document& doc, MuMsg *msg, if (mu_msg_field_normalize (mfid)) mu_str_normalize_in_place (val, TRUE); + + if (mu_msg_field_xapian_escape (mfid)) + mu_str_ascii_xapian_escape_in_place (val); doc.add_term (prefix(mfid) + std::string(val, 0, MU_STORE_MAX_TERM_LENGTH)); diff --git a/src/tests/test-mu-cmd.c b/src/tests/test-mu-cmd.c index 4e72def5..762609c1 100644 --- a/src/tests/test-mu-cmd.c +++ b/src/tests/test-mu-cmd.c @@ -115,7 +115,7 @@ test_mu_index (void) store = mu_store_new (xpath, NULL, NULL); g_assert (store); - g_assert_cmpuint (mu_store_count (store), ==, 8); + g_assert_cmpuint (mu_store_count (store), ==, 9); mu_store_destroy (store); g_free (muhome); @@ -498,7 +498,7 @@ test_mu_view_multi_separate (void) tmpdir = test_mu_common_get_random_tmpdir(); g_assert (g_mkdir_with_parents (tmpdir, 0700) == 0); - cmdline = g_strdup_printf ("%s view --separate --muhome=%s " + cmdline = g_strdup_printf ("%s view --terminate --muhome=%s " "%s%cbar%ccur%cmail5 " "%s%cbar%ccur%cmail5", MU_PROGRAM, @@ -517,8 +517,7 @@ test_mu_view_multi_separate (void) len = strlen(output); /* g_print ("\n[%s](%u)\n", output, len); */ - g_assert_cmpuint (len,==,165); - + g_assert_cmpuint (len,==,166); g_free (output); g_free (cmdline); diff --git a/src/tests/test-mu-query.c b/src/tests/test-mu-query.c index 9d97e226..6cfeff3f 100644 --- a/src/tests/test-mu-query.c +++ b/src/tests/test-mu-query.c @@ -87,7 +87,6 @@ run_and_count_matches (const char *xpath, const char *query) MuQuery *mquery; MuMsgIter *iter; guint count1, count2; - GHashTable *hash; mquery = mu_query_new (xpath, NULL); g_assert (query); @@ -107,9 +106,6 @@ run_and_count_matches (const char *xpath, const char *query) mu_query_destroy (mquery); g_assert (iter); - hash = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify)g_free, NULL); - assert_no_dups (iter); /* run query twice, to test mu_msg_iter_reset */ @@ -414,7 +410,7 @@ test_mu_query_attach (void) /* g_print ("(%s)\n", xpath); */ - for (i = 0; i != G_N_ELEMENTS(queries); ++i) + for (i = 0; i != G_N_ELEMENTS(queries); ++i) g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query), ==, queries[i].count); @@ -450,6 +446,36 @@ test_mu_query_tags (void) } +static void +test_mu_query_tags_02 (void) +{ + gchar *xpath; + int i; + + QResults queries[] = { + { "x:paradise", 1}, + { "tag:@NextActions", 1}, + { "x:queensrÿche", 1}, + { "tag:lost OR tag:operation:mindcrime", 2}, + }; + + xpath = fill_database (MU_TESTMAILDIR2); + g_assert (xpath != NULL); + + /* g_print ("(%s)\n", xpath); */ + + for (i = 0; i != G_N_ELEMENTS(queries); ++i) { + /* g_print ("%s\n", queries[i].query); */ + g_assert_cmpuint (run_and_count_matches (xpath, queries[i].query), + ==, queries[i].count); + } + + g_free (xpath); +} + + + + int main (int argc, char *argv[]) { @@ -474,6 +500,8 @@ main (int argc, char *argv[]) test_mu_query_attach); g_test_add_func ("/mu-query/test-mu-query-tags", test_mu_query_tags); + g_test_add_func ("/mu-query/test-mu-query-tags_02", + test_mu_query_tags_02); g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION, diff --git a/src/tests/testdir2/bar/cur/mail6 b/src/tests/testdir2/bar/cur/mail6 new file mode 100644 index 00000000..1d5c1d74 --- /dev/null +++ b/src/tests/testdir2/bar/cur/mail6 @@ -0,0 +1,18 @@ +Date: Thu, 31 Jul 2008 14:57:25 -0400 +From: "Geoff Tate" +Subject: eyes of a stranger +To: "Enrico Fermi" +Message-id: <3BE9E6535E302944823E7A1A20D852173@msg.id> +MIME-version: 1.0 +X-label: @NextActions, operation:mindcrime, Queensrÿche +Content-type: text/plain; charset=us-ascii +Content-transfer-encoding: 7BIT +Precedence: high + +And I raise my head and stare +Into the eyes of a stranger +I've always known that the mirror never lies +People always turn away +From the eyes of a stranger +Afraid to know what +Lies behind the stare