diff options
author | ache <ache@FreeBSD.org> | 1999-02-14 09:44:56 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1999-02-14 09:44:56 +0000 |
commit | c9385fa2e56ab925d4479161ae983da6de7a556f (patch) | |
tree | ad673f2957fd80e23fbfe2380c3e6e0c83ef82f5 | |
parent | 1b84e2b2fec7de47a61492d069ad8d8b7e04330e (diff) | |
download | FreeBSD-src-c9385fa2e56ab925d4479161ae983da6de7a556f.zip FreeBSD-src-c9385fa2e56ab925d4479161ae983da6de7a556f.tar.gz |
use minimum length for strcoll too
-rw-r--r-- | gnu/usr.bin/sort/sort.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/gnu/usr.bin/sort/sort.c b/gnu/usr.bin/sort/sort.c index 8e17ac6..c1d9004 100644 --- a/gnu/usr.bin/sort/sort.c +++ b/gnu/usr.bin/sort/sort.c @@ -197,8 +197,7 @@ static struct keyfield keyhead; #ifdef __FreeBSD__ static int -COLLDIFF (a, b) - int a, b; +COLLDIFF (int a, int b) { static char s[2][2]; @@ -208,6 +207,22 @@ COLLDIFF (a, b) s[1][0] = b; return strcoll(s[0], s[1]); } + +static int +collcmp(char *a, char *b, int mini) +{ + char sa, sb; + int r; + + sa = a[mini]; + a[mini] = '\0'; + sb = b[mini]; + b[mini] = '\0'; + r = strcoll(a, b); + a[mini] = sa; + b[mini] = sb; + return r; +} #endif /* __FreeBSD__ */ static void @@ -1138,7 +1153,7 @@ keycompare (const struct line *a, const struct line *b) } else #ifdef __FreeBSD__ - diff = strcoll (texta, textb); + diff = collcmp (texta, textb, min (lena, lenb)); #else diff = memcmp (texta, textb, min (lena, lenb)); #endif @@ -1188,7 +1203,7 @@ compare (register const struct line *a, register const struct line *b) { #endif #ifdef __FreeBSD__ - diff = strcoll (ap, bp); + diff = collcmp (ap, bp, mini); #else diff = memcmp (ap, bp, mini); #endif |