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

Unified Diff: fusl/src/stdio/fgetwc.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/fgetwc.c
diff --git a/fusl/src/stdio/fgetwc.c b/fusl/src/stdio/fgetwc.c
index e455cfec408bc101c7c15077e68d45f4491e3395..56387f819e8a63f067c6be8a06b1a1f5527ce6ee 100644
--- a/fusl/src/stdio/fgetwc.c
+++ b/fusl/src/stdio/fgetwc.c
@@ -3,58 +3,59 @@
#include <wchar.h>
#include <errno.h>
-static wint_t __fgetwc_unlocked_internal(FILE *f)
-{
- mbstate_t st = { 0 };
- wchar_t wc;
- int c;
- unsigned char b;
- size_t l;
+static wint_t __fgetwc_unlocked_internal(FILE* f) {
+ mbstate_t st = {0};
+ wchar_t wc;
+ int c;
+ unsigned char b;
+ size_t l;
- /* Convert character from buffer if possible */
- if (f->rpos < f->rend) {
- l = mbrtowc(&wc, (void *)f->rpos, f->rend - f->rpos, &st);
- if (l+2 >= 2) {
- f->rpos += l + !l; /* l==0 means 1 byte, null */
- return wc;
- }
- if (l == -1) {
- f->rpos++;
- return WEOF;
- }
- } else l = -2;
+ /* Convert character from buffer if possible */
+ if (f->rpos < f->rend) {
+ l = mbrtowc(&wc, (void*)f->rpos, f->rend - f->rpos, &st);
+ if (l + 2 >= 2) {
+ f->rpos += l + !l; /* l==0 means 1 byte, null */
+ return wc;
+ }
+ if (l == -1) {
+ f->rpos++;
+ return WEOF;
+ }
+ } else
+ l = -2;
- /* Convert character byte-by-byte */
- while (l == -2) {
- b = c = getc_unlocked(f);
- if (c < 0) {
- if (!mbsinit(&st)) errno = EILSEQ;
- return WEOF;
- }
- l = mbrtowc(&wc, (void *)&b, 1, &st);
- if (l == -1) return WEOF;
- }
+ /* Convert character byte-by-byte */
+ while (l == -2) {
+ b = c = getc_unlocked(f);
+ if (c < 0) {
+ if (!mbsinit(&st))
+ errno = EILSEQ;
+ return WEOF;
+ }
+ l = mbrtowc(&wc, (void*)&b, 1, &st);
+ if (l == -1)
+ return WEOF;
+ }
- return wc;
+ return wc;
}
-wint_t __fgetwc_unlocked(FILE *f)
-{
- locale_t *ploc = &CURRENT_LOCALE, loc = *ploc;
- if (f->mode <= 0) fwide(f, 1);
- *ploc = f->locale;
- wchar_t wc = __fgetwc_unlocked_internal(f);
- *ploc = loc;
- return wc;
+wint_t __fgetwc_unlocked(FILE* f) {
+ locale_t *ploc = &CURRENT_LOCALE, loc = *ploc;
+ if (f->mode <= 0)
+ fwide(f, 1);
+ *ploc = f->locale;
+ wchar_t wc = __fgetwc_unlocked_internal(f);
+ *ploc = loc;
+ return wc;
}
-wint_t fgetwc(FILE *f)
-{
- wint_t c;
- FLOCK(f);
- c = __fgetwc_unlocked(f);
- FUNLOCK(f);
- return c;
+wint_t fgetwc(FILE* f) {
+ wint_t c;
+ FLOCK(f);
+ c = __fgetwc_unlocked(f);
+ FUNLOCK(f);
+ return c;
}
weak_alias(__fgetwc_unlocked, fgetwc_unlocked);

Powered by Google App Engine
This is Rietveld 408576698