diff options
| author | Carl Worth <cworth@cworth.org> | 2009-10-13 16:09:54 -0700 |
|---|---|---|
| committer | Carl Worth <cworth@cworth.org> | 2009-10-13 21:14:44 -0700 |
| commit | 048b8aec111188385a806c7ebc2930e7b046f8cb (patch) | |
| tree | bf65e66735f1f6358fa1d0ab6e9a129098b90789 | |
| parent | 9dbb1facfb1af5f16b3311a75593693ec04fa6a6 (diff) | |
notmuch-index-message: Don't index quoted lines and signatures.
At this point, we're achieving a result that is *very* close to
what sup does. The only difference is that we are still indexing
the "excerpts from message ..." line, and we are not yet indexing
references.
| -rw-r--r-- | notmuch-index-message.cc | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc index b7a0d3e7..dedbff37 100644 --- a/notmuch-index-message.cc +++ b/notmuch-index-message.cc @@ -198,7 +198,7 @@ gen_terms_body (Xapian::TermGenerator term_gen, GIOChannel *channel; GIOStatus gio_status; GError *error = NULL; - char *body_str; + char *body_line = NULL; channel = g_io_channel_new_file (filename, "r", &error); if (channel == NULL) { @@ -213,16 +213,31 @@ gen_terms_body (Xapian::TermGenerator term_gen, exit (1); } - gio_status = g_io_channel_read_to_end (channel, &body_str, - NULL, &error); - if (gio_status != G_IO_STATUS_NORMAL) { - fprintf (stderr, "Error: %s\n", error->message); - exit (1); + while (1) { + if (body_line) + g_free (body_line); + + gio_status = g_io_channel_read_line (channel, &body_line, + NULL, NULL, &error); + if (gio_status == G_IO_STATUS_EOF) + break; + if (gio_status != G_IO_STATUS_NORMAL) { + fprintf (stderr, "Error: %s\n", error->message); + exit (1); + } + + if (body_line[0] == '>') + continue; + + if (strncmp (body_line, "-- ", 3) == 0) + break; + + gen_terms (term_gen, "body", body_line); } - gen_terms (term_gen, "body", body_str); + if (body_line) + g_free (body_line); - g_free (body_str); g_io_channel_close (channel); } |
