Loading...
stdio/FreeBSD/sscanf.c.patch Libc-320 Libc-763.13
--- Libc/Libc-320/stdio/FreeBSD/sscanf.c.patch
+++ Libc/Libc-763.13/stdio/FreeBSD/sscanf.c.patch
@@ -1,20 +1,57 @@
-Index: sscanf.c
-===================================================================
-RCS file: /cvs/root/Libc/stdio/FreeBSD/sscanf.c,v
-retrieving revision 1.2
-diff -u -d -b -w -u -r1.2 sscanf.c
---- sscanf.c	2003/05/20 22:22:44	1.2
-+++ sscanf.c	2003/06/03 06:56:38
-@@ -66,6 +66,12 @@
- 	struct __sFILEX extra;
- 	FILE f;
+--- sscanf.c.orig	2009-11-30 16:15:30.000000000 -0800
++++ sscanf.c	2009-12-02 16:50:00.000000000 -0800
+@@ -36,42 +36,33 @@ static char sccsid[] = "@(#)sscanf.c	8.1
+ #include <sys/cdefs.h>
+ __FBSDID("$FreeBSD: src/lib/libc/stdio/sscanf.c,v 1.13 2008/04/17 22:17:54 jhb Exp $");
  
-+#if defined(__APPLE_PR3275149_HACK__)
-+	/* If the string is NULL and we're using the broken Jaguar behavior, there's no sense in proceeding any further since we know we can return 0 */
-+	if (str && str[0] == '\0')
-+		return 0;
-+#endif
++#include "xlocale_private.h"
 +
- 	f._file = -1;
- 	f._flags = __SRD;
- 	f._bf._base = f._p = (unsigned char *)str;
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdarg.h>
+ #include "local.h"
+ 
+-static int eofread(void *, char *, int);
+-
+-/* ARGSUSED */
+-static int
+-eofread(cookie, buf, len)
+-	void *cookie;
+-	char *buf;
+-	int len;
++int
++sscanf(const char * __restrict str, char const * __restrict fmt, ...)
+ {
++	int ret;
++	va_list ap;
+ 
+-	return (0);
++	va_start(ap, fmt);
++	ret = vsscanf_l(str, __current_locale(), fmt, ap);
++	va_end(ap);
++	return (ret);
+ }
+ 
+ int
+-sscanf(const char * __restrict str, char const * __restrict fmt, ...)
++sscanf_l(const char * __restrict str, locale_t loc, char const * __restrict fmt, ...)
+ {
+ 	int ret;
+ 	va_list ap;
+-	FILE f;
+ 
+-	f._file = -1;
+-	f._flags = __SRD;
+-	f._bf._base = f._p = (unsigned char *)str;
+-	f._bf._size = f._r = strlen(str);
+-	f._read = eofread;
+-	f._ub._base = NULL;
+-	f._lb._base = NULL;
+-	f._orientation = 0;
+-	memset(&f._mbstate, 0, sizeof(mbstate_t));
+ 	va_start(ap, fmt);
+-	ret = __svfscanf(&f, fmt, ap);
++	ret = vsscanf_l(str, loc, fmt, ap);
+ 	va_end(ap);
+ 	return (ret);
+ }