Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 2c / c7a24b0c1abaca59837d0c2887483ec7ad1eb3
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 olra.theworths.org (Postfix) with ESMTP id E8913431FBC\r
6         for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:16 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.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.7\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
13         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id DapZPzOilK5N for <notmuch@notmuchmail.org>;\r
17         Sat, 30 Nov 2013 07:34:11 -0800 (PST)\r
18 Received: from mail-ea0-f174.google.com (mail-ea0-f174.google.com\r
19         [209.85.215.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 6A75E431FC7\r
22         for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:08 -0800 (PST)\r
23 Received: by mail-ea0-f174.google.com with SMTP id b10so7490094eae.19\r
24         for <notmuch@notmuchmail.org>; Sat, 30 Nov 2013 07:34:07 -0800 (PST)\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=awJ8sTwb5zV9KmWYH7p/0CJsHSvVgVzVXv9ctBdYGDE=;\r
30         b=Ahw92OUn+d3zEv5VY0lE5NiCQV+8TNuowPeT+hj5bNtpL9uTmrbbClLn/y4/MtYq9T\r
31         9+xWAbReT30bQxVByPq/ekHigTZkSNkXZa44Pc0mV7nBgsZcmULh43K35IOO7MLgH6hq\r
32         cbW5FeG68KYBYy+w3C8G+GgnE7oYtFpzGZwliec4mh0i5h3i1I6toiNtDLtta+TrqP9A\r
33         Mk8AA4bqRNJrpHk1wTfRCCA5Rh2t31aXpYHxeeiWWPNmtSeAKBE6Vt2YeKRvsHrRtxx8\r
34         jYIdbrJ37Df/G4hrMHOVfMqhFLvynn90FU+7vYHWIVab8qFoCQ5+MneUmr7LVGeCDGH4\r
35         1VSQ==\r
36 X-Gm-Message-State:\r
37  ALoCoQmscjeV69WeNI4ij2DIFhOCSr20xdoAVe/p01QG7JbtERukMcJM1Iw02f1siHEpC+l3SBf3\r
38 X-Received: by 10.15.67.195 with SMTP id u43mr33405654eex.14.1385825647433;\r
39         Sat, 30 Nov 2013 07:34:07 -0800 (PST)\r
40 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
41         [88.195.111.91])\r
42         by mx.google.com with ESMTPSA id b42sm51870665eem.9.2013.11.30.07.34.06\r
43         for <multiple recipients>\r
44         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
45         Sat, 30 Nov 2013 07:34:06 -0800 (PST)\r
46 From: Jani Nikula <jani@nikula.org>\r
47 To: notmuch@notmuchmail.org\r
48 Subject: [PATCH v2 3/7] util: make sanitize string available in string util\r
49         for reuse\r
50 Date: Sat, 30 Nov 2013 17:33:52 +0200\r
51 Message-Id:\r
52  <6859d1e9de273e00101c10122cd8ca162cc3a542.1385825425.git.jani@nikula.org>\r
53 X-Mailer: git-send-email 1.8.4.2\r
54 In-Reply-To: <cover.1385825425.git.jani@nikula.org>\r
55 References: <cover.1385825425.git.jani@nikula.org>\r
56 In-Reply-To: <cover.1385825425.git.jani@nikula.org>\r
57 References: <cover.1385825425.git.jani@nikula.org>\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Sat, 30 Nov 2013 15:34:17 -0000\r
71 \r
72 No functional changes.\r
73 ---\r
74  notmuch-search.c   | 19 -------------------\r
75  util/string-util.c | 22 ++++++++++++++++++++++\r
76  util/string-util.h |  7 +++++++\r
77  3 files changed, 29 insertions(+), 19 deletions(-)\r
78 \r
79 diff --git a/notmuch-search.c b/notmuch-search.c\r
80 index 11cd6ee..8b6940a 100644\r
81 --- a/notmuch-search.c\r
82 +++ b/notmuch-search.c\r
83 @@ -30,25 +30,6 @@ typedef enum {\r
84      OUTPUT_TAGS\r
85  } output_t;\r
86  \r
87 -static char *\r
88 -sanitize_string (const void *ctx, const char *str)\r
89 -{\r
90 -    char *out, *loop;\r
91 -\r
92 -    if (NULL == str)\r
93 -       return NULL;\r
94 -\r
95 -    loop = out = talloc_strdup (ctx, str);\r
96 -\r
97 -    for (; *loop; loop++) {\r
98 -       if (*loop == '\t' || *loop == '\n')\r
99 -           *loop = ' ';\r
100 -       else if ((unsigned char)(*loop) < 32)\r
101 -           *loop = '?';\r
102 -    }\r
103 -    return out;\r
104 -}\r
105 -\r
106  /* Return two stable query strings that identify exactly the matched\r
107   * and unmatched messages currently in thread.  If there are no\r
108   * matched or unmatched messages, the returned buffers will be\r
109 diff --git a/util/string-util.c b/util/string-util.c\r
110 index a5622d7..9e2f728 100644\r
111 --- a/util/string-util.c\r
112 +++ b/util/string-util.c\r
113 @@ -37,6 +37,28 @@ strtok_len (char *s, const char *delim, size_t *len)\r
114      return *len ? s : NULL;\r
115  }\r
116  \r
117 +char *\r
118 +sanitize_string (const void *ctx, const char *str)\r
119 +{\r
120 +    char *out, *loop;\r
121 +\r
122 +    if (! str)\r
123 +       return NULL;\r
124 +\r
125 +    out = talloc_strdup (ctx, str);\r
126 +    if (! out)\r
127 +       return NULL;\r
128 +\r
129 +    for (loop = out; *loop; loop++) {\r
130 +       if (*loop == '\t' || *loop == '\n')\r
131 +           *loop = ' ';\r
132 +       else if ((unsigned char)(*loop) < 32)\r
133 +           *loop = '?';\r
134 +    }\r
135 +\r
136 +    return out;\r
137 +}\r
138 +\r
139  static int\r
140  is_unquoted_terminator (unsigned char c)\r
141  {\r
142 diff --git a/util/string-util.h b/util/string-util.h\r
143 index 0194607..228420d 100644\r
144 --- a/util/string-util.h\r
145 +++ b/util/string-util.h\r
146 @@ -19,6 +19,13 @@\r
147  \r
148  char *strtok_len (char *s, const char *delim, size_t *len);\r
149  \r
150 +/* Return a talloced string with str sanitized.\r
151 + *\r
152 + * Whitespace (tabs and newlines) is replaced with spaces,\r
153 + * non-printable characters with question marks.\r
154 + */\r
155 +char *sanitize_string (const void *ctx, const char *str);\r
156 +\r
157  /* Construct a boolean term query with the specified prefix (e.g.,\r
158   * "id") and search term, quoting term as necessary.  Specifically, if\r
159   * term contains any non-printable ASCII characters, non-ASCII\r
160 -- \r
161 1.8.4.2\r
162 \r