diff options
author | Denys Vlasenko | 2015-10-24 02:29:00 +0200 |
---|---|---|
committer | Denys Vlasenko | 2015-10-24 02:29:00 +0200 |
commit | 5c23f2566c1d26c62024cc2c78ca5aad4c99dd33 (patch) | |
tree | d0d6dfadf3831123ae0b3cf44f28b01d94ea4111 /coreutils/sort.c | |
parent | 7ab00a0de9cfeeacff70a74402808d225ba07397 (diff) | |
download | busybox-1_24_1.zip busybox-1_24_1.tar.gz |
Apply post-1.24.0 patches, bump version to 1.24.11_24_1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/sort.c')
-rw-r--r-- | coreutils/sort.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/coreutils/sort.c b/coreutils/sort.c index 36f0254..c2e8bb8 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c @@ -106,7 +106,9 @@ static struct sort_key { static char *get_key(char *str, struct sort_key *key, int flags) { - int start = 0, end = 0, len, j; + int start = start; /* for compiler */ + int end; + int len, j; unsigned i; /* Special case whole string, so we don't have to make a copy */ @@ -123,12 +125,15 @@ static char *get_key(char *str, struct sort_key *key, int flags) end = len; /* Loop through fields */ else { + unsigned char ch = 0; + end = 0; for (i = 1; i < key->range[2*j] + j; i++) { if (key_separator) { /* Skip body of key and separator */ - while (str[end]) { - if (str[end++] == key_separator) + while ((ch = str[end]) != '\0') { + end++; + if (ch == key_separator) break; } } else { @@ -136,7 +141,7 @@ static char *get_key(char *str, struct sort_key *key, int flags) while (isspace(str[end])) end++; /* Skip body of key */ - while (str[end]) { + while (str[end] != '\0') { if (isspace(str[end])) break; end++; @@ -144,8 +149,13 @@ static char *get_key(char *str, struct sort_key *key, int flags) } } /* Remove last delim: "abc:def:" => "abc:def" */ - if (key_separator && j && end != 0) + if (j && ch) { + //if (str[end-1] != key_separator) + // bb_error_msg(_and_die("BUG! " + // "str[start:%d,end:%d]:'%.*s'", + // start, end, (int)(end-start), &str[start]); end--; + } } if (!j) start = end; } |