diff options
author | Rob Landley <rob@landley.net> | 2019-03-18 23:36:12 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-03-18 23:36:12 -0500 |
commit | 7709875b443fcd155e1737f18d3fff75c4b2753a (patch) | |
tree | 48df8db9a31763b96672a2be2e155ad0b1e5bcde /toys/posix | |
parent | b1562a6fda7eb43d874890e6700a9fa3f4478984 (diff) | |
download | toybox-7709875b443fcd155e1737f18d3fff75c4b2753a.tar.gz |
Document the -k2.3,4.5 syntax and make it behave closer to the other one.
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/sort.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/toys/posix/sort.c b/toys/posix/sort.c index 9433aef2..9bf81ebc 100644 --- a/toys/posix/sort.c +++ b/toys/posix/sort.c @@ -34,12 +34,13 @@ config SORT -o Output to FILE instead of stdout -V Version numbers (name-1.234-rc6.5b.tgz) - Sorting by key looks at a subset of the words on each line. -k2 - uses the second word to the end of the line, -k2,2 looks at only - the second word, -k2,4 looks from the start of the second to the end - of the fourth word. Specifying multiple keys uses the later keys as - tie breakers, in order. A type specifier appended to a sort key - (such as -2,2n) applies only to sorting that key. + Sorting by key looks at a subset of the words on each line. -k2 uses the + second word to the end of the line, -k2,2 looks at only the second word, + -k2,4 looks from the start of the second to the end of the fourth word. + -k2.4,5 starts from the fourth character of the second word, to the end + of the fifth word. Specifying multiple keys uses the later keys as tie + breakers, in order. A type specifier appended to a sort key (such as -2,2n) + applies only to sorting that key. config SORT_FLOAT bool @@ -121,7 +122,8 @@ static char *get_key_data(char *str, struct sort_key *key, int flags) if (TT.t && str[start]==*TT.t) start++; // Strip leading and trailing whitespace if necessary - if (flags&FLAG_b) while (isspace(str[start])) start++; + if ((flags&FLAG_b) || (!TT.t && !key->range[3])) + while (isspace(str[start])) start++; if (flags&FLAG_bb) while (end>start && isspace(str[end-1])) end--; // Handle offsets on start and end |