Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
steam
systemd
Commits
7c2d8094
Commit
7c2d8094
authored
Feb 07, 2013
by
Thomas Hindoe Paaboel Andersen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strv: add strv_print
Clearer, and spares the temp variable.
parent
fa3cd739
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
19 deletions
+17
-19
src/locale/localectl.c
src/locale/localectl.c
+2
-7
src/shared/strv.c
src/shared/strv.c
+10
-0
src/shared/strv.h
src/shared/strv.h
+1
-0
src/test/test-env-replace.c
src/test/test-env-replace.c
+3
-9
src/timedate/timedatectl.c
src/timedate/timedatectl.c
+1
-3
No files found.
src/locale/localectl.c
View file @
7c2d8094
...
...
@@ -432,7 +432,6 @@ static int add_locales_from_libdir (Set *locales) {
static
int
list_locales
(
DBusConnection
*
bus
,
char
**
args
,
unsigned
n
)
{
_cleanup_set_free_
Set
*
locales
;
_cleanup_strv_free_
char
**
l
=
NULL
;
char
**
j
;
int
r
;
locales
=
set_new
(
string_hash_func
,
string_compare_func
);
...
...
@@ -455,8 +454,7 @@ static int list_locales(DBusConnection *bus, char **args, unsigned n) {
pager_open_if_enabled
();
STRV_FOREACH
(
j
,
l
)
puts
(
*
j
);
strv_print
(
l
);
return
0
;
}
...
...
@@ -539,7 +537,6 @@ static int nftw_cb(
static
int
list_vconsole_keymaps
(
DBusConnection
*
bus
,
char
**
args
,
unsigned
n
)
{
char
_cleanup_strv_free_
**
l
=
NULL
;
char
**
i
;
keymaps
=
set_new
(
string_hash_func
,
string_compare_func
);
if
(
!
keymaps
)
...
...
@@ -566,9 +563,7 @@ static int list_vconsole_keymaps(DBusConnection *bus, char **args, unsigned n) {
pager_open_if_enabled
();
STRV_FOREACH
(
i
,
l
)
puts
(
*
i
);
strv_print
(
l
);
return
0
;
}
...
...
src/shared/strv.c
View file @
7c2d8094
...
...
@@ -774,3 +774,13 @@ char **strv_sort(char **l) {
qsort
(
l
,
strv_length
(
l
),
sizeof
(
char
*
),
str_compare
);
return
l
;
}
void
strv_print
(
char
**
l
)
{
char
**
s
;
if
(
!
l
)
return
;
STRV_FOREACH
(
s
,
l
)
puts
(
*
s
);
}
src/shared/strv.h
View file @
7c2d8094
...
...
@@ -87,3 +87,4 @@ bool strv_overlap(char **a, char **b);
char
**
strv_sort
(
char
**
l
);
void
strv_print
(
char
**
l
);
src/test/test-env-replace.c
View file @
7c2d8094
...
...
@@ -58,10 +58,7 @@ int main(int argc, char *argv[]) {
strv_free
(
a
);
r
=
replace_env_argv
((
char
**
)
line
,
(
char
**
)
env
);
STRV_FOREACH
(
i
,
r
)
printf
(
"%s
\n
"
,
*
i
);
strv_print
(
r
);
strv_free
(
r
);
t
=
normalize_env_assignment
(
"foo=bar"
);
...
...
@@ -127,16 +124,13 @@ int main(int argc, char *argv[]) {
strv_free
(
a
);
strv_free
(
b
);
STRV_FOREACH
(
i
,
r
)
printf
(
"%s
\n
"
,
*
i
);
strv_print
(
r
);
printf
(
"CLEANED UP:
\n
"
);
r
=
strv_env_clean
(
r
);
STRV_FOREACH
(
i
,
r
)
printf
(
"%s
\n
"
,
*
i
);
strv_print
(
r
);
strv_free
(
r
);
return
0
;
...
...
src/timedate/timedatectl.c
View file @
7c2d8094
...
...
@@ -425,7 +425,6 @@ static int list_timezones(DBusConnection *bus, char **args, unsigned n) {
_cleanup_fclose_
FILE
*
f
=
NULL
;
_cleanup_strv_free_
char
**
zones
=
NULL
;
size_t
n_zones
=
0
;
char
**
i
;
assert
(
args
);
assert
(
n
==
1
);
...
...
@@ -487,8 +486,7 @@ static int list_timezones(DBusConnection *bus, char **args, unsigned n) {
pager_open_if_enabled
();
strv_sort
(
zones
);
STRV_FOREACH
(
i
,
zones
)
puts
(
*
i
);
strv_print
(
zones
);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment