From 2539b53760dd4efad304e6f5f5e0880b4510d378 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 3 May 2007 13:45:26 +0200 Subject: 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. --- src/split.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/split.c') 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); -- cgit v1.2.3-54-g00ecf