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 C2A69431FBD for ; Sun, 19 Aug 2012 18:53:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled 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 jIgH5m0kamSE for ; Sun, 19 Aug 2012 18:53:14 -0700 (PDT) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id 8CE8E431FC4 for ; Sun, 19 Aug 2012 18:53:08 -0700 (PDT) Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1]) by fire-doxen-postvirus (Postfix) with ESMTP id 2EC072E50B36 for ; Sun, 19 Aug 2012 18:53:06 -0700 (PDT) X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new Received: from finestructure.net (unknown [76.89.192.57]) (Authenticated sender: jrollins) by fire-doxen-submit (Postfix) with ESMTP id 4C793328012 for ; Sun, 19 Aug 2012 18:53:04 -0700 (PDT) Received: by finestructure.net (Postfix, from userid 1000) id CE8AF88B; Sun, 19 Aug 2012 18:53:03 -0700 (PDT) From: Jameson Graef Rollins To: Notmuch Mail Subject: [PATCH 03/11] lib: give _thread_cleanup_author a more generic name Date: Sun, 19 Aug 2012 18:52:42 -0700 Message-Id: <1345427570-26518-4-git-send-email-jrollins@finestructure.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1345427570-26518-3-git-send-email-jrollins@finestructure.net> References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net> <1345427570-26518-2-git-send-email-jrollins@finestructure.net> <1345427570-26518-3-git-send-email-jrollins@finestructure.net> 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: Mon, 20 Aug 2012 01:53:16 -0000 We will use this for cleaning non-author address fields, so we give it the more generic name _thread_cleanup_address. --- lib/thread.cc | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/thread.cc b/lib/thread.cc index 9e0e5cb..b53ccb0 100644 --- a/lib/thread.cc +++ b/lib/thread.cc @@ -242,48 +242,49 @@ _resolve_thread_authors_string (notmuch_thread_t *thread) * "Last, First MI" */ static char * -_thread_cleanup_author (notmuch_thread_t *thread, - const char *author, const char *from) +_thread_cleanup_address (notmuch_thread_t *thread, + const char *address, + const char *original) { - char *clean_author,*test_author; + char *clean_address,*test_address; const char *comma; char *blank; int fname,lname; - if (author == NULL) + if (address == NULL) return NULL; - clean_author = talloc_strdup(thread, author); - if (clean_author == NULL) + clean_address = talloc_strdup(thread, address); + if (clean_address == 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 + * Otherwise just return the copy of the original address name that * we just made*/ - comma = strchr(author,','); + comma = strchr(address,','); 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'; + lname = comma - address; + fname = strlen(address) - lname - 2; + strncpy(clean_address, comma + 2, fname); + *(clean_address+fname) = ' '; + strncpy(clean_address + fname + 1, address, lname); + *(clean_address+fname+1+lname) = '\0'; /* make a temporary copy and see if it matches the email */ - test_author = talloc_strdup(thread,clean_author); + test_address = talloc_strdup(thread,clean_address); - blank=strchr(test_author,' '); + blank=strchr(test_address,' '); while (blank != NULL) { *blank = '.'; - blank=strchr(test_author,' '); + blank=strchr(test_address,' '); } - if (strcasestr(from, test_author) == NULL) + if (strcasestr(original, test_address) == 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); + * so let's punt and return the original address */ + strcpy (clean_address, address); } - return clean_author; + return clean_address; } /* Add 'message' as a message that belongs to 'thread'. -- 1.7.10.4