Commit Graph
136 Commits
Author SHA1 Message Date
Yu Watanabe 19bbcd35d7 strv: introduce strv_extend_joined() and strv_extend_joined_with_size() 2025-11-01 00:59:36 +09:00
Yu Watanabe 3c66f40262 strv: introduce strv_extendf_with_size() 2025-11-01 00:58:39 +09:00
Daan De Meyer 0c15577abe basic + fundamental: Clean up includes
Split out of #37344.
2025-05-25 10:06:07 +02:00
Daan De Meyer 6553db6063 strv: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer c09ce222b6 hashmap: Drop debug params
Passing in the func, file and line information complicates the
interface. On top of that, it prevents forward declaring Hashmap in
strv.h, as we need to pass the macros everywhere that we allocate a
hashmap, which means we have to include the hashmap header everywhere
we have a function that allocates a hashmap instead of just having to
forward declare Hashmap.

Let's drop the file, func and line information from the debug information.
Instead, in the future we can add a description field to hashmaps like we
already have in various other structs to describe the purpose of the hashmap
which should be much more useful than having the file, line and function where
the hashmap was allocated.
2025-05-06 10:14:26 +02:00
Daan De Meyer 93a1f7921a basic: Stop including log.h in macro.h
Now that the necessary functions from log.h have been moved to macro.h,
we can stop including log.h in macro.h. This requires modifying source
files all over the tree to include log.h instead.
2025-04-18 14:19:15 +02:00
Yu Watanabe 3f23b37c5a strv: constify arguments for strv_equal_ignore_order()
Follow-up for 5072f4268b.
2025-04-13 04:59:26 +09:00
Zbigniew Jędrzejewski-Szmek 55a8d118d6 basic/strv: return NULL from strv_skip
strv_skip was written to carefully return the original array, but this turns
out to be an unnecessary complication. After the previous patch, no caller
cares about the distinction between NULL and { NULL }, but various callers need
to wrap the process the returned value with strv_isempty(), sometimes more than
once. Let's always return NULL for an empty result to allow callers to be
simplified.
2025-03-27 12:04:23 +01:00
Mike Yuan 3ab19c1f0a basic/strv: minor coding style follow-ups
Follow-up for 428146dc89

Addresses https://github.com/systemd/systemd/pull/36271#discussion_r1958334800
2025-02-21 16:12:59 +01:00
Lennart Poettering 428146dc89 strv-util: add strv_filter_prefix() helper 2025-02-17 15:00:00 +01:00
Yu Watanabe c540875cd3 strv: introduce string_strv_hashmap_remove() 2025-01-29 04:36:24 +09:00
Yu Watanabe b883a9f5be strv: drop redundant string_strv_hash_ops
It is completely equivalent to string_hash_ops_free_strv_free.
2025-01-27 07:49:04 +01:00
Yu Watanabe d7306348b2 tree-wide: insert a space at the end of comments 2025-01-25 05:24:23 +09:00
Yu Watanabe c1e0518064 strv: fix typo
Follow-up for 5072f4268b.
2025-01-24 22:08:56 +09:00
Lennart Poettering 5072f4268b strv: add strv_equal_ignore_order() helper 2025-01-21 09:56:53 +01:00
Yu Watanabe bfa834f138 Merge pull request #34511 from YHNdnzj/strv-extend-strv-consume
basic/strv: introduce strv_extend_strv_consume()
2024-09-21 13:57:02 +09:00
Mike Yuan a2c8652a2a tree-wide: use strv_extend_strv_consume() where appropriate 2024-09-21 00:53:50 +02:00
Mike Yuan 8a7ade7427 basic/strv: introduce strv_extend_strv_consume() 2024-09-21 00:53:49 +02:00
Mike Yuan 527b9e2437 basic/strv: make string_strv_hash_ops static, add missing assertions 2024-09-20 22:44:35 +02:00
Yu Watanabe ffdf497860 strv: introduce strv_find_closest()
Follow-up for 1e1ac5d53b.
2024-09-21 05:06:12 +09:00
Michael Ferrari 1e1ac5d53b firstboot: add similar input suggestion
This uses the same logic as similar verb suggestion for command line
utilities. Try to be helpful when the user entered something invalid
instead of just showing the prompt again.
2024-09-20 08:34:03 +09:00
Yu Watanabe f2d2aa0934 strv: replace always-true condition with assertion
Follow-up for aca093018c.
Fixes CID#1547105.
2024-06-18 21:09:04 +01:00
Luca Boccassi 5d42acada4 Merge pull request #33376 from yuwata/strv_sort_uniq
strv: introduce strv_sort_uniq()
2024-06-18 00:22:19 +01:00
Yu Watanabe 3dc546ad75 strv: introduce strv_sort_uniq()
We often call strv_sort() and strv_uniq(). If a strv is already sorted.
uniquifying can be faster.

