diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-01-14 18:29:50 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-01-15 11:52:40 +0900 |
commit | 8b75798d12cc5a5577ae1ae2020c92ec66f683ee (patch) | |
tree | d41ee90071e52c239c5f9a093cbc3d43ff71ae9c /src/basic/strv.c | |
parent | dbca7332130f8a7345dcf1ca2316d8e951d6052a (diff) | |
download | systemd-8b75798d12cc5a5577ae1ae2020c92ec66f683ee.tar.gz |
strv: introduce strv_compare()
Diffstat (limited to 'src/basic/strv.c')
-rw-r--r-- | src/basic/strv.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/basic/strv.c b/src/basic/strv.c index 99bcfde089..5588cd7c41 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -730,19 +730,26 @@ char **strv_sort(char **l) { return l; } -bool strv_equal(char * const *a, char * const *b) { +int strv_compare(char * const *a, char * const *b) { + int r; - if (strv_isempty(a)) - return strv_isempty(b); + if (strv_isempty(a)) { + if (strv_isempty(b)) + return 0; + else + return -1; + } if (strv_isempty(b)) - return false; + return 1; - for ( ; *a || *b; ++a, ++b) - if (!streq_ptr(*a, *b)) - return false; + for ( ; *a || *b; ++a, ++b) { + r = strcmp_ptr(*a, *b); + if (r != 0) + return r; + } - return true; + return 0; } void strv_print(char * const *l) { |