Loading...
stdio/FreeBSD/sscanf.c.patch Libc-320 Libc-391.4.1
--- Libc/Libc-320/stdio/FreeBSD/sscanf.c.patch
+++ Libc/Libc-391.4.1/stdio/FreeBSD/sscanf.c.patch
@@ -1,20 +1,44 @@
-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	2003-05-20 15:22:44.000000000 -0700
++++ sscanf.c	2005-02-23 16:42:49.000000000 -0800
+@@ -40,6 +40,8 @@
+ #include <sys/cdefs.h>
+ __FBSDID("$FreeBSD: src/lib/libc/stdio/sscanf.c,v 1.11 2002/10/12 16:13:41 mike 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>
+@@ -76,7 +78,31 @@
+ 	f._extra = &extra;
+ 	INITEXTRA(&f);
+ 	va_start(ap, fmt);
+-	ret = __svfscanf(&f, fmt, ap);
++	ret = __svfscanf_l(&f, __current_locale(), fmt, ap);
++	va_end(ap);
++	return (ret);
++}
++
++int
++sscanf_l(const char * __restrict str, locale_t loc, char const * __restrict fmt, ...)
++{
++	int ret;
++	va_list ap;
++	struct __sFILEX extra;
++	FILE f;
++
++	NORMALIZE_LOCALE(loc);
++	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._extra = &extra;
++	INITEXTRA(&f);
++	va_start(ap, fmt);
++	ret = __svfscanf_l(&f, loc, fmt, ap);
+ 	va_end(ap);
+ 	return (ret);
+ }