[PATCH 03/11] lib: give _thread_cleanup_author a more generic name

2012-09-08 Thread Austin Clements
Should this patch also rename calls to this function?

Quoth Jameson Graef Rollins on Aug 19 at  6:52 pm:
> We will use this for cleaning non-author address fields, so we give it
> the more generic name _thread_cleanup_address.
> ---
>  lib/thread.cc |   43 ++-
>  1 file changed, 22 insertions(+), 21 deletions(-)
> 
> diff --git a/lib/thread.cc b/lib/thread.cc
> index 9e0e5cb..b53ccb0 100644
> --- a/lib/thread.cc
> +++ b/lib/thread.cc
> @@ -242,48 +242,49 @@ _resolve_thread_authors_string (notmuch_thread_t 
> *thread)
>   * "Last, First MI" 
>   */
>  static char *
> -_thread_cleanup_author (notmuch_thread_t *thread,
> - const char *author, const char *from)
> +_thread_cleanup_address (notmuch_thread_t *thread,
> +  const char *address,
> +  const char *original)
>  {
> -char *clean_author,*test_author;
> +char *clean_address,*test_address;
>  const char *comma;
>  char *blank;
>  int fname,lname;
>  
> -if (author == NULL)
> +if (address == NULL)
>   return NULL;
> -clean_author = talloc_strdup(thread, author);
> -if (clean_author == NULL)
> +clean_address = talloc_strdup(thread, address);
> +if (clean_address == NULL)
>   return NULL;
>  /* check if there's a comma in the name and that there's a
>   * component of the name behind it (so the name doesn't end with
>   * the comma - in which case the string that strchr finds is just
>   * one character long ",\0").
> - * Otherwise just return the copy of the original author name that
> + * Otherwise just return the copy of the original address name that
>   * we just made*/
> -comma = strchr(author,',');
> +comma = strchr(address,',');
>  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);
> - *(clean_author+fname) = ' ';
> - strncpy(clean_author + fname + 1, author, lname);
> - *(clean_author+fname+1+lname) = '\0';
> + lname = comma - address;
> + fname = strlen(address) - lname - 2;
> + strncpy(clean_address, comma + 2, fname);
> + *(clean_address+fname) = ' ';
> + strncpy(clean_address + fname + 1, address, lname);
> + *(clean_address+fname+1+lname) = '\0';
>   /* make a temporary copy and see if it matches the email */
> - test_author = talloc_strdup(thread,clean_author);
> + test_address = talloc_strdup(thread,clean_address);
>  
> - blank=strchr(test_author,' ');
> + blank=strchr(test_address,' ');
>   while (blank != NULL) {
>   *blank = '.';
> - blank=strchr(test_author,' ');
> + blank=strchr(test_address,' ');
>   }
> - if (strcasestr(from, test_author) == NULL)
> + if (strcasestr(original, test_address) == NULL)
>   /* we didn't identify this as part of the email address
> - * so let's punt and return the original author */
> - strcpy (clean_author, author);
> + * so let's punt and return the original address */
> + strcpy (clean_address, address);
>  }
> -return clean_author;
> +return clean_address;
>  }
>  
>  /* Add 'message' as a message that belongs to 'thread'.

-- 
Austin Clements  MIT/'06/PhD/CSAIL
amdragon at mit.edu   http://web.mit.edu/amdragon
   Somewhere in the dream we call reality you will find me,
  searching for the reality we call dreams.


Re: [PATCH 03/11] lib: give _thread_cleanup_author a more generic name

2012-09-08 Thread Austin Clements
Should this patch also rename calls to this function?

Quoth Jameson Graef Rollins on Aug 19 at  6:52 pm:
> We will use this for cleaning non-author address fields, so we give it
> the more generic name _thread_cleanup_address.
> ---
>  lib/thread.cc |   43 ++-
>  1 file changed, 22 insertions(+), 21 deletions(-)
> 
> diff --git a/lib/thread.cc b/lib/thread.cc
> index 9e0e5cb..b53ccb0 100644
> --- a/lib/thread.cc
> +++ b/lib/thread.cc
> @@ -242,48 +242,49 @@ _resolve_thread_authors_string (notmuch_thread_t 
> *thread)
>   * "Last, First MI" 
>   */
>  static char *
> -_thread_cleanup_author (notmuch_thread_t *thread,
> - const char *author, const char *from)
> +_thread_cleanup_address (notmuch_thread_t *thread,
> +  const char *address,
> +  const char *original)
>  {
> -char *clean_author,*test_author;
> +char *clean_address,*test_address;
>  const char *comma;
>  char *blank;
>  int fname,lname;
>  
> -if (author == NULL)
> +if (address == NULL)
>   return NULL;
> -clean_author = talloc_strdup(thread, author);
> -if (clean_author == NULL)
> +clean_address = talloc_strdup(thread, address);
> +if (clean_address == NULL)
>   return NULL;
>  /* check if there's a comma in the name and that there's a
>   * component of the name behind it (so the name doesn't end with
>   * the comma - in which case the string that strchr finds is just
>   * one character long ",\0").
> - * Otherwise just return the copy of the original author name that
> + * Otherwise just return the copy of the original address name that
>   * we just made*/
> -comma = strchr(author,',');
> +comma = strchr(address,',');
>  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);
> - *(clean_author+fname) = ' ';
> - strncpy(clean_author + fname + 1, author, lname);
> - *(clean_author+fname+1+lname) = '\0';
> + lname = comma - address;
> + fname = strlen(address) - lname - 2;
> + strncpy(clean_address, comma + 2, fname);
> + *(clean_address+fname) = ' ';
> + strncpy(clean_address + fname + 1, address, lname);
> + *(clean_address+fname+1+lname) = '\0';
>   /* make a temporary copy and see if it matches the email */
> - test_author = talloc_strdup(thread,clean_author);
> + test_address = talloc_strdup(thread,clean_address);
>  
> - blank=strchr(test_author,' ');
> + blank=strchr(test_address,' ');
>   while (blank != NULL) {
>   *blank = '.';
> - blank=strchr(test_author,' ');
> + blank=strchr(test_address,' ');
>   }
> - if (strcasestr(from, test_author) == NULL)
> + if (strcasestr(original, test_address) == NULL)
>   /* we didn't identify this as part of the email address
> - * so let's punt and return the original author */
> - strcpy (clean_author, author);
> + * so let's punt and return the original address */
> + strcpy (clean_address, address);
>  }
> -return clean_author;
> +return clean_address;
>  }
>  
>  /* Add 'message' as a message that belongs to 'thread'.

-- 
Austin Clements  MIT/'06/PhD/CSAIL
amdra...@mit.edu   http://web.mit.edu/amdragon
   Somewhere in the dream we call reality you will find me,
  searching for the reality we call dreams.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 03/11] lib: give _thread_cleanup_author a more generic name

2012-08-19 Thread Jameson Graef Rollins
We will use this for cleaning non-author address fields, so we give it
the more generic name _thread_cleanup_address.
---
 lib/thread.cc |   43 ++-
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 9e0e5cb..b53ccb0 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -242,48 +242,49 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)
  * "Last, First MI" 
  */
 static char *
