diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-03-26 10:46:31 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-03-26 10:46:31 +0000 |
commit | cd43dfdeec6250dc17fa6bd247d4690897f5361e (patch) | |
tree | aef290e9abaa5b12e3da176c1b1ea4682a00e439 /coreutils/split.c | |
parent | cad04ef4f3435e56181a81c896912543be34ea3c (diff) | |
download | busybox-w32-cd43dfdeec6250dc17fa6bd247d4690897f5361e.tar.gz busybox-w32-cd43dfdeec6250dc17fa6bd247d4690897f5361e.tar.bz2 busybox-w32-cd43dfdeec6250dc17fa6bd247d4690897f5361e.zip |
- shrink a tiny bit (-8b)
Diffstat (limited to 'coreutils/split.c')
-rw-r--r-- | coreutils/split.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/coreutils/split.c b/coreutils/split.c index 312906f6e..86fd20437 100644 --- a/coreutils/split.c +++ b/coreutils/split.c | |||
@@ -11,6 +11,17 @@ | |||
11 | */ | 11 | */ |
12 | #include "busybox.h" | 12 | #include "busybox.h" |
13 | static unsigned suffix_len = 2; | 13 | static unsigned suffix_len = 2; |
14 | static const struct suffix_mult split_suffices[] = { | ||
15 | #if ENABLE_FEATURE_SPLIT_FANCY | ||
16 | { "b", 512 }, | ||
17 | #endif | ||
18 | { "k", 1024 }, | ||
19 | { "m", 1024*1024 }, | ||
20 | #if ENABLE_FEATURE_SPLIT_FANCY | ||
21 | { "g", 1024*1024*1024 }, | ||
22 | #endif | ||
23 | { NULL, 0 } | ||
24 | }; | ||
14 | 25 | ||
15 | /* Increment the suffix part of the filename. | 26 | /* Increment the suffix part of the filename. |
16 | * Returns 0 on success and 1 on error (if we are out of files) | 27 | * Returns 0 on success and 1 on error (if we are out of files) |
@@ -22,13 +33,12 @@ static bool next_file(char **old) | |||
22 | char *curr; | 33 | char *curr; |
23 | 34 | ||
24 | do { | 35 | do { |
25 | // if (**(old + end - i) < 'z') { | ||
26 | curr = *old + end - i; | 36 | curr = *old + end - i; |
27 | if (*curr < 'z') { | 37 | if (*curr < 'z') { |
28 | *(*old + end - i) += 1; | 38 | *curr += 1; |
29 | break; | 39 | break; |
30 | } | 40 | } |
31 | *(*old +end - i) = 'a'; | 41 | *curr = 'a'; |
32 | i++; | 42 | i++; |
33 | } while (i <= suffix_len); | 43 | } while (i <= suffix_len); |
34 | if ((*curr == 'z') && (i == suffix_len)) | 44 | if ((*curr == 'z') && (i == suffix_len)) |
@@ -37,13 +47,14 @@ static bool next_file(char **old) | |||
37 | } | 47 | } |
38 | #define SPLIT_OPT_l (1<<0) | 48 | #define SPLIT_OPT_l (1<<0) |
39 | #define SPLIT_OPT_b (1<<1) | 49 | #define SPLIT_OPT_b (1<<1) |
50 | #define SPLIT_OPT_a (1<<2) | ||
40 | 51 | ||
41 | int split_main(int argc, char **argv); | 52 | int split_main(int argc, char **argv); |
42 | int split_main(int argc, char **argv) | 53 | int split_main(int argc, char **argv) |
43 | { | 54 | { |
44 | char *pfx; | 55 | char *pfx; |
45 | char *count_p = NULL; | 56 | char *count_p; |
46 | char *sfx_len = NULL; | 57 | char *sfx_len; |
47 | unsigned cnt = 1000; | 58 | unsigned cnt = 1000; |
48 | char *input_file; | 59 | char *input_file; |
49 | 60 | ||
@@ -51,9 +62,9 @@ int split_main(int argc, char **argv) | |||
51 | getopt32(argc, argv, "l:b:a:", &count_p, &count_p, &sfx_len); | 62 | getopt32(argc, argv, "l:b:a:", &count_p, &count_p, &sfx_len); |
52 | argv += optind; | 63 | argv += optind; |
53 | 64 | ||
54 | if (count_p) | 65 | if (option_mask32 & (SPLIT_OPT_l|SPLIT_OPT_b)) |
55 | cnt = xatoi(count_p); | 66 | cnt = xatoi(count_p); |
56 | if (sfx_len) | 67 | if (option_mask32 & SPLIT_OPT_a) |
57 | suffix_len = xatoul(sfx_len); | 68 | suffix_len = xatoul(sfx_len); |
58 | 69 | ||
59 | if (!*argv) | 70 | if (!*argv) |