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

Side by Side Diff: fusl/src/multibyte/c16rtomb.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 <uchar.h> 1 #include <uchar.h>
2 #include <errno.h> 2 #include <errno.h>
3 #include <wchar.h> 3 #include <wchar.h>
4 4
5 size_t c16rtomb(char *restrict s, char16_t c16, mbstate_t *restrict ps) 5 size_t c16rtomb(char* restrict s, char16_t c16, mbstate_t* restrict ps) {
6 { 6 static unsigned internal_state;
7 » static unsigned internal_state; 7 if (!ps)
8 » if (!ps) ps = (void *)&internal_state; 8 ps = (void*)&internal_state;
9 » unsigned *x = (unsigned *)ps; 9 unsigned* x = (unsigned*)ps;
10 » wchar_t wc; 10 wchar_t wc;
11 11
12 » if (!s) { 12 if (!s) {
13 » » if (*x) goto ilseq; 13 if (*x)
14 » » return 1; 14 goto ilseq;
15 » } 15 return 1;
16 }
16 17
17 » if (!*x && c16 - 0xd800u < 0x400) { 18 if (!*x && c16 - 0xd800u < 0x400) {
18 » » *x = (c16 - 0xd7c0) << 10; 19 *x = (c16 - 0xd7c0) << 10;
19 » » return 0; 20 return 0;
20 » } 21 }
21 22
22 » if (*x) { 23 if (*x) {
23 » » if (c16 - 0xdc00u >= 0x400) goto ilseq; 24 if (c16 - 0xdc00u >= 0x400)
24 » » else wc = *x + c16 - 0xdc00; 25 goto ilseq;
25 » » *x = 0; 26 else
26 » } else { 27 wc = *x + c16 - 0xdc00;
27 » » wc = c16; 28 *x = 0;
28 » } 29 } else {
29 » return wcrtomb(s, wc, 0); 30 wc = c16;
31 }
32 return wcrtomb(s, wc, 0);
30 33
31 ilseq: 34 ilseq:
32 » *x = 0; 35 *x = 0;
33 » errno = EILSEQ; 36 errno = EILSEQ;
34 » return -1; 37 return -1;
35 } 38 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698