1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-30 12:04:07 +00:00

Use vsscanf instead of rolling our own.

PR:		bin/140530
Submitted by:	Jeremy Huddleston <jeremyhu apple.com>
MFC after:	1 month
This commit is contained in:
Xin LI 2009-12-21 19:56:03 +00:00
parent c19ee5a0fb
commit d22fecc5e6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200800

View File

@ -41,37 +41,14 @@ __FBSDID("$FreeBSD$");
#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;
{
return (0);
}
int
sscanf(const char * __restrict str, 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(str, fmt, ap);
va_end(ap);
return (ret);
}