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

Side by Side Diff: fusl/src/stdlib/strtol.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/strtod.c ('k') | fusl/src/stdlib/wcstod.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 "intscan.h"
3 #include "shgetc.h"
4 #include <inttypes.h>
5 #include <limits.h>
6 #include <ctype.h>
7 #include "libc.h"
8
9 static unsigned long long strtox(const char *s, char **p, int base, unsigned lon g long lim)
10 {
11 /* FIXME: use a helper function or macro to setup the FILE */
12 FILE f;
13 f.flags = 0;
14 f.buf = f.rpos = (void *)s;
15 if ((size_t)s > (size_t)-1/2)
16 f.rend = (void *)-1;
17 else
18 f.rend = (unsigned char *)s+(size_t)-1/2;
19 f.lock = -1;
20 shlim(&f, 0);
21 unsigned long long y = __intscan(&f, base, 1, lim);
22 if (p) {
23 size_t cnt = shcnt(&f);
24 *p = (char *)s + cnt;
25 }
26 return y;
27 }
28
29 unsigned long long strtoull(const char *restrict s, char **restrict p, int base)
30 {
31 return strtox(s, p, base, ULLONG_MAX);
32 }
33
34 long long strtoll(const char *restrict s, char **restrict p, int base)
35 {
36 return strtox(s, p, base, LLONG_MIN);
37 }
38
39 unsigned long strtoul(const char *restrict s, char **restrict p, int base)
40 {
41 return strtox(s, p, base, ULONG_MAX);
42 }
43
44 long strtol(const char *restrict s, char **restrict p, int base)
45 {
46 return strtox(s, p, base, 0UL+LONG_MIN);
47 }
48
49 intmax_t strtoimax(const char *restrict s, char **restrict p, int base)
50 {
51 return strtoll(s, p, base);
52 }
53
54 uintmax_t strtoumax(const char *restrict s, char **restrict p, int base)
55 {
56 return strtoull(s, p, base);
57 }
58
59 weak_alias(strtol, __strtol_internal);
60 weak_alias(strtoul, __strtoul_internal);
61 weak_alias(strtoll, __strtoll_internal);
62 weak_alias(strtoull, __strtoull_internal);
63 weak_alias(strtoimax, __strtoimax_internal);
64 weak_alias(strtoumax, __strtoumax_internal);
OLDNEW
« no previous file with comments | « fusl/src/stdlib/strtod.c ('k') | fusl/src/stdlib/wcstod.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698