source: asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdio/vswscanf.c@ 337

Last change on this file since 337 was 337, checked in by coas-nagasima, 6 years ago

ASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 741 bytes
Line 
1#include "stdio_impl.h"
2#include "libc.h"
3#include <wchar.h>
4
5static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
6{
7 const wchar_t *src = f->cookie;
8 size_t k;
9
10 if (!src) return 0;
11
12 k = wcsrtombs((void *)f->buf, &src, f->buf_size, 0);
13 if (k==(size_t)-1) {
14 f->rpos = f->rend = 0;
15 return 0;
16 }
17
18 f->rpos = f->buf;
19 f->rend = f->buf + k;
20 f->cookie = (void *)src;
21
22 if (!len || !k) return 0;
23
24 *buf = *f->rpos++;
25 return 1;
26}
27
28int vswscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, va_list ap)
29{
30 unsigned char buf[256];
31 FILE f = {
32 .buf = buf, .buf_size = sizeof buf,
33 .cookie = (void *)s,
34 .read = wstring_read, .lock = -1
35 };
36 return vfwscanf(&f, fmt, ap);
37}
38
39weak_alias(vswscanf,__isoc99_vswscanf);
Note: See TracBrowser for help on using the repository browser.