Module Name:    src
Committed By:   joerg
Date:           Fri Apr 19 23:32:17 UTC 2013

Modified Files:
        src/include: stdio.h wchar.h
        src/lib/libc/include: namespace.h
        src/lib/libc/stdio: fscanf.c fwscanf.c local.h scanf.c sscanf.c
            swscanf.c vfscanf.c vfwscanf.c vscanf.c vsscanf.c vswscanf.c
            vwscanf.c wscanf.c

Log Message:
Add scanf_l and wscanf_l families.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/include/stdio.h
cvs rdiff -u -r1.35 -r1.36 src/include/wchar.h
cvs rdiff -u -r1.163 -r1.164 src/lib/libc/include/namespace.h
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/stdio/fscanf.c \
    src/lib/libc/stdio/scanf.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/stdio/fwscanf.c \
    src/lib/libc/stdio/swscanf.c src/lib/libc/stdio/vwscanf.c \
    src/lib/libc/stdio/wscanf.c
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/stdio/local.h
cvs rdiff -u -r1.20 -r1.21 src/lib/libc/stdio/sscanf.c
cvs rdiff -u -r1.43 -r1.44 src/lib/libc/stdio/vfscanf.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/stdio/vfwscanf.c
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/stdio/vscanf.c
cvs rdiff -u -r1.19 -r1.20 src/lib/libc/stdio/vsscanf.c
cvs rdiff -u -r1.9 -r1.10 src/lib/libc/stdio/vswscanf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/include/stdio.h
diff -u src/include/stdio.h:1.84 src/include/stdio.h:1.85
--- src/include/stdio.h:1.84	Fri Apr 19 15:22:24 2013
+++ src/include/stdio.h	Fri Apr 19 23:32:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: stdio.h,v 1.84 2013/04/19 15:22:24 joerg Exp $	*/
+/*	$NetBSD: stdio.h,v 1.85 2013/04/19 23:32:16 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -559,6 +559,21 @@ int	 sprintf_l(char * __restrict, locale
 int	 vsprintf_l(char * __restrict, locale_t, const char * __restrict,
 		    __va_list) __printflike(3, 0);
 #endif
+
+int	 fscanf_l(FILE * __restrict, locale_t, const char * __restrict, ...)
+    __scanflike(3, 4);
+int	 scanf_l(locale_t, const char * __restrict, ...)
+    __scanflike(2, 3);
+int	 sscanf_l(const char * __restrict, locale_t,
+    const char * __restrict, ...) __scanflike(3, 4);
+int	 vscanf_l(locale_t, const char * __restrict, __va_list)
+    __scanflike(2, 0);
+int	 vscanf_l(locale_t, const char * __restrict, __va_list)
+    __scanflike(2, 0);
+int	 vfscanf_l(FILE * __restrict, locale_t, const char * __restrict,
+    __va_list) __scanflike(3, 0);
+int	 vsscanf_l(const char * __restrict, locale_t, const char * __restrict,
+    __va_list) __scanflike(3, 0);
 #endif
 
 #if _FORTIFY_SOURCE > 0

Index: src/include/wchar.h
diff -u src/include/wchar.h:1.35 src/include/wchar.h:1.36
--- src/include/wchar.h:1.35	Fri Apr 19 15:22:24 2013
+++ src/include/wchar.h	Fri Apr 19 23:32:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: wchar.h,v 1.35 2013/04/19 15:22:24 joerg Exp $	*/
+/*	$NetBSD: wchar.h,v 1.36 2013/04/19 23:32:16 joerg Exp $	*/
 
 /*-
  * Copyright (c)1999 Citrus Project,
@@ -257,6 +257,16 @@ int vswprintf_l(wchar_t * __restrict, si
     const wchar_t * __restrict, __va_list);
 int vwprintf_l(locale_t, const wchar_t * __restrict, __va_list);
 int wprintf_l(locale_t, const wchar_t * __restrict, ...);
+
+int fwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...);
+int swscanf_l(const wchar_t * __restrict, locale_t, const wchar_t *
+    __restrict, ...);
+int wscanf_l(locale_t, const wchar_t * __restrict, ...);
+int vfwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict,
+    __va_list);
+int vswscanf_l(const wchar_t * __restrict, locale_t, const wchar_t * __restrict,
+    __va_list);
+int vwscanf_l(locale_t, const wchar_t * __restrict, __va_list);
 #endif /* _NETBSD_SOURCE */
 
 #endif /* !_WCHAR_H_ */

