summaryrefslogtreecommitdiff
path: root/src/split.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2007-05-03 13:45:26 +0200
committerJim Meyering <jim@meyering.net>2007-05-03 13:45:26 +0200
commit2539b53760dd4efad304e6f5f5e0880b4510d378 (patch)
tree409fd46b349d143c65076800a1db5351816c079c /src/split.c
parent4e89cf8fb8ccf01ee1d5c351d9fa327a3735007f (diff)
downloadcoreutils-2539b53760dd4efad304e6f5f5e0880b4510d378.tar.xz
The following commands and options now support the standard size
suffixes kB, M, MB, G, GB, and so on for T, P, Y, Z, and Y: head -c, head -n, od -j, od -N, od -S, split -b, split -C, tail -c, tail -n. * doc/coreutils.texi (od invocation, head invocation, tail invocation): Document support for new size suffixes. (head invocation, tail invocation): Document that -n uses the same suffixes as -c. (tail invocation): More-clearly document what leading "+" does. * src/head.c (usage, string_to_integer): Support new suffixes. * src/od.c (usage, main): Likewise. * src/split.c (usage, main): Likewise. * src/tail.c (usage, parse_options): Likewise. Prompted by a patch from Evan Hunt.
Diffstat (limited to 'src/split.c')
-rw-r--r--src/split.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/split.c b/src/split.c
index 207cc13b3..a5ab8faf2 100644
--- a/src/split.c
+++ b/src/split.c
@@ -131,7 +131,9 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fputs (VERSION_OPTION_DESCRIPTION, stdout);
fputs (_("\
\n\
-SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.\n\
+SIZE may have a multiplier suffix:\n\
+b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\n\
+GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n\
"), stdout);
emit_bug_reporting_address ();
}
@@ -388,6 +390,7 @@ main (int argc, char **argv)
char *buf; /* file i/o buffer */
size_t page_size = getpagesize ();
uintmax_t n_units;
+ static char const multipliers[] = "bEGKkMmPTYZ0";
int c;
int digits_optind = 0;
@@ -432,7 +435,7 @@ main (int argc, char **argv)
if (split_type != type_undef)
FAIL_ONLY_ONE_WAY ();
split_type = type_bytes;
- if (xstrtoumax (optarg, NULL, 10, &n_units, "bkm") != LONGINT_OK
+ if (xstrtoumax (optarg, NULL, 10, &n_units, multipliers) != LONGINT_OK
|| n_units == 0)
{
error (0, 0, _("%s: invalid number of bytes"), optarg);
@@ -456,7 +459,7 @@ main (int argc, char **argv)
if (split_type != type_undef)
FAIL_ONLY_ONE_WAY ();
split_type = type_byteslines;
- if (xstrtoumax (optarg, NULL, 10, &n_units, "bkm") != LONGINT_OK
+ if (xstrtoumax (optarg, NULL, 10, &n_units, multipliers) != LONGINT_OK
|| n_units == 0 || SIZE_MAX < n_units)
{
error (0, 0, _("%s: invalid number of bytes"), optarg);