[PATCH] lib: Fix name reordering to handle commas without spaces

Tomi Ollila tomi.ollila at iki.fi
Tue Feb 5 10:08:02 PST 2013


On Thu, Jan 31 2013, Adam Wolfe Gordon <awg+notmuch at xvx.ca> wrote:

> Notmuch automatically re-orders names of the format "Last, First" to
> "First Last" when the associated email address is
> First.Last at 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.

Looks good to me, but should this check any (1-n) amount of whitespace ?

Tomi

> ---
>  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
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list