diff options
author | Cliff Miller <cbm@whatexit.org> | 2009-06-11 18:30:32 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2009-06-13 01:25:06 +0100 |
commit | 24c727d3c26122c4f1c29381e7c6f5d96985ccca (patch) | |
tree | 24443f3009e77d0ae83758b8f17147c0955d80ac /src/sort.c | |
parent | ba1c5239bc4b9719a20cedd35a313fa4237e7151 (diff) | |
download | coreutils-24c727d3c26122c4f1c29381e7c6f5d96985ccca.tar.xz |
sort: Ignore fields where end position is before the start position
* NEWS: Mention the fix
* THANKS: Add Cliff Miller
* src/sort.c (keycompare): Ensure lima >= texta
* tests/misc/sort: Add 3 corresponding tests
Signed-off-by: Pádraig Brady <P@draigBrady.com>
Diffstat (limited to 'src/sort.c')
-rw-r--r-- | src/sort.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sort.c b/src/sort.c index d571ddf02..6acec070d 100644 --- a/src/sort.c +++ b/src/sort.c @@ -1998,9 +1998,13 @@ keycompare (const struct line *a, const struct line *b) char const *translate = key->translate; bool const *ignore = key->ignore; + /* Treat field ends before field starts as empty fields. */ + lima = MAX (texta, lima); + limb = MAX (textb, limb); + /* Find the lengths. */ - size_t lena = lima <= texta ? 0 : lima - texta; - size_t lenb = limb <= textb ? 0 : limb - textb; + size_t lena = lima - texta; + size_t lenb = limb - textb; /* Actually compare the fields. */ |