+ s1size -= size1;
+ s2size -= size2;
+
+ if (s1size == 0)
+ return - (s2size != 0);
+ if (s2size == 0)
+ return 1;
+ }
+
+ return diff;
+}
+
+/* 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. Perhaps temporarily modify the bytes after S1 and S2,
+ but restore their original contents before returning. Set errno to an
+ error number if there is an error, and to zero otherwise. */
+int
+memcoll (char *s1, size_t s1len, char *s2, size_t s2len)
+{
+ int diff;
+
+ /* strcoll is slow on many platforms, so check for the common case
+ where the arguments are bytewise equal. Otherwise, walk through
+ the buffers using strcoll on each substring. */
+
+ if (s1len == s2len && memcmp (s1, s2, s1len) == 0)
+ {
+ errno = 0;
+ diff = 0;