]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
strv: introduce strv_print_full()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 19 Mar 2023 14:32:43 +0000 (23:32 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 20 Mar 2023 08:32:09 +0000 (09:32 +0100)
src/basic/strv.c
src/basic/strv.h

index 9b4a7663a90562340e957f5f631d6e6f60cf3731..5fcf3620a60ca7932a90e590c9a4643cbc8da837 100644 (file)
@@ -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, ...) {
index 49e1c3d8b1317218aa2059502b7d0749d14f1ef2..419cda1ee3f9456a4eb1178a9f66c971352b3f83 100644 (file)
@@ -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)                          \
         ({                                                      \