Re: [PATCH 1/2] Add Google Inc. to AUTHORS as a contributor.
[notmuch-archives.git] / 54 / 96fef7b6abe11a5cfb0e70f867d79fbc5d5f63
1 Return-Path: <jani@nikula.org>\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 arlo.cworth.org (Postfix) with ESMTP id 218AB6DE1B56\r
6  for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 12:40:35 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.424\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.424 tagged_above=-999 required=5 tests=[AWL=0.296,\r
13   RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01]\r
14  autolearn=disabled\r
15 Received: from arlo.cworth.org ([127.0.0.1])\r
16  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
17  with ESMTP id oVAmmC1pzGg2 for <notmuch@notmuchmail.org>;\r
18  Thu,  3 Sep 2015 12:40:33 -0700 (PDT)\r
19 Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
20  [209.85.212.175])\r
21  by arlo.cworth.org (Postfix) with ESMTPS id 48C726DE15D4\r
22  for <notmuch@notmuchmail.org>; Thu,  3 Sep 2015 12:40:25 -0700 (PDT)\r
23 Received: by wicfx3 with SMTP id fx3so1166855wic.1\r
24  for <notmuch@notmuchmail.org>; Thu, 03 Sep 2015 12:40:23 -0700 (PDT)\r
25 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26  d=1e100.net; s=20130820;\r
27  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
28  :references:in-reply-to:references;\r
29  bh=VFHDC72I5GoT6PKzmB1izsWZDFNqN7WikG58dF2ZAyA=;\r
30  b=Ps+CaFqXd/i7ebRBM5SrMy4r3HhVaYRuOtHYp0YnFjYZqBtwynuf/NQ20cnylJ2dFJ\r
31  LDLNC4dCQ/Dq3DTifXnGRU6ReRza1NOHXzcZ4DPFlsjKgtJXmUT+LzUG6vrgutyRuwvN\r
32  9+ARdBljQwKDy2ro585EOEBf4oa0qD0fpZCmrTqnFPCxg89FDIp5KtDCgIyZ0HlkCFcH\r
33  WUAAkWhBdwRq6gTmLUWY6CG1Ag5CSHHy8XMBarmR9khweimDf51wyD+I0IJ+F08D9mUe\r
34  ugmX/+Dvw1KqhtD3ToQyfaLuPgcL0GfvaIQeRsF4LKEdHdd7LLEWuyZmoqI1Q2vQ6lRF\r
35  HQRA==\r
36 X-Gm-Message-State:\r
37  ALoCoQnctlhEIgLHVm97wQbCXg5hYPxqWgUS+ii01EMGL8dA2PepdsayrlJXQ2drPpi7dH0hUow8\r
38 X-Received: by 10.180.87.71 with SMTP id v7mr17872859wiz.74.1441309223852;\r
39  Thu, 03 Sep 2015 12:40:23 -0700 (PDT)\r
40 Received: from localhost (mobile-access-bcee4f-131.dhcp.inet.fi.\r
41  [188.238.79.131])\r
42  by smtp.gmail.com with ESMTPSA id eu2sm639314wic.8.2015.09.03.12.40.23\r
43  (version=TLSv1/SSLv3 cipher=OTHER);\r
44  Thu, 03 Sep 2015 12:40:23 -0700 (PDT)\r
45 From: Jani Nikula <jani@nikula.org>\r
46 To: notmuch@notmuchmail.org\r
47 Subject: [PATCH v2 5/9] util: move strcase_equal and strcase_hash to util\r
48 Date: Thu,  3 Sep 2015 22:40:01 +0300\r
49 Message-Id:\r
50  <37a90b2c8ac540599daf0e864b2a6b65b4ee35a3.1441308761.git.jani@nikula.org>\r
51 X-Mailer: git-send-email 2.1.4\r
52 In-Reply-To: <cover.1441308761.git.jani@nikula.org>\r
53 References: <cover.1441308761.git.jani@nikula.org>\r
54 In-Reply-To: <cover.1441308761.git.jani@nikula.org>\r
55 References: <cover.1441308761.git.jani@nikula.org>\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.18\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60  <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Thu, 03 Sep 2015 19:40:35 -0000\r
69 \r
70 For future use in both cli and lib.\r
71 ---\r
72  lib/message-file.c    | 21 ---------------------\r
73  lib/notmuch-private.h |  1 +\r
74  util/string-util.c    | 21 +++++++++++++++++++++\r
75  util/string-util.h    |  6 ++++++\r
76  4 files changed, 28 insertions(+), 21 deletions(-)\r
77 \r
78 diff --git a/lib/message-file.c b/lib/message-file.c\r
79 index 8ac96e8e06a5..ee305202fffa 100644\r
80 --- a/lib/message-file.c\r
81 +++ b/lib/message-file.c\r
82 @@ -38,27 +38,6 @@ struct _notmuch_message_file {\r
83  };\r
84  \r
85  static int\r
86 -strcase_equal (const void *a, const void *b)\r
87 -{\r
88 -    return strcasecmp (a, b) == 0;\r
89 -}\r
90 -\r
91 -static unsigned int\r
92 -strcase_hash (const void *ptr)\r
93 -{\r
94 -    const char *s = ptr;\r
95 -\r
96 -    /* This is the djb2 hash. */\r
97 -    unsigned int hash = 5381;\r
98 -    while (s && *s) {\r
99 -       hash = ((hash << 5) + hash) + tolower (*s);\r
100 -       s++;\r
101 -    }\r
102 -\r
103 -    return hash;\r
104 -}\r
105 -\r
106 -static int\r
107  _notmuch_message_file_destructor (notmuch_message_file_t *message)\r
108  {\r
109      if (message->headers)\r
110 diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
111 index f52b4e4776f9..5dd4770e9619 100644\r
112 --- a/lib/notmuch-private.h\r
113 +++ b/lib/notmuch-private.h\r
114 @@ -50,6 +50,7 @@ NOTMUCH_BEGIN_DECLS\r
115  \r
116  #include "xutil.h"\r
117  #include "error_util.h"\r
118 +#include "string-util.h"\r
119  \r
120  #pragma GCC visibility push(hidden)\r
121  \r
122 diff --git a/util/string-util.c b/util/string-util.c\r
123 index a90501ee3e70..76c0b9025d0f 100644\r
124 --- a/util/string-util.c\r
125 +++ b/util/string-util.c\r
126 @@ -221,3 +221,24 @@ parse_boolean_term (void *ctx, const char *str,\r
127      errno = err;\r
128      return -1;\r
129  }\r
130 +\r
131 +int\r
132 +strcase_equal (const void *a, const void *b)\r
133 +{\r
134 +    return strcasecmp (a, b) == 0;\r
135 +}\r
136 +\r
137 +unsigned int\r
138 +strcase_hash (const void *ptr)\r
139 +{\r
140 +    const char *s = ptr;\r
141 +\r
142 +    /* This is the djb2 hash. */\r
143 +    unsigned int hash = 5381;\r
144 +    while (s && *s) {\r
145 +       hash = ((hash << 5) + hash) + tolower (*s);\r
146 +       s++;\r
147 +    }\r
148 +\r
149 +    return hash;\r
150 +}\r
151 diff --git a/util/string-util.h b/util/string-util.h\r
152 index e409cb3d2ab1..80d24d1c1053 100644\r
153 --- a/util/string-util.h\r
154 +++ b/util/string-util.h\r
155 @@ -64,6 +64,12 @@ int\r
156  parse_boolean_term (void *ctx, const char *str,\r
157                     char **prefix_out, char **term_out);\r
158  \r
159 +/* GLib GEqualFunc compatible strcasecmp wrapper */\r
160 +int strcase_equal (const void *a, const void *b);\r
161 +\r
162 +/* GLib GHashFunc compatible case insensitive hash function */\r
163 +unsigned int strcase_hash (const void *ptr);\r
164 +\r
165  #ifdef __cplusplus\r
166  }\r
167  #endif\r
168 -- \r
169 2.1.4\r
170 \r