This commit is contained in:
40
lib/hawk.c
40
lib/hawk.c
@ -110,7 +110,7 @@ int hawk_init (hawk_t* hawk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_pr
|
||||
{
|
||||
{
|
||||
HAWK_HTB_COPIER_INLINE,
|
||||
HAWK_HTB_COPIER_DEFAULT
|
||||
HAWK_HTB_COPIER_DEFAULT
|
||||
},
|
||||
{
|
||||
HAWK_HTB_FREEER_DEFAULT,
|
||||
@ -126,7 +126,7 @@ int hawk_init (hawk_t* hawk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_pr
|
||||
{
|
||||
{
|
||||
HAWK_HTB_COPIER_INLINE,
|
||||
HAWK_HTB_COPIER_DEFAULT
|
||||
HAWK_HTB_COPIER_DEFAULT
|
||||
},
|
||||
{
|
||||
HAWK_HTB_FREEER_DEFAULT,
|
||||
@ -160,7 +160,7 @@ int hawk_init (hawk_t* hawk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_pr
|
||||
HAWK_ASSERT (prm != HAWK_NULL);
|
||||
HAWK_ASSERT (prm->math.pow != HAWK_NULL);
|
||||
HAWK_ASSERT (prm->math.mod != HAWK_NULL);
|
||||
if (prm == HAWK_NULL ||
|
||||
if (prm == HAWK_NULL ||
|
||||
prm->math.pow == HAWK_NULL ||
|
||||
prm->math.mod == HAWK_NULL)
|
||||
{
|
||||
@ -215,7 +215,7 @@ int hawk_init (hawk_t* hawk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_pr
|
||||
hawk->parse.lcls == HAWK_NULL ||
|
||||
hawk->parse.params == HAWK_NULL ||
|
||||
hawk->fnc.user == HAWK_NULL ||
|
||||
hawk->modtab == HAWK_NULL)
|
||||
hawk->modtab == HAWK_NULL)
|
||||
{
|
||||
hawk_seterrnum (hawk, HAWK_NULL, HAWK_ENOMEM);
|
||||
goto oops;
|
||||
@ -334,7 +334,7 @@ void hawk_fini (hawk_t* hawk)
|
||||
|
||||
if (hawk->log.len > 0)
|
||||
{
|
||||
/* flush pending log message that could be generated by the fini
|
||||
/* flush pending log message that could be generated by the fini
|
||||
* callbacks. however, the actual logging might not be produced at
|
||||
* this point because one of the callbacks could arrange to stop
|
||||
* logging */
|
||||
@ -344,7 +344,7 @@ void hawk_fini (hawk_t* hawk)
|
||||
hawk->shuterr = shuterr;
|
||||
}
|
||||
|
||||
if (hawk->log.ptr)
|
||||
if (hawk->log.ptr)
|
||||
{
|
||||
hawk_freemem (hawk, hawk->log.ptr);
|
||||
hawk->log.capa = 0;
|
||||
@ -388,7 +388,7 @@ void hawk_clear (hawk_t* hawk)
|
||||
HAWK_ASSERT (HAWK_ARR_SIZE(hawk->parse.gbls) == hawk->tree.ngbls);
|
||||
/* delete all non-builtin global variables */
|
||||
hawk_arr_delete (
|
||||
hawk->parse.gbls, hawk->tree.ngbls_base,
|
||||
hawk->parse.gbls, hawk->tree.ngbls_base,
|
||||
HAWK_ARR_SIZE(hawk->parse.gbls) - hawk->tree.ngbls_base);
|
||||
|
||||
hawk_arr_clear (hawk->parse.lcls);
|
||||
@ -396,7 +396,7 @@ void hawk_clear (hawk_t* hawk)
|
||||
hawk_htb_clear (hawk->parse.named);
|
||||
hawk_htb_clear (hawk->parse.funs);
|
||||
|
||||
hawk->parse.nlcls_max = 0;
|
||||
hawk->parse.nlcls_max = 0;
|
||||
hawk->parse.depth.block = 0;
|
||||
hawk->parse.depth.loop = 0;
|
||||
hawk->parse.depth.expr = 0;
|
||||
@ -416,21 +416,21 @@ void hawk_clear (hawk_t* hawk)
|
||||
hawk->tree.cur_fun.len = 0;
|
||||
hawk_htb_clear (hawk->tree.funs);
|
||||
|
||||
if (hawk->tree.begin)
|
||||
if (hawk->tree.begin)
|
||||
{
|
||||
hawk_clrpt (hawk, hawk->tree.begin);
|
||||
hawk->tree.begin = HAWK_NULL;
|
||||
hawk->tree.begin_tail = HAWK_NULL;
|
||||
}
|
||||
|
||||
if (hawk->tree.end)
|
||||
if (hawk->tree.end)
|
||||
{
|
||||
hawk_clrpt (hawk, hawk->tree.end);
|
||||
hawk->tree.end = HAWK_NULL;
|
||||
hawk->tree.end_tail = HAWK_NULL;
|
||||
}
|
||||
|
||||
while (hawk->tree.chain)
|
||||
while (hawk->tree.chain)
|
||||
{
|
||||
hawk_chain_t* next = hawk->tree.chain->next;
|
||||
if (hawk->tree.chain->pattern) hawk_clrpt (hawk, hawk->tree.chain->pattern);
|
||||
@ -443,7 +443,7 @@ void hawk_clear (hawk_t* hawk)
|
||||
hawk->tree.chain_size = 0;
|
||||
|
||||
/* this table must not be cleared here as there can be a reference
|
||||
* to an entry of this table from errinf.loc.file when hawk_parse()
|
||||
* to an entry of this table from errinf.loc.file when hawk_parse()
|
||||
* failed. this table is cleared in hawk_parse().
|
||||
* hawk_claersionames (hawk);
|
||||
*/
|
||||
@ -622,17 +622,17 @@ void hawk_pushecb (hawk_t* hawk, hawk_ecb_t* ecb)
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
hawk_oow_t hawk_fmttoucstr_ (hawk_t* hawk, hawk_uch_t* buf, hawk_oow_t bufsz, const hawk_uch_t* fmt, ...)
|
||||
hawk_oow_t hawk_fmttoucstr_ (hawk_t* hawk, hawk_uch_t* buf, hawk_oow_t bufsz, const hawk_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hawk_oow_t n;
|
||||
va_start(ap, fmt);
|
||||
n = hawk_gem_vfmttoucstr(hawk_getgem(hawk), buf, bufsz, fmt, ap);
|
||||
va_end(ap);
|
||||
return n;
|
||||
return n;
|
||||
}
|
||||
|
||||
hawk_oow_t hawk_fmttobcstr_ (hawk_t* hawk, hawk_bch_t* buf, hawk_oow_t bufsz, const hawk_bch_t* fmt, ...)
|
||||
hawk_oow_t hawk_fmttobcstr_ (hawk_t* hawk, hawk_bch_t* buf, hawk_oow_t bufsz, const hawk_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hawk_oow_t n;
|
||||
@ -663,7 +663,7 @@ int hawk_findmodsymfnc_noseterr (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_
|
||||
{
|
||||
mid = base + (lim >> 1);
|
||||
n = hawk_comp_oocstr(name, fnctab[mid].name, 0);
|
||||
if (n == 0)
|
||||
if (n == 0)
|
||||
{
|
||||
sym->type = HAWK_MOD_FNC;
|
||||
sym->name = fnctab[mid].name;
|
||||
@ -673,7 +673,7 @@ int hawk_findmodsymfnc_noseterr (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_
|
||||
if (n > 0) { base = mid + 1; lim--; }
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -688,7 +688,7 @@ int hawk_findmodsymint_noseterr (hawk_t* hawk, hawk_mod_int_tab_t* inttab, hawk_
|
||||
{
|
||||
mid = base + (lim >> 1);
|
||||
n = hawk_comp_oocstr(name, inttab[mid].name, 0);
|
||||
if (n == 0)
|
||||
if (n == 0)
|
||||
{
|
||||
sym->type = HAWK_MOD_INT;
|
||||
sym->name = inttab[mid].name;
|
||||
@ -712,7 +712,7 @@ int hawk_findmodsymflt_noseterr (hawk_t* hawk, hawk_mod_flt_tab_t* flttab, hawk_
|
||||
{
|
||||
mid = base + (lim >> 1);
|
||||
n = hawk_comp_oocstr(name, flttab[mid].name, 0);
|
||||
if (n == 0)
|
||||
if (n == 0)
|
||||
{
|
||||
sym->type = HAWK_MOD_FLT;
|
||||
sym->name = flttab[mid].name;
|
||||
@ -759,7 +759,7 @@ static HAWK_INLINE int secure_space_in_sbuf (hawk_t* hawk, hawk_oow_t req, hawk_
|
||||
newcapa = p->len + req + 1;
|
||||
newcapa = HAWK_ALIGN_POW2(newcapa, 512); /* TODO: adjust this capacity */
|
||||
|
||||
tmp = (hawk_ooch_t*)hawk_reallocmem(hawk, p->ptr, newcapa * HAWK_SIZEOF(*tmp));
|
||||
tmp = (hawk_ooch_t*)hawk_reallocmem(hawk, p->ptr, newcapa * HAWK_SIZEOF(*tmp));
|
||||
if (!tmp) return -1;
|
||||
|
||||
p->ptr = tmp;
|
||||
|
Reference in New Issue
Block a user