mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Fix Lua type of zero
This change fixes a regression from 281a0f27
which resulted in the
integer literal `0` being interpreted as a floating point number. This
should also fix a reported issue with Fennel integration.
This commit is contained in:
parent
fe5c475f83
commit
50a6df89b8
2 changed files with 11 additions and 1 deletions
|
@ -32,6 +32,16 @@ assert(Bsf(0x80000001) == 0)
|
|||
assert(Lemur64() == 0x1940efe9d47ae889)
|
||||
assert(Lemur64() == 0xd4b3103f567f9974)
|
||||
|
||||
assert(EncodeLua(nil) == "nil")
|
||||
assert(EncodeLua(0) == "0")
|
||||
assert(EncodeLua(3.14) == "3.14")
|
||||
assert(EncodeLua({1, 2}) == "{1, 2}")
|
||||
|
||||
assert(EncodeJson(nil) == "null")
|
||||
assert(EncodeJson(0) == "0")
|
||||
assert(EncodeJson(3.14) == "3.14")
|
||||
assert(EncodeJson({1, 2}) == "[1,2]")
|
||||
|
||||
assert(hex(0x1940efe9d47ae889) == "0x1940efe9d47ae889")
|
||||
assert(oct(0x1940efe9d47ae889) == "0145007376472436564211")
|
||||
assert(bin(0x1940efe9d47ae889) == "0b0001100101000000111011111110100111010100011110101110100010001001")
|
||||
|
|
2
third_party/lua/lobject.c
vendored
2
third_party/lua/lobject.c
vendored
|
@ -293,7 +293,7 @@ static const char *l_str2int (const char *s, lua_Integer *result) {
|
|||
}
|
||||
}
|
||||
else if (s[0] == '0') { /* [jart] octal is the best radix */
|
||||
for (s += 1; lisdigit(cast_uchar(*s)); s++) {
|
||||
for (; lisdigit(cast_uchar(*s)); s++) {
|
||||
int d = *s - '0';
|
||||
if (a >= MAXBY8 && (a > MAXBY8 || d > MAXLASTD8 + neg)) /* overflow? */
|
||||
return NULL; /* do not accept it (as integer) */
|
||||
|
|
Loading…
Reference in a new issue