mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
Merge pull request #14351 from yuwata/util-constify-strv-xxx
util: constify arguments of strv_xxx()
This commit is contained in:
commit
024941a521
@ -16,8 +16,8 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
char *strv_find(char **l, const char *name) {
|
||||
char **i;
|
||||
char *strv_find(char * const *l, const char *name) {
|
||||
char * const *i;
|
||||
|
||||
assert(name);
|
||||
|
||||
@ -28,8 +28,8 @@ char *strv_find(char **l, const char *name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *strv_find_prefix(char **l, const char *name) {
|
||||
char **i;
|
||||
char *strv_find_prefix(char * const *l, const char *name) {
|
||||
char * const *i;
|
||||
|
||||
assert(name);
|
||||
|
||||
@ -40,8 +40,8 @@ char *strv_find_prefix(char **l, const char *name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *strv_find_startswith(char **l, const char *name) {
|
||||
char **i, *e;
|
||||
char *strv_find_startswith(char * const *l, const char *name) {
|
||||
char * const *i, *e;
|
||||
|
||||
assert(name);
|
||||
|
||||
@ -181,8 +181,8 @@ char **strv_new_internal(const char *x, ...) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int strv_extend_strv(char ***a, char **b, bool filter_duplicates) {
|
||||
char **s, **t;
|
||||
int strv_extend_strv(char ***a, char * const *b, bool filter_duplicates) {
|
||||
char * const *s, **t;
|
||||
size_t p, q, i = 0, j;
|
||||
|
||||
assert(a);
|
||||
@ -228,9 +228,9 @@ rollback:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
int strv_extend_strv_concat(char ***a, char **b, const char *suffix) {
|
||||
int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix) {
|
||||
char * const *s;
|
||||
int r;
|
||||
char **s;
|
||||
|
||||
STRV_FOREACH(s, b) {
|
||||
char *v;
|
||||
@ -346,9 +346,9 @@ int strv_split_extract(char ***t, const char *s, const char *separators, Extract
|
||||
return (int) n;
|
||||
}
|
||||
|
||||
char *strv_join_prefix(char **l, const char *separator, const char *prefix) {
|
||||
char *strv_join_prefix(char * const *l, const char *separator, const char *prefix) {
|
||||
char * const *s;
|
||||
char *r, *e;
|
||||
char **s;
|
||||
size_t n, k, m;
|
||||
|
||||
if (!separator)
|
||||
@ -562,8 +562,8 @@ char **strv_uniq(char **l) {
|
||||
return l;
|
||||
}
|
||||
|
||||
bool strv_is_uniq(char **l) {
|
||||
char **i;
|
||||
bool strv_is_uniq(char * const *l) {
|
||||
char * const *i;
|
||||
|
||||
STRV_FOREACH(i, l)
|
||||
if (strv_find(i+1, *i))
|
||||
@ -666,7 +666,7 @@ char **strv_split_nulstr(const char *s) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int strv_make_nulstr(char **l, char **p, size_t *q) {
|
||||
int strv_make_nulstr(char * const *l, char **ret, size_t *ret_size) {
|
||||
/* A valid nulstr with two NULs at the end will be created, but
|
||||
* q will be the length without the two trailing NULs. Thus the output
|
||||
* string is a valid nulstr and can be iterated over using NULSTR_FOREACH,
|
||||
@ -676,10 +676,10 @@ int strv_make_nulstr(char **l, char **p, size_t *q) {
|
||||
|
||||
size_t n_allocated = 0, n = 0;
|
||||
_cleanup_free_ char *m = NULL;
|
||||
char **i;
|
||||
char * const *i;
|
||||
|
||||
assert(p);
|
||||
assert(q);
|
||||
assert(ret);
|
||||
assert(ret_size);
|
||||
|
||||
STRV_FOREACH(i, l) {
|
||||
size_t z;
|
||||
@ -703,16 +703,16 @@ int strv_make_nulstr(char **l, char **p, size_t *q) {
|
||||
m[n] = '\0';
|
||||
|
||||
assert(n > 0);
|
||||
*p = m;
|
||||
*q = n - 1;
|
||||
*ret = m;
|
||||
*ret_size = n - 1;
|
||||
|
||||
m = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool strv_overlap(char **a, char **b) {
|
||||
char **i;
|
||||
bool strv_overlap(char * const *a, char * const *b) {
|
||||
char * const *i;
|
||||
|
||||
STRV_FOREACH(i, a)
|
||||
if (strv_contains(b, *i))
|
||||
@ -730,7 +730,7 @@ char **strv_sort(char **l) {
|
||||
return l;
|
||||
}
|
||||
|
||||
bool strv_equal(char **a, char **b) {
|
||||
bool strv_equal(char * const *a, char * const *b) {
|
||||
|
||||
if (strv_isempty(a))
|
||||
return strv_isempty(b);
|
||||
@ -745,8 +745,8 @@ bool strv_equal(char **a, char **b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void strv_print(char **l) {
|
||||
char **s;
|
||||
void strv_print(char * const *l) {
|
||||
char * const *s;
|
||||
|
||||
STRV_FOREACH(s, l)
|
||||
puts(*s);
|
||||
@ -874,9 +874,9 @@ rollback:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
int fputstrv(FILE *f, char **l, const char *separator, bool *space) {
|
||||
int fputstrv(FILE *f, char * const *l, const char *separator, bool *space) {
|
||||
bool b = false;
|
||||
char **s;
|
||||
char * const *s;
|
||||
int r;
|
||||
|
||||
/* Like fputs(), but for strv, and with a less stupid argument order */
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include "macro.h"
|
||||
#include "string-util.h"
|
||||
|
||||
char *strv_find(char **l, const char *name) _pure_;
|
||||
char *strv_find_prefix(char **l, const char *name) _pure_;
|
||||
char *strv_find_startswith(char **l, const char *name) _pure_;
|
||||
char *strv_find(char * const *l, const char *name) _pure_;
|
||||
char *strv_find_prefix(char * const *l, const char *name) _pure_;
|
||||
char *strv_find_startswith(char * const *l, const char *name) _pure_;
|
||||
|
||||
char **strv_free(char **l);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);
|
||||
@ -30,8 +30,8 @@ void strv_clear(char **l);
|
||||
char **strv_copy(char * const *l);
|
||||
size_t strv_length(char * const *l) _pure_;
|
||||
|
||||
int strv_extend_strv(char ***a, char **b, bool filter_duplicates);
|
||||
int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
|
||||
int strv_extend_strv(char ***a, char * const *b, bool filter_duplicates);
|
||||
int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix);
|
||||
int strv_extend(char ***l, const char *value);
|
||||
int strv_extendf(char ***l, const char *format, ...) _printf_(2,0);
|
||||
int strv_extend_front(char ***l, const char *value);
|
||||
@ -49,9 +49,9 @@ int strv_consume_prepend(char ***l, char *value);
|
||||
|
||||
char **strv_remove(char **l, const char *s);
|
||||
char **strv_uniq(char **l);
|
||||
bool strv_is_uniq(char **l);
|
||||
bool strv_is_uniq(char * const *l);
|
||||
|
||||
bool strv_equal(char **a, char **b);
|
||||
bool strv_equal(char * const *a, char * const *b);
|
||||
|
||||
#define strv_contains(l, s) (!!strv_find((l), (s)))
|
||||
|
||||
@ -77,16 +77,16 @@ char **strv_split_newlines(const char *s);
|
||||
|
||||
int strv_split_extract(char ***t, const char *s, const char *separators, ExtractFlags flags);
|
||||
|
||||
char *strv_join_prefix(char **l, const char *separator, const char *prefix);
|
||||
static inline char *strv_join(char **l, const char *separator) {
|
||||
char *strv_join_prefix(char * const *l, const char *separator, const char *prefix);
|
||||
static inline char *strv_join(char * const *l, const char *separator) {
|
||||
return strv_join_prefix(l, separator, NULL);
|
||||
}
|
||||
|
||||
char **strv_parse_nulstr(const char *s, size_t l);
|
||||
char **strv_split_nulstr(const char *s);
|
||||
int strv_make_nulstr(char **l, char **p, size_t *n);
|
||||
int strv_make_nulstr(char * const *l, char **p, size_t *n);
|
||||
|
||||
bool strv_overlap(char **a, char **b) _pure_;
|
||||
bool strv_overlap(char * const *a, char * const *b) _pure_;
|
||||
|
||||
#define STRV_FOREACH(s, l) \
|
||||
for ((s) = (l); (s) && *(s); (s)++)
|
||||
@ -103,7 +103,7 @@ bool strv_overlap(char **a, char **b) _pure_;
|
||||
for ((x) = (l), (y) = (x+1); (x) && *(x) && *(y); (x) += 2, (y) = (x + 1))
|
||||
|
||||
char **strv_sort(char **l);
|
||||
void strv_print(char **l);
|
||||
void strv_print(char * const *l);
|
||||
|
||||
#define STRV_MAKE(...) ((char**) ((const char*[]) { __VA_ARGS__, NULL }))
|
||||
|
||||
@ -192,7 +192,7 @@ char **strv_skip(char **l, size_t n);
|
||||
|
||||
int strv_extend_n(char ***l, const char *value, size_t n);
|
||||
|
||||
int fputstrv(FILE *f, char **l, const char *separator, bool *space);
|
||||
int fputstrv(FILE *f, char * const *l, const char *separator, bool *space);
|
||||
|
||||
#define strv_free_and_replace(a, b) \
|
||||
({ \
|
||||
|
Loading…
Reference in New Issue
Block a user