Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 97 / b44e47846344b2603c1a8b68048a1898f1ba47
1 Return-Path: <jrollins@finestructure.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id C2A69431FBD\r
6         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:15 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id jIgH5m0kamSE for <notmuch@notmuchmail.org>;\r
16         Sun, 19 Aug 2012 18:53:14 -0700 (PDT)\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
18         [131.215.239.19])\r
19         by olra.theworths.org (Postfix) with ESMTP id 8CE8E431FC4\r
20         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:08 -0700 (PDT)\r
21 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
22         by fire-doxen-postvirus (Postfix) with ESMTP id 2EC072E50B36\r
23         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:06 -0700 (PDT)\r
24 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
25 Received: from finestructure.net (unknown [76.89.192.57])\r
26         (Authenticated sender: jrollins)\r
27         by fire-doxen-submit (Postfix) with ESMTP id 4C793328012\r
28         for <notmuch@notmuchmail.org>; Sun, 19 Aug 2012 18:53:04 -0700 (PDT)\r
29 Received: by finestructure.net (Postfix, from userid 1000)\r
30         id CE8AF88B; Sun, 19 Aug 2012 18:53:03 -0700 (PDT)\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>\r
33 Subject: [PATCH 03/11] lib: give _thread_cleanup_author a more generic name\r
34 Date: Sun, 19 Aug 2012 18:52:42 -0700\r
35 Message-Id: <1345427570-26518-4-git-send-email-jrollins@finestructure.net>\r
36 X-Mailer: git-send-email 1.7.10.4\r
37 In-Reply-To: <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
38 References: <1345427570-26518-1-git-send-email-jrollins@finestructure.net>\r
39         <1345427570-26518-2-git-send-email-jrollins@finestructure.net>\r
40         <1345427570-26518-3-git-send-email-jrollins@finestructure.net>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Mon, 20 Aug 2012 01:53:16 -0000\r
54 \r
55 We will use this for cleaning non-author address fields, so we give it\r
56 the more generic name _thread_cleanup_address.\r
57 ---\r
58  lib/thread.cc |   43 ++++++++++++++++++++++---------------------\r
59  1 file changed, 22 insertions(+), 21 deletions(-)\r
60 \r
61 diff --git a/lib/thread.cc b/lib/thread.cc\r
62 index 9e0e5cb..b53ccb0 100644\r
63 --- a/lib/thread.cc\r
64 +++ b/lib/thread.cc\r
65 @@ -242,48 +242,49 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)\r
66   * "Last, First MI" <first.mi.last@company.com>\r
67   */\r
68  static char *\r
69 -_thread_cleanup_author (notmuch_thread_t *thread,\r
70 -                       const char *author, const char *from)\r
71 +_thread_cleanup_address (notmuch_thread_t *thread,\r
72 +                        const char *address,\r
73 +                        const char *original)\r
74  {\r
75 -    char *clean_author,*test_author;\r
76 +    char *clean_address,*test_address;\r
77      const char *comma;\r
78      char *blank;\r
79      int fname,lname;\r
80  \r
81 -    if (author == NULL)\r
82 +    if (address == NULL)\r
83         return NULL;\r
84 -    clean_author = talloc_strdup(thread, author);\r
85 -    if (clean_author == NULL)\r
86 +    clean_address = talloc_strdup(thread, address);\r
87 +    if (clean_address == NULL)\r
88         return NULL;\r
89      /* check if there's a comma in the name and that there's a\r
90       * component of the name behind it (so the name doesn't end with\r
91       * the comma - in which case the string that strchr finds is just\r
92       * one character long ",\0").\r
93 -     * Otherwise just return the copy of the original author name that\r
94 +     * Otherwise just return the copy of the original address name that\r
95       * we just made*/\r
96 -    comma = strchr(author,',');\r
97 +    comma = strchr(address,',');\r
98      if (comma && strlen(comma) > 1) {\r
99         /* let's assemble what we think is the correct name */\r
100 -       lname = comma - author;\r
101 -       fname = strlen(author) - lname - 2;\r
102 -       strncpy(clean_author, comma + 2, fname);\r
103 -       *(clean_author+fname) = ' ';\r
104 -       strncpy(clean_author + fname + 1, author, lname);\r
105 -       *(clean_author+fname+1+lname) = '\0';\r
106 +       lname = comma - address;\r
107 +       fname = strlen(address) - lname - 2;\r
108 +       strncpy(clean_address, comma + 2, fname);\r
109 +       *(clean_address+fname) = ' ';\r
110 +       strncpy(clean_address + fname + 1, address, lname);\r
111 +       *(clean_address+fname+1+lname) = '\0';\r
112         /* make a temporary copy and see if it matches the email */\r
113 -       test_author = talloc_strdup(thread,clean_author);\r
114 +       test_address = talloc_strdup(thread,clean_address);\r
115  \r
116 -       blank=strchr(test_author,' ');\r
117 +       blank=strchr(test_address,' ');\r
118         while (blank != NULL) {\r
119             *blank = '.';\r
120 -           blank=strchr(test_author,' ');\r
121 +           blank=strchr(test_address,' ');\r
122         }\r
123 -       if (strcasestr(from, test_author) == NULL)\r
124 +       if (strcasestr(original, test_address) == NULL)\r
125             /* we didn't identify this as part of the email address\r
126 -           * so let's punt and return the original author */\r
127 -           strcpy (clean_author, author);\r
128 +           * so let's punt and return the original address */\r
129 +           strcpy (clean_address, address);\r
130      }\r
131 -    return clean_author;\r
132 +    return clean_address;\r
133  }\r
134  \r
135  /* Add 'message' as a message that belongs to 'thread'.\r
136 -- \r
137 1.7.10.4\r
138 \r