Prompted by https://github.com/systemd/systemd/pull/33012#discussion_r1636633627.
2024-06-18 00:22:33 +09:00
Lennart Poettering aca093018c strv: add new helper strv_rebreak_lines() with a simple line breaking algorithm 2024-06-17 09:20:21 +02:00
Zbigniew Jędrzejewski-Szmek ec596fe34e Merge pull request #30480 from keszybz/kernel-install-more-paths
Read kernel-install config from /run/kernel too
2024-03-08 08:25:07 +01:00
Zbigniew Jędrzejewski-Szmek 9bc7493098 strv: add helper to extend strv from both sides
Also, use the more correct type of 'const char* const*' for the input strv.
This requires adding the cast in a few places, but also allows to remove some
casts in others.
2024-03-07 18:49:44 +01:00
Mike Yuan 4f49512695 extract-word: modernize extract_many_words 2024-03-03 19:01:00 +08:00
Zbigniew Jędrzejewski-Szmek 8f43182847 various: use modern strv helpers
If we're building a strv, let's just use strv_new() with the CONF_PATHS macro,
which gives as an exploded string set.
2024-02-28 11:10:34 +01:00
Mike Yuan 215286a405 fileio: fputs_with_space → _with_separator and modernization 2024-01-26 00:37:59 +08:00
Lennart Poettering 80f1e209a5 strv: add strv_extend_many() helper
This is supposed to be a nicer, faster replacement for the often seen
pattern strv_extend_strv(l, STRV_MAKE(…), false)
2024-01-17 11:32:11 +01:00
Lennart Poettering b9d37112f2 strv: remove strv_extend_front()
It's entirely identical to strv_push_prepend() hence drop the duplicate
definition.
2024-01-17 11:32:11 +01:00
Lennart Poettering a43431067e strv: modernize strv_insert()
Let's use memmove() to move the string contents, rather than manual
loops.

Fix the overflow extension.

Prefer reallocarray() over malloc()
2024-01-17 11:32:11 +01:00
Ludwig Nussel 5058bd7e1f strv: introduce strv_copy_unless_empty() 2024-01-15 17:16:37 +01:00
Mike Yuan 2e6f012bf0 strv: rename strv_endswith to endswith_strv and dedup ENDSWITH_SET 2024-01-04 16:51:57 +08:00
Mike Yuan eba8b54130 string-util: move startswith_strv to strv 2024-01-04 16:49:05 +08:00
Lennart Poettering cb599f881a strv: add new strv_endswith() helper 2024-01-03 18:38:46 +01:00
Luca Boccassi a39cba252e strv: add strv_free_many() to be used with CLEANUP_ARRAY() 2023-11-03 16:59:58 +00:00
Lennart Poettering 24ae45cb65 alloc-util: add free_many() helper
We often free an array of things. Let's create a common helper for this,
and port some potential users over. (Not all, too lazy for that for
now).
2023-08-24 15:04:33 +02:00
David Tardon d6f2cd671c tree-wide: use free_and_replace() more 2023-05-24 14:59:07 +02:00
Luca Boccassi 2ed74695b3 strv: add helper to find value in key/value pairs from list of keys 2023-03-28 10:36:01 +01:00
Yu Watanabe 00546c18fd strv: introduce strv_print_full() 2023-03-20 09:32:09 +01:00
Lennart Poettering 4ea517a6e0 strv: add strv_copy_n() helper for copying part of a n strv 2023-02-17 09:55:35 +01:00
Daan De Meyer 6658f7c792 basic: Add strv_extend_assignment() 2023-01-08 16:31:16 +01:00
Lennart Poettering 08af3cc5a5 strv: move nulstr utilities to nulstr-util.[ch]
Let's move them out of the generic, already very long strv.[ch] module
into the more specific nulst-util.[ch]

No code changes.
2022-11-13 17:39:08 +09:00
Daan De Meyer 12e2b70f9b nulstr-util: Declare NULSTR_FOREACH() iterator inline 2022-11-11 16:31:32 +01:00
Daan De Meyer 5ea173a91b strv: Make sure strv_make_nulstr() always returns a valid nulstr
strv_make_nulstr() is documented to always return a valid nulstr,
but if the input is `NULL` we return a string terminated with only
a single NUL terminator, so let's fix that and always terminate the
resulting string with two NUL bytes.
2022-11-11 16:31:20 +01:00
Lennart Poettering bcfc0e8872 strv: modernize strv_fnmatch() a bit 2022-08-30 01:09:12 +09:00
Zbigniew Jędrzejewski-Szmek 3ec3ae68d2 basic/strv: add optimizable version of strv_push/consume/extend
This will be helpful in cases where we are repeatedly adding entries
to a long strv and want to skip the iteration over old entries leading
to quadratic behaviour.

Note that we don't want to calculate the length if not necessary, so
the calculation is delayed until after we've checked that value is not
NULL.
2022-05-20 15:18:28 +02:00
Zbigniew Jędrzejewski-Szmek e5f2d77b48 basic/strv: fix typos and confusion whether we are escaping or unescaping 2022-04-06 15:26:05 +02:00