changeset 4104:f16f0fbf6ce2

Don't use strcoll if it is broken.
author Bruno Haible <bruno@clisp.org>
date Tue, 31 Dec 2002 13:01:56 +0000
parents a615f32b9998
children 7f998811f2f0
files lib/ChangeLog lib/memcoll.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2002-12-23  Bruno Haible  <bruno@clisp.org>
+
+	* memcoll.c (STRCOLL): New macro.
+	(memcoll): Use it.
+
 2002-12-22  Bruno Haible  <bruno@clisp.org>
 
 	* getstr.h (getstr): Define, to avoid clash with libcurses.
--- a/lib/memcoll.c
+++ b/lib/memcoll.c
@@ -32,6 +32,13 @@
 # include <string.h>
 #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 @@
   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