From d705137b5b3a9a3f6d362a3d9789dcbdeecc1aa1 Mon Sep 17 00:00:00 2001 From: Adam Wolfe Gordon Date: Thu, 31 Jan 2013 16:28:30 +1700 Subject: [PATCH] [PATCH] lib: Fix name reordering to handle commas without spaces --- d0/c25f9dfe1df9ee67b2a78b1a56441825cd667a | 83 +++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 d0/c25f9dfe1df9ee67b2a78b1a56441825cd667a diff --git a/d0/c25f9dfe1df9ee67b2a78b1a56441825cd667a b/d0/c25f9dfe1df9ee67b2a78b1a56441825cd667a new file mode 100644 index 000000000..f106d9a71 --- /dev/null +++ b/d0/c25f9dfe1df9ee67b2a78b1a56441825cd667a @@ -0,0 +1,83 @@ +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 25FCE431FAF + for ; Wed, 30 Jan 2013 15:38:27 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 FAaJzPWGC3t3 for ; + Wed, 30 Jan 2013 15:38:25 -0800 (PST) +X-Greylist: delayed 581 seconds by postgrey-1.32 at olra; + Wed, 30 Jan 2013 15:38:25 PST +Received: from smtp-out-05.shaw.ca (smtp-out-05.shaw.ca [64.59.134.13]) + by olra.theworths.org (Postfix) with ESMTP id CDA7F431FAE + for ; Wed, 30 Jan 2013 15:38:25 -0800 (PST) +X-Cloudmark-SP-Filtered: true +X-Cloudmark-SP-Result: v=1.1 cv=/OolT88hxzZB4/D8S1pLLnpaRVcdzwgG3HupJc0czqk= + c=1 sm=1 + a=flFsAdDc1OsA:10 a=BLceEmwcHowA:10 a=gumk1giGF0obp6xRQyl7Yg==:17 + a=A1X0JdhQAAAA:8 a=m7NE1Zox25VmYJf3OS4A:9 a=9Mll2h4CvCUA:10 + a=Y6qChIQXU1wA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 +Received: from unknown (HELO lagos.xvx.ca) ([68.150.39.45]) + by smtp-out-05.shaw.ca with ESMTP; 30 Jan 2013 16:28:41 -0700 +Received: by lagos.xvx.ca (Postfix, from userid 1000) + id E48B4800214E; Wed, 30 Jan 2013 16:28:37 -0700 (MST) +From: Adam Wolfe Gordon +To: notmuch@notmuchmail.org +Subject: [PATCH] lib: Fix name reordering to handle commas without spaces +Date: Wed, 30 Jan 2013 16:28:30 -0700 +Message-Id: <1359588510-20106-1-git-send-email-awg+notmuch@xvx.ca> +X-Mailer: git-send-email 1.7.9.5 +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: Wed, 30 Jan 2013 23:38:27 -0000 + +Notmuch automatically re-orders names of the format "Last, First" to +"First Last" when the associated email address is +First.Last@example.com. But, if a name is of the format "Last,First" +then notmuch will format the name as "irst Last". Fix this by checking +for a space when doing the reordering. +--- + lib/thread.cc | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/lib/thread.cc b/lib/thread.cc +index e976d64..005b355 100644 +--- a/lib/thread.cc ++++ b/lib/thread.cc +@@ -186,8 +186,13 @@ _thread_cleanup_author (notmuch_thread_t *thread, + 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); ++ if (*(comma + 1) == ' ') { ++ fname = strlen(author) - lname - 2; ++ strncpy(clean_author, comma + 2, fname); ++ } else { ++ fname = strlen(author) - lname - 1; ++ strncpy(clean_author, comma + 1, fname); ++ } + *(clean_author+fname) = ' '; + strncpy(clean_author + fname + 1, author, lname); + *(clean_author+fname+1+lname) = '\0'; +-- +1.7.9.5 + -- 2.26.2