-_thread_cleanup_author (notmuch_thread_t *thread,
-   const char *author, const char *from)
+_thread_cleanup_address (notmuch_thread_t *thread,
+const char *address,
+const char *original)
 {
-char *clean_author,*test_author;
+char *clean_address,*test_address;
 const char *comma;
 char *blank;
 int fname,lname;
 
-if (author == NULL)
+if (address == NULL)
return NULL;
-clean_author = talloc_strdup(thread, author);
-if (clean_author == NULL)
+clean_address = talloc_strdup(thread, address);
+if (clean_address == NULL)
return NULL;
 /* check if there's a comma in the name and that there's a
  * component of the name behind it (so the name doesn't end with
  * the comma - in which case the string that strchr finds is just
  * one character long ",\0").
- * Otherwise just return the copy of the original author name that
+ * Otherwise just return the copy of the original address name that
  * we just made*/
-comma = strchr(author,',');
+comma = strchr(address,',');
 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);
-   *(clean_author+fname) = ' ';
-   strncpy(clean_author + fname + 1, author, lname);
-   *(clean_author+fname+1+lname) = '\0';
+   lname = comma - address;
+   fname = strlen(address) - lname - 2;
+   strncpy(clean_address, comma + 2, fname);
+   *(clean_address+fname) = ' ';
+   strncpy(clean_address + fname + 1, address, lname);
+   *(clean_address+fname+1+lname) = '\0';
/* make a temporary copy and see if it matches the email */
-   test_author = talloc_strdup(thread,clean_author);
+   test_address = talloc_strdup(thread,clean_address);
 
