]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
all: further adjustments for new Ronna, Quetta SI prefixes
authorPádraig Brady <P@draigBrady.com>
Fri, 6 Jan 2023 13:13:54 +0000 (13:13 +0000)
committerPádraig Brady <P@draigBrady.com>
Fri, 6 Jan 2023 14:26:40 +0000 (14:26 +0000)
* src/dd.c (parse_integer): Support Q,R suffixes.
* src/od.c (main): Likewise.
* src/split.c (main): Likewise.
* src/stdbuf.c (parse_size): Likewise.
* src/truncate.c (main): Likewise.
* src/sort.c (specify_size_size): Likewise.
Also line length syntax check fix.
* tests/misc/numfmt.pl: Adust top end large number checks
to the new largest values.
* doc/coreutils.texi (numfmt invocation): Add a numfmt example.
* NEWS: Tweak to aid searchability.

NEWS
doc/coreutils.texi
src/dd.c
src/od.c
src/sort.c
src/split.c
src/stdbuf.c
src/truncate.c
tests/misc/numfmt.pl

diff --git a/NEWS b/NEWS
index 52c92ddb40fde2fb044b8ee4c95bab3de524b7ba..7ec3ce1fb3876640245b79e6e530ed1cf860bc8b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -48,8 +48,9 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Changes in behavior
 
-  Programs now use the new SI prefixes R (10**27) and Q (10**30)
-  along with their binary counterparts Ri (2**90) and Qi (2**100).
+  Programs now support the new Ronna (R), and Quetta (Q) SI prefixes,
+  corresponding to 10^27 and 10^30 respectively,
+  along with their binary counterparts Ri (2^90) and Qi (2^100).
   In some cases (e.g., 'sort -h') these new prefixes simply work;
   in others, where they exceed integer width limits, they now elicit
   the same integer overflow diagnostics as other large prefixes.
index 4c278bf271c923c0de9344ea691c99b638b272f1..f5e531d65cf3a524ec87b7918c0b915ba43bf19c 100644 (file)
@@ -19073,6 +19073,13 @@ $ numfmt --from=si --to=iec 1T
 932G
 @end example
 
