mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 19:43:32 +00:00
b41f91c658
The cosmopolitan command interpreter now has 13 builtin commands, variable support, support for ; / && / || syntax, asynchronous support, and plenty of unit tests with bug fixes. This change fixes a bug in posix_spawn() with null envp arg. strace logging now uses atomic writes for scatter functions. Breaking change renaming GetCpuCount() to _getcpucount(). TurfWar is now updated to use the new token bucket algorithm. WIN32 affinity masks now inherit across fork() and execve().
42 lines
1.6 KiB
C
42 lines
1.6 KiB
C
#ifndef COSMOPOLITAN_LIBC_FMT_STRTOL_H_
|
|
#define COSMOPOLITAN_LIBC_FMT_STRTOL_H_
|
|
#include "libc/errno.h"
|
|
|
|
#define CONSUME_SPACES(s, c) \
|
|
if (endptr) *endptr = s; \
|
|
while (c == ' ' || c == '\t') c = *++s
|
|
|
|
#define GET_SIGN(s, c, d) \
|
|
d = c == '-' ? -1 : 1; \
|
|
if (c == '-' || c == '+') c = *++s
|
|
|
|
#define GET_RADIX(s, c, r) \
|
|
if (!r) { \
|
|
if (c == '0') { \
|
|
t |= 1; \
|
|
c = *++s; \
|
|
if (c == 'x' || c == 'X') { \
|
|
c = *++s; \
|
|
r = 16; \
|
|
} else if (c == 'b' || c == 'B') { \
|
|
c = *++s; \
|
|
r = 2; \
|
|
} else { \
|
|
r = 8; \
|
|
} \
|
|
} else { \
|
|
r = 10; \
|
|
} \
|
|
} else if (!(2 <= r && r <= 36)) { \
|
|
errno = EINVAL; \
|
|
return 0; \
|
|
} else if (c == '0') { \
|
|
t |= 1; \
|
|
c = *++s; \
|
|
if ((r == 2 && (c == 'b' || c == 'B')) || \
|
|
(r == 16 && (c == 'x' || c == 'X'))) { \
|
|
c = *++s; \
|
|
} \
|
|
}
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_FMT_STRTOL_H_ */
|