From: Adam Wolfe Gordon <awg+notmuch@xvx.ca>
To: notmuch@notmuchmail.org
Subject: [PATCH v2] lib: Fix name reordering to handle commas without spaces
Date: Mon, 25 Feb 2013 15:47:13 -0700 [thread overview]
Message-ID: <1361832433-13036-1-git-send-email-awg+notmuch@xvx.ca> (raw)
In-Reply-To: <m238xavdkt.fsf@guru.guru-group.fi>
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.
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
next prev parent reply other threads:[~2013-02-25 22:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-30 23:28 [PATCH] lib: Fix name reordering to handle commas without spaces Adam Wolfe Gordon
2013-02-05 18:08 ` Tomi Ollila
2013-02-25 22:47 ` Adam Wolfe Gordon [this message]
2013-02-26 6:47 ` [PATCH v2] " Tomi Ollila
2013-03-29 14:11 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361832433-13036-1-git-send-email-awg+notmuch@xvx.ca \
--to=awg+notmuch@xvx.ca \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).