Index: src/lib/libc/include/namespace.h
diff -u src/lib/libc/include/namespace.h:1.163 src/lib/libc/include/namespace.h:1.164
--- src/lib/libc/include/namespace.h:1.163	Fri Apr 19 23:28:47 2013
+++ src/lib/libc/include/namespace.h	Fri Apr 19 23:32:16 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: namespace.h,v 1.163 2013/04/19 23:28:47 joerg Exp $	*/
+/*	$NetBSD: namespace.h,v 1.164 2013/04/19 23:32:16 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
@@ -290,6 +290,7 @@
 #define freenetconfigent	_freenetconfigent
 #define freeaddrinfo		_freeaddrinfo
 #define freeifaddrs		_freeifaddrs
+#define fscanf_l		_fscanf_l
 #define fstatvfs		_fstatvfs
 #define ftok			_ftok
 #define ftruncate		_ftruncate
@@ -299,6 +300,7 @@
 #define fts_read		_fts_read
 #define fts_set			_fts_set
 #define fwprintf_l		_fwprintf_l
+#define fwscanf_l		_fwscanf_l
 #define gai_strerror		_gai_strerror
 #define get_myaddress		_get_myaddress
 #define getaddrinfo		_getaddrinfo
@@ -550,6 +552,7 @@
 #define rpcb_uaddr2taddr	_rpcb_uaddr2taddr
 #define rpcb_unset		_rpcb_unset
 #define scandir			_scandir
+#define scanf_l			_scanf_l
 #define seed48			_seed48
 #define seekdir			_seekdir
 #define select			_select
@@ -604,6 +607,7 @@
 #define sradixsort		_sradixsort
 #define srand48			_srand48
 #define srandom			_srandom
+#define sscanf_l		_sscanf_l
 #define statvfs(a, b)		_statvfs(a, b)
 #define strcasecmp		_strcasecmp
 #define strcoll_l		_strcoll_l
@@ -654,6 +658,7 @@
 #define svcudp_enablecache	_svcudp_enablecache
 #define sysarch			_sys_sysarch
 #define swprintf_l		_swprintf_l
+#define swscanf_l		_swscanf_l
 #define sysctl			_sysctl
 #define sysctlbyname		_sysctlbyname
 #define sysctlgetmibinfo	_sysctlgetmibinfo
@@ -708,11 +713,15 @@
 #define vfprintf_l		_vfprintf_l
 #define vfwprintf_l		_vfwprintf_l
 #define vprintf_l		_vprintf_l
+#define vscanf_l		_vscanf_l
+#define vsscanf_l		_vsscanf_l
+#define vswscanf_l		_vswscanf_l
 #define vsnprintf_l		_vsnprintf_l
 #define vsnprintf_ss		_vsnprintf_ss
 #define vsprintf_l		_vsprintf_l
 #define vswprintf_l		_vswprintf_l
 #define vwprintf_l		_vwprintf_l
+#define vwscanf_l		_vwscanf_l
 #define vsyslog			_vsyslog
 #define vsyslog_r		_vsyslog_r
 #define vsyslog_ss		_vsyslog_ss
@@ -737,6 +746,7 @@
 #define wcwidth			_wcwidth
 #define wcwidth_l		_wcwidth_l
 #define wprintf_l		_wprintf_l
+#define wscanf_l		_wscanf_l
 #define xdr_accepted_reply	_xdr_accepted_reply
 #define xdr_array		_xdr_array
 #define xdr_authunix_parms	_xdr_authunix_parms

Index: src/lib/libc/stdio/fscanf.c
diff -u src/lib/libc/stdio/fscanf.c:1.13 src/lib/libc/stdio/fscanf.c:1.14
--- src/lib/libc/stdio/fscanf.c:1.13	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/fscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fscanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $	*/
+/*	$NetBSD: fscanf.c,v 1.14 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,10 +37,12 @@
 #if 0
 static char sccsid[] = "@(#)fscanf.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fscanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
+__RCSID("$NetBSD: fscanf.c,v 1.14 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <stdarg.h>
@@ -49,6 +51,8 @@ __RCSID("$NetBSD: fscanf.c,v 1.13 2012/0
 #include "reentrant.h"
 #include "local.h"
 
+__weak_alias(fscanf_l, _fscanf_l)
+
 int
 fscanf(FILE *fp, char const *fmt, ...)
 {
@@ -60,3 +64,15 @@ fscanf(FILE *fp, char const *fmt, ...)
 	va_end(ap);
 	return ret;
 }
+
+int
+fscanf_l(FILE *fp, locale_t loc, char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+
+	va_start(ap, fmt);
+	ret = __svfscanf_l(fp, loc, fmt, ap);
+	va_end(ap);
+	return ret;
+}
Index: src/lib/libc/stdio/scanf.c
diff -u src/lib/libc/stdio/scanf.c:1.13 src/lib/libc/stdio/scanf.c:1.14
--- src/lib/libc/stdio/scanf.c:1.13	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/scanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: scanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $	*/
+/*	$NetBSD: scanf.c,v 1.14 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,10 +37,12 @@
 #if 0
 static char sccsid[] = "@(#)scanf.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: scanf.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
+__RCSID("$NetBSD: scanf.c,v 1.14 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <stdarg.h>
@@ -49,6 +51,8 @@ __RCSID("$NetBSD: scanf.c,v 1.13 2012/03
 #include "reentrant.h"
 #include "local.h"
 
+__weak_alias(scanf_l, _scanf_l)
+
 int
 scanf(char const *fmt, ...)
 {
@@ -62,3 +66,17 @@ scanf(char const *fmt, ...)
 	va_end(ap);
 	return ret;
 }
+
+int
+scanf_l(locale_t loc, char const *fmt, ...)
+{
+	int ret;
+	va_list ap;
+
+	_DIAGASSERT(fmt != NULL);
+
+	va_start(ap, fmt);
+	ret = __svfscanf_l(stdin, loc, fmt, ap);
+	va_end(ap);
+	return ret;
+}

Index: src/lib/libc/stdio/fwscanf.c
diff -u src/lib/libc/stdio/fwscanf.c:1.2 src/lib/libc/stdio/fwscanf.c:1.3
--- src/lib/libc/stdio/fwscanf.c:1.2	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/fwscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: fwscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $	*/
+/*	$NetBSD: fwscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2002 Tim J. Robbins
@@ -31,14 +31,18 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/stdio/fwscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
 #else
-__RCSID("$NetBSD: fwscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $");
+__RCSID("$NetBSD: fwscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
 
+__weak_alias(fwscanf_l, _fwscanf_l)
+
 int
 fwscanf(FILE * __restrict fp, const wchar_t * __restrict fmt, ...)
 {
@@ -51,3 +55,17 @@ fwscanf(FILE * __restrict fp, const wcha
 
 	return r;
 }
+
+int
+fwscanf_l(FILE * __restrict fp, locale_t loc, const wchar_t * __restrict fmt,
+    ...)
+{
+	va_list ap;
+	int r;
+
+	va_start(ap, fmt);
+	r = vfwscanf_l(fp, loc, fmt, ap);
+	va_end(ap);
+
+	return r;
+}
Index: src/lib/libc/stdio/swscanf.c
diff -u src/lib/libc/stdio/swscanf.c:1.2 src/lib/libc/stdio/swscanf.c:1.3
--- src/lib/libc/stdio/swscanf.c:1.2	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/swscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: swscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $	*/
+/*	$NetBSD: swscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2002 Tim J. Robbins
@@ -31,14 +31,18 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/stdio/swscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
 #else
-__RCSID("$NetBSD: swscanf.c,v 1.2 2012/03/15 18:22:30 christos Exp $");
+__RCSID("$NetBSD: swscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
 
+__weak_alias(swscanf_l, _swscanf_l)
+
 int
 swscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt, ...)
 {
@@ -51,3 +55,17 @@ swscanf(const wchar_t * __restrict str, 
 
 	return r;
 }
+
+int
+swscanf_l(const wchar_t * __restrict str, locale_t loc,
+    const wchar_t * __restrict fmt, ...)
+{
+	va_list ap;
+	int r;
+
+	va_start(ap, fmt);
+	r = vswscanf_l(str, loc, fmt, ap);
+	va_end(ap);
+
+	return r;
+}
Index: src/lib/libc/stdio/vwscanf.c
diff -u src/lib/libc/stdio/vwscanf.c:1.2 src/lib/libc/stdio/vwscanf.c:1.3
--- src/lib/libc/stdio/vwscanf.c:1.2	Thu Mar 15 18:22:31 2012
+++ src/lib/libc/stdio/vwscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vwscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $	*/
+/*	$NetBSD: vwscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2002 Tim J. Robbins
@@ -31,17 +31,28 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/stdio/vwscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
 #else
-__RCSID("$NetBSD: vwscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $");
+__RCSID("$NetBSD: vwscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
 
+__weak_alias(vwscanf_l, _vwscanf_l)
+
 int
 vwscanf(const wchar_t * __restrict fmt, va_list ap)
 {
 
 	return vfwscanf(stdin, fmt, ap);
 }
+
+int
+vwscanf_l(locale_t loc, const wchar_t * __restrict fmt, va_list ap)
+{
+
+	return vfwscanf_l(stdin, loc, fmt, ap);
+}
Index: src/lib/libc/stdio/wscanf.c
diff -u src/lib/libc/stdio/wscanf.c:1.2 src/lib/libc/stdio/wscanf.c:1.3
--- src/lib/libc/stdio/wscanf.c:1.2	Thu Mar 15 18:22:31 2012
+++ src/lib/libc/stdio/wscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: wscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $	*/
+/*	$NetBSD: wscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2002 Tim J. Robbins
@@ -31,14 +31,18 @@
 #if 0
 __FBSDID("$FreeBSD: src/lib/libc/stdio/wscanf.c,v 1.1 2002/09/23 12:40:06 tjr Exp $");
 #else
-__RCSID("$NetBSD: wscanf.c,v 1.2 2012/03/15 18:22:31 christos Exp $");
+__RCSID("$NetBSD: wscanf.c,v 1.3 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
 
+__weak_alias(wscanf_l, _wscanf_l)
+
 int
 wscanf(const wchar_t * __restrict fmt, ...)
 {
@@ -51,3 +55,16 @@ wscanf(const wchar_t * __restrict fmt, .
 
 	return r;
 }
+
+int
+wscanf_l(locale_t loc, const wchar_t * __restrict fmt, ...)
+{
+	va_list ap;
+	int r;
+
+	va_start(ap, fmt);
+	r = vfwscanf_l(stdin, loc, fmt, ap);
+	va_end(ap);
+
+	return r;
+}

Index: src/lib/libc/stdio/local.h
diff -u src/lib/libc/stdio/local.h:1.35 src/lib/libc/stdio/local.h:1.36
--- src/lib/libc/stdio/local.h:1.35	Fri Apr 19 15:22:25 2013
+++ src/lib/libc/stdio/local.h	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: local.h,v 1.35 2013/04/19 15:22:25 joerg Exp $	*/
+/*	$NetBSD: local.h,v 1.36 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -65,8 +65,10 @@ extern int	__swsetup(FILE *);
 extern int	__sflags(const char *, int *);
 extern int	__svfscanf(FILE * __restrict, const char * __restrict,
     va_list) __scanflike(2, 0);
-extern int	__svfscanf_unlocked(FILE * __restrict, const char * __restrict,
-    va_list) __scanflike(2, 0);
+extern int	__svfscanf_l(FILE * __restrict, locale_t,
+    const char * __restrict, va_list) __scanflike(3, 0);
+extern int	__svfscanf_unlocked_l(FILE * __restrict, locale_t,
+    const char * __restrict, va_list) __scanflike(3, 0);
 extern int	__vfprintf_unlocked_l(FILE * __restrict, locale_t,
     const char * __restrict, va_list) __printflike(3, 0);
 
@@ -82,7 +84,7 @@ extern ssize_t	__getdelim(char **__restr
     FILE *__restrict);
 extern char	*__fgetstr(FILE * __restrict, size_t * __restrict, int);
 extern int 	 __vfwprintf_unlocked_l(FILE *, locale_t, const wchar_t *, va_list);
-extern int	 __vfwscanf_unlocked(FILE * __restrict,
+extern int	 __vfwscanf_unlocked_l(FILE * __restrict, locale_t,
     const wchar_t * __restrict, va_list);
 
 /*

Index: src/lib/libc/stdio/sscanf.c
diff -u src/lib/libc/stdio/sscanf.c:1.20 src/lib/libc/stdio/sscanf.c:1.21
--- src/lib/libc/stdio/sscanf.c:1.20	Tue Mar 27 15:05:42 2012
+++ src/lib/libc/stdio/sscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: sscanf.c,v 1.20 2012/03/27 15:05:42 christos Exp $	*/
+/*	$NetBSD: sscanf.c,v 1.21 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,10 +37,12 @@
 #if 0
 static char sccsid[] = "@(#)sscanf.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: sscanf.c,v 1.20 2012/03/27 15:05:42 christos Exp $");
+__RCSID("$NetBSD: sscanf.c,v 1.21 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <stdarg.h>
@@ -50,36 +52,32 @@ __RCSID("$NetBSD: sscanf.c,v 1.20 2012/0
 #include "reentrant.h"
 #include "local.h"
 
-/* ARGSUSED */
-static ssize_t
-eofread(void *cookie, void *buf, size_t len)
+__weak_alias(sscanf_l, _sscanf_l)
+
+int
+sscanf(const char *str, char const *fmt, ...)
 {
+	int ret;
+	va_list ap;
 
-	return 0;
+	_DIAGASSERT(fmt != NULL);
+
+	va_start(ap, fmt);
+	ret = vsscanf(str, fmt, ap);
+	va_end(ap);
+	return ret;
 }
 
 int
