Commit Graph

250 Commits

Author SHA1 Message Date
29dc1cea0c Fix typos. 2024-09-22 17:27:18 +00:00
075394b35f lib: use time_t_max for empty datetime
In Mu::parse_date_time, when provided with an empty string, return
time_t_max instead of G_MAXINT64. For systems with a 64-bit time_t, there
is no difference. With a 32-bit time_t it caused a test to fail:

    not ok /utils/date-basic - ERROR:../mu-1.12.4/lib/utils/tests/test-utils.cc:92
    void test_date_basic(): assertion failed
    (parse_date_time(std::get<0>(test), std::get<1>(test)).value_or(-1)
      == std::get<2>(test)): (18446744073709551615 == 2147483647)

This edge case probably only affected the test, as when other parts of
the application call parse_date_time (e.g. mu-server.cc and
mu-query-processor.cc), they check if the input string is empty first.
2024-08-26 14:46:54 +00:00
23941735df logging: rework a bit, maybe support syslog
Seems journal logging fails on NetBSD (no surprise), but has some
unwanted/not-fully-understood side-effects.

In any case, outside Linux there's no use in even trying to use
journald; so we don't do that anymore.

Add conditional support for syslog (requires glib 2.80).
2024-05-07 09:27:50 +03:00
a0d60d23b0 compat: include sys/wait.h where needed
netbsd needs this explicitly, other systems let us get away without it.
2024-04-21 22:08:10 +03:00
29ce96923a test-mu-utils: update parse_date_time tests
We're using ::time_t now.
2024-04-14 11:30:20 +03:00
a6ec43a740 mu-utils: update casting from int64_t -> time_t
Esp. for systems with 32-bit time_t.
2024-04-13 20:06:39 +03:00
4a03a30d04 utils: build test-utils when tests are not disabled
Fixes #2685
2024-04-08 18:29:57 +03:00
5186264852 utils: only build mu-tests-utils when tests are enabled
This fixes a compilation failure.

Fixes #2684.
2024-04-06 10:36:18 +03:00
45b4f60348 mu-utils: Fix build with musl
In musl, `stdout` is a macro that expands to `(stdout)`, and
`::(stdout)` is not valid C++.

../mu-1.12.2/lib/utils/mu-utils.hh:268:32: error: expected
  id-expression before '(' token
 268 |                              ::stdout);
     |                                ^~~~~~

Nothing in the Mu namespace is named stdout, so it is safe to drop
the `::`.

Bug: https://bugs.gentoo.org/928361
2024-04-01 11:23:39 +00:00
9fd0d2be12 clang: fix some compiler warnings
From CI.
2024-03-15 19:47:30 +02:00
915335fd76 tests: check setlocale return value
It might fail while nl_langinfo does not.
2024-02-25 17:11:29 +02:00
30b8238522 tests: move to tests/, make optional
While not recommended, sometimes it can be useful to disable building
the unit tests. This can be done now with
    meson -Dtests=disabled build
2024-01-06 18:35:22 +02:00
b4c768e6d0 mu-init: guess maildir when --maildir is missing
Re-instate the guessing that's in the manpage. Add unit tests.
Update documentation.

Fixes #2616.
2024-01-01 10:33:03 +02:00
25776da557 mu-result: small tweaks 2023-12-13 21:48:43 +02:00
fcd89039eb expand_path: better handle paths with spaces
I.e., work around surprising behavior of wordexp

