loongarch64: add new syscall numbers
[musl.git] / src / stdio / vsscanf.c
blob4d6d259b8291a6af68e101d871ac7d4b2f8373e9
1 #include "stdio_impl.h"
2 #include <string.h>
4 static size_t string_read(FILE *f, unsigned char *buf, size_t len)
6 char *src = f->cookie;
7 size_t k = len+256;
8 char *end = memchr(src, 0, k);
9 if (end) k = end-src;
10 if (k < len) len = k;
11 memcpy(buf, src, len);
12 f->rpos = (void *)(src+len);
13 f->rend = (void *)(src+k);
14 f->cookie = src+k;
15 return len;
18 int vsscanf(const char *restrict s, const char *restrict fmt, va_list ap)
20 FILE f = {
21 .buf = (void *)s, .cookie = (void *)s,
22 .read = string_read, .lock = -1
24 return vfscanf(&f, fmt, ap);
27 weak_alias(vsscanf,__isoc99_vsscanf);