Commit graph

12 commits

Author SHA1 Message Date
David Bremner
b8e6f042c5 util/string-util: export skip_space
It's only few lines, but we already define the function, so make it
usable elsewhere
2018-09-06 08:07:13 -03:00
Yuri Volchkov
cec4a87539 database: move striping of trailing '/' into helper function
Stripping trailing character is not that uncommon
operation. Particularly, the next patch has to perform it as
well. Lets move it to the separate function to avoid code duplication.

Also the new function has a little improvement: if the character to
strip is repeated several times in the end of a string, function
strips them all.

Signed-off-by: Yuri Volchkov <yuri.volchkov@gmail.com>
2017-08-22 18:47:51 -03:00
Daniel Kahn Gillmor
6a833a6e83 Use https instead of http where possible
Many of the external links found in the notmuch source can be resolved
using https instead of http.  This changeset addresses as many as i
could find, without touching the e-mail corpus or expected outputs
found in tests.
2016-06-05 08:32:17 -03:00
Jani Nikula
bcb695a716 util: add strcmp_null, a strcmp that handles NULL parameters
Add strcmp_null, a strcmp that handles NULL strings; in strcmp terms a
NULL string is considered to be less than a non-NULL string.
2015-09-26 07:37:35 -03:00
Jani Nikula
f460ad4e9a util: move strcase_equal and strcase_hash to util
For future use in both cli and lib.
2015-09-07 09:43:31 -03:00
Austin Clements
9f0f30f7de util: Const version of strtok_len
Because of limitations in the C type system, we can't a strtok_len
that can work on both const string and non-const strings.  The C
library solves this by taking a const char* and returning a char*
in functions like this (e.g., strchr), but that's not const-safe.
Solve it by introducing strtok_len_c, a version of strtok_len for
const strings.
2014-08-06 09:56:36 -03:00
Austin Clements
3fed6736a7 util: Fix two corner-cases in boolean term quoting function
Previously, make_boolean_term did not quote empty boolean terms or
boolean terms that started with '('.  These cases are incompatible
with Xapian: empty terms cannot be omitted, and boolean terms that
start with '(' trigger an alternate term quoting syntax.

Fix this by quoting empty terms and terms that contain '('.
2014-03-15 15:05:06 -03:00
Jani Nikula
029790d3ff util: make sanitize string available in string util for reuse
No functional changes.
2014-03-09 10:13:30 -03:00
Austin Clements
b4b22d3714 string-util: Disallow empty prefixes in parse_boolean_term
Xapian doesn't consider ":abc" to be a prefixed term.  This makes
parse_boolean_term similarly reject queries with an empty prefix.
2013-01-07 20:55:21 -04:00
Austin Clements
7c3a995d6b util: Function to parse boolean term queries
This parses the subset of Xapian's boolean term quoting rules that are
used by make_boolean_term.  This is provided as a generic string
utility, but will be used shortly in notmuch restore to parse and
optimize for ID queries.
2013-01-06 22:39:51 -04:00
Austin Clements
25cf5f5dc4 util: Factor out boolean term quoting routine
This is now a generic boolean term quoting function.  It performs
minimal quoting to produce user-friendly queries.

This could live in tag-util as well, but it is really nothing specific
to tags (although the conventions are specific to Xapian).

The API is changed from "caller-allocates" to "readline-like".  The
scan for max tag length is pushed down into the quoting routine.
Furthermore, this now combines the term prefix with the quoted term;
arguably this is just as easy to do in the caller, but this will
nicely parallel the boolean term parsing function to be introduced
shortly.

This is an amalgamation of code written by David Bremner and myself.
2013-01-06 22:39:36 -04:00
David Bremner
9ff72a83bd util: add string-util.[ch]
This is to give a home to strtok_len. It's a bit silly to add a header
for one routine, but it needs to be shared between several compilation
units (or at least that's the most natural design).
2012-12-08 10:56:11 -04:00