Fixes #2566.
2023-10-07 00:18:56 +03:00
ee18c02762 maildir: improve unit tests
And get some more info from run_command.
2023-09-24 21:33:18 +03:00
4a0eba8ddf improve unit tests 2023-09-24 20:21:57 +03:00
e16e1f78ce command-handler: more unit tests 2023-09-24 17:29:56 +03:00
fa22fc28d9 error: more unit tests 2023-09-24 17:29:56 +03:00
abb0fb4fd5 utils/add: improve unit test coverage 2023-09-24 17:29:56 +03:00
11003000e8 mu: log warning when exiting with error 2023-09-23 09:26:37 +03:00
04e3a2f9a8 mu-utils: improve tests 2023-09-21 23:41:15 +03:00
6ce94ce914 mu-utils: add to_string_view 2023-09-21 23:41:15 +03:00
24add72126 mu-file-utils: add run_command0
To ensure command ran and had exit-code=0 in one go.
2023-09-19 22:26:45 +03:00
472f69beb2 utils-file: default args for canonicalize_filename / determine_dtype
Make a little easier to use
2023-09-19 22:26:30 +03:00
7cbab21099 utils: add utf8_wordbreak
Determine if a string has wordbreaks in a mostly Xapian-compatible way.
We need this to determine what strings should be considered "phrases".
2023-09-17 18:11:10 +03:00
3123f3e983 mu-error: allow for adding end-user hints 2023-09-16 11:12:16 +03:00
0a12b70d7b utils-file: improve mu_play
implement in terms of run_command
2023-09-13 23:03:51 +03:00
9dcbe1d96c lib: unit tests: improve / better coverage 2023-09-13 23:02:53 +03:00
7c16d080d2 Merge pull request #2552 from dme/devel/misc
mu: Fix "expected command" server error report
2023-09-12 22:28:30 +03:00
a8440bb258 mu: Fix "expected command" server error report 2023-09-12 08:37:10 +01:00
af9eb36ca0 unit-tests: modernize
Use TempDir, join_paths etc.
2023-09-11 23:51:37 +03:00
85ad35bd8e utils/unbroken: avoid pre-C++20 compiler warning 2023-09-10 10:15:33 +03:00
c8568eecd4 utils/file: add basename/dirname helpers and use them 2023-09-10 10:15:28 +03:00
264bb092f0 support xapian ngrams
Xapian supports an "ngrams" option to help with languages/scripts
without explicit wordbreaks, such as Chinese / Japanese / Korean.

Add some plumbing for supporting this in mu as well. Experimental for
now.
2023-09-09 17:26:20 +03:00
9c28c65d45 utils: handle "unbroken" scripts
Do not removing combining characters from scripts without explicit word
boundaries, such as those for CJK.

Reuse some Xapian code for that.
2023-09-09 11:40:36 +03:00
77a8a67f6c move lib/thirdparty to thirdparty/ 2023-09-05 08:34:27 +03:00
e1308a9b40 utils: small tweaks 2023-08-27 11:07:55 +03:00
c1950ae0cb mu-utils: support UTC in parse_date_time
Parsing dates known to be in UTC.
2023-08-21 18:29:21 +03:00
15f08488d3 remove Mu::format, use mu_format
Use the new fmt-based formatting.
2023-08-19 20:04:50 +03:00
11df0bedce utils: add mu_print[ln] for ostreams 2023-08-11 19:57:00 +03:00
7aa38d0b56 option/result: add "unwrap"
Sprinkle some more Rust on Option & Result
2023-08-09 23:24:47 +03:00
4ecf386cda utils-file: don't use regexp in join_paths
It's slow.
2023-08-06 16:19:43 +03:00
27c07280b1 utils: replace time_to_string with fmt-based formatting
It's faster; make "mu find" ~5-10% faster, and removes some code we no
longer need.
2023-08-06 16:19:43 +03:00
111e48efa3 utils: add expand_path (wordexp wrapper)
For expanding command-line options for shells that don't do that by themselves.
2023-08-03 22:47:27 +03:00
33fd79a9f0 mu-regex: add multiline test 2023-07-30 00:50:45 +03:00
3a38d6366a mu-view: test locale to C for tests 2023-07-29 17:25:07 +03:00
766d1849ff test-utils: add TempTz, RAII temporary timezone 2023-07-29 16:39:08 +03:00
1f0342a91f mu-view: add unit-test 2023-07-28 19:43:46 +03:00
dc29dc8395 html-to-text: add missing include <array> 2023-07-26 23:30:54 +03:00