[PATCH v2] lib: Fix name reordering to handle commas without spaces
authorAdam Wolfe Gordon <awg+notmuch@xvx.ca>
Mon, 25 Feb 2013 22:47:13 +0000 (15:47 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:45 +0000 (09:53 -0800)
2e/25c5bbc02908174ee9cf610ae5485dc8fc70fb [new file with mode: 0644]

diff --git a/2e/25c5bbc02908174ee9cf610ae5485dc8fc70fb b/2e/25c5bbc02908174ee9cf610ae5485dc8fc70fb
new file mode 100644 (file)
index 0000000..127c6b1
--- /dev/null
@@ -0,0 +1,90 @@
+Return-Path: <awg@lagos.xvx.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 957BB431FB6\r
+       for <notmuch@notmuchmail.org>; Mon, 25 Feb 2013 14:48:52 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 8JL1VGnlOQtl for <notmuch@notmuchmail.org>;\r
+       Mon, 25 Feb 2013 14:48:52 -0800 (PST)\r
+Received: from smtp-out-04.shaw.ca (smtp-out-04.shaw.ca [64.59.134.12])\r
+       by olra.theworths.org (Postfix) with ESMTP id EA1B8431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 25 Feb 2013 14:48:51 -0800 (PST)\r
+X-Cloudmark-SP-Filtered: true\r
+X-Cloudmark-SP-Result: v=1.1 cv=6HkG4LK5i0ZTEQwzSfMqnsQ8WbrxJ2NwB1mI+RNtyjI=\r
+       c=1 sm=1\r
+       a=MY12FBClXswA:10 a=BLceEmwcHowA:10 a=gumk1giGF0obp6xRQyl7Yg==:17\r
+       a=A1X0JdhQAAAA:8 a=m7NE1Zox25VmYJf3OS4A:9 a=9Mll2h4CvCUA:10\r
+       a=Y6qChIQXU1wA:10 a=FHn133utvqvlW6fs:21 a=RDXoABUQQL8Ji2za:21\r
+       a=HpAAvcLHHh0Zw7uRqdWCyQ==:117\r
+Received: from unknown (HELO lagos.xvx.ca) ([68.150.39.45])\r
+       by smtp-out-04.shaw.ca with ESMTP; 25 Feb 2013 15:48:51 -0700\r
+Received: by lagos.xvx.ca (Postfix, from userid 1000)\r
+       id 237E280031A5; Mon, 25 Feb 2013 15:48:51 -0700 (MST)\r
+From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] lib: Fix name reordering to handle commas without spaces\r
+Date: Mon, 25 Feb 2013 15:47:13 -0700\r
+Message-Id: <1361832433-13036-1-git-send-email-awg+notmuch@xvx.ca>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <m238xavdkt.fsf@guru.guru-group.fi>\r
+References: <m238xavdkt.fsf@guru.guru-group.fi>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 25 Feb 2013 22:48:52 -0000\r
+\r
+Notmuch automatically re-orders names of the format "Last, First" to\r
+"First Last" when the associated email address is\r
+First.Last@example.com. But, if a name is of the format "Last,First"\r
+then notmuch will format the name as "irst Last". Handle any number of\r
+spaces after the comma, including none.\r
+---\r
+\r
+Good idea, Tomi. This version handles any number of spaces.\r
+\r
+lib/thread.cc |   12 ++++++++++--\r
+ 1 file changed, 10 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/lib/thread.cc b/lib/thread.cc\r
+index e976d64..ce6b0ef 100644\r
+--- a/lib/thread.cc\r
++++ b/lib/thread.cc\r
+@@ -186,8 +186,16 @@ _thread_cleanup_author (notmuch_thread_t *thread,\r
+     if (comma && strlen(comma) > 1) {\r
+       /* let's assemble what we think is the correct name */\r
+       lname = comma - author;\r
+-      fname = strlen(author) - lname - 2;\r
+-      strncpy(clean_author, comma + 2, fname);\r
++\r
++      /* Skip all the spaces after the comma */\r
++      fname = strlen(author) - lname - 1;\r
++      comma += 1;\r
++      while (*comma == ' ') {\r
++          fname -= 1;\r
++          comma += 1;\r
++      }\r
++      strncpy(clean_author, comma, fname);\r
++\r
+       *(clean_author+fname) = ' ';\r
+       strncpy(clean_author + fname + 1, author, lname);\r
+       *(clean_author+fname+1+lname) = '\0';\r
+-- \r
+1.7.9.5\r
+\r