1 --- wcscoll.c.orig 2004-11-25 11:38:47.000000000 -0800
2 +++ wcscoll.c 2005-02-18 18:17:11.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/string/wcscoll.c,v 1.3 2004/04/07 09:47:56 tjr Exp $");
7 +#include "xlocale_private.h"
15 -static char *__mbsdup(const wchar_t *);
16 +static char *__mbsdup(const wchar_t *, locale_t);
19 * Placeholder implementation of wcscoll(). Attempts to use the single-byte
21 * with extended character sets.
24 -wcscoll(const wchar_t *ws1, const wchar_t *ws2)
25 +wcscoll_l(const wchar_t *ws1, const wchar_t *ws2, locale_t loc)
30 - if (__collate_load_error || MB_CUR_MAX > 1)
31 + NORMALIZE_LOCALE(loc);
32 + if (loc->__collate_load_error || MB_CUR_MAX_L(loc) > 1)
34 * Locale has no special collating order, could not be
35 * loaded, or has an extended character set; do a fast binary
38 return (wcscmp(ws1, ws2));
40 - if ((mbs1 = __mbsdup(ws1)) == NULL || (mbs2 = __mbsdup(ws2)) == NULL) {
41 + if ((mbs1 = __mbsdup(ws1, loc)) == NULL || (mbs2 = __mbsdup(ws2, loc)) == NULL) {
43 * Out of memory or illegal wide chars; fall back to wcscmp()
44 * but leave errno indicating the error. Callers that don't
46 return (wcscmp(ws1, ws2));
49 - diff = strcoll(mbs1, mbs2);
50 + diff = strcoll_l(mbs1, mbs2, loc);
59 +wcscoll(const wchar_t *ws1, const wchar_t *ws2)
61 + return wcscoll_l(ws1, ws2, __current_locale());
65 -__mbsdup(const wchar_t *ws)
66 +__mbsdup(const wchar_t *ws, locale_t loc)
68 static const mbstate_t initial;
74 - if ((len = wcsrtombs(NULL, &wcp, 0, &st)) == (size_t)-1)
75 + if ((len = wcsrtombs_l(NULL, &wcp, 0, &st, loc)) == (size_t)-1)
77 if ((mbs = malloc(len + 1)) == NULL)
80 - wcsrtombs(mbs, &ws, len + 1, &st);
81 + wcsrtombs_l(mbs, &ws, len + 1, &st, loc);