diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-03-28 16:48:40 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-03-28 16:48:40 +0000 |
commit | 0a537a0c5760215f3ea9e5af07f0a656e5bfa408 (patch) | |
tree | 871fd85ef843375e5ff9885e852f4e1b466cf337 /coreutils/split.c | |
parent | 0864f4d14f8838e721a17717efc5f9de4db61480 (diff) | |
download | busybox-w32-0a537a0c5760215f3ea9e5af07f0a656e5bfa408.tar.gz busybox-w32-0a537a0c5760215f3ea9e5af07f0a656e5bfa408.tar.bz2 busybox-w32-0a537a0c5760215f3ea9e5af07f0a656e5bfa408.zip |
- move additional fancy options not mandated by SUSv3 into a FANCY option
Diffstat (limited to 'coreutils/split.c')
-rw-r--r-- | coreutils/split.c | 15 |
1 files changed, 10 insertions, 5 deletions
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; |