diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-03-28 20:48:40 +0400 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-03-28 20:48:40 +0400 |
commit | 0a537a0c5760215f3ea9e5af07f0a656e5bfa408 (patch) | |
tree | 871fd85ef843375e5ff9885e852f4e1b466cf337 /coreutils | |
parent | 0864f4d14f8838e721a17717efc5f9de4db61480 (diff) |
- move additional fancy options not mandated by SUSv3 into a FANCY option
Diffstat (limited to 'coreutils')
-rw-r--r-- | coreutils/Config.in | 11 | ||||
-rw-r--r-- | coreutils/split.c | 15 |
2 files changed, 19 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 default n help split a file into pieces. - - http://www.opengroup.org/onlinepubs/007904975/utilities/split.html + +config FEATURE_SPLIT_FANCY + bool "fancy extensions" + default n + depends on SPLIT + help + Add support for features not required by SUSv3. + Supports additional suffixes 'b' for 512 bytes, + 'g' for 1GiB for the -b option. config STAT 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 @@ #include "busybox.h" static const struct suffix_mult split_suffices[] = { +#if ENABLE_FEATURE_SPLIT_FANCY { "b", 512 }, +#endif { "k", 1024 }, { "m", 1024*1024 }, +#if ENABLE_FEATURE_SPLIT_FANCY { "g", 1024*1024*1024 }, +#endif { NULL, 0 } }; @@ -58,10 +62,10 @@ int split_main(int argc, char **argv) char *pfx; char *count_p; const char *sfx; - unsigned long cnt = 1000; - unsigned long remaining = 0; + off_t cnt = 1000; + off_t remaining = 0; unsigned opt; - int bytes_read, to_write; + ssize_t bytes_read, to_write; char *src; opt_complementary = "?2"; @@ -73,8 +77,9 @@ int split_main(int argc, char **argv) cnt = xatoul_sfx(count_p, split_suffices); if (opt & SPLIT_OPT_a) suffix_len = xatou(sfx); - argv += optind; sfx = "x"; + + argv += optind; if (argv[0]) { if (argv[1]) sfx = argv[1]; @@ -104,7 +109,7 @@ int split_main(int argc, char **argv) do { if (!remaining) { if (!pfx) - bb_error_msg_and_die("suffices exhausted"); + bb_error_msg_and_die("suffixes exhausted"); xmove_fd(xopen(pfx, O_WRONLY | O_CREAT | O_TRUNC), 1); pfx = next_file(pfx, suffix_len); remaining = cnt; |