-   blank=strchr(test_author,' ');
+   blank=strchr(test_address,' ');
while (blank != NULL) {
*blank = '.';
-   blank=strchr(test_author,' ');
+   blank=strchr(test_address,' ');
}
-   if (strcasestr(from, test_author) == NULL)
+   if (strcasestr(original, test_address) == NULL)
/* we didn't identify this as part of the email address
-   * so let's punt and return the original author */
-   strcpy (clean_author, author);
+   * so let's punt and return the original address */
+   strcpy (clean_address, address);
 }
-return clean_author;
+return clean_address;
 }
 
 /* Add 'message' as a message that belongs to 'thread'.
-- 
1.7.10.4

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 03/11] lib: give _thread_cleanup_author a more generic name

2012-08-19 Thread Jameson Graef Rollins
We will use this for cleaning non-author address fields, so we give it
the more generic name _thread_cleanup_address.
---
 lib/thread.cc |   43 ++-
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 9e0e5cb..b53ccb0 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -242,48 +242,49 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)
  * "Last, First MI" 
  */
 static char *
-_thread_cleanup_author (notmuch_thread_t *thread,
-   const char *author, const char *from)
+_thread_cleanup_address (notmuch_thread_t *thread,
+const char *address,
+const char *original)
 {
-char *clean_author,*test_author;
+char *clean_address,*test_address;
 const char *comma;
 char *blank;
 int fname,lname;

-if (author == NULL)
+if (address == NULL)
return NULL;
-clean_author = talloc_strdup(thread, author);
-if (clean_author == NULL)
+clean_address = talloc_strdup(thread, address);
+if (clean_address == NULL)
return NULL;
 /* check if there's a comma in the name and that there's a
  * component of the name behind it (so the name doesn't end with
  * the comma - in which case the string that strchr finds is just
  * one character long ",\0").
- * Otherwise just return the copy of the original author name that
+ * Otherwise just return the copy of the original address name that
  * we just made*/
-comma = strchr(author,',');
+comma = strchr(address,',');
 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);
-   *(clean_author+fname) = ' ';
-   strncpy(clean_author + fname + 1, author, lname);
-   *(clean_author+fname+1+lname) = '\0';
+   lname = comma - address;
+   fname = strlen(address) - lname - 2;
+   strncpy(clean_address, comma + 2, fname);
+   *(clean_address+fname) = ' ';
+   strncpy(clean_address + fname + 1, address, lname);
+   *(clean_address+fname+1+lname) = '\0';
/* make a temporary copy and see if it matches the email */
-   test_author = talloc_strdup(thread,clean_author);
+   test_address = talloc_strdup(thread,clean_address);

-   blank=strchr(test_author,' ');
+   blank=strchr(test_address,' ');
while (blank != NULL) {
*blank = '.';
-   blank=strchr(test_author,' ');
+   blank=strchr(test_address,' ');
}
-   if (strcasestr(from, test_author) == NULL)
+   if (strcasestr(original, test_address) == NULL)
/* we didn't identify this as part of the email address
-   * so let's punt and return the original author */
-   strcpy (clean_author, author);
+   * so let's punt and return the original address */
+   strcpy (clean_address, address);
 }
-return clean_author;
+return clean_address;
 }

 /* Add 'message' as a message that belongs to 'thread'.
-- 
1.7.10.4