Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: fusl/src/stdio/vswscanf.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/stdio/vswprintf.c ('k') | fusl/src/stdio/vwprintf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "stdio_impl.h"
2 #include "libc.h"
3 #include <wchar.h>
4
5 static 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
28 int 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
39 weak_alias(vswscanf,__isoc99_vswscanf);
OLDNEW
« no previous file with comments | « fusl/src/stdio/vswprintf.c ('k') | fusl/src/stdio/vwprintf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698