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

Side by Side Diff: fusl/src/stdio/fwrite.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/fwprintf.c ('k') | fusl/src/stdio/fwscanf.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 <string.h>
3
4 size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f)
5 {
6 size_t i=0;
7
8 if (!f->wend && __towrite(f)) return 0;
9
10 if (l > f->wend - f->wpos) return f->write(f, s, l);
11
12 if (f->lbf >= 0) {
13 /* Match /^(.*\n|)/ */
14 for (i=l; i && s[i-1] != '\n'; i--);
15 if (i) {
16 if (f->write(f, s, i) < i)
17 return i;
18 s += i;
19 l -= i;
20 }
21 }
22
23 memcpy(f->wpos, s, l);
24 f->wpos += l;
25 return l+i;
26 }
27
28 size_t fwrite(const void *restrict src, size_t size, size_t nmemb, FILE *restric t f)
29 {
30 size_t k, l = size*nmemb;
31 FLOCK(f);
32 k = __fwritex(src, l, f);
33 FUNLOCK(f);
34 return k==l ? nmemb : k/size;
35 }
36
37 weak_alias(fwrite, fwrite_unlocked);
OLDNEW
« no previous file with comments | « fusl/src/stdio/fwprintf.c ('k') | fusl/src/stdio/fwscanf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698