|
Lines 78-83
static bool elide_empty_files;
Link Here
|
| 78 |
input to output, which is much slower, so disabled by default. */ |
78 |
input to output, which is much slower, so disabled by default. */ |
| 79 |
static bool unbuffered; |
79 |
static bool unbuffered; |
| 80 |
|
80 |
|
|
|
81 |
/* The split mode to use. */ |
| 82 |
enum Split_type |
| 83 |
{ |
| 84 |
type_undef, type_bytes, type_byteslines, type_lines, type_digits, |
| 85 |
type_chunk_bytes, type_chunk_lines, type_rr |
| 86 |
}; |
| 87 |
|
| 81 |
/* For long options that have no equivalent short option, use a |
88 |
/* For long options that have no equivalent short option, use a |
| 82 |
non-character as a pseudo short option, starting with CHAR_MAX + 1. */ |
89 |
non-character as a pseudo short option, starting with CHAR_MAX + 1. */ |
| 83 |
enum |
90 |
enum |
|
Lines 105-120
static struct option const longopts[] =
Link Here
|
| 105 |
}; |
112 |
}; |
| 106 |
|
113 |
|
| 107 |
static void |
114 |
static void |
| 108 |
set_suffix_length (uintmax_t n_units) |
115 |
set_suffix_length (uintmax_t n_units, enum Split_type split_type) |
| 109 |
{ |
116 |
{ |
| 110 |
#define DEFAULT_SUFFIX_LENGTH 2 |
117 |
#define DEFAULT_SUFFIX_LENGTH 2 |
| 111 |
|
118 |
|
| 112 |
size_t suffix_needed = 0; |
119 |
size_t suffix_needed = 0; |
| 113 |
size_t alphabet_len = strlen (suffix_alphabet); |
120 |
|
| 114 |
bool alphabet_slop = (n_units % alphabet_len) != 0; |
121 |
if (split_type == type_chunk_bytes || split_type == type_chunk_lines |
| 115 |
while (n_units /= alphabet_len) |
122 |
|| split_type == type_rr) |
| 116 |
suffix_needed++; |
123 |
{ |
| 117 |
suffix_needed += alphabet_slop; |
124 |
size_t alphabet_len = strlen (suffix_alphabet); |
|
|
125 |
bool alphabet_slop = (n_units % alphabet_len) != 0; |
| 126 |
while (n_units /= alphabet_len) |
| 127 |
suffix_needed++; |
| 128 |
suffix_needed += alphabet_slop; |
| 129 |
} |
| 118 |
|
130 |
|
| 119 |
if (suffix_length) /* set by user */ |
131 |
if (suffix_length) /* set by user */ |
| 120 |
{ |
132 |
{ |
|
Lines 780-790
int
Link Here
|
| 780 |
main (int argc, char **argv) |
792 |
main (int argc, char **argv) |
| 781 |
{ |
793 |
{ |
| 782 |
struct stat stat_buf; |
794 |
struct stat stat_buf; |
| 783 |
enum |
795 |
enum Split_type split_type = type_undef; |
| 784 |
{ |
|
|
| 785 |
type_undef, type_bytes, type_byteslines, type_lines, type_digits, |
| 786 |
type_chunk_bytes, type_chunk_lines, type_rr |
| 787 |
} split_type = type_undef; |
| 788 |
size_t in_blk_size = 0; /* optimal block size of input file device */ |
796 |
size_t in_blk_size = 0; /* optimal block size of input file device */ |
| 789 |
char *buf; /* file i/o buffer */ |
797 |
char *buf; /* file i/o buffer */ |
| 790 |
size_t page_size = getpagesize (); |
798 |
size_t page_size = getpagesize (); |
|
Lines 984-990
main (int argc, char **argv)
Link Here
|
| 984 |
usage (EXIT_FAILURE); |
992 |
usage (EXIT_FAILURE); |
| 985 |
} |
993 |
} |
| 986 |
|
994 |
|
| 987 |
set_suffix_length (n_units); |
995 |
set_suffix_length (n_units, split_type); |
| 988 |
|
996 |
|
| 989 |
/* Get out the filename arguments. */ |
997 |
/* Get out the filename arguments. */ |
| 990 |
|
998 |
|