diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-12 15:48:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-04-12 15:48:19 +0200 |
commit | d9eb40c18519d10aac3b3d008aa7e338ae830b72 (patch) | |
tree | cffe3867dedefadb361ec6cbd507e9f967e36e90 | |
parent | 0cecbe7d5de237a6c699c67ae53ae2e2481eff43 (diff) | |
download | busybox-w32-d9eb40c18519d10aac3b3d008aa7e338ae830b72.tar.gz busybox-w32-d9eb40c18519d10aac3b3d008aa7e338ae830b72.tar.bz2 busybox-w32-d9eb40c18519d10aac3b3d008aa7e338ae830b72.zip |
fix errors found with make_single_applets.sh
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/cat.c | 27 | ||||
-rw-r--r-- | coreutils/who.c | 5 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | libbb/bb_cat.c | 33 | ||||
-rw-r--r-- | libbb/print_numbered_lines.c | 29 | ||||
-rw-r--r-- | procps/kill.c | 10 |
6 files changed, 71 insertions, 35 deletions
diff --git a/coreutils/cat.c b/coreutils/cat.c index 4169d9516..96970b19d 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c | |||
@@ -16,8 +16,6 @@ | |||
16 | //applet:IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat)) | 16 | //applet:IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat)) |
17 | 17 | ||
18 | //kbuild:lib-$(CONFIG_CAT) += cat.o | 18 | //kbuild:lib-$(CONFIG_CAT) += cat.o |
19 | // For -n: | ||
20 | //kbuild:lib-$(CONFIG_CAT) += nl.o | ||
21 | 19 | ||
22 | /* BB_AUDIT SUSv3 compliant */ | 20 | /* BB_AUDIT SUSv3 compliant */ |
23 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */ | 21 | /* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */ |
@@ -49,31 +47,6 @@ | |||
49 | 47 | ||
50 | /* This is a NOFORK applet. Be very careful! */ | 48 | /* This is a NOFORK applet. Be very careful! */ |
51 | 49 | ||
52 | |||
53 | int bb_cat(char **argv) | ||
54 | { | ||
55 | int fd; | ||
56 | int retval = EXIT_SUCCESS; | ||
57 | |||
58 | if (!*argv) | ||
59 | argv = (char**) &bb_argv_dash; | ||
60 | |||
61 | do { | ||
62 | fd = open_or_warn_stdin(*argv); | ||
63 | if (fd >= 0) { | ||
64 | /* This is not a xfunc - never exits */ | ||
65 | off_t r = bb_copyfd_eof(fd, STDOUT_FILENO); | ||
66 | if (fd != STDIN_FILENO) | ||
67 | close(fd); | ||
68 | if (r >= 0) | ||
69 | continue; | ||
70 | } | ||
71 | retval = EXIT_FAILURE; | ||
72 | } while (*++argv); | ||
73 | |||
74 | return retval; | ||
75 | } | ||
76 | |||
77 | int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 50 | int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
78 | int cat_main(int argc UNUSED_PARAM, char **argv) | 51 | int cat_main(int argc UNUSED_PARAM, char **argv) |
79 | { | 52 | { |
diff --git a/coreutils/who.c b/coreutils/who.c index ec9d25159..4adead77e 100644 --- a/coreutils/who.c +++ b/coreutils/who.c | |||
@@ -40,11 +40,12 @@ | |||
40 | 40 | ||
41 | // APPLET_ODDNAME:name main location suid_type help | 41 | // APPLET_ODDNAME:name main location suid_type help |
42 | //applet:IF_USERS(APPLET_ODDNAME(users, who, BB_DIR_USR_BIN, BB_SUID_DROP, users)) | 42 | //applet:IF_USERS(APPLET_ODDNAME(users, who, BB_DIR_USR_BIN, BB_SUID_DROP, users)) |
43 | //applet:IF_USERS(APPLET_ODDNAME(w, who, BB_DIR_USR_BIN, BB_SUID_DROP, w)) | 43 | //applet:IF_W( APPLET_ODDNAME(w, who, BB_DIR_USR_BIN, BB_SUID_DROP, w)) |
44 | //applet:IF_WHO( APPLET( who, BB_DIR_USR_BIN, BB_SUID_DROP)) | 44 | //applet:IF_WHO( APPLET( who, BB_DIR_USR_BIN, BB_SUID_DROP)) |
45 | 45 | ||
46 | //kbuild:lib-$(CONFIG_USERS) += who.o | 46 | //kbuild:lib-$(CONFIG_USERS) += who.o |
47 | //kbuild:lib-$(CONFIG_WHO) += who.o | 47 | //kbuild:lib-$(CONFIG_W) += who.o |
48 | //kbuild:lib-$(CONFIG_WHO) += who.o | ||
48 | 49 | ||
49 | /* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */ | 50 | /* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */ |
50 | 51 | ||
diff --git a/include/libbb.h b/include/libbb.h index 04071639a..2c30bde6f 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1247,7 +1247,7 @@ extern void bb_logenv_override(void) FAST_FUNC; | |||
1247 | 1247 | ||
1248 | 1248 | ||
1249 | /* Applets which are useful from another applets */ | 1249 | /* Applets which are useful from another applets */ |
1250 | int bb_cat(char** argv); | 1250 | int bb_cat(char** argv) FAST_FUNC; |
1251 | /* If shell needs them, they exist even if not enabled as applets */ | 1251 | /* If shell needs them, they exist even if not enabled as applets */ |
1252 | int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); | 1252 | int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); |
1253 | int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); | 1253 | int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); |
diff --git a/libbb/bb_cat.c b/libbb/bb_cat.c new file mode 100644 index 000000000..0a4a350fb --- /dev/null +++ b/libbb/bb_cat.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> | ||
4 | * | ||
5 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
6 | */ | ||
7 | //kbuild:lib-y += bb_cat.o | ||
8 | |||
9 | #include "libbb.h" | ||
10 | |||
11 | int FAST_FUNC bb_cat(char **argv) | ||
12 | { | ||
13 | int fd; | ||
14 | int retval = EXIT_SUCCESS; | ||
15 | |||
16 | if (!*argv) | ||
17 | argv = (char**) &bb_argv_dash; | ||
18 | |||
19 | do { | ||
20 | fd = open_or_warn_stdin(*argv); | ||
21 | if (fd >= 0) { | ||
22 | /* This is not a xfunc - never exits */ | ||
23 | off_t r = bb_copyfd_eof(fd, STDOUT_FILENO); | ||
24 | if (fd != STDIN_FILENO) | ||
25 | close(fd); | ||
26 | if (r >= 0) | ||
27 | continue; | ||
28 | } | ||
29 | retval = EXIT_FAILURE; | ||
30 | } while (*++argv); | ||
31 | |||
32 | return retval; | ||
33 | } | ||
diff --git a/libbb/print_numbered_lines.c b/libbb/print_numbered_lines.c new file mode 100644 index 000000000..702aed1ea --- /dev/null +++ b/libbb/print_numbered_lines.c | |||
@@ -0,0 +1,29 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com> | ||
4 | * | ||
5 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
6 | */ | ||
7 | //kbuild:lib-y += print_numbered_lines.o | ||
8 | |||
9 | #include "libbb.h" | ||
10 | |||
11 | void FAST_FUNC print_numbered_lines(struct number_state *ns, const char *filename) | ||
12 | { | ||
13 | FILE *fp = fopen_or_warn_stdin(filename); | ||
14 | unsigned N = ns->start; | ||
15 | char *line; | ||
16 | |||
17 | while ((line = xmalloc_fgetline(fp)) != NULL) { | ||
18 | if (ns->all | ||
19 | || (ns->nonempty && line[0]) | ||
20 | ) { | ||
21 | printf("%*u%s%s\n", ns->width, N, ns->sep, line); | ||
22 | N += ns->inc; | ||
23 | } else if (ns->empty_str) | ||
24 | fputs(ns->empty_str, stdout); | ||
25 | free(line); | ||
26 | } | ||
27 | |||
28 | fclose(fp); | ||
29 | } | ||
diff --git a/procps/kill.c b/procps/kill.c index 7ae5beead..975a3e8c5 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -201,7 +201,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv) | |||
201 | pid_t sid; | 201 | pid_t sid; |
202 | procps_status_t* p = NULL; | 202 | procps_status_t* p = NULL; |
203 | /* compat: exitcode 2 is "no one was signaled" */ | 203 | /* compat: exitcode 2 is "no one was signaled" */ |
204 | int ret = 2; | 204 | errors = 2; |
205 | 205 | ||
206 | /* Find out our session id */ | 206 | /* Find out our session id */ |
207 | sid = getsid(pid); | 207 | sid = getsid(pid); |
@@ -229,7 +229,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv) | |||
229 | arg = *args++; | 229 | arg = *args++; |
230 | if (arg[0] != '-' || arg[1] != 'o') { | 230 | if (arg[0] != '-' || arg[1] != 'o') { |
231 | bb_error_msg("bad option '%s'", arg); | 231 | bb_error_msg("bad option '%s'", arg); |
232 | ret = 1; | 232 | errors = 1; |
233 | goto resume; | 233 | goto resume; |
234 | } | 234 | } |
235 | arg += 2; | 235 | arg += 2; |
@@ -238,21 +238,21 @@ int kill_main(int argc UNUSED_PARAM, char **argv) | |||
238 | omit = bb_strtoi(arg, NULL, 10); | 238 | omit = bb_strtoi(arg, NULL, 10); |
239 | if (errno) { | 239 | if (errno) { |
240 | bb_error_msg("invalid number '%s'", arg); | 240 | bb_error_msg("invalid number '%s'", arg); |
241 | ret = 1; | 241 | errors = 1; |
242 | goto resume; | 242 | goto resume; |
243 | } | 243 | } |
244 | if (p->pid == omit) | 244 | if (p->pid == omit) |
245 | goto dont_kill; | 245 | goto dont_kill; |
246 | } | 246 | } |
247 | kill(p->pid, signo); | 247 | kill(p->pid, signo); |
248 | ret = 0; | 248 | errors = 0; |
249 | dont_kill: ; | 249 | dont_kill: ; |
250 | } | 250 | } |
251 | resume: | 251 | resume: |
252 | /* And let them continue */ | 252 | /* And let them continue */ |
253 | if (signo != SIGSTOP && signo != SIGCONT) | 253 | if (signo != SIGSTOP && signo != SIGCONT) |
254 | kill(-1, SIGCONT); | 254 | kill(-1, SIGCONT); |
255 | return ret; | 255 | return errors; |
256 | } | 256 | } |
257 | 257 | ||
258 | #if ENABLE_KILL || ENABLE_KILLALL | 258 | #if ENABLE_KILL || ENABLE_KILLALL |