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

Side by Side Diff: fusl/src/stdio/fputwc.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/fputs.c ('k') | fusl/src/stdio/fputws.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 "locale_impl.h"
3 #include <wchar.h>
4 #include <limits.h>
5 #include <ctype.h>
6
7 wint_t __fputwc_unlocked(wchar_t c, FILE *f)
8 {
9 char mbc[MB_LEN_MAX];
10 int l;
11 locale_t *ploc = &CURRENT_LOCALE, loc = *ploc;
12
13 if (f->mode <= 0) fwide(f, 1);
14 *ploc = f->locale;
15
16 if (isascii(c)) {
17 c = putc_unlocked(c, f);
18 } else if (f->wpos + MB_LEN_MAX < f->wend) {
19 l = wctomb((void *)f->wpos, c);
20 if (l < 0) c = WEOF;
21 else f->wpos += l;
22 } else {
23 l = wctomb(mbc, c);
24 if (l < 0 || __fwritex((void *)mbc, l, f) < l) c = WEOF;
25 }
26 if (c==WEOF) f->flags |= F_ERR;
27 *ploc = loc;
28 return c;
29 }
30
31 wint_t fputwc(wchar_t c, FILE *f)
32 {
33 FLOCK(f);
34 c = __fputwc_unlocked(c, f);
35 FUNLOCK(f);
36 return c;
37 }
38
39 weak_alias(__fputwc_unlocked, fputwc_unlocked);
40 weak_alias(__fputwc_unlocked, putwc_unlocked);
OLDNEW
« no previous file with comments | « fusl/src/stdio/fputs.c ('k') | fusl/src/stdio/fputws.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698