* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
#endif /* LIBC_SCCS and not lint */
__FBSDID("FreeBSD: src/lib/libc/stdio/vsscanf.c,v 1.11 2002/08/21 16:19:57 mike Exp ");
#endif
-__FBSDID("$FreeBSD: src/lib/libc/stdio/vswscanf.c,v 1.3 2004/04/07 09:55:05 tjr Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/stdio/vswscanf.c,v 1.6 2009/01/15 18:53:52 rdivacky Exp $");
+
+#include "xlocale_private.h"
#include <limits.h>
#include <stdarg.h>
}
int
-vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
+vswscanf_l(const wchar_t * __restrict str, locale_t loc, const wchar_t * __restrict fmt,
va_list ap)
{
static const mbstate_t initial;
mbstate_t mbs;
FILE f;
- struct __sFILEX ext;
char *mbstr;
size_t mlen;
int r;
+ const wchar_t *strp;
+ struct __sFILEX ext;
+ f._extra = &ext;
+ INITEXTRA(&f);
+ NORMALIZE_LOCALE(loc);
/*
* XXX Convert the wide character string to multibyte, which
* __vfwscanf() will convert back to wide characters.
*/
- if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX + 1)) == NULL)
+ if ((mbstr = malloc(wcslen(str) * MB_CUR_MAX_L(loc) + 1)) == NULL)
return (EOF);
mbs = initial;
- if ((mlen = wcsrtombs(mbstr, &str, SIZE_T_MAX, &mbs)) == (size_t)-1) {
+ strp = str;
+ if ((mlen = wcsrtombs_l(mbstr, &strp, SIZE_T_MAX, &mbs, loc)) == (size_t)-1) {
free(mbstr);
return (EOF);
}
f._read = eofread;
f._ub._base = NULL;
f._lb._base = NULL;
- f._extra = &ext;
- INITEXTRA(&f);
- r = __vfwscanf(&f, fmt, ap);
+ f._orientation = 0;
+ memset(&f._mbstate, 0, sizeof(mbstate_t));
+ r = __vfwscanf(&f, loc, fmt, ap);
free(mbstr);
return (r);
}
+
+int
+vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
+ va_list ap)
+{
+ return vswscanf_l(str, __current_locale(), fmt, ap);
+}
+