int xmemcoll (char *s1, size_t s1len, char *s2, size_t s2len) { int diff = memcoll (s1, s1len, s2, s2len); int collation_errno = errno; if (collation_errno) collate_error (collation_errno, s1, s1len, s2, s2len); return diff; }
int xmemcoll (char *s1, size_t s1len, char *s2, size_t s2len) { int diff = memcoll (s1, s1len, s2, s2len); int collation_errno = errno; if (collation_errno) { error (0, collation_errno, _("string comparison failed")); error (0, 0, _("Set LC_ALL='C' to work around the problem.")); error (xmemcoll_exit_failure, 0, _("The strings compared were %s and %s."), quotearg_n_style_mem (0, locale_quoting_style, s1, s1len), quotearg_n_style_mem (1, locale_quoting_style, s2, s2len)); } return diff; }
int mbmemcasecoll (const char *s1, size_t s1len, const char *s2, size_t s2len, bool hard_LC_COLLATE) { char *t1; size_t t1len; char *t2; size_t t2len; char *memory; int cmp; if (MB_CUR_MAX > 1) { /* Application of towlower grows each character by a factor 2 at most. */ t1len = 2 * s1len; t2len = 2 * s2len; } else { /* Application of tolower doesn't change the size. */ t1len = s1len; t2len = s2len; } /* Allocate memory for t1 and t2. */ memory = (char *) malloca (t1len + 1 + t2len + 1); if (memory == NULL) { errno = ENOMEM; return 0; } t1 = memory; t2 = memory + t1len + 1; /* Csae-fold the two argument strings. */ if (MB_CUR_MAX > 1) { t1len = apply_towlower (s1, s1len, t1, t1len); t2len = apply_towlower (s2, s2len, t2, t2len); } else { apply_tolower (s1, t1, s1len); apply_tolower (s2, t2, s2len); } /* Compare the two case-folded strings. */ if (hard_LC_COLLATE) cmp = memcoll (t1, t1len, t2, t2len); else { cmp = memcmp2 (t1, t1len, t2, t2len); errno = 0; } { int saved_errno = errno; freea (memory); errno = saved_errno; } return cmp; }