From d5d061ee9bdce12dd96fb4acc241bb20733ba7f9 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 27 Apr 1998 04:29:05 +0000 Subject: (keycompare): Don't return 0 from inside the keyspec-iterating loop. With this change, test 22a passes. Reported by Zvi Har'El. --- src/sort.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3-70-g09d2