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

Side by Side Diff: fusl/src/stdlib/strtod.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/stdlib/qsort.c ('k') | fusl/src/stdlib/strtol.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 <stdlib.h>
2 #include "shgetc.h"
3 #include "floatscan.h"
4 #include "stdio_impl.h"
5 #include "libc.h"
6
7 static long double strtox(const char *s, char **p, int prec)
8 {
9 FILE f = {
10 .buf = (void *)s, .rpos = (void *)s,
11 .rend = (void *)-1, .lock = -1
12 };
13 shlim(&f, 0);
14 long double y = __floatscan(&f, prec, 1);
15 off_t cnt = shcnt(&f);
16 if (p) *p = cnt ? (char *)s + cnt : (char *)s;
17 return y;
18 }
19
20 float strtof(const char *restrict s, char **restrict p)
21 {
22 return strtox(s, p, 0);
23 }
24
25 double strtod(const char *restrict s, char **restrict p)
26 {
27 return strtox(s, p, 1);
28 }
29
30 long double strtold(const char *restrict s, char **restrict p)
31 {
32 return strtox(s, p, 2);
33 }
34
35 weak_alias(strtof, strtof_l);
36 weak_alias(strtod, strtod_l);
37 weak_alias(strtold, strtold_l);
38 weak_alias(strtof, __strtof_l);
39 weak_alias(strtod, __strtod_l);
40 weak_alias(strtold, __strtold_l);
OLDNEW
« no previous file with comments | « fusl/src/stdlib/qsort.c ('k') | fusl/src/stdlib/strtol.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698