diff options
-rw-r--r-- | applets/applet_tables.c | 2 | ||||
-rw-r--r-- | applets/applets.c | 2 | ||||
-rw-r--r-- | coreutils/cat.c | 2 | ||||
-rw-r--r-- | coreutils/tac.c | 2 | ||||
-rw-r--r-- | docs/new-applet-HOWTO.txt | 2 | ||||
-rw-r--r-- | e2fsprogs/old_e2fsprogs/e2fsck.c | 2 | ||||
-rw-r--r-- | editors/patch.c | 37 | ||||
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | include/xregex.h | 2 | ||||
-rw-r--r-- | libbb/Kbuild.src | 3 | ||||
-rw-r--r-- | libbb/appletlib.c | 2 | ||||
-rw-r--r-- | libbb/get_cpu_count.c | 47 | ||||
-rw-r--r-- | libbb/strrstr.c | 2 | ||||
-rw-r--r-- | miscutils/adjtimex.c | 2 | ||||
-rw-r--r-- | miscutils/conspy.c | 2 | ||||
-rw-r--r-- | miscutils/readahead.c | 2 | ||||
-rw-r--r-- | procps/iostat.c | 32 | ||||
-rw-r--r-- | procps/mpstat.c | 42 | ||||
-rwxr-xr-x | testsuite/patch.tests | 37 | ||||
-rw-r--r-- | util-linux/hexdump.c | 2 | ||||
-rw-r--r-- | util-linux/more.c | 2 | ||||
-rw-r--r-- | util-linux/rdate.c | 2 | ||||
-rw-r--r-- | util-linux/rev.c | 2 | ||||
-rw-r--r-- | util-linux/script.c | 2 | ||||
-rw-r--r-- | util-linux/scriptreplay.c | 2 | ||||
-rw-r--r-- | util-linux/setarch.c | 2 |
26 files changed, 133 insertions, 105 deletions
diff --git a/applets/applet_tables.c b/applets/applet_tables.c index 338dc20f9..f56908420 100644 --- a/applets/applet_tables.c +++ b/applets/applet_tables.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com> | 6 | * Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com> |
7 | * | 7 | * |
8 | * Licensed under GPLv2, see file License in this tarball for details. | 8 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
diff --git a/applets/applets.c b/applets/applets.c index 6a3996272..5a7b88e88 100644 --- a/applets/applets.c +++ b/applets/applets.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com> | 5 | * Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com> |
6 | * | 6 | * |
7 | * Licensed under GPLv2, see file License in this tarball for details. | 7 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | #include "busybox.h" | 9 | #include "busybox.h" |
10 | 10 | ||
diff --git a/coreutils/cat.c b/coreutils/cat.c index ab682588f..454c46b68 100644 --- a/coreutils/cat.c +++ b/coreutils/cat.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> | 5 | * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> |
6 | * | 6 | * |
7 | * Licensed under GPLv2, see file License in this tarball for details. | 7 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* BB_AUDIT SUSv3 compliant */ | 10 | /* BB_AUDIT SUSv3 compliant */ |
diff --git a/coreutils/tac.c b/coreutils/tac.c index d70e23ad4..b8db8eaba 100644 --- a/coreutils/tac.c +++ b/coreutils/tac.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (C) 2007 Natanael Copa <natanael.copa@gmail.com> | 6 | * Copyright (C) 2007 Natanael Copa <natanael.copa@gmail.com> |
7 | * Copyright (C) 2007 Tito Ragusa <farmatito@tiscali.it> | 7 | * Copyright (C) 2007 Tito Ragusa <farmatito@tiscali.it> |
8 | * | 8 | * |
9 | * Licensed under GPLv2, see file License in this tarball for details. | 9 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
diff --git a/docs/new-applet-HOWTO.txt b/docs/new-applet-HOWTO.txt index 7fbd62ed1..a2c5a49fe 100644 --- a/docs/new-applet-HOWTO.txt +++ b/docs/new-applet-HOWTO.txt | |||
@@ -36,7 +36,7 @@ For a new applet mu, here is the code that would go in mu.c: | |||
36 | * | 36 | * |
37 | * Copyright (C) [YEAR] by [YOUR NAME] <YOUR EMAIL> | 37 | * Copyright (C) [YEAR] by [YOUR NAME] <YOUR EMAIL> |
38 | * | 38 | * |
39 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 39 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
40 | */ | 40 | */ |
41 | 41 | ||
42 | #include "libbb.h" | 42 | #include "libbb.h" |
diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c index f58fe9286..cf52f51b6 100644 --- a/e2fsprogs/old_e2fsprogs/e2fsck.c +++ b/e2fsprogs/old_e2fsprogs/e2fsck.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * Journal recovery routines for the generic filesystem journaling code; | 26 | * Journal recovery routines for the generic filesystem journaling code; |
27 | * part of the ext2fs journaling system. | 27 | * part of the ext2fs journaling system. |
28 | * | 28 | * |
29 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 29 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "e2fsck.h" /*Put all of our defines here to clean things up*/ | 32 | #include "e2fsck.h" /*Put all of our defines here to clean things up*/ |
diff --git a/editors/patch.c b/editors/patch.c index 7f3234e66..eb16bca12 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -82,6 +82,9 @@ void TOY_llist_free(void *list, void (*freeit)(void *data)) | |||
82 | if (list==pop) break; | 82 | if (list==pop) break; |
83 | } | 83 | } |
84 | } | 84 | } |
85 | //Override bbox's names | ||
86 | #define llist_pop TOY_llist_pop | ||
87 | #define llist_free TOY_llist_free | ||
85 | 88 | ||
86 | // Add an entry to the end off a doubly linked list | 89 | // Add an entry to the end off a doubly linked list |
87 | static | 90 | static |
@@ -227,7 +230,8 @@ struct globals { | |||
227 | long prefix; | 230 | long prefix; |
228 | 231 | ||
229 | struct double_list *current_hunk; | 232 | struct double_list *current_hunk; |
230 | long oldline, oldlen, newline, newlen, linenum; | 233 | long oldline, oldlen, newline, newlen; |
234 | long linenum; | ||
231 | int context, state, filein, fileout, filepatch, hunknum; | 235 | int context, state, filein, fileout, filepatch, hunknum; |
232 | char *tempname; | 236 | char *tempname; |
233 | 237 | ||
@@ -241,14 +245,16 @@ struct globals { | |||
241 | 245 | ||
242 | 246 | ||
243 | //bbox had: "p:i:RN" | 247 | //bbox had: "p:i:RN" |
244 | #define FLAG_STR "Rup:i:x" | 248 | #define FLAG_STR "Rup:i:Nx" |
245 | /* FLAG_REVERSE must be == 1! Code uses this fact. */ | 249 | /* FLAG_REVERSE must be == 1! Code uses this fact. */ |
246 | #define FLAG_REVERSE (1 << 0) | 250 | #define FLAG_REVERSE (1 << 0) |
247 | #define FLAG_u (1 << 1) | 251 | #define FLAG_u (1 << 1) |
248 | #define FLAG_PATHLEN (1 << 2) | 252 | #define FLAG_PATHLEN (1 << 2) |
249 | #define FLAG_INPUT (1 << 3) | 253 | #define FLAG_INPUT (1 << 3) |
254 | // -N: not supported yet | ||
255 | #define FLAG_IGNORE (1 << 4) | ||
250 | //non-standard: | 256 | //non-standard: |
251 | #define FLAG_DEBUG (1 << 4) | 257 | #define FLAG_DEBUG (1 << 5) |
252 | 258 | ||
253 | // Dispose of a line of input, either by writing it out or discarding it. | 259 | // Dispose of a line of input, either by writing it out or discarding it. |
254 | 260 | ||
@@ -291,7 +297,7 @@ static void fail_hunk(void) | |||
291 | // this file and advance to next file. | 297 | // this file and advance to next file. |
292 | 298 | ||
293 | TT.state = 2; | 299 | TT.state = 2; |
294 | TOY_llist_free(TT.current_hunk, do_line); | 300 | llist_free(TT.current_hunk, do_line); |
295 | TT.current_hunk = NULL; | 301 | TT.current_hunk = NULL; |
296 | delete_tempfile(TT.filein, TT.fileout, &TT.tempname); | 302 | delete_tempfile(TT.filein, TT.fileout, &TT.tempname); |
297 | TT.state = 0; | 303 | TT.state = 0; |
@@ -377,7 +383,7 @@ static int apply_one_hunk(void) | |||
377 | fdprintf(2, "NOT: %s\n", plist->data); | 383 | fdprintf(2, "NOT: %s\n", plist->data); |
378 | 384 | ||
379 | TT.state = 3; | 385 | TT.state = 3; |
380 | check = TOY_llist_pop(&buf); | 386 | check = llist_pop(&buf); |
381 | check->prev->next = buf; | 387 | check->prev->next = buf; |
382 | buf->prev = check->prev; | 388 | buf->prev = check->prev; |
383 | do_line(check); | 389 | do_line(check); |
@@ -404,13 +410,13 @@ static int apply_one_hunk(void) | |||
404 | out: | 410 | out: |
405 | // We have a match. Emit changed data. | 411 | // We have a match. Emit changed data. |
406 | TT.state = "-+"[reverse]; | 412 | TT.state = "-+"[reverse]; |
407 | TOY_llist_free(TT.current_hunk, do_line); | 413 | llist_free(TT.current_hunk, do_line); |
408 | TT.current_hunk = NULL; | 414 | TT.current_hunk = NULL; |
409 | TT.state = 1; | 415 | TT.state = 1; |
410 | done: | 416 | done: |
411 | if (buf) { | 417 | if (buf) { |
412 | buf->prev->next = NULL; | 418 | buf->prev->next = NULL; |
413 | TOY_llist_free(buf, do_line); | 419 | llist_free(buf, do_line); |
414 | } | 420 | } |
415 | 421 | ||
416 | return TT.state; | 422 | return TT.state; |
@@ -505,14 +511,19 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
505 | // way the patch man page says, so you have to read the first hunk | 511 | // way the patch man page says, so you have to read the first hunk |
506 | // and _guess_. | 512 | // and _guess_. |
507 | 513 | ||
508 | // Start a new hunk? | 514 | // Start a new hunk? Usually @@ -oldline,oldlen +newline,newlen @@ |
515 | // but a missing ,value means the value is 1. | ||
509 | } else if (state == 1 && !strncmp("@@ -", patchline, 4)) { | 516 | } else if (state == 1 && !strncmp("@@ -", patchline, 4)) { |
510 | int i; | 517 | int i; |
518 | char *s = patchline+4; | ||
511 | 519 | ||
512 | i = sscanf(patchline+4, "%ld,%ld +%ld,%ld", &TT.oldline, | 520 | // Read oldline[,oldlen] +newline[,newlen] |
513 | &TT.oldlen, &TT.newline, &TT.newlen); | 521 | |
514 | if (i != 4) | 522 | TT.oldlen = TT.newlen = 1; |
515 | bb_error_msg_and_die("corrupt hunk %d at %ld", TT.hunknum, TT.linenum); | 523 | TT.oldline = strtol(s, &s, 10); |
524 | if (*s == ',') TT.oldlen=strtol(s+1, &s, 10); | ||
525 | TT.newline = strtol(s+2, &s, 10); | ||
526 | if (*s == ',') TT.newlen = strtol(s+1, &s, 10); | ||
516 | 527 | ||
517 | TT.context = 0; | 528 | TT.context = 0; |
518 | state = 2; | 529 | state = 2; |
@@ -520,7 +531,7 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
520 | // If this is the first hunk, open the file. | 531 | // If this is the first hunk, open the file. |
521 | if (TT.filein == -1) { | 532 | if (TT.filein == -1) { |
522 | int oldsum, newsum, del = 0; | 533 | int oldsum, newsum, del = 0; |
523 | char *s, *name; | 534 | char *name; |
524 | 535 | ||
525 | oldsum = TT.oldline + TT.oldlen; | 536 | oldsum = TT.oldline + TT.oldlen; |
526 | newsum = TT.newline + TT.newlen; | 537 | newsum = TT.newline + TT.newlen; |
diff --git a/include/libbb.h b/include/libbb.h index 3a7a8f33f..fcff7b51e 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -1495,6 +1495,8 @@ procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; | |||
1495 | void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; | 1495 | void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; |
1496 | pid_t *find_pid_by_name(const char* procName) FAST_FUNC; | 1496 | pid_t *find_pid_by_name(const char* procName) FAST_FUNC; |
1497 | pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; | 1497 | pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; |
1498 | int starts_with_cpu(const char *str) FAST_FUNC; | ||
1499 | unsigned get_cpu_count(void) FAST_FUNC; | ||
1498 | 1500 | ||
1499 | 1501 | ||
1500 | extern const char bb_uuenc_tbl_base64[]; | 1502 | extern const char bb_uuenc_tbl_base64[]; |
diff --git a/include/xregex.h b/include/xregex.h index 61658ed85..44a2297e6 100644 --- a/include/xregex.h +++ b/include/xregex.h | |||
@@ -6,7 +6,7 @@ | |||
6 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | 6 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell |
7 | * Permission has been granted to redistribute this code under the GPL. | 7 | * Permission has been granted to redistribute this code under the GPL. |
8 | * | 8 | * |
9 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
10 | */ | 10 | */ |
11 | #ifndef BB_REGEX_H | 11 | #ifndef BB_REGEX_H |
12 | #define BB_REGEX_H 1 | 12 | #define BB_REGEX_H 1 |
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index a4f77414b..a6a163f3e 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src | |||
@@ -158,6 +158,9 @@ lib-$(CONFIG_MOUNT) += find_mount_point.o | |||
158 | lib-$(CONFIG_HWCLOCK) += rtc.o | 158 | lib-$(CONFIG_HWCLOCK) += rtc.o |
159 | lib-$(CONFIG_RTCWAKE) += rtc.o | 159 | lib-$(CONFIG_RTCWAKE) += rtc.o |
160 | 160 | ||
161 | lib-$(CONFIG_IOSTAT) += get_cpu_count.o | ||
162 | lib-$(CONFIG_MPSTAT) += get_cpu_count.o | ||
163 | |||
161 | # We shouldn't build xregcomp.c if we don't need it - this ensures we don't | 164 | # We shouldn't build xregcomp.c if we don't need it - this ensures we don't |
162 | # require regex.h to be in the include dir even if we don't need it thereby | 165 | # require regex.h to be in the include dir even if we don't need it thereby |
163 | # allowing us to build busybox even if uclibc regex support is disabled. | 166 | # allowing us to build busybox even if uclibc regex support is disabled. |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index cae7da48a..b470f30f9 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell | 9 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell |
10 | * Permission has been granted to redistribute this code under the GPL. | 10 | * Permission has been granted to redistribute this code under the GPL. |
11 | * | 11 | * |
12 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 12 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | /* We are trying to not use printf, this benefits the case when selected | 15 | /* We are trying to not use printf, this benefits the case when selected |
diff --git a/libbb/get_cpu_count.c b/libbb/get_cpu_count.c new file mode 100644 index 000000000..edb7e6d37 --- /dev/null +++ b/libbb/get_cpu_count.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Factored out of mpstat/iostat. | ||
4 | * | ||
5 | * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> | ||
6 | * | ||
7 | * Licensed under GPLv2, see file LICENSE in this tarball for details. | ||
8 | */ | ||
9 | #include "libbb.h" | ||
10 | |||
11 | /* Does str start with "cpu"? */ | ||
12 | int FAST_FUNC starts_with_cpu(const char *str) | ||
13 | { | ||
14 | return ((str[0] - 'c') | (str[1] - 'p') | (str[2] - 'u')) == 0; | ||
15 | } | ||
16 | |||
17 | /* | ||
18 | * Get number of processors. Uses /proc/stat. | ||
19 | * Return value 0 means one CPU and non SMP kernel. | ||
20 | * Otherwise N means N processor(s) and SMP kernel. | ||
21 | */ | ||
22 | unsigned FAST_FUNC get_cpu_count(void) | ||
23 | { | ||
24 | FILE *fp; | ||
25 | char line[256]; | ||
26 | int proc_nr = -1; | ||
27 | |||
28 | fp = xfopen_for_read("/proc/stat"); | ||
29 | while (fgets(line, sizeof(line), fp)) { | ||
30 | if (!starts_with_cpu(line)) { | ||
31 | if (proc_nr >= 0) | ||
32 | break; /* we are past "cpuN..." lines */ | ||
33 | continue; | ||
34 | } | ||
35 | if (line[3] != ' ') { /* "cpuN" */ | ||
36 | int num_proc; | ||
37 | if (sscanf(line + 3, "%u", &num_proc) == 1 | ||
38 | && num_proc > proc_nr | ||
39 | ) { | ||
40 | proc_nr = num_proc; | ||
41 | } | ||
42 | } | ||
43 | } | ||
44 | |||
45 | fclose(fp); | ||
46 | return proc_nr + 1; | ||
47 | } | ||
diff --git a/libbb/strrstr.c b/libbb/strrstr.c index a803dd983..d201f5172 100644 --- a/libbb/strrstr.c +++ b/libbb/strrstr.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2008 Bernhard Reutner-Fischer | 5 | * Copyright (C) 2008 Bernhard Reutner-Fischer |
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #ifdef __DO_STRRSTR_TEST | 10 | #ifdef __DO_STRRSTR_TEST |
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c index c12a10b25..a6f323ba2 100644 --- a/miscutils/adjtimex.c +++ b/miscutils/adjtimex.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * | 8 | * |
9 | * busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov> | 9 | * busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov> |
10 | * | 10 | * |
11 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 11 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "libbb.h" | 14 | #include "libbb.h" |
diff --git a/miscutils/conspy.c b/miscutils/conspy.c index a173d8efd..02b13e9c8 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Based on Russell Stuart's conspy.c | 7 | * Based on Russell Stuart's conspy.c |
8 | * http://ace-host.stuart.id.au/russell/files/conspy.c | 8 | * http://ace-host.stuart.id.au/russell/files/conspy.c |
9 | * | 9 | * |
10 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 10 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | //applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP)) | 13 | //applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP)) |
diff --git a/miscutils/readahead.c b/miscutils/readahead.c index f3b21a2fc..e7b75f12f 100644 --- a/miscutils/readahead.c +++ b/miscutils/readahead.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * Copyright (C) 2006 Michael Opdenacker <michael@free-electrons.com> | 8 | * Copyright (C) 2006 Michael Opdenacker <michael@free-electrons.com> |
9 | * | 9 | * |
10 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 10 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include "libbb.h" | 13 | #include "libbb.h" |
diff --git a/procps/iostat.c b/procps/iostat.c index 76c5353cc..05c758b6c 100644 --- a/procps/iostat.c +++ b/procps/iostat.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> | 5 | * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> |
6 | * | 6 | * |
7 | * Licensed under GPLv2, see file License in this tarball for details. | 7 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_IOSTAT(APPLET(iostat, _BB_DIR_BIN, _BB_SUID_DROP)) | 10 | //applet:IF_IOSTAT(APPLET(iostat, _BB_DIR_BIN, _BB_SUID_DROP)) |
@@ -114,26 +114,6 @@ static void print_header(void) | |||
114 | buf, uts.machine, G.total_cpus); | 114 | buf, uts.machine, G.total_cpus); |
115 | } | 115 | } |
116 | 116 | ||
117 | static int get_number_of_cpus(void) | ||
118 | { | ||
119 | #ifdef _SC_NPROCESSORS_CONF | ||
120 | return sysconf(_SC_NPROCESSORS_CONF); | ||
121 | #else | ||
122 | char buf[128]; | ||
123 | int n = 0; | ||
124 | FILE *fp; | ||
125 | |||
126 | fp = xfopen_for_read("/proc/cpuinfo"); | ||
127 | |||
128 | while (fgets(buf, sizeof(buf), fp)) | ||
129 | if (strncmp(buf, "processor\t:", 11) == 0) | ||
130 | n++; | ||
131 | |||
132 | fclose(fp); | ||
133 | return n; | ||
134 | #endif | ||
135 | } | ||
136 | |||
137 | static void get_localtime(struct tm *ptm) | 117 | static void get_localtime(struct tm *ptm) |
138 | { | 118 | { |
139 | time_t timer; | 119 | time_t timer; |
@@ -148,12 +128,6 @@ static void print_timestamp(void) | |||
148 | printf("%s\n", buf); | 128 | printf("%s\n", buf); |
149 | } | 129 | } |
150 | 130 | ||
151 | /* Does str start with "cpu"? */ | ||
152 | static int starts_with_cpu(const char *str) | ||
153 | { | ||
154 | return ((str[0] - 'c') | (str[1] - 'p') | (str[2] - 'u')) == 0; | ||
155 | } | ||
156 | |||
157 | /* Fetch CPU statistics from /proc/stat */ | 131 | /* Fetch CPU statistics from /proc/stat */ |
158 | static void get_cpu_statistics(struct stats_cpu *sc) | 132 | static void get_cpu_statistics(struct stats_cpu *sc) |
159 | { | 133 | { |
@@ -509,7 +483,9 @@ int iostat_main(int argc, char **argv) | |||
509 | G.clk_tck = get_user_hz(); | 483 | G.clk_tck = get_user_hz(); |
510 | 484 | ||
511 | /* Determine number of CPUs */ | 485 | /* Determine number of CPUs */ |
512 | G.total_cpus = get_number_of_cpus(); | 486 | G.total_cpus = get_cpu_count(); |
487 | if (G.total_cpus == 0) | ||
488 | G.total_cpus = 1; | ||
513 | 489 | ||
514 | /* Parse and process arguments */ | 490 | /* Parse and process arguments */ |
515 | /* -k and -m are mutually exclusive */ | 491 | /* -k and -m are mutually exclusive */ |
diff --git a/procps/mpstat.c b/procps/mpstat.c index 85cbb45db..bf0f593f7 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> | 5 | * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> |
6 | * | 6 | * |
7 | * Licensed under GPLv2, see file License in this tarball for details. | 7 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP)) | 10 | //applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP)) |
@@ -119,12 +119,6 @@ enum { | |||
119 | }; | 119 | }; |
120 | 120 | ||
121 | 121 | ||
122 | /* Does str start with "cpu"? */ | ||
123 | static int starts_with_cpu(const char *str) | ||
124 | { | ||
125 | return !((str[0] - 'c') | (str[1] - 'p') | (str[2] - 'u')); | ||
126 | } | ||
127 | |||
128 | /* Is option on? */ | 122 | /* Is option on? */ |
129 | static ALWAYS_INLINE int display_opt(int opt) | 123 | static ALWAYS_INLINE int display_opt(int opt) |
130 | { | 124 | { |
@@ -816,38 +810,6 @@ static void print_header(struct tm *t) | |||
816 | } | 810 | } |
817 | 811 | ||
818 | /* | 812 | /* |
819 | * Get number of processors in /proc/stat | ||
820 | * Return value '0' means one CPU and non SMP kernel. | ||
821 | * Otherwise N means N processor(s) and SMP kernel. | ||
822 | */ | ||
823 | static int get_cpu_nr(void) | ||
824 | { | ||
825 | FILE *fp; | ||
826 | char line[256]; | ||
827 | int proc_nr = -1; | ||
828 | |||
829 | fp = xfopen_for_read(PROCFS_STAT); | ||
830 | while (fgets(line, sizeof(line), fp)) { | ||
831 | if (!starts_with_cpu(line)) { | ||
832 | if (proc_nr >= 0) | ||
833 | break; /* we are past "cpuN..." lines */ | ||
834 | continue; | ||
835 | } | ||
836 | if (line[3] != ' ') { /* "cpuN" */ | ||
837 | int num_proc; | ||
838 | if (sscanf(line + 3, "%u", &num_proc) == 1 | ||
839 | && num_proc > proc_nr | ||
840 | ) { | ||
841 | proc_nr = num_proc; | ||
842 | } | ||
843 | } | ||
844 | } | ||
845 | |||
846 | fclose(fp); | ||
847 | return proc_nr + 1; | ||
848 | } | ||
849 | |||
850 | /* | ||
851 | * Get number of interrupts available per processor | 813 | * Get number of interrupts available per processor |
852 | */ | 814 | */ |
853 | static int get_irqcpu_nr(const char *f, int max_irqs) | 815 | static int get_irqcpu_nr(const char *f, int max_irqs) |
@@ -910,7 +872,7 @@ int mpstat_main(int UNUSED_PARAM argc, char **argv) | |||
910 | G.interval = -1; | 872 | G.interval = -1; |
911 | 873 | ||
912 | /* Get number of processors */ | 874 | /* Get number of processors */ |
913 | G.cpu_nr = get_cpu_nr(); | 875 | G.cpu_nr = get_cpu_count(); |
914 | 876 | ||
915 | /* Get number of clock ticks per sec */ | 877 | /* Get number of clock ticks per sec */ |
916 | G.hz = get_hz(); | 878 | G.hz = get_hz(); |
diff --git a/testsuite/patch.tests b/testsuite/patch.tests index 6ee795dba..f55b53f61 100755 --- a/testsuite/patch.tests +++ b/testsuite/patch.tests | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | . ./testing.sh | 5 | . ./testing.sh |
6 | 6 | ||
7 | # testing "test name" "options" "expected result" "file input" "stdin" | 7 | # testing "test name" "command(s)" "expected result" "file input" "stdin" |
8 | 8 | ||
9 | testing "patch with old_file == new_file" \ | 9 | testing "patch with old_file == new_file" \ |
10 | 'patch 2>&1; echo $?; cat input' \ | 10 | 'patch 2>&1; echo $?; cat input' \ |
@@ -100,13 +100,15 @@ def | |||
100 | 123 | 100 | 123 |
101 | " \ | 101 | " \ |
102 | 102 | ||
103 | # Currently fails (erroneously appends second "456" line): | 103 | testing "patch detects already applied hunk at the EOF" \ |
104 | false && testing "patch detects already applied hunk" \ | ||
105 | 'patch 2>&1; echo $?; cat input' \ | 104 | 'patch 2>&1; echo $?; cat input' \ |
106 | "\ | 105 | "\ |
106 | Possibly reversed hunk 1 at 3 | ||
107 | Hunk 1 FAILED 1/1. | ||
108 | abc | ||
109 | 123 | ||
110 | +456 | ||
107 | patching file input | 111 | patching file input |
108 | patch: hunk #1 FAILED at 2 | ||
109 | patch: 1 out of 1 hunk FAILED | ||
110 | 1 | 112 | 1 |
111 | abc | 113 | abc |
112 | 123 | 114 | 123 |
@@ -126,6 +128,31 @@ abc | |||
126 | +456 | 128 | +456 |
127 | " \ | 129 | " \ |
128 | 130 | ||
131 | # testing "test name" "command(s)" "expected result" "file input" "stdin" | ||
132 | |||
133 | testing "patch -N ignores already applied hunk" \ | ||
134 | 'patch -N 2>&1; echo $?; cat input' \ | ||
135 | "\ | ||
136 | patching file input | ||
137 | 0 | ||
138 | abc | ||
139 | def | ||
140 | 123 | ||
141 | " \ | ||
142 | "\ | ||
143 | abc | ||
144 | def | ||
145 | 123 | ||
146 | " \ | ||
147 | "\ | ||
148 | --- input | ||
149 | +++ input | ||
150 | @@ -1,2 +1,3 @@ | ||
151 | abc | ||
152 | +def | ||
153 | 123 | ||
154 | " \ | ||
155 | |||
129 | rm input.orig 2>/dev/null | 156 | rm input.orig 2>/dev/null |
130 | 157 | ||
131 | exit $FAILCOUNT | 158 | exit $FAILCOUNT |
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c index 7b89e6fdc..3db91113d 100644 --- a/util-linux/hexdump.c +++ b/util-linux/hexdump.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Copyright (c) 1989 | 6 | * Copyright (c) 1989 |
7 | * The Regents of the University of California. All rights reserved. | 7 | * The Regents of the University of California. All rights reserved. |
8 | * | 8 | * |
9 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
diff --git a/util-linux/more.c b/util-linux/more.c index 9216b6137..00a427a6f 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
@@ -11,7 +11,7 @@ | |||
11 | * | 11 | * |
12 | * Termios corrects by Vladimir Oleynik <dzo@simtreas.ru> | 12 | * Termios corrects by Vladimir Oleynik <dzo@simtreas.ru> |
13 | * | 13 | * |
14 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 14 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "libbb.h" | 17 | #include "libbb.h" |
diff --git a/util-linux/rdate.c b/util-linux/rdate.c index f257d5438..f5df2f794 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * by Sterling Huxley <sterling@europa.com> | 6 | * by Sterling Huxley <sterling@europa.com> |
7 | * | 7 | * |
8 | * Licensed under GPL v2 or later, see file License for details. | 8 | * Licensed under GPL v2 or later, see file LICENSE for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include "libbb.h" | 11 | #include "libbb.h" |
diff --git a/util-linux/rev.c b/util-linux/rev.c index fa3a453ae..8d5ac2f2d 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> | 4 | * Copyright (C) 2010 Marek Polacek <mmpolacek@gmail.com> |
5 | * | 5 | * |
6 | * Licensed under GPLv2, see file License in this tarball for details. | 6 | * Licensed under GPLv2, see file LICENSE in this tarball for details. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | //applet:IF_REV(APPLET(rev, _BB_DIR_BIN, _BB_SUID_DROP)) | 9 | //applet:IF_REV(APPLET(rev, _BB_DIR_BIN, _BB_SUID_DROP)) |
diff --git a/util-linux/script.c b/util-linux/script.c index c23117cf3..ba90b065d 100644 --- a/util-linux/script.c +++ b/util-linux/script.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Copyright (c) 1980 | 8 | * Copyright (c) 1980 |
9 | * The Regents of the University of California. All rights reserved. | 9 | * The Regents of the University of California. All rights reserved. |
10 | * | 10 | * |
11 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 11 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
12 | */ | 12 | */ |
13 | #include "libbb.h" | 13 | #include "libbb.h" |
14 | 14 | ||
diff --git a/util-linux/scriptreplay.c b/util-linux/scriptreplay.c index d7e193303..c87e44dfb 100644 --- a/util-linux/scriptreplay.c +++ b/util-linux/scriptreplay.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * pascal.bellard@ads-lu.com | 5 | * pascal.bellard@ads-lu.com |
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file License in this tarball for details. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | #include "libbb.h" | 10 | #include "libbb.h" |
diff --git a/util-linux/setarch.c b/util-linux/setarch.c index 8213382e4..776caf909 100644 --- a/util-linux/setarch.c +++ b/util-linux/setarch.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright 2002 Andi Kleen, SuSE Labs. | 5 | * Copyright 2002 Andi Kleen, SuSE Labs. |
6 | * | 6 | * |
7 | * Licensed under GPL v2 or later, see file License for details. | 7 | * Licensed under GPL v2 or later, see file LICENSE for details. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <sys/personality.h> | 10 | #include <sys/personality.h> |