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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: fusl/src/stdio/vswscanf.c
diff --git a/fusl/src/stdio/vswscanf.c b/fusl/src/stdio/vswscanf.c
index 411dd39c9a27f763932126665cf95f9edc0bf422..3f8b6505ca9e28ddc1c79bd388580be2aebc8024 100644
--- a/fusl/src/stdio/vswscanf.c
+++ b/fusl/src/stdio/vswscanf.c
@@ -2,38 +2,40 @@
#include "libc.h"
#include <wchar.h>
-static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
-{
- const wchar_t *src = f->cookie;
- size_t k;
+static size_t wstring_read(FILE* f, unsigned char* buf, size_t len) {
+ const wchar_t* src = f->cookie;
+ size_t k;
- if (!src) return 0;
+ if (!src)
+ return 0;
- k = wcsrtombs((void *)f->buf, &src, f->buf_size, 0);
- if (k==(size_t)-1) {
- f->rpos = f->rend = 0;
- return 0;
- }
+ k = wcsrtombs((void*)f->buf, &src, f->buf_size, 0);
+ if (k == (size_t)-1) {
+ f->rpos = f->rend = 0;
+ return 0;
+ }
- f->rpos = f->buf;
- f->rend = f->buf + k;
- f->cookie = (void *)src;
+ f->rpos = f->buf;
+ f->rend = f->buf + k;
+ f->cookie = (void*)src;
- if (!len || !k) return 0;
+ if (!len || !k)
+ return 0;
- *buf = *f->rpos++;
- return 1;
+ *buf = *f->rpos++;
+ return 1;
}
-int vswscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, va_list ap)
-{
- unsigned char buf[256];
- FILE f = {
- .buf = buf, .buf_size = sizeof buf,
- .cookie = (void *)s,
- .read = wstring_read, .lock = -1
- };
- return vfwscanf(&f, fmt, ap);
+int vswscanf(const wchar_t* restrict s,
+ const wchar_t* restrict fmt,
+ va_list ap) {
+ unsigned char buf[256];
+ FILE f = {.buf = buf,
+ .buf_size = sizeof buf,
+ .cookie = (void*)s,
+ .read = wstring_read,
+ .lock = -1};
+ return vfwscanf(&f, fmt, ap);
}
-weak_alias(vswscanf,__isoc99_vswscanf);
+weak_alias(vswscanf, __isoc99_vswscanf);

Powered by Google App Engine
This is Rietveld 408576698