diff options
-rw-r--r-- | coreutils/Config.in | 11 | ||||
-rw-r--r-- | coreutils/split.c | 15 | ||||
-rw-r--r-- | scripts/defconfig | 2 |
3 files changed, 21 insertions, 7 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in index baac799db..be5e9527b 100644 --- a/coreutils/Config.in +++ b/coreutils/Config.in | |||
@@ -541,8 +541,15 @@ config SPLIT | |||
541 | default n | 541 | default n |
542 | help | 542 | help |
543 | split a file into pieces. | 543 | split a file into pieces. |
544 | 544 | ||
545 | http://www.opengroup.org/onlinepubs/007904975/utilities/split.html | 545 | config FEATURE_SPLIT_FANCY |
546 | bool "fancy extensions" | ||
547 | default n | ||
548 | depends on SPLIT | ||
549 | help | ||
550 | Add support for features not required by SUSv3. | ||
551 | Supports additional suffixes 'b' for 512 bytes, | ||
552 | 'g' for 1GiB for the -b option. | ||
546 | 553 | ||
547 | config STAT | 554 | config STAT |
548 | bool "stat" | 555 | bool "stat" |
diff --git a/coreutils/split.c b/coreutils/split.c index 07eb97e0c..10035e9ab 100644 --- a/coreutils/split.c +++ b/coreutils/split.c | |||
@@ -12,10 +12,14 @@ | |||
12 | #include "busybox.h" | 12 | #include "busybox.h" |
13 | 13 | ||
14 | static const struct suffix_mult split_suffices[] = { | 14 | static const struct suffix_mult split_suffices[] = { |
15 | #if ENABLE_FEATURE_SPLIT_FANCY | ||
15 | { "b", 512 }, | 16 | { "b", 512 }, |
17 | #endif | ||
16 | { "k", 1024 }, | 18 | { "k", 1024 }, |
17 | { "m", 1024*1024 }, | 19 | { "m", 1024*1024 }, |
20 | #if ENABLE_FEATURE_SPLIT_FANCY | ||
18 | { "g", 1024*1024*1024 }, | 21 | { "g", 1024*1024*1024 }, |
22 | #endif | ||
19 | { NULL, 0 } | 23 | { NULL, 0 } |
20 | }; | 24 | }; |
21 | 25 | ||
@@ -58,10 +62,10 @@ int split_main(int argc, char **argv) | |||
58 | char *pfx; | 62 | char *pfx; |
59 | char *count_p; | 63 | char *count_p; |
60 | const char *sfx; | 64 | const char *sfx; |
61 | unsigned long cnt = 1000; | 65 | off_t cnt = 1000; |
62 | unsigned long remaining = 0; | 66 | off_t remaining = 0; |
63 | unsigned opt; | 67 | unsigned opt; |
64 | int bytes_read, to_write; | 68 | ssize_t bytes_read, to_write; |
65 | char *src; | 69 | char *src; |
66 | 70 | ||
67 | opt_complementary = "?2"; | 71 | opt_complementary = "?2"; |
@@ -73,8 +77,9 @@ int split_main(int argc, char **argv) | |||
73 | cnt = xatoul_sfx(count_p, split_suffices); | 77 | cnt = xatoul_sfx(count_p, split_suffices); |
74 | if (opt & SPLIT_OPT_a) | 78 | if (opt & SPLIT_OPT_a) |
75 | suffix_len = xatou(sfx); | 79 | suffix_len = xatou(sfx); |
76 | argv += optind; | ||
77 | sfx = "x"; | 80 | sfx = "x"; |
81 | |||
82 | argv += optind; | ||
78 | if (argv[0]) { | 83 | if (argv[0]) { |
79 | if (argv[1]) | 84 | if (argv[1]) |
80 | sfx = argv[1]; | 85 | sfx = argv[1]; |
@@ -104,7 +109,7 @@ int split_main(int argc, char **argv) | |||
104 | do { | 109 | do { |
105 | if (!remaining) { | 110 | if (!remaining) { |
106 | if (!pfx) | 111 | if (!pfx) |
107 | bb_error_msg_and_die("suffices exhausted"); | 112 | bb_error_msg_and_die("suffixes exhausted"); |
108 | xmove_fd(xopen(pfx, O_WRONLY | O_CREAT | O_TRUNC), 1); | 113 | xmove_fd(xopen(pfx, O_WRONLY | O_CREAT | O_TRUNC), 1); |
109 | pfx = next_file(pfx, suffix_len); | 114 | pfx = next_file(pfx, suffix_len); |
110 | remaining = cnt; | 115 | remaining = cnt; |
diff --git a/scripts/defconfig b/scripts/defconfig index 6ca10b63d..5846b0cf7 100644 --- a/scripts/defconfig +++ b/scripts/defconfig | |||
@@ -194,6 +194,7 @@ CONFIG_SHA1SUM=y | |||
194 | CONFIG_SLEEP=y | 194 | CONFIG_SLEEP=y |
195 | CONFIG_FEATURE_FANCY_SLEEP=y | 195 | CONFIG_FEATURE_FANCY_SLEEP=y |
196 | CONFIG_SPLIT=y | 196 | CONFIG_SPLIT=y |
197 | # CONFIG_FEATURE_SPLIT_FANCY is not set | ||
197 | CONFIG_SORT=y | 198 | CONFIG_SORT=y |
198 | CONFIG_FEATURE_SORT_BIG=y | 199 | CONFIG_FEATURE_SORT_BIG=y |
199 | CONFIG_STAT=y | 200 | CONFIG_STAT=y |
@@ -272,6 +273,7 @@ CONFIG_READLINK=y | |||
272 | CONFIG_FEATURE_READLINK_FOLLOW=y | 273 | CONFIG_FEATURE_READLINK_FOLLOW=y |
273 | CONFIG_RUN_PARTS=y | 274 | CONFIG_RUN_PARTS=y |
274 | CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y | 275 | CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y |
276 | CONFIG_FEATURE_RUN_PARTS_FANCY=y | ||
275 | CONFIG_START_STOP_DAEMON=y | 277 | CONFIG_START_STOP_DAEMON=y |
276 | CONFIG_FEATURE_START_STOP_DAEMON_FANCY=y | 278 | CONFIG_FEATURE_START_STOP_DAEMON_FANCY=y |
277 | CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y | 279 | CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y |