enhanced the radix check in the feed handler
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
568166b4e2
commit
2595e5b35d
19
lib/comp.c
19
lib/comp.c
@ -4305,7 +4305,9 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_cnode_t* obj, int nret
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_CALLABLE, HCL_CNODE_GET_LOC(car), HCL_CNODE_GET_TOK(car), "invalid callable in function call");
|
hcl_setsynerrbfmt (hcl, HCL_SYNERR_CALLABLE, HCL_CNODE_GET_LOC(car), HCL_NULL,
|
||||||
|
"invalid callable '%.*js' in function call",
|
||||||
|
HCL_CNODE_GET_TOKLEN(car), HCL_CNODE_GET_TOKPTR(car));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4679,9 +4681,8 @@ HCL_UNUSED static int string_to_ooi (hcl_t* hcl, hcl_oocs_t* str, int radixed, h
|
|||||||
|
|
||||||
if (base < 2 || base > 36)
|
if (base < 2 || base > 36)
|
||||||
{
|
{
|
||||||
invalid_radix_value:
|
|
||||||
hcl_seterrbfmt (hcl, HCL_EINVAL,
|
hcl_seterrbfmt (hcl, HCL_EINVAL,
|
||||||
"invalid radix value '%d' in radixed number '%.*js'", base, str->len, str->ptr);
|
"unsupported radix '%d' in radixed number '%.*js'", base, str->len, str->ptr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4731,7 +4732,10 @@ static hcl_oop_t string_to_num (hcl_t* hcl, hcl_oocs_t* str, const hcl_loc_t* lo
|
|||||||
end = str->ptr + str->len;
|
end = str->ptr + str->len;
|
||||||
|
|
||||||
/* [NOTE]
|
/* [NOTE]
|
||||||
* The code here assumes that the reader ensures that
|
* - this is not a generic conversion functionu
|
||||||
|
* - it assumes a certain pre-sanity check on the string
|
||||||
|
* done by the lexical analyzer.
|
||||||
|
* - it also assumes that the reader ensures that
|
||||||
* there is at least 1 valid digit after radix specifier. */
|
* there is at least 1 valid digit after radix specifier. */
|
||||||
|
|
||||||
HCL_ASSERT (hcl, ptr < end);
|
HCL_ASSERT (hcl, ptr < end);
|
||||||
@ -4774,13 +4778,14 @@ static hcl_oop_t string_to_num (hcl_t* hcl, hcl_oocs_t* str, const hcl_loc_t* lo
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HCL_ASSERT (hcl, base >= 2 && base <= 36); /* the lexer must guarantee this */
|
||||||
|
/*
|
||||||
if (base < 2 || base > 36)
|
if (base < 2 || base > 36)
|
||||||
{
|
{
|
||||||
invalid_radix_value:
|
|
||||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_RADIX, loc, HCL_NULL,
|
hcl_setsynerrbfmt (hcl, HCL_SYNERR_RADIX, loc, HCL_NULL,
|
||||||
"invalid radix value '%d' in radixed number '%.*js'", base, str->len, str->ptr);
|
"unsupported radix '%d' in radixed number '%.*js'", base, str->len, str->ptr);
|
||||||
return HCL_NULL;
|
return HCL_NULL;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: handle floating point numbers ... etc */
|
/* TODO: handle floating point numbers ... etc */
|
||||||
|
@ -3124,10 +3124,10 @@ static int flx_plain_number (hcl_t* hcl, hcl_ooci_t c) /* number */
|
|||||||
if (!pn->fpdec && pn->tok_type == HCL_TOK_NUMLIT && pn->digit_count[0] > 0 && c == 'r')
|
if (!pn->fpdec && pn->tok_type == HCL_TOK_NUMLIT && pn->digit_count[0] > 0 && c == 'r')
|
||||||
{
|
{
|
||||||
/* 16rABCD */
|
/* 16rABCD */
|
||||||
if (pn->radix_cand_overflown)
|
if (pn->radix_cand_overflown || pn->radix_cand < 2 || pn->radix_cand > 36)
|
||||||
{
|
{
|
||||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_NUMLIT, TOKEN_LOC(hcl), HCL_NULL,
|
hcl_setsynerrbfmt (hcl, HCL_SYNERR_NUMLIT, TOKEN_LOC(hcl), HCL_NULL,
|
||||||
"radix too large '%.*js' before '%jc'",
|
"unsupported radix '%.*js' before '%jc'",
|
||||||
TOKEN_NAME_LEN(hcl), TOKEN_NAME_PTR(hcl), c);
|
TOKEN_NAME_LEN(hcl), TOKEN_NAME_PTR(hcl), c);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,22 @@ printf "%O\n" 35rabcdefghijklzabcd ##ERROR: syntax error - invalid numeric lite
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
+ 12389127398127389217382197283197321897r11221 1 ##ERROR: syntax error - radix too large '12389127398127389217382197283197321897' before 'r'
|
+ 12389127398127389217382197283197321897r11221 1 ##ERROR: syntax error - unsupported radix '12389127398127389217382197283197321897' before 'r'
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
+ 0000r11221 1 ##ERROR: syntax error - unsupported radix '0000' before 'r'
|
||||||
|
---
|
||||||
|
|
||||||
|
+ 0r11221 1 ##ERROR: syntax error - unsupported radix '0' before 'r'
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
+ 1r11221 1 ##ERROR: syntax error - unsupported radix '1' before 'r'
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
+ 37r11221 1 ##ERROR: syntax error - unsupported radix '37' before 'r'
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user