Commit graph

17 commits

Author SHA1 Message Date
Jonas Bernoulli
6c84dee531 Fix typos 2020-08-09 21:14:36 -03:00
Jani Nikula
0f314c0c99 cli: convert notmuch_bool_t to stdbool
C99 stdbool turned 18 this year. There really is no reason to use our
own, except in the library interface for backward
compatibility. Convert the cli and test binaries to stdbool.
2017-10-09 22:24:02 -03:00
Piotr Trojanek
410b96080c remove ineffective assignments
Detected by cppcheck.
2017-06-25 09:38:22 -03:00
Piotr Trojanek
e9d73f90a6 fix leaks due to missing invocations of va_end
As the Linux man page states: "Each invocation of va_start() must be
matched by a corresponding invocation of va_end() in the same
function." Detected by cppcheck.
2017-06-25 09:35:23 -03:00
Piotr Trojanek
a17eb162ee minor whitespace cleanups 2017-06-25 09:32:08 -03:00
Jani Nikula
735cbb8719 cli: add missing \n in error message
The error messages returned by illegal_tag() don't contain newlines.
2014-03-06 07:46:27 -04:00
Jani Nikula
07dd9d53cb cli: export function for illegal tag checking
This lets us check for forbidden tags consistently across the cli. No
functional changes.
2014-03-06 07:41:38 -04:00
Peter Wang
f00c925bd1 tag-util: do not reset list in parse_tag_command_line
The 'insert' command will be better served if parse_tag_command_line
modifies a pre-populated list (of new.tags) instead of clobbering the
list outright.  The sole existing caller, notmuch_tag_command, is
unaffected by this change.
2013-06-29 14:36:23 -03:00
Peter Wang
e8efa11da9 tag-util: move out 'tag' command-line check
Move an error condition specific to the 'tag' command out of
parse_tag_command_line so that parse_tag_command_line can be used for
the forthcoming 'insert' command.
2013-06-29 14:36:07 -03:00
Jani Nikula
a6822eccac cli: make caller check tag count in parse_tag_command_line 2013-03-30 18:33:40 -04:00
David Bremner
e9b6e46474 notmuch-tag.c: convert to use tag-util
Command line parsing is factored out into a function
parse_tag_command_line in tag-util.c.

There is some duplicated code eliminated in tag_query, and a bunch of
translation from using the bare tag_op structs to using that tag-utils
API.
2013-01-07 20:42:21 -04:00
David Bremner
e13e259147 tag-util: factor out rules for illegal tags, use in parse_tag_line
This will allow us to be consistent between batch tagging and command
line tagging as far as what is an illegal tag.
2013-01-06 22:57:41 -04:00
Austin Clements
425e2bc812 dump/restore: Use Xapian queries for batch-tag format
This switches the new batch-tag format away from using a home-grown
hex-encoding scheme for message IDs in the dump to simply using Xapian
queries with Xapian quoting syntax.

This has a variety of advantages beyond presenting a cleaner and more
consistent interface.  Foremost is that it will dramatically simplify
the quoting for batch tagging, which shares the same input format.
While the hex-encoding is no better or worse for the simple ID queries
used by dump/restore, it becomes onerous for general-purpose queries
used in batch tagging.  It also better handles strange cases like
"id:foo and bar", since this is no longer syntactically valid.
2013-01-06 22:40:32 -04:00
David Bremner
1325e1afb9 parse_tag_line: use enum for return value.
This is essentially cosmetic, since success=0 is promised by
the comments in tag-utils.h.
2012-12-26 09:44:31 -04:00
David Bremner
ba4e856529 tag-utils: use the tag_opt_list_t as talloc context, if possible.
The memory usage discipline of tag_op_list_t is never to free the
internal array of tag operations before freeing the whole list, so it
makes sense to take advantage of hierarchical de-allocation by talloc.

By not relying on the context passed into tag_parse_line, we can allow
tag_op_list_t structures to live longer than that context.
2012-12-22 23:13:15 -04:00
David Bremner
5c7990f251 tag-util: optimization of tag application
The idea is not to bother with restore operations if they don't change
the set of tags. This is actually a relatively common case.

In order to avoid fancy datastructures, this method is quadratic in
the number of tags; at least on my mail database this doesn't seem to
be a big problem.
2012-12-09 13:33:34 -04:00
David Bremner
fb50cc41fe tag-util.[ch]: New files for common tagging routines
These are meant to be shared between notmuch-tag and notmuch-restore.

The bulk of the routines implement a "tag operation list" abstract
data type act as a structured representation of a set of tag
operations (typically coming from a single tag command or line of
input).
2012-12-09 13:33:34 -04:00