1 --- wcsftime.c.orig 2004-11-25 11:38:20.000000000 -0800
2 +++ wcsftime.c 2005-02-24 00:53:36.000000000 -0800
5 __FBSDID("$FreeBSD: src/lib/libc/locale/wcsftime.c,v 1.4 2004/04/07 09:47:56 tjr Exp $");
7 +#include "xlocale_private.h"
13 * format specifications in the format string.
16 -wcsftime(wchar_t * __restrict wcs, size_t maxsize,
17 - const wchar_t * __restrict format, const struct tm * __restrict timeptr)
18 +wcsftime_l(wchar_t * __restrict wcs, size_t maxsize,
19 + const wchar_t * __restrict format, const struct tm * __restrict timeptr,
22 static const mbstate_t initial;
28 + NORMALIZE_LOCALE(loc);
33 * for strftime(), which only handles single-byte characters.
36 - sflen = wcsrtombs(NULL, &format, 0, &mbs);
37 + sflen = wcsrtombs_l(NULL, &format, 0, &mbs, loc);
38 if (sflen == (size_t)-1)
40 if ((sformat = malloc(sflen + 1)) == NULL)
43 - wcsrtombs(sformat, &format, sflen + 1, &mbs);
44 + wcsrtombs_l(sformat, &format, sflen + 1, &mbs, loc);
47 * Allocate memory for longest multibyte sequence that will fit
49 * Then, copy and convert the result back into wide characters in
50 * the caller's buffer.
52 - if (SIZE_T_MAX / MB_CUR_MAX <= maxsize) {
53 + if (SIZE_T_MAX / MB_CUR_MAX_L(loc) <= maxsize) {
54 /* maxsize is prepostorously large - avoid int. overflow. */
58 - if ((dst = malloc(maxsize * MB_CUR_MAX)) == NULL)
59 + if ((dst = malloc(maxsize * MB_CUR_MAX_L(loc))) == NULL)
61 - if (strftime(dst, maxsize, sformat, timeptr) == 0)
62 + if (strftime_l(dst, maxsize, sformat, timeptr, loc) == 0)
66 - n = mbsrtowcs(wcs, (const char **)&dstp, maxsize, &mbs);
67 + n = mbsrtowcs_l(wcs, (const char **)&dstp, maxsize, &mbs, loc);
68 if (n == (size_t)-2 || n == (size_t)-1 || dstp != NULL)
77 +wcsftime(wchar_t * __restrict wcs, size_t maxsize,
78 + const wchar_t * __restrict format, const struct tm * __restrict timeptr)
80 + return wcsftime_l(wcs, maxsize, format, timeptr, __current_locale());