wcstombs.c.patch   [plain text]


--- wcstombs.c.orig	Thu Nov 25 11:38:20 2004
+++ wcstombs.c	Fri Feb 18 17:17:37 2005
@@ -27,17 +27,27 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/locale/wcstombs.c,v 1.10 2004/07/21 10:54:57 tjr Exp $");
 
+#include "xlocale_private.h"
+
 #include <limits.h>
 #include <stdlib.h>
 #include <wchar.h>
 #include "mblocal.h"
 
 size_t
-wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
+wcstombs_l(char * __restrict s, const wchar_t * __restrict pwcs, size_t n,
+    locale_t loc)
 {
 	static const mbstate_t initial;
 	mbstate_t mbs;
 
+	NORMALIZE_LOCALE(loc);
 	mbs = initial;
-	return (__wcsnrtombs(s, &pwcs, SIZE_T_MAX, n, &mbs));
+	return (loc->__lc_ctype->__wcsnrtombs(s, &pwcs, SIZE_T_MAX, n, &mbs, loc));
+}
+
+size_t
+wcstombs(char * __restrict s, const wchar_t * __restrict pwcs, size_t n)
+{
+	return wcstombs_l(s, pwcs, n, __current_locale());
 }