X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Findex.cc;h=7e2da0854aa130b234b8f5e032c2402e840d5602;hp=80df64bfb73a3edbf2ff9819e99c473c3d41f81b;hb=1a38cb841ca4ce87f6b57f9b1baf1a5f8b8e35b7;hpb=2ce25b93a72b4a8d6daa5321f9ef7df0772a789f diff --git a/lib/index.cc b/lib/index.cc index 80df64bf..7e2da085 100644 --- a/lib/index.cc +++ b/lib/index.cc @@ -31,7 +31,7 @@ _index_address_mailbox (notmuch_message_t *message, { InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address); const char *name, *addr; - int own_name = 0; + void *local = talloc_new (message); name = internet_address_get_name (address); addr = internet_address_mailbox_get_addr (mailbox); @@ -42,16 +42,16 @@ _index_address_mailbox (notmuch_message_t *message, const char *at; at = strchr (addr, '@'); - if (at) { - name = strndup (addr, at - addr); - own_name = 1; - } + 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); + + talloc_free (local); } static void @@ -123,60 +123,6 @@ skip_re_in_subject (const char *subject) return s; } -/* Given a string representing the body of a message, generate terms - * for it, (skipping quoted portions and signatures). - * - * This function is evil in that it modifies the string passed to it, - * (changing some newlines into '\0'). - */ -static void -_index_body_text (notmuch_message_t *message, char *body) -{ - char *line, *line_end, *next_line; - - if (body == NULL) - return; - - next_line = body; - - while (1) { - line = next_line; - if (*line == '\0') - break; - - next_line = strchr (line, '\n'); - if (next_line == NULL) { - next_line = line + strlen (line); - } - line_end = next_line - 1; - - /* Get to the next non-blank line. */ - while (*next_line == '\n') - next_line++; - - /* Skip blank lines. */ - if (line_end < line) - continue; - - /* Skip lines that are quotes. */ - if (*line == '>') - continue; - - /* Also skip lines introducing a quote on the next line. */ - if (*line_end == ':' && *next_line == '>') - continue; - - /* Finally, bail as soon as we see a signature. */ - /* XXX: Should only do this if "near" the end of the message. */ - if (strncmp (line, "-- ", 3) == 0) - break; - - *(line_end + 1) = '\0'; - - _notmuch_message_gen_terms (message, NULL, line); - } -} - /* Callback to generate terms for each mime part of a message. */ static void _index_mime_part (notmuch_message_t *message, @@ -249,9 +195,11 @@ _index_mime_part (notmuch_message_t *message, g_byte_array_append (byte_array, (guint8 *) "\0", 1); body = (char *) g_byte_array_free (byte_array, FALSE); - _index_body_text (message, body); + if (body) { + _notmuch_message_gen_terms (message, NULL, body); - free (body); + free (body); + } } notmuch_status_t