touched up hawk_rtx_truncrec().
fixed a bug in hawk_xma_init()
This commit is contained in:
parent
792f38acae
commit
97bd469ce8
@ -1050,7 +1050,7 @@ static hawk_mmgr_t xma_mmgr =
|
|||||||
HAWK_NULL
|
HAWK_NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static int xma_dumper_without_hawk (void* ctx, const hawk_bch_t* fmt, ...)
|
static void xma_dumper_without_hawk (void* ctx, const hawk_bch_t* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
|
@ -468,7 +468,7 @@ static int fnc_tonum (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
/* str::tonum(value) */
|
/* str::tonum(value) */
|
||||||
/* str::tonum(string, base) */
|
/* str::tonum(string, base) */
|
||||||
|
|
||||||
hawk_t* hawk = hawk_rtx_gethawk(rtx);
|
/*hawk_t* hawk = hawk_rtx_gethawk(rtx);*/
|
||||||
hawk_val_t* retv;
|
hawk_val_t* retv;
|
||||||
hawk_val_t* a0;
|
hawk_val_t* a0;
|
||||||
hawk_int_t lv;
|
hawk_int_t lv;
|
||||||
|
@ -492,68 +492,62 @@ int hawk_rtx_truncrec (hawk_rtx_t* rtx, hawk_oow_t nflds)
|
|||||||
hawk_val_t* v = HAWK_NULL, * w;
|
hawk_val_t* v = HAWK_NULL, * w;
|
||||||
hawk_ooch_t* ofs_free = HAWK_NULL, * ofs_ptr;
|
hawk_ooch_t* ofs_free = HAWK_NULL, * ofs_ptr;
|
||||||
hawk_oow_t ofs_len, i;
|
hawk_oow_t ofs_len, i;
|
||||||
hawk_ooecs_t tmp;
|
|
||||||
hawk_val_type_t vtype;
|
hawk_val_type_t vtype;
|
||||||
|
hawk_ooecs_t tmp;
|
||||||
|
int fini_tmp = 0;
|
||||||
|
|
||||||
HAWK_ASSERT (nflds <= rtx->inrec.nflds);
|
HAWK_ASSERT (nflds <= rtx->inrec.nflds);
|
||||||
|
|
||||||
if (nflds > 1)
|
|
||||||
{
|
|
||||||
v = HAWK_RTX_STACK_GBL(rtx, HAWK_GBL_OFS);
|
|
||||||
hawk_rtx_refupval (rtx, v);
|
|
||||||
vtype = HAWK_RTX_GETVALTYPE(rtx, v);
|
|
||||||
|
|
||||||
if (vtype == HAWK_VAL_NIL)
|
|
||||||
{
|
|
||||||
/* OFS not set */
|
|
||||||
ofs_ptr = HAWK_T(" ");
|
|
||||||
ofs_len = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ofs_ptr = hawk_rtx_getvaloocstr(rtx, v, &ofs_len);
|
|
||||||
if (HAWK_UNLIKELY(!ofs_ptr)) goto oops;
|
|
||||||
ofs_free = ofs_ptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hawk_ooecs_init(&tmp, hawk_rtx_getgem(rtx), HAWK_OOECS_LEN(&rtx->inrec.line)) <= -1) goto oops;
|
if (hawk_ooecs_init(&tmp, hawk_rtx_getgem(rtx), HAWK_OOECS_LEN(&rtx->inrec.line)) <= -1) goto oops;
|
||||||
|
fini_tmp = 1;
|
||||||
|
|
||||||
for (i = 0; i < nflds; i++)
|
if (nflds > 0)
|
||||||
{
|
{
|
||||||
if (i > 0 && hawk_ooecs_ncat(&tmp,ofs_ptr,ofs_len) == (hawk_oow_t)-1)
|
if (nflds > 1)
|
||||||
{
|
{
|
||||||
hawk_ooecs_fini (&tmp);
|
v = HAWK_RTX_STACK_GBL(rtx, HAWK_GBL_OFS);
|
||||||
goto oops;
|
hawk_rtx_refupval (rtx, v);
|
||||||
|
vtype = HAWK_RTX_GETVALTYPE(rtx, v);
|
||||||
|
|
||||||
|
if (vtype == HAWK_VAL_NIL)
|
||||||
|
{
|
||||||
|
/* OFS not set */
|
||||||
|
ofs_ptr = HAWK_T(" ");
|
||||||
|
ofs_len = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ofs_ptr = hawk_rtx_getvaloocstr(rtx, v, &ofs_len);
|
||||||
|
if (HAWK_UNLIKELY(!ofs_ptr)) goto oops;
|
||||||
|
ofs_free = ofs_ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hawk_ooecs_ncat(&tmp, rtx->inrec.flds[0].ptr, rtx->inrec.flds[0].len) == (hawk_oow_t)-1) goto oops;
|
||||||
|
for (i = 1; i < nflds; i++)
|
||||||
|
{
|
||||||
|
if (i > 0 && hawk_ooecs_ncat(&tmp,ofs_ptr,ofs_len) == (hawk_oow_t)-1) goto oops;
|
||||||
|
if (hawk_ooecs_ncat(&tmp, rtx->inrec.flds[i].ptr, rtx->inrec.flds[i].len) == (hawk_oow_t)-1) goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hawk_ooecs_ncat(&tmp, rtx->inrec.flds[i].ptr, rtx->inrec.flds[i].len) == (hawk_oow_t)-1)
|
if (v)
|
||||||
{
|
{
|
||||||
hawk_ooecs_fini (&tmp);
|
if (ofs_free) hawk_rtx_freevaloocstr (rtx, v, ofs_free);
|
||||||
goto oops;
|
hawk_rtx_refdownval(rtx, v);
|
||||||
|
v = HAWK_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v)
|
|
||||||
{
|
|
||||||
if (ofs_free) hawk_rtx_freevaloocstr (rtx, v, ofs_free);
|
|
||||||
hawk_rtx_refdownval(rtx, v);
|
|
||||||
v = HAWK_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
w = (hawk_val_t*)hawk_rtx_makestrvalwithoocs(rtx, HAWK_OOECS_OOCS(&tmp));
|
w = (hawk_val_t*)hawk_rtx_makestrvalwithoocs(rtx, HAWK_OOECS_OOCS(&tmp));
|
||||||
if (!w)
|
if (HAWK_UNLIKELY(!w)) goto oops;
|
||||||
{
|
|
||||||
hawk_ooecs_fini (&tmp);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HAWK_RTX_GETVALTYPE(rtx, rtx->inrec.d0) != HAWK_VAL_NIL) hawk_rtx_refdownval (rtx, rtx->inrec.d0);
|
hawk_rtx_refdownval (rtx, rtx->inrec.d0);
|
||||||
rtx->inrec.d0 = w;
|
rtx->inrec.d0 = w;
|
||||||
hawk_rtx_refupval (rtx, rtx->inrec.d0);
|
hawk_rtx_refupval (rtx, rtx->inrec.d0);
|
||||||
|
|
||||||
hawk_ooecs_swap (&tmp, &rtx->inrec.line);
|
hawk_ooecs_swap (&tmp, &rtx->inrec.line);
|
||||||
hawk_ooecs_fini (&tmp);
|
hawk_ooecs_fini (&tmp);
|
||||||
|
fini_tmp = 0;
|
||||||
|
|
||||||
for (i = nflds; i < rtx->inrec.nflds; i++)
|
for (i = nflds; i < rtx->inrec.nflds; i++)
|
||||||
{
|
{
|
||||||
@ -564,6 +558,7 @@ int hawk_rtx_truncrec (hawk_rtx_t* rtx, hawk_oow_t nflds)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
|
if (fini_tmp) hawk_ooecs_fini (&tmp);
|
||||||
if (v)
|
if (v)
|
||||||
{
|
{
|
||||||
if (ofs_free) hawk_rtx_freevaloocstr (rtx, v, ofs_free);
|
if (ofs_free) hawk_rtx_freevaloocstr (rtx, v, ofs_free);
|
||||||
|
@ -3051,7 +3051,7 @@ static ioattr_t* find_or_make_ioattr (hawk_rtx_t* rtx, hawk_htb_t* tab, const ha
|
|||||||
|
|
||||||
static int fnc_setioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
static int fnc_setioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||||
{
|
{
|
||||||
hawk_t* hawk = hawk_rtx_gethawk(rtx);
|
/*hawk_t* hawk = hawk_rtx_gethawk(rtx);*/
|
||||||
rxtn_t* rxtn;
|
rxtn_t* rxtn;
|
||||||
hawk_val_t* v[3];
|
hawk_val_t* v[3];
|
||||||
hawk_ooch_t* ptr[3];
|
hawk_ooch_t* ptr[3];
|
||||||
|
@ -2293,7 +2293,8 @@ hawk_ooch_t* hawk_rtx_getvaloocstrwithcmgr (hawk_rtx_t* rtx, hawk_val_t* v, hawk
|
|||||||
rtx->ctos.b[fi].c[0] = c;
|
rtx->ctos.b[fi].c[0] = c;
|
||||||
rtx->ctos.b[fi].c[1] = '\0';
|
rtx->ctos.b[fi].c[1] = '\0';
|
||||||
if (len) *len = l;
|
if (len) *len = l;
|
||||||
return &rtx->ctos.b[fi];
|
HAWK_ASSERT ((void*)&rtx->ctos.b[fi] == (void*)rtx->ctos.b[fi].c);
|
||||||
|
return rtx->ctos.b[fi].c;
|
||||||
}
|
}
|
||||||
goto duplicate;
|
goto duplicate;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ int hawk_xma_init (hawk_xma_t* xma, hawk_mmgr_t* mmgr, void* zoneptr, hawk_oow_t
|
|||||||
/* let it be the head, which is natural with only a block */
|
/* let it be the head, which is natural with only a block */
|
||||||
xma->start = (hawk_uint8_t*)first;
|
xma->start = (hawk_uint8_t*)first;
|
||||||
xma->end = xma->start + zonesize;
|
xma->end = xma->start + zonesize;
|
||||||
xma->internal = 1;
|
xma->internal = internal;
|
||||||
|
|
||||||
/* initialize some statistical variables */
|
/* initialize some statistical variables */
|
||||||
#if defined(HAWK_XMA_ENABLE_STAT)
|
#if defined(HAWK_XMA_ENABLE_STAT)
|
||||||
|
Loading…
Reference in New Issue
Block a user