summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-07-30 01:52:59 -0600
committerPaul Eggert <eggert@cs.ucla.edu>2010-07-30 01:53:46 -0600
commitabd040180e210e74448c42f094aab1769ca6c636 (patch)
tree5d1030fb4b77f7d0363d4a894a8bb0accb705bbb /doc
parent1bf73ebb97b2f20bf3d8b1adba43fc9fbbc335f6 (diff)
downloadcoreutils-abd040180e210e74448c42f094aab1769ca6c636.tar.xz
sort: -h now handles comparisons such as 6000K vs 5M and 5MiB vs 5MB
* NEWS: Document changes to sort -h. * doc/coreutils.texi (sort invocation): Likewise. * src/sort.c (long_double, strtold): Move to prelude, since they're now used by multiple functions. (LD): New macro. (struct keyfield.iec_present): Remove this member. All uses removed. (check_mixed_SI_IEC): Remove. This code was busted in the presence of multiple threads, as it had a race condition. (find_unit_order): Remove arg KEY; add arg THOU_SEP; arg ENDPTR is now char ** rather than char const **. Return an integer that distinguishes decimal from binary powers. Parse the number consistently with the intersection of strtold and strnumcmp. Set *ENDPTR unconditionally. (compute_human): New static function. (human_numcompare): Remove arg KEY. Remove 'const' from other args. Use strnumcmp if possible, but fall back on floating point if not. (numcompare, general_numcompare): Arg EA is now char ** rather than char const **. (numcompare): Adjust to new find_unit_order signature and behavior. (keycompare): Adjus to new human_numcompare signature. * tests/misc/sort (h1, h3, h4, h6): Adjust to new behavior. * tests/misc/sort-debug-keys: Likewise.
Diffstat (limited to 'doc')
-rw-r--r--doc/coreutils.texi19
1 files changed, 13 insertions, 6 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 942978f33..4a4143039 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -3802,12 +3802,19 @@ converting to floating point.
@opindex --sort
@cindex human numeric sort
@vindex LC_NUMERIC
-Sort numerically, as per the @option{--numeric-sort} option below, and in
-addition handle IEC or SI suffixes like MiB, MB etc (@ref{Block size}).
-Note a mixture of IEC and SI suffixes is not supported and will
-be flagged as an error. Also the numbers must be abbreviated uniformly.
-I.E. values with different precisions like 6000K and 5M will be sorted
-incorrectly.
+Sort numerically, and in addition handle IEC or SI suffixes like MiB,
+MB etc (@ref{Block size}). Each number consists of optional blanks,
+an optional @samp{-} sign, zero or more digits, optionally followed by
+a decimal-point character and zero or more digits, and optionally
+followed by an IEC or SI suffix. A number with no digits is treated
+as @samp{0}. The @env{LC_NUMERIC} locale specifies the decimal-point
+character.
+
+Numbers containing differing suffixes are compared using
+floating-point arithmetic, and therefore may not be compared exactly
+due to rounding error. However, the output of @command{df},
+@command{du}, and @command{ls} contains so few digits before suffixes
+that rounding error is not significant and comparisons are exact.
@item -i
@itemx --ignore-nonprinting