diff options
| author | Carl Worth <cworth@cworth.org> | 2009-10-14 13:46:01 -0700 |
|---|---|---|
| committer | Carl Worth <cworth@cworth.org> | 2009-10-14 13:47:18 -0700 |
| commit | 535b14dcba772786541a95db280daf24398aacc5 (patch) | |
| tree | d9a0229c9513ab1f81fddf142921cb355c4151d1 | |
| parent | be72bf30703c5df814d4f572c3d9132d39700b36 (diff) | |
notmuch-index-message: Use local-part of email addres in lieu of name.
If there's no name given, take the portion of the email addres
before the '@' sign.
One step closer to matching sup's terms in the database.
| -rw-r--r-- | notmuch-index-message.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc index 1922dd37..91330658 100644 --- a/notmuch-index-message.cc +++ b/notmuch-index-message.cc @@ -139,11 +139,29 @@ gen_terms_address_name (Xapian::TermGenerator term_gen, const char *prefix_name) { const char *name; + int own_name = 0; name = internet_address_get_name (address); + /* In the absence of a name, we'll strip the part before the @ + * from the address. */ + if (! name) { + InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address); + const char *addr = internet_address_mailbox_get_addr (mailbox); + const char *at; + + at = strchr (addr, '@'); + if (at) { + name = strndup (addr, at - addr); + own_name = 1; + } + } + if (name) gen_terms (term_gen, prefix_name, name); + + if (own_name) + free ((void *) name); } static void |
