Merge pull request #14562 from yuwata/table-strv
introduce TABLE_STRV and use it in networkctl and resolvectl
This commit is contained in:
+15
-8
@@ -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) {
|
||||
|
||||
+4
-1
@@ -51,7 +51,10 @@ char **strv_remove(char **l, const char *s);
|
||||
char **strv_uniq(char **l);
|
||||
bool strv_is_uniq(char * const *l);
|
||||
|
||||
bool strv_equal(char * const *a, char * const *b);
|
||||
int strv_compare(char * const *a, char * const *b);
|
||||
static inline bool strv_equal(char * const *a, char * const *b) {
|
||||
return strv_compare(a, b) == 0;
|
||||
}
|
||||
|
||||
#define strv_contains(l, s) (!!strv_find((l), (s)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user