summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-04-27 04:29:05 +0000
committerJim Meyering <jim@meyering.net>1998-04-27 04:29:05 +0000
commitd5d061ee9bdce12dd96fb4acc241bb20733ba7f9 (patch)
tree08ec17e1fc217450ef43c9d5d6817fe180fbe54a
parentb44e91e99dc95539513594fa1ecf5368190f5186 (diff)
downloadcoreutils-d5d061ee9bdce12dd96fb4acc241bb20733ba7f9.tar.xz
(keycompare): Don't return 0 from inside the keyspec-iterating loop.
With this change, test 22a passes. Reported by Zvi Har'El.
-rw-r--r--src/sort.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/sort.c b/src/sort.c
index f3809814c..a1ada7640 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -1511,6 +1511,8 @@ keycompare (const struct line *a, const struct line *b)
for (key = keyhead.next; key; key = key->next, ++iter)
{
+ int comparable_lengths = 1;
+
ignore = key->ignore;
translate = (unsigned char *) key->translate;
@@ -1725,7 +1727,7 @@ keycompare (const struct line *a, const struct line *b)
Handling this case here avoids what might be an invalid length \
comparison below. */ \
if (diff == 0 && texta == lima && textb == limb) \
- return 0; \
+ comparable_lengths = 0; \
} \
while (0)
@@ -1749,7 +1751,7 @@ keycompare (const struct line *a, const struct line *b)
if (diff)
return key->reverse ? -diff : diff;
- if ((diff = lena - lenb) != 0)
+ if (comparable_lengths && (diff = lena - lenb) != 0)
return key->reverse ? -diff : diff;
}
@@ -2143,7 +2145,11 @@ sortlines (struct line *lines, int nlines, struct line *temp)
if (nlines == 2)
{
if (compare (&lines[0], &lines[1]) > 0)
- *temp = lines[0], lines[0] = lines[1], lines[1] = *temp;
+ {
+ *temp = lines[0];
+ lines[0] = lines[1];
+ lines[1] = *temp;
+ }
return;
}