summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-01-29lib: bump minor version to 6.David Bremner
One new status value and one configuration value added.
2022-01-27lib: strip trailing '/' from pathnames (sexp queries).David Bremner
This changes makes the sexp query parser consistent with the infix one in ignoring trailing '/'. Here we do a bit better and ignore any number of trailing '/'.
2022-01-27lib: drop trailing slash for path and folder searches (infix)David Bremner
This resolves an old bug reported by David Edmondson in 2014. The fix is only needed for the "boolean" case, as probabilistic / phrase searching already ignores punctuation. This fix is only for the infix (xapian provided) query parser. [1]: id:cunoasuolcv.fsf@gargravarr.hh.sledj.net
2022-01-26lib/parse-sexp: handle lastmod queries.David Bremner
This particular choice of converting strings to integers requires C++11.
2022-01-26lib/parse-sexp: support actual date queries.David Bremner
The default argument processing overlaps somewhat with what is already done in _notmuch_date_strings_to_query, but we can give more specific error messages for the s-expression context. The extra generality of _sexp_parse_range will be useful when we implement additional range prefixes (at least 'lastmod' is needed).
2022-01-26lib/date: factor out date range parsing.David Bremner
This will allow re-using the same logic in the s-expression parser.
2022-01-26lib/parse-sexp: support zero argument date queriesDavid Bremner
These are not too practical, although they may simplify some user query generation code. Mainly this adds a new prefix keyword to the parser.
2022-01-22lib/database: delete stemmer on destroyDavid Bremner
Commit [0] left the stemmer object accessible, but did not add de-allocation code to notmuch_database_destroy. This commit corrects that oversight. Leak originally reported by Austin Ray [1]. [0]: 3202e0d1feba1ab955ba1c07098c00208f8f0ada [1]: id:20220105224538.m36lnjn7rf3ieonc@athena
2022-01-22lib/config: move g_key_File_get_string before continueDavid Bremner
In [1] Austin Ray reported some memory leaks in notmuch_database_open. One of those leaks is caused by jumping to the next key without freeing val. This change avoids that leak. [1]: id:20220105224538.m36lnjn7rf3ieonc@athena
2022-01-18lib/config: add known config key "show.extra_headers"David Bremner
Used in a following commit to enable including extra headers beyond the default in structured output.
2022-01-15lib/open: no default mail root in split configurationsDavid Bremner
If we know the configuration is split, but there is no mail root defined, this indicates a (lack of) configuration error. Currently this can only arise in XDG configurations.
2022-01-15lib/config: make sure the config map exists when loading defaultsDavid Bremner
We should not rely on one of the other "_notmuch_config_load_*" functions being called before this one.
2022-01-15lib/open: use notmuch->params to track split statusDavid Bremner
Persisting this status will allow us to use the information in other compilation units, in particular when setting configuration defaults.
2022-01-15lib/open: use db struct as talloc ctx for choose_database_pathDavid Bremner
The extra talloc struct "local" was left over from before the notmuch struct was allocated earlier. Having the notmuch struct available in this function will allow more flexibility to track the configuration variations (e.g. split vs. non-split).
2021-12-29Merge branch 'release'David Bremner
2021-12-29lib/open: do not consider .notmuch alone as an existing database.David Bremner
It makes perfect sense for users to want to pre-create .notmuch, e.g. to install hooks, so we should handle the case of a .notmuch directory without an actual xapian database more gracefully.
2021-12-04lib/config: use g_key_file_get_string to read config valuesDavid Bremner
Unlike the previous g_key_file_get_value, this version processes escape codes for whitespace and \. The remaining two broken tests from the last commit are because "notmuch config get" treats every value as a list, and thus the previously introduces stripping of leading whitespace applies.
2021-12-04Merge branch 'release'David Bremner
2021-12-03lib/config: don't overwrite database.path if the caller passed itDavid Bremner
If the user passed a path, and we opened it, then we consider that definitive definition of "database.path". This makes libnotmuch respond more gracefully to certain erroneous combinations of NOTMUCH_CONFIG settings and config file contents.
2021-12-03lib/open: track which parameters are passedDavid Bremner
This will be used to fine tune the loading of configuration for certain special configuration items (initially just "database.path").
2021-12-03rename built_with.sexpr_query to built_with.sexp_queriesDavid Bremner
It is confusing to use two different names (sexp vs sexpr) when compared with the command line option --query=sexp and (furthermore) singular vs plural when compared with the man page title.
2021-10-30lib/open: replace call to deprecated notmuch_database_open_verboseDavid Bremner
Essentially inline the existing shim definition of notmuch_database_open_verbose.
2021-10-30lib/compact: replace deprecated notmuch_database_open_verboseDavid Bremner
It should not be necesary to have any config information here, hence passing "" to n_d_open_with_config.
2021-10-30Merge branch 'release'David Bremner
2021-10-30lib/load_config: deallocate / NULL database on fatal errorDavid Bremner
This fixes a potential memory leak, and makes the behaviour of notmuch_database_load_config (somewhat) consistent with n_d_{open,create} with config.
2021-10-30lib/load_config: document expectations for db on error, add testsDavid Bremner
This is a bit different than n_d_{open,create}_with_config, since there are several non-zero status codes where we do want to return a non-NULL database structure.
2021-10-30lib/create: fix memory leak, ensure *database=NULL on errorDavid Bremner
This code previously relied on _finish_open to free the notmuch struct on errors (except for the case of database == NULL, which was a potential double free). When we removed those frees from _finish_open, we introduced a (small) memory leak. In this commit, fix the memory leak, and harmonize the on-error behaviour with n_d_open_with_config.
2021-10-30lib/create: document expectations for db on error, add testsDavid Bremner
It seems sensible to harmonize the behaviour with n_d_open_with_config. In this commit we just assert the desired behaviour.
2021-10-30lib/open: fix potential double-free, ensure *database=NULL on errorDavid Bremner
During refactoring for 0.32, the code that set notmuch=NULL on various errors was moved into _finish_open. This meant that the the code which relied on that to set *database to NULL on error was no longer correct. It also introduced a potential double free, since the notmuch struct was deallocated inside _finish_open (via n_d_destroy). In this commit we revert to "allocator frees", and leave any cleanup to the caller of _finish_open. This allows us to get back the behaviour of setting *database to NULL with a small change. Other callers of _finish_open will need free notmuch on errors.
2021-10-30lib: document n_o_w_config can return NOTMUCH_STATUS_NO_CONFIGDavid Bremner
This should be treated as fatal by callers, since we didn't succeed in opening a Xapian database.
2021-10-23lib: make indexopts pointers opaqueDavid Bremner
There is no reason for anything outside the indexopts.c compilation unit to have access to structure members.
2021-10-23lib: remove enum names from typedefsJani Nikula
There are some enum typedefs with the enum name: typedef enum _name_t { ... } name_t; We don't need or use the enum names _name_t for anything, and not all of the enum typedefs have them. We have the typedefs specifically to use the typedef name. Use the anonymous enum in the typedefs: typedef enum { ... } name_t;
2021-10-23lib: fix commented out NOTMUCH_DEPRECATED()Jani Nikula
Remove the comment markers from the placeholder NOTMUCH_DEPRECATED(), added in commit e5f3c3ed5024 ("lib: add stub for notmuch_database_open_with_config").
2021-10-15lib: bump lib minor version to 5David Bremner
One new function (and an enum) was added to the API/ABI.
2021-09-10Merge tag '0.33.1'David Bremner
notmuch 0.33.1 release
2021-09-10lib: use 'localhost' rather than fqdn for default mail address.David Bremner
As discussed in the thread starting at [1], the fully qualified domain name is a bit tricky to get reproducibly, might reveal information people prefer to keep private, and somewhat unlikely to provide reliable mail routing. The new approach of $current_username@localhost is better for the first two considerations, and probably at least as good as a test mail address. [1]: id:87sfyibqhj.fsf@tethera.net
2021-09-04lib/parse-sexp: apply macrosDavid Bremner
Macros implement lazy evaluation and lexical scope. The former is needed to make certain natural constructs work sensibly (e.g. (tag ,param)) but the latter is mainly future-proofing in case the DSL is is extended to allow local bindings. For technical background, see chapters 6 and 17 of [1] (or some other intermediate programming languages textbook). [1] http://cs.brown.edu/courses/cs173/2012/book/
2021-09-04lib/parse-sexp: thread environment argument through parserDavid Bremner
No functionality change, just an extra argument carried everywhere.
2021-09-04lib/parse-sexp: support saved s-expression queriesDavid Bremner
It turns out there is not really much code in query-fp.cc useful for supporting the new syntax. The code we could potentially factor out amounts to calling notmuch_database_get_config; both the key construction and the parsing of the results are specific to the query syntax involved.
2021-09-04lib/parse-sexp: handle saved queriesDavid Bremner
This provides functionality analogous to query: in the Xapian QueryParser based parser. Perhaps counterintuitively, the saved queries currently have to be in the original query syntax (i.e. not s-expressions).
2021-09-04lib: factor out expansion of saved queries.David Bremner
This is intended to allow use outside of the Xapian query parser.
2021-09-04lib/parse-sexp: parse user headersDavid Bremner
One subtle aspect is the replacement of _find_prefix with _notmuch_database_prefix, which understands user headers. Otherwise the code mainly consists of creating a fake prefix record (since the user prefixes are not in the prefix table) and error handling.
2021-09-04lib/parse-sexp: support infix subqueriesDavid Bremner
This is necessary so that programs can take infix syntax queries from a user and use the sexp query syntax to construct e.g. a refinement of that query.
2021-09-04lib/parse-sexp: expand queriesDavid Bremner
The code here is just gluing together _notmuch_query_expand with the existing sexp parser infrastructure.
2021-09-04lib/thread-fp: factor out query expansion, rewrite in XapianDavid Bremner
It will be convenient not to have to construct a notmuch query object when parsing subqueries, so the commit rewrites the query expansion (currently only used for thread:{} queries) using only Xapian. As a bonus it seems about 15% faster in initial experiments.
2021-09-04lib/query: factor out _notmuch_query_string_to_xapian_queryDavid Bremner
When dealing with recursive queries (i.e. thread:{foo}) it turns out to be useful just to deal with the underlying Xapian objects, and not wrap them in notmuch objects.
2021-09-04lib: generate actual Xapian query for "*" and ""David Bremner
The previous code had the somewhat bizarre effect that the (notmuch specific) query string was "*" (interpreted as MatchAll) and the allegedly parsed xapian_query was "MatchNothing". This commit also reduces code duplication.
2021-09-04lib/parse-sexp: support regular expressionsDavid Bremner
At least to the degree that the Xapian QueryParser based parser also supports them. Support short alias 'rx' as it seems to make more complex queries nicer to read.
2021-09-04lib: factor out query construction from regexpDavid Bremner
This will allow re-use of this code outside of the Xapian query parser.
2021-09-04lib/query: generalize exclude handling to s-expression queriesDavid Bremner
In fact most of the code path is in common, only the caching of terms in the query needs to be added for s-expression queries.