mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +00:00
Make small fixes and oops ran clang-format on dtoa
This commit is contained in:
parent
b5b60015f5
commit
ac00be1a4e
47 changed files with 4933 additions and 5306 deletions
|
@ -30,7 +30,7 @@ unsigned long strtoul(const char *, char **, int) paramsnonnull((1));
|
|||
long long strtoll(const char *, char **, int) paramsnonnull((1));
|
||||
unsigned long long strtoull(const char *, char **, int) paramsnonnull((1));
|
||||
long long strtonum(const char *, long long, long long, const char **);
|
||||
intmax_t div10(intmax_t x, unsigned *rem) hidden;
|
||||
intmax_t div10(intmax_t, unsigned *) hidden;
|
||||
intmax_t strtoimax(const char *, char **, int) paramsnonnull((1));
|
||||
uintmax_t strtoumax(const char *, char **, int) paramsnonnull((1));
|
||||
intmax_t wcstoimax(const wchar_t *, wchar_t **, int);
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
* @see strtoumax
|
||||
*/
|
||||
intmax_t strtoimax(const char *s, char **endptr, int base) {
|
||||
bool neg;
|
||||
uintmax_t x;
|
||||
intmax_t res;
|
||||
unsigned diglet, bits;
|
||||
bool neg, islong, isunsigned;
|
||||
|
||||
x = 0;
|
||||
bits = 0;
|
||||
|
@ -100,10 +100,23 @@ intmax_t strtoimax(const char *s, char **endptr, int base) {
|
|||
}
|
||||
}
|
||||
|
||||
if (endptr) {
|
||||
*endptr = s;
|
||||
if ((isunsigned = *s == 'u' || *s == 'U')) s++;
|
||||
if ((islong = *s == 'l' || *s == 'L')) s++;
|
||||
if (endptr) *endptr = s;
|
||||
|
||||
if (neg) {
|
||||
res = -x;
|
||||
} else {
|
||||
res = x;
|
||||
}
|
||||
|
||||
res = x;
|
||||
return neg ? -res : res;
|
||||
if (isunsigned) {
|
||||
if (islong) {
|
||||
res = (uint64_t)res;
|
||||
} else {
|
||||
res = (uint32_t)res;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue