From 1d94e2917b1d832dc99826667dcaa29894834bca Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 31 Dec 2002 13:01:56 +0000 Subject: [PATCH 1/1] Don't use strcoll if it is broken. --- lib/ChangeLog | 5 +++++ lib/memcoll.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 6055de6ec..1ff4fefa5 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2002-12-23 Bruno Haible + + * memcoll.c (STRCOLL): New macro. + (memcoll): Use it. + 2002-12-22 Bruno Haible * getstr.h (getstr): Define, to avoid clash with libcurses. diff --git a/lib/memcoll.c b/lib/memcoll.c index a2decfe27..e1b884efb 100644 --- a/lib/memcoll.c +++ b/lib/memcoll.c @@ -32,6 +32,13 @@ extern int errno; # include #endif +/* Use strcoll() only if it really works. */ +#if HAVE_STRCOLL +# define STRCOLL strcoll +#else +# define STRCOLL strcmp +#endif + /* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according to the LC_COLLATE locale. S1 and S2 do not overlap, and are not adjacent. Temporarily modify the bytes after S1 and S2, but @@ -47,7 +54,7 @@ memcoll (char *s1, size_t s1len, char *s2, size_t s2len) s1[s1len++] = '\0'; s2[s2len++] = '\0'; - while (! (errno = 0, (diff = strcoll (s1, s2)) || errno)) + while (! (errno = 0, (diff = STRCOLL (s1, s2)) || errno)) { /* strcoll found no difference, but perhaps it was fooled by NUL characters in the data. Work around this problem by advancing -- 2.11.0