mirror of
https://github.com/janet-lang/janet
synced 2024-11-28 11:09:54 +00:00
Fix number parsing for bases between 2 and 9.
Allow multisyms to have number keys.
This commit is contained in:
parent
122312dbf6
commit
29ec30c79f
@ -30,7 +30,16 @@ static JanetSlot multisym_parse_part(JanetCompiler *c, const uint8_t *sympart, i
|
||||
if (sympart[0] == ':') {
|
||||
return janetc_cslot(janet_symbolv(sympart, len));
|
||||
} else {
|
||||
double index;
|
||||
int err;
|
||||
index = janet_scan_number(sympart + 1, len - 1, &err);
|
||||
if (err) {
|
||||
/* not a number */
|
||||
return janetc_resolve(c, janet_symbol(sympart + 1, len - 1));
|
||||
} else {
|
||||
/* is a number */
|
||||
return janetc_cslot(janet_wrap_number(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,6 +272,11 @@ double janet_scan_number(
|
||||
if (str + 1 < end && str[0] == '0' && str[1] == 'x') {
|
||||
base = 16;
|
||||
str += 2;
|
||||
} else if (str + 1 < end &&
|
||||
str[0] >= '0' && str[0] <= '9' &&
|
||||
str[1] == 'r') {
|
||||
base = str[0] - '0';
|
||||
str += 2;
|
||||
} else if (str + 2 < end &&
|
||||
str[0] >= '0' && str[0] <= '9' &&
|
||||
str[1] >= '0' && str[1] <= '9' &&
|
||||
|
Loading…
Reference in New Issue
Block a user