-sscanf(const char *str, char const *fmt, ...)
+sscanf_l(const char *str, locale_t loc, char const *fmt, ...)
 {
 	int ret;
 	va_list ap;
-	FILE f;
-	size_t len;
-	struct __sfileext fext;
 
-	_DIAGASSERT(str != NULL);
 	_DIAGASSERT(fmt != NULL);
 
-	_FILEEXT_SETUP(&f, &fext);
-	f._flags = __SRD;
-	f._bf._base = f._p = __UNCONST(str);
-	len = strlen(str);
-	_DIAGASSERT(__type_fit(int, len));
-	f._bf._size = f._r = (int)len;
-	f._read = eofread;
-	_UB(&f)._base = NULL;
 	va_start(ap, fmt);
-	ret = __svfscanf_unlocked(&f, fmt, ap);
+	ret = vsscanf_l(str, loc, fmt, ap);
 	va_end(ap);
 	return ret;
 }

Index: src/lib/libc/stdio/vfscanf.c
diff -u src/lib/libc/stdio/vfscanf.c:1.43 src/lib/libc/stdio/vfscanf.c:1.44
--- src/lib/libc/stdio/vfscanf.c:1.43	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/vfscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfscanf.c,v 1.43 2012/03/15 18:22:30 christos Exp $	*/
+/*	$NetBSD: vfscanf.c,v 1.44 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
 static char sccsid[] = "@(#)vfscanf.c	8.1 (Berkeley) 6/4/93";
 __FBSDID("$FreeBSD: src/lib/libc/stdio/vfscanf.c,v 1.41 2007/01/09 00:28:07 imp Exp $");
 #else
-__RCSID("$NetBSD: vfscanf.c,v 1.43 2012/03/15 18:22:30 christos Exp $");
+__RCSID("$NetBSD: vfscanf.c,v 1.44 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -57,9 +57,8 @@ __RCSID("$NetBSD: vfscanf.c,v 1.43 2012/
 #include "reentrant.h"
 #include "local.h"
 
-#ifndef NO_FLOATING_POINT
 #include <locale.h>
-#endif
+#include "setlocale_local.h"
 
 /*
  * Provide an external name for vfscanf.  Note, we don't use the normal
@@ -68,6 +67,7 @@ __RCSID("$NetBSD: vfscanf.c,v 1.43 2012/
  */
 #ifdef __weak_alias
 __weak_alias(vfscanf,__svfscanf)
