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

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

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 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
OLDNEW
1 #include "stdio_impl.h" 1 #include "stdio_impl.h"
2 #include "libc.h" 2 #include "libc.h"
3 #include <wchar.h> 3 #include <wchar.h>
4 4
5 static size_t wstring_read(FILE *f, unsigned char *buf, size_t len) 5 static size_t wstring_read(FILE* f, unsigned char* buf, size_t len) {
6 { 6 const wchar_t* src = f->cookie;
7 » const wchar_t *src = f->cookie; 7 size_t k;
8 » size_t k;
9 8
10 » if (!src) return 0; 9 if (!src)
10 return 0;
11 11
12 » k = wcsrtombs((void *)f->buf, &src, f->buf_size, 0); 12 k = wcsrtombs((void*)f->buf, &src, f->buf_size, 0);
13 » if (k==(size_t)-1) { 13 if (k == (size_t)-1) {
14 » » f->rpos = f->rend = 0; 14 f->rpos = f->rend = 0;
15 » » return 0; 15 return 0;
16 » } 16 }
17 17
18 » f->rpos = f->buf; 18 f->rpos = f->buf;
19 » f->rend = f->buf + k; 19 f->rend = f->buf + k;
20 » f->cookie = (void *)src; 20 f->cookie = (void*)src;
21 21
22 » if (!len || !k) return 0; 22 if (!len || !k)
23 return 0;
23 24
24 » *buf = *f->rpos++; 25 *buf = *f->rpos++;
25 » return 1; 26 return 1;
26 } 27 }
27 28
28 int vswscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, va_list ap) 29 int vswscanf(const wchar_t* restrict s,
29 { 30 const wchar_t* restrict fmt,
30 » unsigned char buf[256]; 31 va_list ap) {
31 » FILE f = { 32 unsigned char buf[256];
32 » » .buf = buf, .buf_size = sizeof buf, 33 FILE f = {.buf = buf,
33 » » .cookie = (void *)s, 34 .buf_size = sizeof buf,
34 » » .read = wstring_read, .lock = -1 35 .cookie = (void*)s,
35 » }; 36 .read = wstring_read,
36 » return vfwscanf(&f, fmt, ap); 37 .lock = -1};
38 return vfwscanf(&f, fmt, ap);
37 } 39 }
38 40
39 weak_alias(vswscanf,__isoc99_vswscanf); 41 weak_alias(vswscanf, __isoc99_vswscanf);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698