Re: [PATCH 03/11] lib: give _thread_cleanup_author a more generic name
authorAustin Clements <amdragon@MIT.EDU>
Sat, 8 Sep 2012 17:25:14 +0000 (13:25 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:27 +0000 (09:49 -0800)
26/34ac6df63197233bc4112d766187244f592c51 [new file with mode: 0644]

diff --git a/26/34ac6df63197233bc4112d766187244f592c51 b/26/34ac6df63197233bc4112d766187244f592c51
new file mode 100644 (file)
index 0000000..aa809b5
--- /dev/null
@@ -0,0 +1,170 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id AB655431FBF\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Sep 2012 10:25:21 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id L9PdA4g8-Lll for <notmuch@notmuchmail.org>;\r
+       Sat,  8 Sep 2012 10:25:19 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id 61D6F431FC0\r
+       for <notmuch@notmuchmail.org>; Sat,  8 Sep 2012 10:25:16 -0700 (PDT)\r
+X-AuditID: 1209190e-b7f256d000000c6a-61-504b7f7bc471\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id F6.78.03178.B7F7B405; Sat,  8 Sep 2012 13:25:16 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q88HPFQL014468; \r
+       Sat, 8 Sep 2012 13:25:15 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q88HPE9w026436\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sat, 8 Sep 2012 13:25:15 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1TAOmQ-00061x-9K; Sat, 08 Sep 2012 13:25:14 -0400\r
+Date: Sat, 8 Sep 2012 13:25:14 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>\r
+Subject: Re: [PATCH 03/11] lib: give _thread_cleanup_author a more generic\r
+ name\r
+Message-ID: <20120908172514.GA22336@mit.edu>\r
+References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net>\r
+       <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
+       <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
+       <1345427570-26518-4-git-send-email-jrollins@finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1345427570-26518-4-git-send-email-jrollins@finestructure.net>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFvrHIsWRmVeSWpSXmKPExsUixG6noltT7x1gcDfRYs8+L4vrN2cyOzB5\r
+       3D3N5fFs1S3mAKYoLpuU1JzMstQifbsErox1R+4zF7TIVDxYv42tgbFbtIuRk0NCwESic9tJ\r
+       ZghbTOLCvfVsILaQwD5Gif3zuboYuYDs9YwSU+/uYIZwTjBJ3HncyQxRtYRR4nZnbhcjBweL\r
+       gIrE6bUeIGE2AQ2JbfuXM4LYIgJmEj1f/oDZzAJaEls3fgCzhQUCJXrvLWcBsXkFdCTuf5jC\r
+       AjGyl0liyc16iLigxMmZT1hgem/8e8kEsopZQFpi+T8OkDCngLfEpO/tYDeLAl0w5eQ2tgmM\r
+       QrOQdM9C0j0LoXsBI/MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXWO93MwSvdSU0k2MoGDmlOTb\r
+       wfj1oNIhRgEORiUe3g1yXgFCrIllxZW5hxglOZiURHl313gHCPEl5adUZiQWZ8QXleakFh9i\r
+       lOBgVhLhvZ4OlONNSaysSi3Kh0lJc7AoifNeSbnpLySQnliSmp2aWpBaBJOV4eBQkuC1rQNq\r
+       FCxKTU+tSMvMKUFIM3FwggznARpeAFLDW1yQmFucmQ6RP8WoKCXO6w1ykQBIIqM0D64Xlmxe\r
+       MYoDvSIMsYIHmKjgul8BDWYCGizyzANkcEkiQkqqgZF175zCF0wHao67SJT1BrzoPnidn0vw\r
+       4Z9a8aP8kbfatm/w4J8icN70xUtdsd8zviV1SywSWyeXnDv92IoKkzPr58cycvJGN+ZUzaxy\r
+       Ftc5N0V9zQT/ALXI7aHmLv++n6nvylaWD/u8TlLuV9dRXROhyqWqy26fXfT1rrDAD7aehOV7\r
+       Vy2SuqrEUpyRaKjFXFScCABn4DXFEQMAAA==\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 08 Sep 2012 17:25:22 -0000\r
+\r
+Should this patch also rename calls to this function?\r
+\r
+Quoth Jameson Graef Rollins on Aug 19 at  6:52 pm:\r
+> We will use this for cleaning non-author address fields, so we give it\r
+> the more generic name _thread_cleanup_address.\r
+> ---\r
+>  lib/thread.cc |   43 ++++++++++++++++++++++---------------------\r
+>  1 file changed, 22 insertions(+), 21 deletions(-)\r
+> \r
+> diff --git a/lib/thread.cc b/lib/thread.cc\r
+> index 9e0e5cb..b53ccb0 100644\r
+> --- a/lib/thread.cc\r
+> +++ b/lib/thread.cc\r
+> @@ -242,48 +242,49 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)\r
+>   * "Last, First MI" <first.mi.last@company.com>\r
+>   */\r
+>  static char *\r
+> -_thread_cleanup_author (notmuch_thread_t *thread,\r
+> -                    const char *author, const char *from)\r
+> +_thread_cleanup_address (notmuch_thread_t *thread,\r
+> +                     const char *address,\r
+> +                     const char *original)\r
+>  {\r
+> -    char *clean_author,*test_author;\r
+> +    char *clean_address,*test_address;\r
+>      const char *comma;\r
+>      char *blank;\r
+>      int fname,lname;\r
+>  \r
+> -    if (author == NULL)\r
+> +    if (address == NULL)\r
+>      return NULL;\r
+> -    clean_author = talloc_strdup(thread, author);\r
+> -    if (clean_author == NULL)\r
+> +    clean_address = talloc_strdup(thread, address);\r
+> +    if (clean_address == NULL)\r
+>      return NULL;\r
+>      /* check if there's a comma in the name and that there's a\r
+>       * component of the name behind it (so the name doesn't end with\r
+>       * the comma - in which case the string that strchr finds is just\r
+>       * one character long ",\0").\r
+> -     * Otherwise just return the copy of the original author name that\r
+> +     * Otherwise just return the copy of the original address name that\r
+>       * we just made*/\r
+> -    comma = strchr(author,',');\r
+> +    comma = strchr(address,',');\r
+>      if (comma && strlen(comma) > 1) {\r
+>      /* let's assemble what we think is the correct name */\r
+> -    lname = comma - author;\r
+> -    fname = strlen(author) - lname - 2;\r
+> -    strncpy(clean_author, comma + 2, fname);\r
+> -    *(clean_author+fname) = ' ';\r
+> -    strncpy(clean_author + fname + 1, author, lname);\r
+> -    *(clean_author+fname+1+lname) = '\0';\r
+> +    lname = comma - address;\r
+> +    fname = strlen(address) - lname - 2;\r
+> +    strncpy(clean_address, comma + 2, fname);\r
+> +    *(clean_address+fname) = ' ';\r
+> +    strncpy(clean_address + fname + 1, address, lname);\r
+> +    *(clean_address+fname+1+lname) = '\0';\r
+>      /* make a temporary copy and see if it matches the email */\r
+> -    test_author = talloc_strdup(thread,clean_author);\r
+> +    test_address = talloc_strdup(thread,clean_address);\r
+>  \r
+> -    blank=strchr(test_author,' ');\r
+> +    blank=strchr(test_address,' ');\r
+>      while (blank != NULL) {\r
+>          *blank = '.';\r
+> -        blank=strchr(test_author,' ');\r
+> +        blank=strchr(test_address,' ');\r
+>      }\r
+> -    if (strcasestr(from, test_author) == NULL)\r
+> +    if (strcasestr(original, test_address) == NULL)\r
+>          /* we didn't identify this as part of the email address\r
+> -        * so let's punt and return the original author */\r
+> -        strcpy (clean_author, author);\r
+> +        * so let's punt and return the original address */\r
+> +        strcpy (clean_address, address);\r
+>      }\r
+> -    return clean_author;\r
+> +    return clean_address;\r
+>  }\r
+>  \r
+>  /* Add 'message' as a message that belongs to 'thread'.\r
+\r
+-- \r
+Austin Clements                                      MIT/'06/PhD/CSAIL\r
+amdragon@mit.edu                           http://web.mit.edu/amdragon\r
+       Somewhere in the dream we call reality you will find me,\r
+              searching for the reality we call dreams.\r