aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Wolfe Gordon <awg+notmuch@xvx.ca>2013-02-25 15:47:13 -0700
committerGravatar David Bremner <bremner@unb.ca>2013-03-29 09:24:29 -0400
commitf55b35b3df4d8708dfba0e95e33877305fd9f8d9 (patch)
tree43be6b4b8547e99a93d30ede85debf53e0bf95cf /lib
parenta629b2e1cb5be87abf7914730c80620e6a8c1139 (diff)
lib: Fix name reordering to handle commas without spaces
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/thread.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/thread.cc b/lib/thread.cc
index c126aac8..50bdef11 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -190,8 +190,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';