* [PATCH] lib: Fix name reordering to handle commas without spaces
@ 2013-01-30 23:28 Adam Wolfe Gordon
2013-02-05 18:08 ` Tomi Ollila
0 siblings, 1 reply; 5+ messages in thread
From: Adam Wolfe Gordon @ 2013-01-30 23:28 UTC (permalink / raw)
To: notmuch
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". Fix this by checking
for a space when doing the reordering.
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] lib: Fix name reordering to handle commas without spaces
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 ` [PATCH v2] " Adam Wolfe Gordon
0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2013-02-05 18:08 UTC (permalink / raw)
To: Adam Wolfe Gordon, notmuch
On Thu, Jan 31 2013, Adam Wolfe Gordon <awg+notmuch@xvx.ca> 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". 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@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] lib: Fix name reordering to handle commas without spaces
2013-02-05 18:08 ` Tomi Ollila
@ 2013-02-25 22:47 ` Adam Wolfe Gordon
2013-02-26 6:47 ` Tomi Ollila
2013-03-29 14:11 ` David Bremner
0 siblings, 2 replies; 5+ messages in thread
From: Adam Wolfe Gordon @ 2013-02-25 22:47 UTC (permalink / raw)
To: notmuch
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] lib: Fix name reordering to handle commas without spaces
2013-02-25 22:47 ` [PATCH v2] " Adam Wolfe Gordon
@ 2013-02-26 6:47 ` Tomi Ollila
2013-03-29 14:11 ` David Bremner
1 sibling, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2013-02-26 6:47 UTC (permalink / raw)
To: Adam Wolfe Gordon, notmuch
On Tue, Feb 26 2013, Adam Wolfe Gordon <awg+notmuch@xvx.ca> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] lib: Fix name reordering to handle commas without spaces
2013-02-25 22:47 ` [PATCH v2] " Adam Wolfe Gordon
2013-02-26 6:47 ` Tomi Ollila
@ 2013-03-29 14:11 ` David Bremner
1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2013-03-29 14:11 UTC (permalink / raw)
To: Adam Wolfe Gordon, notmuch
Adam Wolfe Gordon <awg+notmuch@xvx.ca> writes:
> 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.
pushed.
d
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-29 14:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2] " Adam Wolfe Gordon
2013-02-26 6:47 ` Tomi Ollila
2013-03-29 14:11 ` David Bremner
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).