+With both input and output scales specified,
+the largest defined prefixes are supported:
+
+@example
+$ numfmt --from=si --to=iec-i 2000R
+1.6Qi
+@end example
 
 Converting a single field from an input file / piped input (these contrived
 examples are for demonstration purposes only, as both @command{ls} and
index 6d448a57b74fb9bdfb0261e9b0dc5bc26adc87ef..2808a79ab307e2db31cffc822b65d9c288ab96c7 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -1424,7 +1424,7 @@ parse_integer (char const *str, strtol_error *invalid)
   int indeterminate = 0;
   uintmax_t n = indeterminate;
   char *suffix;
-  static char const suffixes[] = "bcEGkKMPTwYZ0";
+  static char const suffixes[] = "bcEGkKMPQRTwYZ0";
   strtol_error e = xstrtoumax (str, &suffix, 10, &n, suffixes);
   intmax_t result;
 
index 9e91427603748ddffbde920a69c8e9ac1dd28db0..10a28e21fed9cbed030f2981bd1a1cd9a627c57a 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -1578,7 +1578,7 @@ main (int argc, char **argv)
   bool width_specified = false;
   bool ok = true;
   size_t width_per_block = 0;
-  static char const multipliers[] = "bEGKkMmPTYZ0";
+  static char const multipliers[] = "bEGKkMmPQRTYZ0";
 
   /* The old-style 'pseudo starting address' to be printed in parentheses
      after any true address.  */
index 5f159374b9f18ac464c9b68ecc1a3309d0ef3ac7..8ca7a88c48ec07eccd952b14739e427721466c5d 100644 (file)
@@ -519,8 +519,8 @@ the entire line as the key.  Use --debug to diagnose incorrect key usage.\n\
 SIZE may be followed by the following multiplicative suffixes:\n\
 "), stdout);
       fputs (_("\
-% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y, R, Q.\n\
-\n\
+% 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y, R, Q.\
+\n\n\
 *** WARNING ***\n\
 The locale specified by the environment affects sort order.\n\
 Set LC_ALL=C to get the traditional sort order that uses\n\
@@ -1387,7 +1387,7 @@ specify_sort_size (int oi, char c, char const *s)
 {
   uintmax_t n;
   char *suffix;
-  enum strtol_error e = xstrtoumax (s, &suffix, 10, &n, "EgGkKmMPtTYZ");
+  enum strtol_error e = xstrtoumax (s, &suffix, 10, &n, "EgGkKmMPQRtTYZ");
 
   /* The default unit is KiB.  */
   if (e == LONGINT_OK && ISDIGIT (suffix[-1]))
index d0f4e66e26a6bfd2313b247a1dd05416c458bc8d..74b389f852e6f71ab15abcda9463b79645c2e352 100644 (file)
@@ -1307,7 +1307,7 @@ main (int argc, char **argv)
   uintmax_t k_units = 0;
   uintmax_t n_units = 0;
 
-  static char const multipliers[] = "bEGKkMmPTYZ0";
+  static char const multipliers[] = "bEGKkMmPQRTYZ0";
   int c;
   int digits_optind = 0;
   off_t file_size = OFF_T_MAX;
index 2d7aec28c7db04d0c43342d475a615a63e16de48..0372eda32067ef4c6a6e186241f2db894b1f710b 100644 (file)
@@ -66,7 +66,7 @@ static int
 parse_size (char const *str, size_t *size)
 {
   uintmax_t tmp_size;
-  enum strtol_error e = xstrtoumax (str, NULL, 10, &tmp_size, "EGkKMPTYZ0");
+  enum strtol_error e = xstrtoumax (str, NULL, 10, &tmp_size, "EGkKMPQRTYZ0");
   if (e == LONGINT_OK && SIZE_MAX < tmp_size)
     e = LONGINT_OVERFLOW;
 
index 24f2db418166852ad54d4851906256544faa622c..4e50d4bf39f3805ffef6a95b32783f4d961254af 100644 (file)
@@ -269,7 +269,7 @@ main (int argc, char **argv)
             }
           /* Support dd BLOCK size suffixes + lowercase g,t,m for bsd compat.
              Note we don't support dd's b=512, c=1, w=2 or 21x512MiB formats. */
-          size = xdectoimax (optarg, OFF_T_MIN, OFF_T_MAX, "EgGkKmMPtTYZ0",
+          size = xdectoimax (optarg, OFF_T_MIN, OFF_T_MAX, "EgGkKmMPQRtTYZ0",
                              _("Invalid number"), 0);
           /* Rounding to multiple of 0 is nonsensical */
           if ((rel_mode == rm_rup || rel_mode == rm_rdn) && size == 0)
index 31a87dc14f57a6a1935bff12564b0fabc8d825d6..86fb78f1e0565f4a64c52df2c83349f9bb1885e3 100755 (executable)
@@ -947,9 +947,9 @@ my @Limit_Tests =
      ['large-7','--from=si --to=si 80Y', {OUT=>"80Y"}],
      ['large-8','--from=si --to=si 9000Z', {OUT=>"9.0Y"}],
 
-     ['large-10','--from=si --to=si 999Y', {OUT=>"999Y"}],
-     ['large-11','--from=si --to=iec 999Y', {OUT=>"827Y"}],
-     ['large-12','--from=si --round=down --to=iec 999Y', {OUT=>"826Y"}],
+     ['large-10','--from=si --to=si 999Q', {OUT=>"999Q"}],
+     ['large-11','--from=si --to=iec 999Q', {OUT=>"789Q"}],
+     ['large-12','--from=si --round=down --to=iec 999Q', {OUT=>"788Q"}],
 
      # units can also affect the output
      ['large-13','--from=si --from-unit=1000000 9P',