updatecd basicAt and basicAtPut to cater for fixed fields
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
151653aaf4
commit
185f72381a
11
bin/hcl.c
11
bin/hcl.c
@ -730,7 +730,6 @@ int main (int argc, char* argv[])
|
||||
hcl_oow_t heapsize = DEFAULT_HEAPSIZE;
|
||||
int verbose = 0;
|
||||
int show_info = 0;
|
||||
int nl_terminator = 0;
|
||||
const char* modlibdirs = HCL_NULL;
|
||||
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
@ -745,7 +744,7 @@ int main (int argc, char* argv[])
|
||||
print_usage:
|
||||
fprintf (stderr, "Usage: %s [options] script-filename [output-filename]\n", argv[0]);
|
||||
fprintf (stderr, "Options are:\n");
|
||||
fprintf (stderr, " -n enable line-break as expression terminator\n");
|
||||
fprintf (stderr, " -v show verbose messages\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -757,10 +756,6 @@ int main (int argc, char* argv[])
|
||||
logopt = opt.arg;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
nl_terminator = 1;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
@ -831,11 +826,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
/*trait |= HCL_TRAIT_NOGC;*/
|
||||
trait |= HCL_TRAIT_AWAIT_PROCS;
|
||||
#if 0
|
||||
if (nl_terminator) trait |= HCL_TRAIT_LANG_ENABLE_EOL;
|
||||
#else
|
||||
trait |= HCL_TRAIT_LANG_ENABLE_EOL;
|
||||
#endif
|
||||
hcl_setoption (hcl, HCL_TRAIT, &trait);
|
||||
}
|
||||
|
||||
|
25
mod/core.c
25
mod/core.c
@ -65,7 +65,9 @@ static hcl_pfrc_t pf_core_basic_at (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t obj, val;
|
||||
hcl_oop_t pos;
|
||||
hcl_ooi_t index;
|
||||
hcl_oow_t index;
|
||||
hcl_oop_class_t _class;
|
||||
hcl_oow_t fixed, flexi;
|
||||
|
||||
obj = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
pos = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
@ -84,11 +86,16 @@ static hcl_pfrc_t pf_core_basic_at (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position not valid - %O", pos);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
if (index >= HCL_OBJ_GET_SIZE(obj))
|
||||
|
||||
_class = (hcl_oop_class_t)HCL_CLASSOF(hcl, obj);
|
||||
fixed = HCL_CLASS_SPEC_NAMED_INSTVARS(_class->spec);
|
||||
flexi = HCL_OBJ_GET_SIZE(obj) - fixed;
|
||||
if (index >= flexi)
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
index += fixed;
|
||||
|
||||
switch (HCL_OBJ_GET_FLAGS_TYPE(obj))
|
||||
{
|
||||
@ -135,7 +142,9 @@ static hcl_pfrc_t pf_core_basic_at_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t na
|
||||
{
|
||||
hcl_oop_t obj, val;
|
||||
hcl_oop_t pos;
|
||||
hcl_ooi_t index;
|
||||
hcl_oow_t index;
|
||||
hcl_oop_class_t _class;
|
||||
hcl_oow_t fixed, flexi;
|
||||
|
||||
obj = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
pos = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
@ -154,6 +163,16 @@ static hcl_pfrc_t pf_core_basic_at_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t na
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position not valid - %O", pos);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
_class = (hcl_oop_class_t)HCL_CLASSOF(hcl, obj);
|
||||
fixed = HCL_CLASS_SPEC_NAMED_INSTVARS(_class->spec);
|
||||
flexi = HCL_OBJ_GET_SIZE(obj) - fixed;
|
||||
if (index >= flexi)
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
index += fixed;
|
||||
if (index >= HCL_OBJ_GET_SIZE(obj))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));
|
||||
|
Loading…
Reference in New Issue
Block a user