+__weak_alias(vfscanf_l,__svfscanf_l)
 #endif
 
 #define	BUF		513	/* Maximum length of numeric string. */
@@ -107,22 +107,22 @@ __weak_alias(vfscanf,__svfscanf)
 #define	CT_INT		3	/* %[dioupxX] conversion */
 #define	CT_FLOAT	4	/* %[efgEFG] conversion */
 
-static const u_char *__sccl(char *, const u_char *);
+static const u_char *__sccl(char *, const u_char *, locale_t);
 #ifndef NO_FLOATING_POINT
-static size_t parsefloat(FILE *, char *, char *);
+static size_t parsefloat(FILE *, char *, char *, locale_t);
 #endif
 
 int __scanfdebug = 0;
 
 #define __collate_load_error /*CONSTCOND*/0
 static int
-__collate_range_cmp(int c1, int c2)
+__collate_range_cmp(int c1, int c2, locale_t loc)
 {
 	static char s1[2], s2[2];
 
 	s1[0] = c1;
 	s2[0] = c2;
-	return strcoll(s1, s2);
+	return strcoll_l(s1, s2, loc);
 }
 
 
@@ -132,17 +132,23 @@ __collate_range_cmp(int c1, int c2)
 int
 __svfscanf(FILE *fp, char const *fmt0, va_list ap)
 {
+	return __svfscanf_l(fp, *_current_locale(), fmt0, ap);
+}
+
+int
+__svfscanf_l(FILE *fp, locale_t loc, char const *fmt0, va_list ap)
+{
 	int ret;
 
 	FLOCKFILE(fp);
-	ret = __svfscanf_unlocked(fp, fmt0, ap);
+	ret = __svfscanf_unlocked_l(fp, loc, fmt0, ap);
 	FUNLOCKFILE(fp);
 	return ret;
 }
 
 #define SCANF_SKIP_SPACE() \
 do { \
-	while ((fp->_r > 0 || __srefill(fp) == 0) && isspace(*fp->_p)) \
+	while ((fp->_r > 0 || __srefill(fp) == 0) && isspace_l(*fp->_p, loc)) \
 		nread++, fp->_r--, fp->_p++; \
 } while (/*CONSTCOND*/ 0)
 
@@ -150,7 +156,7 @@ do { \
  * __svfscanf_unlocked - non-MT-safe version of __svfscanf
  */
 int
-__svfscanf_unlocked(FILE *fp, const char *fmt0, va_list ap)
+__svfscanf_unlocked_l(FILE *fp, locale_t loc, const char *fmt0, va_list ap)
 {
 	const u_char *fmt = (const u_char *)fmt0;
 	int c;			/* character from format, or conversion */
@@ -187,9 +193,9 @@ __svfscanf_unlocked(FILE *fp, const char
 		c = (unsigned char)*fmt++;
 		if (c == 0)
 			return nassigned;
-		if (isspace(c)) {
+		if (isspace_l(c, loc)) {
 			while ((fp->_r > 0 || __srefill(fp) == 0) &&
-			    isspace(*fp->_p))
+			    isspace_l(*fp->_p, loc))
 				nread++, fp->_r--, fp->_p++;
 			continue;
 		}
@@ -300,7 +306,7 @@ literal:
 			break;
 
 		case '[':
-			fmt = __sccl(ccltab, fmt);
+			fmt = __sccl(ccltab, fmt, loc);
 			flags |= NOSKIP;
 			c = CT_CCL;
 			break;
@@ -363,7 +369,7 @@ literal:
 		 * that suppress this.
 		 */
 		if ((flags & NOSKIP) == 0) {
-			while (isspace(*fp->_p)) {
+			while (isspace_l(*fp->_p, loc)) {
 				nread++;
 				if (--fp->_r > 0)
 					fp->_p++;
@@ -393,7 +399,7 @@ literal:
 					wcp = NULL;
 				n = 0;
 				while (width != 0) {
-					if (n == MB_CUR_MAX) {
+					if (n == MB_CUR_MAX_L(loc)) {
 						fp->_flags |= __SERR;
 						goto input_failure;
 					}
@@ -401,7 +407,8 @@ literal:
 					fp->_p++;
 					fp->_r--;
 					mbs = initial;
-					nconv = mbrtowc(wcp, buf, n, &mbs);
+					nconv = mbrtowc_l(wcp, buf, n, &mbs,
+					    loc);
 					if (nconv == (size_t)-1) {
 						fp->_flags |= __SERR;
 						goto input_failure;
@@ -475,7 +482,7 @@ literal:
 				n = 0;
 				nchars = 0;
 				while (width != 0) {
-					if (n == MB_CUR_MAX) {
+					if (n == MB_CUR_MAX_L(loc)) {
 						fp->_flags |= __SERR;
 						goto input_failure;
 					}
@@ -483,7 +490,8 @@ literal:
 					fp->_p++;
 					fp->_r--;
 					mbs = initial;
-					nconv = mbrtowc(wcp, buf, n, &mbs);
+					nconv = mbrtowc_l(wcp, buf, n, &mbs,
+					    loc);
 					if (nconv == (size_t)-1) {
 						fp->_flags |= __SERR;
 						goto input_failure;
@@ -491,8 +499,8 @@ literal:
 					if (nconv == 0)
 						*wcp = L'\0';
 					if (nconv != (size_t)-2) {
-						if (wctob(*wcp) != EOF &&
-						    !ccltab[wctob(*wcp)]) {
+						if (wctob_l(*wcp, loc) != EOF &&
+						    !ccltab[wctob_l(*wcp, loc)]) {
 							while (n != 0) {
 								n--;
 								(void)ungetc(buf[n],
@@ -575,8 +583,8 @@ literal:
 				else
 					wcp = &twc;
 				n = 0;
-				while (!isspace(*fp->_p) && width != 0) {
-					if (n == MB_CUR_MAX) {
+				while (!isspace_l(*fp->_p, loc) && width != 0) {
+					if (n == MB_CUR_MAX_L(loc)) {
 						fp->_flags |= __SERR;
 						goto input_failure;
 					}
@@ -584,7 +592,8 @@ literal:
 					fp->_p++;
 					fp->_r--;
 					mbs = initial;
-					nconv = mbrtowc(wcp, buf, n, &mbs);
+					nconv = mbrtowc_l(wcp, buf, n, &mbs,
+					    loc);
 					if (nconv == (size_t)-1) {
 						fp->_flags |= __SERR;
 						goto input_failure;
@@ -592,7 +601,7 @@ literal:
 					if (nconv == 0)
 						*wcp = L'\0';
 					if (nconv != (size_t)-2) {
-						if (iswspace(*wcp)) {
+						if (iswspace_l(*wcp, loc)) {
 							while (n != 0) {
 								n--;
 								(void)ungetc(buf[n],
@@ -620,7 +629,7 @@ literal:
 				}
 			} else if (flags & SUPPRESS) {
 				n = 0;
-				while (!isspace(*fp->_p)) {
+				while (!isspace_l(*fp->_p, loc)) {
 					n++, fp->_r--, fp->_p++;
 					if (--width == 0)
 						break;
@@ -630,7 +639,7 @@ literal:
 				nread += n;
 			} else {
 				p0 = p = va_arg(ap, char *);
-				while (!isspace(*fp->_p)) {
+				while (!isspace_l(*fp->_p, loc)) {
 					fp->_r--;
 					*p++ = *fp->_p++;
 					if (--width == 0)
@@ -773,9 +782,11 @@ literal:
 
 				*p = 0;
 				if ((flags & UNSIGNED) == 0)
-				    res = strtoimax(buf, (char **)NULL, base);
+				    res = strtoimax_l(buf, (char **)NULL, base,
+				        loc);
 				else
-				    res = strtoumax(buf, (char **)NULL, base);
+				    res = strtoumax_l(buf, (char **)NULL, base,
+				        loc);
 				if (flags & POINTER)
 					*va_arg(ap, void **) =
 							(void *)(uintptr_t)res;
@@ -807,17 +818,18 @@ literal:
 			/* scan a floating point number as if by strtod */
 			if (width == 0 || width > sizeof(buf) - 1)
 				width = sizeof(buf) - 1;
-			if ((width = parsefloat(fp, buf, buf + width)) == 0)
+			if ((width = parsefloat(fp, buf, buf + width, loc)) == 0)
 				goto match_failure;
 			if ((flags & SUPPRESS) == 0) {
 				if (flags & LONGDBL) {
-					long double res = strtold(buf, &p);
+					long double res = strtold_l(buf, &p,
+					    loc);
 					*va_arg(ap, long double *) = res;
 				} else if (flags & LONG) {
-					double res = strtod(buf, &p);
+					double res = strtod_l(buf, &p, loc);
 					*va_arg(ap, double *) = res;
 				} else {
-					float res = strtof(buf, &p);
+					float res = strtof_l(buf, &p, loc);
 					*va_arg(ap, float *) = res;
 				}
 				if (__scanfdebug && (size_t)(p - buf) != width)
@@ -843,7 +855,7 @@ match_failure:
  * considered part of the scanset.
  */
 static const u_char *
-__sccl(char *tab, const u_char *fmt)
+__sccl(char *tab, const u_char *fmt, locale_t loc)
 {
 	int c, n, v, i;
 
@@ -901,7 +913,7 @@ doswitch:
 			 */
 			n = *fmt;
 			if (n == ']' || (__collate_load_error ? n < c :
-			    __collate_range_cmp(n, c) < 0)) {
+			    __collate_range_cmp(n, c, loc) < 0)) {
 				c = '-';
 				break;	/* resume the for(;;) */
 			}
@@ -913,8 +925,8 @@ doswitch:
 				while (c < n);
 			} else {
 				for (i = 0; i < 256; i ++)
-					if (__collate_range_cmp(c, i) < 0 &&
-					    __collate_range_cmp(i, n) <= 0)
+					if (__collate_range_cmp(c, i, loc) < 0 &&
+					    __collate_range_cmp(i, n, loc) <= 0)
 						tab[i] = v;
 			}
 #if 1	/* XXX another disgusting compatibility hack */
@@ -946,7 +958,7 @@ doswitch:
 
 #ifndef NO_FLOATING_POINT
 static size_t
-parsefloat(FILE *fp, char *buf, char *end)
+parsefloat(FILE *fp, char *buf, char *end, locale_t loc)
 {
 	char *commit, *p;
 	int infnanpos = 0;
@@ -955,7 +967,7 @@ parsefloat(FILE *fp, char *buf, char *en
 		S_DIGITS, S_FRAC, S_EXP, S_EXPDIGITS
 	} state = S_START;
 	unsigned char c;
-	char decpt = *localeconv()->decimal_point;
+	char decpt = *localeconv_l(loc)->decimal_point;
 	_Bool gotmantdig = 0, ishex = 0;
 
 	/*
@@ -1028,7 +1040,7 @@ reswitch:
 				if (c == ')') {
 					commit = p;
 					infnanpos = -2;
-				} else if (!isalnum(c) && c != '_')
+				} else if (!isalnum_l(c, loc) && c != '_')
 					goto parsedone;
 				break;
 			}
@@ -1044,7 +1056,7 @@ reswitch:
 				goto reswitch;
 			}
 		case S_DIGITS:
-			if ((ishex && isxdigit(c)) || isdigit(c))
+			if ((ishex && isxdigit_l(c, loc)) || isdigit_l(c, loc))
 				gotmantdig = 1;
 			else {
 				state = S_FRAC;
@@ -1061,7 +1073,7 @@ reswitch:
 					goto parsedone;
 				else
 					state = S_EXP;
-			} else if ((ishex && isxdigit(c)) || isdigit(c)) {
+			} else if ((ishex && isxdigit_l(c, loc)) || isdigit_l(c, loc)) {
 				commit = p;
 				gotmantdig = 1;
 			} else
@@ -1074,7 +1086,7 @@ reswitch:
 			else
 				goto reswitch;
 		case S_EXPDIGITS:
-			if (isdigit(c))
+			if (isdigit_l(c, loc))
 				commit = p;
 			else
 				goto parsedone;

Index: src/lib/libc/stdio/vfwscanf.c
diff -u src/lib/libc/stdio/vfwscanf.c:1.8 src/lib/libc/stdio/vfwscanf.c:1.9
--- src/lib/libc/stdio/vfwscanf.c:1.8	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/vfwscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfwscanf.c,v 1.8 2012/03/15 18:22:30 christos Exp $	*/
+/*	$NetBSD: vfwscanf.c,v 1.9 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -42,7 +42,7 @@
 static char sccsid[] = "@(#)ftell.c	8.2 (Berkeley) 5/4/95";
 __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwscanf.c,v 1.12 2004/05/02 20:13:29 obrien Exp $");
 #else
-__RCSID("$NetBSD: vfwscanf.c,v 1.8 2012/03/15 18:22:30 christos Exp $");
+__RCSID("$NetBSD: vfwscanf.c,v 1.9 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -62,9 +62,8 @@ __RCSID("$NetBSD: vfwscanf.c,v 1.8 2012/
 #include "reentrant.h"
 #include "local.h"
 
-#ifndef NO_FLOATING_POINT
 #include <locale.h>
-#endif
+#include "setlocale_local.h"
 
 #define	BUF		513	/* Maximum length of numeric string. */
 
@@ -103,7 +102,7 @@ __RCSID("$NetBSD: vfwscanf.c,v 1.8 2012/
 #define	CT_INT		3	/* %[dioupxX] conversion */
 #define	CT_FLOAT	4	/* %[efgEFG] conversion */
 
-static int parsefloat(FILE *, wchar_t *, wchar_t *);
+static int parsefloat(FILE *, wchar_t *, wchar_t *, locale_t);
 
 #define	INCCL(_c)	\
 	(cclcompl ? (wmemchr(ccls, (_c), (size_t)(ccle - ccls)) == NULL) : \
@@ -115,11 +114,18 @@ static int parsefloat(FILE *, wchar_t *,
 int
 vfwscanf(FILE * __restrict fp, const wchar_t * __restrict fmt, va_list ap)
 {
+	return vfwscanf_l(fp, *_current_locale(), fmt, ap);
+}
+
+int
+vfwscanf_l(FILE * __restrict fp, locale_t loc, const wchar_t * __restrict fmt,
+    va_list ap)
+{
 	int ret;
 
 	FLOCKFILE(fp);
 	_SET_ORIENTATION(fp, 1);
-	ret = __vfwscanf_unlocked(fp, fmt, ap);
+	ret = __vfwscanf_unlocked_l(fp, loc, fmt, ap);
 	FUNLOCKFILE(fp);
 	return ret;
 }
@@ -128,7 +134,7 @@ vfwscanf(FILE * __restrict fp, const wch
 do { \
 	wint_t tc; \
  \
-	while ((tc = __fgetwc_unlock(fp)) != WEOF && iswspace(tc)) \
+	while ((tc = __fgetwc_unlock(fp)) != WEOF && iswspace_l(tc, loc)) \
 		continue; \
 	if (tc != WEOF) \
 		ungetwc(tc, fp); \
@@ -138,7 +144,8 @@ do { \
  * Non-MT-safe version.
  */
 int
-__vfwscanf_unlocked(FILE * __restrict fp, const wchar_t * __restrict fmt, va_list ap)
+__vfwscanf_unlocked_l(FILE * __restrict fp, locale_t loc,
+    const wchar_t * __restrict fmt, va_list ap)
 {
 	wint_t c;		/* character from format, or conversion */
 	size_t width;		/* field width, or 0 */
@@ -157,14 +164,16 @@ __vfwscanf_unlocked(FILE * __restrict fp
 	wint_t wi;		/* handy wint_t */
 	char *mbp;		/* multibyte string pointer for %c %s %[ */
 	size_t nconv;		/* number of bytes in mb. conversion */
-	char mbbuf[MB_LEN_MAX];	/* temporary mb. character buffer */
 	static const mbstate_t initial;
 	mbstate_t mbs;
-
+	char mbbuf[MB_LEN_MAX];	/* temporary mb. character buffer */
 	/* `basefix' is used to avoid `if' tests in the integer scanner */
 	static short basefix[17] =
 		{ 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
 
+	if (loc == NULL)
+		loc = _C_locale;
+
 	nassigned = 0;
 	nconversions = 0;
 	nread = 0;
@@ -176,9 +185,9 @@ __vfwscanf_unlocked(FILE * __restrict fp
 		c = *fmt++;
 		if (c == 0)
 			return nassigned;
-		if (iswspace(c)) {
+		if (iswspace_l(c, loc)) {
 			while ((c = __fgetwc_unlock(fp)) != WEOF &&
-			    iswspace(c))
+			    iswspace_l(c, loc))
 				;
 			if (c != WEOF)
 				ungetwc(c, fp);
@@ -360,7 +369,8 @@ literal:
 		 * that suppress this.
 		 */
 		if ((flags & NOSKIP) == 0) {
-			while ((wi = __fgetwc_unlock(fp)) != WEOF && iswspace(wi))
+			while ((wi = __fgetwc_unlock(fp)) != WEOF &&
+			       iswspace_l(wi, loc))
 				nread++;
 			if (wi == WEOF)
 				goto input_failure;
@@ -398,14 +408,15 @@ literal:
 				mbs = initial;
 				while (width != 0 &&
 				    (wi = __fgetwc_unlock(fp)) != WEOF) {
-					if (width >= MB_CUR_MAX &&
+					if (width >= MB_CUR_MAX_L(loc) &&
 					    !(flags & SUPPRESS)) {
-						nconv = wcrtomb(mbp, wi, &mbs);
+						nconv = wcrtomb_l(mbp, wi,
+						    &mbs, loc);
 						if (nconv == (size_t)-1)
 							goto input_failure;
 					} else {
-						nconv = wcrtomb(mbbuf, wi,
-						    &mbs);
+						nconv = wcrtomb_l(mbbuf, wi,
+						    &mbs, loc);
 						if (nconv == (size_t)-1)
 							goto input_failure;
 						if (nconv > width) {
@@ -464,14 +475,15 @@ literal:
 				mbs = initial;
 				while ((wi = __fgetwc_unlock(fp)) != WEOF &&
 				    width != 0 && INCCL(wi)) {
-					if (width >= MB_CUR_MAX &&
+					if (width >= MB_CUR_MAX_L(loc) &&
 					   !(flags & SUPPRESS)) {
-						nconv = wcrtomb(mbp, wi, &mbs);
+						nconv = wcrtomb_l(mbp, wi,
+						    &mbs, loc);
 						if (nconv == (size_t)-1)
 							goto input_failure;
 					} else {
-						nconv = wcrtomb(mbbuf, wi,
-						    &mbs);
+						nconv = wcrtomb_l(mbbuf, wi,
+						    &mbs, loc);
 						if (nconv == (size_t)-1)
 							goto input_failure;
 						if (nconv > width)
@@ -503,7 +515,7 @@ literal:
 			if ((flags & SUPPRESS) && (flags & LONG)) {
 				while ((wi = __fgetwc_unlock(fp)) != WEOF &&
 				    width-- != 0 &&
-				    !iswspace(wi))
+				    !iswspace_l(wi, loc))
 					nread++;
 				if (wi != WEOF)
 					ungetwc(wi, fp);
@@ -511,7 +523,7 @@ literal:
 				p0 = p = va_arg(ap, wchar_t *);
 				while ((wi = __fgetwc_unlock(fp)) != WEOF &&
 				    width-- != 0 &&
-				    !iswspace(wi)) {
+				    !iswspace_l(wi, loc)) {
 					*p++ = (wchar_t)wi;
 					nread++;
 				}
@@ -525,15 +537,16 @@ literal:
 				mbs = initial;
 				while ((wi = __fgetwc_unlock(fp)) != WEOF &&
 				    width != 0 &&
-				    !iswspace(wi)) {
-					if (width >= MB_CUR_MAX &&
+				    !iswspace_l(wi, loc)) {
+					if (width >= MB_CUR_MAX_L(loc) &&
 					    !(flags & SUPPRESS)) {
-						nconv = wcrtomb(mbp, wi, &mbs);
+						nconv = wcrtomb_l(mbp, wi,
+						    &mbs, loc);
 						if (nconv == (size_t)-1)
 							goto input_failure;
 					} else {
-						nconv = wcrtomb(mbbuf, wi,
-						    &mbs);
+						nconv = wcrtomb_l(mbbuf, wi,
+						    &mbs, loc);
 						if (nconv == (size_t)-1)
 							goto input_failure;
 						if (nconv > width)
@@ -677,9 +690,9 @@ literal:
 
 				*p = 0;
 				if ((flags & UNSIGNED) == 0)
-				    res = wcstoimax(buf, NULL, base);
+				    res = wcstoimax_l(buf, NULL, base, loc);
 				else
-				    res = wcstoumax(buf, NULL, base);
+				    res = wcstoumax_l(buf, NULL, base, loc);
 				if (flags & POINTER)
 					*va_arg(ap, void **) =
 							(void *)(uintptr_t)res;
@@ -712,18 +725,19 @@ literal:
 			if (width == 0 || width > sizeof(buf) /
 			    sizeof(*buf) - 1)
 				width = sizeof(buf) / sizeof(*buf) - 1;
-			if ((width = parsefloat(fp, buf, buf + width)) == 0)
+			if ((width = parsefloat(fp, buf, buf + width, loc)) == 0)
 				goto match_failure;
 			if ((flags & SUPPRESS) == 0) {
 				if (flags & LONGDBL) {
-					long double res = wcstold(buf, &p);
+					long double res = wcstold_l(buf, &p,
+					    loc);
 					*va_arg(ap, long double *) = res;
 				} else
 				if (flags & LONG) {
-					double res = wcstod(buf, &p);
+					double res = wcstod_l(buf, &p, loc);
 					*va_arg(ap, double *) = res;
 				} else {
-					float res = wcstof(buf, &p);
+					float res = wcstof_l(buf, &p, loc);
 					*va_arg(ap, float *) = res;
 				}
 #ifdef DEBUG
@@ -746,7 +760,7 @@ match_failure:
 
 #ifndef NO_FLOATING_POINT
 static int
-parsefloat(FILE *fp, wchar_t *buf, wchar_t *end)
+parsefloat(FILE *fp, wchar_t *buf, wchar_t *end, locale_t loc)
 {
 	wchar_t *commit, *p;
 	int infnanpos = 0;
@@ -755,7 +769,7 @@ parsefloat(FILE *fp, wchar_t *buf, wchar
 		S_DIGITS, S_FRAC, S_EXP, S_EXPDIGITS
 	} state = S_START;
 	wchar_t c;
-	wchar_t decpt = (wchar_t)(unsigned char)*localeconv()->decimal_point;
+	wchar_t decpt = (wchar_t)(unsigned char)*localeconv_l(loc)->decimal_point;
 	int gotmantdig = 0, ishex = 0;
 
 	/*
@@ -830,7 +844,7 @@ reswitch:
 				if (c == ')') {
 					commit = p;
 					infnanpos = -2;
-				} else if (!iswalnum(c) && c != '_')
+				} else if (!iswalnum_l(c, loc) && c != '_')
 					goto parsedone;
 				break;
 			}
@@ -846,7 +860,8 @@ reswitch:
 				goto reswitch;
 			}
 		case S_DIGITS:
-			if ((ishex && iswxdigit(c)) || iswdigit(c))
+			if ((ishex && iswxdigit_l(c, loc)) ||
+			    iswdigit_l(c, loc))
 				gotmantdig = 1;
 			else {
 				state = S_FRAC;
@@ -863,7 +878,8 @@ reswitch:
 					goto parsedone;
 				else
 					state = S_EXP;
-			} else if ((ishex && iswxdigit(c)) || iswdigit(c)) {
+			} else if ((ishex && iswxdigit_l(c, loc)) ||
+			    iswdigit_l(c, loc)) {
 				commit = p;
 				gotmantdig = 1;
 			} else
@@ -876,7 +892,7 @@ reswitch:
 			else
 				goto reswitch;
 		case S_EXPDIGITS:
-			if (iswdigit(c))
+			if (iswdigit_l(c, loc))
 				commit = p;
 			else
 				goto parsedone;

Index: src/lib/libc/stdio/vscanf.c
diff -u src/lib/libc/stdio/vscanf.c:1.14 src/lib/libc/stdio/vscanf.c:1.15
--- src/lib/libc/stdio/vscanf.c:1.14	Thu Mar 15 18:22:31 2012
+++ src/lib/libc/stdio/vscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vscanf.c,v 1.14 2012/03/15 18:22:31 christos Exp $	*/
+/*	$NetBSD: vscanf.c,v 1.15 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,10 +37,12 @@
 #if 0
 static char sccsid[] = "@(#)vscanf.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: vscanf.c,v 1.14 2012/03/15 18:22:31 christos Exp $");
+__RCSID("$NetBSD: vscanf.c,v 1.15 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <stdio.h>
@@ -48,6 +50,8 @@ __RCSID("$NetBSD: vscanf.c,v 1.14 2012/0
 #include "reentrant.h"
 #include "local.h"
 
+__weak_alias(vscanf_l, _vscanf_l)
+
 int
 vscanf(const char *fmt, va_list ap)
 {
@@ -56,3 +60,12 @@ vscanf(const char *fmt, va_list ap)
 
 	return __svfscanf(stdin, fmt, ap);
 }
+
+int
+vscanf_l(locale_t loc, const char *fmt, va_list ap)
+{
+
+	_DIAGASSERT(fmt != NULL);
+
+	return __svfscanf_l(stdin, loc, fmt, ap);
+}

Index: src/lib/libc/stdio/vsscanf.c
diff -u src/lib/libc/stdio/vsscanf.c:1.19 src/lib/libc/stdio/vsscanf.c:1.20
--- src/lib/libc/stdio/vsscanf.c:1.19	Tue Mar 27 15:05:42 2012
+++ src/lib/libc/stdio/vsscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vsscanf.c,v 1.19 2012/03/27 15:05:42 christos Exp $	*/
+/*	$NetBSD: vsscanf.c,v 1.20 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,17 +37,23 @@
 #if 0
 static char sccsid[] = "@(#)vsscanf.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: vsscanf.c,v 1.19 2012/03/27 15:05:42 christos Exp $");
+__RCSID("$NetBSD: vsscanf.c,v 1.20 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <assert.h>
 #include <errno.h>
+#include <locale.h>
 #include <stdio.h>
 #include <string.h>
 #include "reentrant.h"
+#include "setlocale_local.h"
 #include "local.h"
 
+__weak_alias(vsscanf_l, _vsscanf_l)
+
 /* ARGSUSED */
 static ssize_t
 eofread(void *cookie, void *buf, size_t len)
@@ -56,7 +62,7 @@ eofread(void *cookie, void *buf, size_t 
 }
 
 int
-vsscanf(const char *str, const char *fmt, va_list ap)
+vsscanf_l(const char *str, locale_t loc, const char *fmt, va_list ap)
 {
 	FILE f;
 	struct __sfileext fext;
@@ -73,5 +79,11 @@ vsscanf(const char *str, const char *fmt
 	f._bf._size = f._r = (int)len;
 	f._read = eofread;
 	_UB(&f)._base = NULL;
-	return __svfscanf_unlocked(&f, fmt, ap);
+	return __svfscanf_unlocked_l(&f, loc, fmt, ap);
+}
+
+int
+vsscanf(const char *str, const char *fmt, va_list ap)
+{
+	return vsscanf_l(str, *_current_locale(), fmt, ap);
 }

Index: src/lib/libc/stdio/vswscanf.c
diff -u src/lib/libc/stdio/vswscanf.c:1.9 src/lib/libc/stdio/vswscanf.c:1.10
--- src/lib/libc/stdio/vswscanf.c:1.9	Tue Mar 27 15:05:42 2012
+++ src/lib/libc/stdio/vswscanf.c	Fri Apr 19 23:32:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: vswscanf.c,v 1.9 2012/03/27 15:05:42 christos Exp $	*/
+/*	$NetBSD: vswscanf.c,v 1.10 2013/04/19 23:32:17 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -42,20 +42,26 @@
 static char sccsid[] = "@(#)vsscanf.c	8.1 (Berkeley) 6/4/93";
 __FBSDID("$FreeBSD: src/lib/libc/stdio/vswscanf.c,v 1.3 2004/04/07 09:55:05 tjr Exp $");
 #else
-__RCSID("$NetBSD: vswscanf.c,v 1.9 2012/03/27 15:05:42 christos Exp $");
+__RCSID("$NetBSD: vswscanf.c,v 1.10 2013/04/19 23:32:17 joerg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
+#include "namespace.h"
+
 #include <assert.h>
 #include <limits.h>
+#include <locale.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
 #include "reentrant.h"
+#include "setlocale_local.h"
 #include "local.h"
 
+__weak_alias(vswscanf_l, _vswscanf_l)
+
 static ssize_t
 /*ARGSUSED*/
 eofread(void *cookie, void *buf, size_t len)
@@ -65,8 +71,8 @@ eofread(void *cookie, void *buf, size_t 
 }
 
 int
-vswscanf(const wchar_t * __restrict str, const wchar_t * __restrict fmt,
-    va_list ap)
+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;
@@ -81,10 +87,12 @@ vswscanf(const wchar_t * __restrict str,
 	 * 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)
+	mbstr = malloc(wcslen(str) * MB_CUR_MAX_L(loc) + 1);
+	if (mbstr == NULL)
 		return EOF;
 	mbs = initial;
-	if ((mlen = wcsrtombs(mbstr, &rstr, SIZE_T_MAX, &mbs)) == (size_t)-1) {
+	if ((mlen = wcsrtombs_l(mbstr, &rstr, SIZE_T_MAX, &mbs, loc))
+	    == (size_t)-1) {
 		free(mbstr);
 		return EOF;
 	}
@@ -97,8 +105,15 @@ vswscanf(const wchar_t * __restrict str,
 	f._bf._size = f._r = (int)mlen;
 	f._read = eofread;
 	_UB(&f)._base = NULL;
-	r = __vfwscanf_unlocked(&f, fmt, ap);
+	r = __vfwscanf_unlocked_l(&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);
+}
\ No newline at end of file

Reply via email to