summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko2015-10-19 19:27:26 +0200
committerDenys Vlasenko2015-10-19 19:27:26 +0200
commit0506e292b518a04846ae1f611ecc0633969a2801 (patch)
tree14dfac41239a1a67fdd4d895b0b27d1ba77fd383 /coreutils
parentd1ed3e68b8080161642cc106099c0a17ac7892e6 (diff)
downloadbusybox-0506e292b518a04846ae1f611ecc0633969a2801.zip
busybox-0506e292b518a04846ae1f611ecc0633969a2801.tar.gz
sort: fix ENDCHAR handling in "-kSTART,N.ENDCHAR"
function old new delta get_key 505 503 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/sort.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c
index f2bc533..07d9033 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -160,17 +160,18 @@ static char *get_key(char *str, struct sort_key *key, int flags)
if (!j) start = end;
}
/* Strip leading whitespace if necessary */
-//XXX: skip_whitespace()
if (flags & FLAG_b)
+ /* not using skip_whitespace() for speed */
while (isspace(str[start])) start++;
/* Strip trailing whitespace if necessary */
if (flags & FLAG_bb)
while (end > start && isspace(str[end-1])) end--;
- /* Handle offsets on start and end */
+ /* -kSTART,N.ENDCHAR: honor ENDCHAR (1-based) */
if (key->range[3]) {
- end += key->range[3] - 1;
+ end = key->range[3];
if (end > len) end = len;
}
+ /* -kN.STARTCHAR[,...]: honor STARTCHAR (1-based) */
if (key->range[1]) {
start += key->range[1] - 1;
if (start > len) start = len;