Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 83CE7417341 for ; Sat, 5 Jun 2010 04:13:09 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.999 X-Spam-Level: X-Spam-Status: No, score=-1.999 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jnr2Au0Du5Nt for ; Sat, 5 Jun 2010 04:12:56 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) by olra.theworths.org (Postfix) with ESMTP id 9524C4196F0 for ; Sat, 5 Jun 2010 04:12:56 -0700 (PDT) Received: by fxm4 with SMTP id 4so284086fxm.26 for ; Sat, 05 Jun 2010 04:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=6KFUk6efsr41pCVz8d/9dGtyw+zvTodllU9PMNfN6Ns=; b=UrDQ60XjOovuZZaY7DNKWd3aAMWd2EP76bmWV/PDTkv+0DjfdjEny0CssS2WAnz2+9 6qqUfqaD0OuASCf1799RIcS7gHtasCM9NwLcX/rUHbxthzLNX5ZTiPWtffaOvqW06gaD iNYpMUzk0Vg1GPqBXFiWcUrbJIG0YhjnMisNs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Wuid/t8xZr/ofewepp/qZjDZta5UMTkUcCrrmORnyY8aX7QBW1j5XPa+sWGi0awLL/ 5qJH/IU4NufVSqPMr6hyWNL8If6LM87Dun/gFSJs40IMaUr6WqTd5pS25qEBhFDT8g0O //3beL8v9S9whgkAP5pttny9iAR4h9xieAgAg= Received: by 10.204.4.66 with SMTP id 2mr4849213bkq.214.1275736374242; Sat, 05 Jun 2010 04:12:54 -0700 (PDT) Received: from localhost (a91-153-253-80.elisa-laajakaista.fi [91.153.253.80]) by mx.google.com with ESMTPS id v3sm9579053bkz.22.2010.06.05.04.12.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 05 Jun 2010 04:12:53 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Subject: [PATCH 1/9] thread: really clean authors Date: Sat, 5 Jun 2010 14:12:34 +0300 Message-Id: <1275736362-22771-2-git-send-email-felipe.contreras@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1275736362-22771-1-git-send-email-felipe.contreras@gmail.com> References: <1275736362-22771-1-git-send-email-felipe.contreras@gmail.com> Cc: Bart Trojanowski X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jun 2010 11:13:09 -0000 To show the thread, usually 'foo' is enough from "Foo Bar ", specially since the authors field is too small anyway. Gmail does something similar: "Foo (2), John (3)". Signed-off-by: Felipe Contreras --- lib/thread.cc | 38 +++++--------------------------------- 1 files changed, 5 insertions(+), 33 deletions(-) diff --git a/lib/thread.cc b/lib/thread.cc index 13872d4..6a445b5 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -151,44 +151,16 @@ char * _thread_cleanup_author (notmuch_thread_t *thread, const char *author, const char *from) { - char *clean_author,*test_author; - const char *comma; - char *blank; - int fname,lname; + char *clean_author; + const char *begin,*end; if (author == NULL) return NULL; - clean_author = talloc_strdup(thread, author); + begin = strchr (from, '<') + 1; + end = strchr (begin, '>'); + clean_author = talloc_strndup (thread, begin, end - begin); if (clean_author == NULL) return NULL; - /* check if there's a comma in the name and that there's a - * component of the name behind it (so the name doesn't end with - * the comma - in which case the string that strchr finds is just - * one character long ",\0"). - * Otherwise just return the copy of the original author name that - * we just made*/ - comma = strchr(author,','); - if (comma && strlen(comma) > 1) { - /* let's assemble what we think is the correct name */ - lname = comma - author; - fname = strlen(author) - lname - 2; - strncpy(clean_author, comma + 2, fname); - *(clean_author+fname) = ' '; - strncpy(clean_author + fname + 1, author, lname); - *(clean_author+fname+1+lname) = '\0'; - /* make a temporary copy and see if it matches the email */ - test_author = talloc_strdup(thread,clean_author); - - blank=strchr(test_author,' '); - while (blank != NULL) { - *blank = '.'; - blank=strchr(test_author,' '); - } - if (strcasestr(from, test_author) == NULL) - /* we didn't identify this as part of the email address - * so let's punt and return the original author */ - strcpy (clean_author, author); - } return clean_author; } -- 1.7.1