1 |
commit: 8fcaba9a22ac0deda7dc6a8d5f270d1df08f9966 |
2 |
Author: James Le Cuirot <chewi <AT> aura-online <DOT> co <DOT> uk> |
3 |
AuthorDate: Wed Apr 20 10:55:06 2011 +0000 |
4 |
Commit: William Hubbs <williamh <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Apr 27 20:27:16 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=8fcaba9a |
7 |
|
8 |
fix rc_service_extra_commands return value |
9 |
|
10 |
If there were no extra commands, rc_service_extra_commands returned a |
11 |
list containing a single empty string. This changes that to return an |
12 |
empty list, which is more consistent with what you would expect. |
13 |
|
14 |
X-Gentoo-Bug: 360013 |
15 |
X-Gentoo-Bug-URL: http://bugs.gentoo.org/show_bug.cgi?id=360013 |
16 |
|
17 |
--- |
18 |
src/librc/librc.c | 12 +++++++----- |
19 |
1 files changed, 7 insertions(+), 5 deletions(-) |
20 |
|
21 |
diff --git a/src/librc/librc.c b/src/librc/librc.c |
22 |
index f2f694d..5feb5d7 100644 |
23 |
--- a/src/librc/librc.c |
24 |
+++ b/src/librc/librc.c |
25 |
@@ -550,14 +550,16 @@ rc_service_extra_commands(const char *service) |
26 |
if ((fp = popen(cmd, "r"))) { |
27 |
rc_getline(&buffer, &len, fp); |
28 |
p = buffer; |
29 |
- while ((token = strsep(&p, " "))) { |
30 |
- if (!commands) |
31 |
- commands = rc_stringlist_new(); |
32 |
- rc_stringlist_add(commands, token); |
33 |
- } |
34 |
+ commands = rc_stringlist_new(); |
35 |
+ |
36 |
+ while ((token = strsep(&p, " "))) |
37 |
+ if (token[0] != '\0') |
38 |
+ rc_stringlist_add(commands, token); |
39 |
+ |
40 |
pclose(fp); |
41 |
free(buffer); |
42 |
} |
43 |
+ |
44 |
free(cmd); |
45 |
return commands; |
46 |
} |