summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-07-01lib/sexp: add parameter expansion for regex and wildcardDavid Bremner
Fix the bug reported at [1]. The parameter expansion for regex and wildcard modifiers has to be done a bit differently, because their arguments are not s-expressions defining complete Xapian queries. [1]: id:87o7yxqxy6.fsf@code.pm
2022-06-25lib/sexp: allow * as alias for "" in range searches.David Bremner
It can be tedious to use "" inside of a string, e.g. in a shell script.
2022-06-25lib/sexp: special case "" as an argument in lastmod ranges.David Bremner
Support this syntax for constincy with (data from to) ranges.
2022-06-25lib: check for writable db in n_m_tags_maildir_flagsDavid Bremner
The database needs to be writable because the list of stored file names will change in general.
2022-06-25lib: add NOTMUCH_STATUS_CLOSED_DATABASE, use in _n_d_ensure_writableDavid Bremner
In order for a database to actually be writeable, it must be the case that it is open, not just the correct type of Xapian object. By explicitely checking, we are able to provide better error reporting, in particular for the previously broken test in T566-lib-message.
2022-06-25lib: Add missing private status values.David Bremner
These were missed when the corresponding status codes were added.
2022-06-25lib/tag: handle NULL argument to notmuch_tags_validDavid Bremner
Make the behaviour when passed NULL consistent with notmuch_filenames_valid. The library already passes the result of notmuch_message_get_tags without checking for NULL, so it should be handled.
2022-06-25lib/message: check return status from _n_m_add_{path,folder}_termsDavid Bremner
Mainly to propagate information about Xapian exceptions.
2022-06-25lib/message: check return status of _n_m_{add,remove}_termDavid Bremner
Xapian exceptions are not something that can be ignored, in general.
2022-06-25lib: define macro NODISCARDDavid Bremner
In either C++17 (or later) mode, or when running cppcheck, this can be used to selectively generate warnings about discarded return values.
2022-06-25lib/message: drop _notmuch_message_get_thread_id_onlyDavid Bremner
This function has been unused since commit 4083fd8.
2022-06-25lib/message: catch exceptions in _n_m_add_termDavid Bremner
Some code movement is needed to make sure the cache is only invalidated when the Xapian operation succeeds.
2022-05-26lib/message: use false from stdbool.hDavid Bremner
As far as I know, this is just a style / consistency thing, unless notmuch code starts defining FALSE inconsistently with false.
2022-05-26lib: fix uninitialized field in message objects.David Bremner
Initially reported by Eliza Vasquez [1] (via valgrind). [1]: id:87o7zxj086.fsf@eliza.
2022-04-15fix build without sfsexpMichael J Gruber
a1d139de ("lib: add sexp: prefix to Xapian (infix) query parser.", 2022-04-09) introduced sfsexp infix queries. This requires the infix preprocessor to be built in in a way which does not require sfsexp when notmuch is built without it. Make the preprocessor throw a Xapian error in this case (and fix the build). Signed-off-by: Michael J Gruber <git@grubix.eu>
2022-04-15lib: add sexp: prefix to Xapian (infix) query parser.David Bremner
This is analogous to the "infix" prefix provided by the s-expression based query parser.
2022-03-19lib: do not phrase parse prefixed bracketed subexpressionsDavid Bremner
Since Xapian does not preserve quotes when passing the subquery to a field processor, we have to make a guess as to what the user intended. Here the added assumption is that a string surrounded by parens is not intended to be a phrase.
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").