From 38eaf1b0e76d79c13d84fde9ee74372b8ab10b76 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Tue, 26 Feb 2013 08:47:56 +0200 Subject: [PATCH] Re: [PATCH v2] lib: Fix name reordering to handle commas without spaces --- 11/7924f7904185af1e5ac426e7118972d868835f | 101 ++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 11/7924f7904185af1e5ac426e7118972d868835f diff --git a/11/7924f7904185af1e5ac426e7118972d868835f b/11/7924f7904185af1e5ac426e7118972d868835f new file mode 100644 index 000000000..2e5fa7ed9 --- /dev/null +++ b/11/7924f7904185af1e5ac426e7118972d868835f @@ -0,0 +1,101 @@ +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 04C19431FB6 + for ; Mon, 25 Feb 2013 22:48:10 -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 kEyIqVH0qCmL for ; + Mon, 25 Feb 2013 22:48:09 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id F3E44431FAF + for ; Mon, 25 Feb 2013 22:48:08 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id A1373100044; + Tue, 26 Feb 2013 08:47:56 +0200 (EET) +From: Tomi Ollila +To: Adam Wolfe Gordon , notmuch@notmuchmail.org +Subject: Re: [PATCH v2] lib: Fix name reordering to handle commas without + spaces +In-Reply-To: <1361832433-13036-1-git-send-email-awg+notmuch@xvx.ca> +References: + <1361832433-13036-1-git-send-email-awg+notmuch@xvx.ca> +User-Agent: Notmuch/0.15.2+45~g5d28a00 (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Tue, 26 Feb 2013 06:48:10 -0000 + +On Tue, Feb 26 2013, Adam Wolfe Gordon wrote: + +> 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". Handle any number of +> spaces after the comma, including none. +> --- +> +> Good idea, Tomi. This version handles any number of spaces. + +LGTM. + +Tomi + +> +> lib/thread.cc | 12 ++++++++++-- +> 1 file changed, 10 insertions(+), 2 deletions(-) +> +> diff --git a/lib/thread.cc b/lib/thread.cc +> index e976d64..ce6b0ef 100644 +> --- a/lib/thread.cc +> +++ b/lib/thread.cc +> @@ -186,8 +186,16 @@ _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); +> + +> + /* Skip all the spaces after the comma */ +> + fname = strlen(author) - lname - 1; +> + comma += 1; +> + while (*comma == ' ') { +> + fname -= 1; +> + comma += 1; +> + } +> + strncpy(clean_author, comma, fname); +> + +> *(clean_author+fname) = ' '; +> strncpy(clean_author + fname + 1, author, lname); +> *(clean_author+fname+1+lname) = '\0'; +> -- +> 1.7.9.5 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2