From 00546c18fd2555e6140f17b307c45ac487e0c5ad Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 19 Mar 2023 23:32:43 +0900 Subject: [PATCH] strv: introduce strv_print_full() --- src/basic/strv.c | 4 ++-- src/basic/strv.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/basic/strv.c b/src/basic/strv.c index 9b4a7663a9..5fcf3620a6 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -668,9 +668,9 @@ int strv_compare(char * const *a, char * const *b) { return 0; } -void strv_print(char * const *l) { +void strv_print_full(char * const *l, const char *prefix) { STRV_FOREACH(s, l) - puts(*s); + printf("%s%s\n", strempty(prefix), *s); } int strv_extendf(char ***l, const char *format, ...) { diff --git a/src/basic/strv.h b/src/basic/strv.h index 49e1c3d8b1..419cda1ee3 100644 --- a/src/basic/strv.h +++ b/src/basic/strv.h @@ -149,7 +149,10 @@ bool strv_overlap(char * const *a, char * const *b) _pure_; _STRV_FOREACH_PAIR(x, y, l, UNIQ_T(i, UNIQ)) char** strv_sort(char **l); -void strv_print(char * const *l); +void strv_print_full(char * const *l, const char *prefix); +static inline void strv_print(char * const *l) { + strv_print_full(l, NULL); +} #define strv_from_stdarg_alloca(first) \ ({ \