changed qse_awk_seterrnum() and qse_awk_rtx_seterrnum()

This commit is contained in:
hyung-hwan 2009-08-17 07:44:20 +00:00
parent 08d87ca85e
commit 267a602d4b
6 changed files with 116 additions and 194 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 246 2009-07-27 02:31:58Z hyunghwan.chung $
* $Id: awk.c 256 2009-08-16 13:44:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -225,7 +225,7 @@ static int apply_fs_and_gvm (qse_awk_rtx_t* rtx, struct arg_t* arg)
{
/* set the value of user-defined global variables
* to a runtime context */
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
qse_map_walk (arg->gvm, set_global, rtx);
if (qse_awk_rtx_geterrnum(rtx) != QSE_AWK_ENOERR) return -1;
}
@ -297,7 +297,7 @@ static int fnc_sleep (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
r = qse_awk_rtx_makeintval (run, n);
if (r == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -739,7 +739,7 @@ static int awk_main (int argc, qse_char_t* argv[])
goto oops;
}
qse_awk_seterrnum (awk, QSE_AWK_ENOERR);
qse_awk_seterrnum (awk, QSE_AWK_ENOERR, QSE_NULL);
qse_map_walk (arg.gvm, add_global, awk);
if (qse_awk_geterrnum(awk) != QSE_AWK_ENOERR)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
* $Id: awk.c 256 2009-08-16 13:44:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -383,7 +383,7 @@ int qse_awk_unsetword (qse_awk_t* awk, const qse_cstr_t* kw)
p = qse_map_search (awk->wtab, kw->ptr, kw->len);
if (p == QSE_NULL)
{
qse_awk_seterror (awk, QSE_AWK_ENOENT, 0, kw);
qse_awk_seterrnum (awk, QSE_AWK_ENOENT, kw);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: fnc.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
* $Id: fnc.c 256 2009-08-16 13:44:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -79,7 +79,7 @@ void* qse_awk_addfnc (
errarg.ptr = name;
errarg.len = name_len;
qse_awk_seterror (awk, QSE_AWK_EEXIST, 0, &errarg);
qse_awk_seterrnum (awk, QSE_AWK_EEXIST, &errarg);
return QSE_NULL;
}
@ -133,7 +133,7 @@ int qse_awk_delfnc (
errarg.ptr = name;
errarg.len = name_len;
qse_awk_seterror (awk, QSE_AWK_ENOENT, 0, &errarg);
qse_awk_seterrnum (awk, QSE_AWK_ENOENT, &errarg);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: rio.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
* $Id: rio.c 256 2009-08-16 13:44:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -114,7 +114,7 @@ int qse_awk_rtx_readio (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -134,7 +134,7 @@ int qse_awk_rtx_readio (
run->awk, QSE_SIZEOF(qse_awk_rio_arg_t));
if (p == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -142,7 +142,7 @@ int qse_awk_rtx_readio (
if (p->name == QSE_NULL)
{
QSE_AWK_FREE (run->awk, p);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -157,7 +157,7 @@ int qse_awk_rtx_readio (
p->in.eof = QSE_FALSE;
p->in.eos = QSE_FALSE;
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
/* request to open the stream */
x = handler (run, QSE_AWK_RIO_OPEN, p, QSE_NULL, 0);
@ -170,7 +170,7 @@ int qse_awk_rtx_readio (
{
/* if the error number has not been
* set by the user handler */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
}
return -1;
@ -240,7 +240,7 @@ int qse_awk_rtx_readio (
break;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_READ,
p, p->in.buf, QSE_COUNTOF(p->in.buf));
@ -250,7 +250,7 @@ int qse_awk_rtx_readio (
{
/* if the error number has not been
* set by the user handler */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
}
ret = -1;
@ -394,7 +394,7 @@ int qse_awk_rtx_readio (
if (qse_str_ccat (buf, c) == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
ret = -1;
break;
}
@ -464,7 +464,7 @@ int qse_awk_rtx_writeio_str (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -493,7 +493,7 @@ int qse_awk_rtx_writeio_str (
run->awk, QSE_SIZEOF(qse_awk_rio_arg_t));
if (p == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -501,7 +501,7 @@ int qse_awk_rtx_writeio_str (
if (p->name == QSE_NULL)
{
QSE_AWK_FREE (run->awk, p);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -513,7 +513,7 @@ int qse_awk_rtx_writeio_str (
p->out.eof = QSE_FALSE;
p->out.eos = QSE_FALSE;
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_OPEN, p, QSE_NULL, 0);
if (n <= -1)
{
@ -521,7 +521,7 @@ int qse_awk_rtx_writeio_str (
QSE_AWK_FREE (run->awk, p);
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -557,12 +557,12 @@ int qse_awk_rtx_writeio_str (
while (len > 0)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_WRITE, p, str, len);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -602,7 +602,7 @@ int qse_awk_rtx_flushio (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -612,13 +612,13 @@ int qse_awk_rtx_flushio (
if (p->type == (io_type | io_mask) &&
(name == QSE_NULL || qse_strcmp(p->name,name) == 0))
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_FLUSH, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -631,7 +631,7 @@ int qse_awk_rtx_flushio (
if (ok) return 0;
/* there is no corresponding rio for name */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF, QSE_NULL);
return -1;
}
@ -656,7 +656,7 @@ int qse_awk_rtx_nextio_read (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -672,7 +672,7 @@ int qse_awk_rtx_nextio_read (
/* something is totally wrong */
QSE_ASSERT (
!"should never happen - cannot find the relevant rio entry");
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN);
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN, QSE_NULL);
return -1;
}
@ -682,12 +682,12 @@ int qse_awk_rtx_nextio_read (
return 0;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -734,7 +734,7 @@ int qse_awk_rtx_nextio_write (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -750,7 +750,7 @@ int qse_awk_rtx_nextio_write (
/* something is totally wrong */
QSE_ASSERT (!"should never happen - cannot find the relevant rio entry");
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN);
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN, QSE_NULL);
return -1;
}
@ -760,12 +760,12 @@ int qse_awk_rtx_nextio_write (
return 0;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -806,7 +806,7 @@ int qse_awk_rtx_closio_read (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -823,7 +823,7 @@ int qse_awk_rtx_closio_read (
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
}
@ -841,7 +841,7 @@ int qse_awk_rtx_closio_read (
}
/* the name given is not found */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF, QSE_NULL);
return -1;
}
@ -865,7 +865,7 @@ int qse_awk_rtx_closio_write (
if (handler == QSE_NULL)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -879,11 +879,11 @@ int qse_awk_rtx_closio_write (
handler = run->rio.handler[p->type & MASK_CLEAR];
if (handler != QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
}
@ -900,7 +900,7 @@ int qse_awk_rtx_closio_write (
p = p->next;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF, QSE_NULL);
return -1;
}
@ -919,12 +919,12 @@ int qse_awk_rtx_closeio (qse_awk_rtx_t* run, const qse_char_t* name)
handler = run->rio.handler[p->type & MASK_CLEAR];
if (handler != QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
}
@ -942,7 +942,7 @@ int qse_awk_rtx_closeio (qse_awk_rtx_t* run, const qse_char_t* name)
p = p->next;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF, QSE_NULL);
return -1;
}
@ -960,12 +960,12 @@ void qse_awk_rtx_cleario (qse_awk_rtx_t* run)
if (handler != QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_CLOSE, run->rio.chain, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
/* TODO: some warnings need to be shown??? */
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 255 2009-08-16 08:08:58Z hyunghwan.chung $
* $Id: run.c 256 2009-08-16 13:44:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -300,12 +300,10 @@ static int set_global (
else
{
/* qse_awk_rtx_setgbl has been called */
qse_cstr_t errarg;
qse_cstr_t ea;
errarg.ptr = qse_awk_getgblname (
run->awk, idx, &errarg.len);
qse_awk_rtx_seterror (run,
QSE_AWK_EMAPTOSCALAR, 0, &errarg);
ea.ptr = qse_awk_getgblname (run->awk, idx, &ea.len);
qse_awk_rtx_seterrnum (run, QSE_AWK_EMAPTOSCALAR, &ea);
}
return -1;
@ -1489,9 +1487,9 @@ qse_awk_val_t* qse_awk_rtx_call (
);
if (pair == QSE_NULL)
{
qse_awk_rtx_seterror (
qse_awk_rtx_seterrnum (
rtx, QSE_AWK_EFUNNF,
0, xstr_to_cstr(&call.what.fun.name));
xstr_to_cstr(&call.what.fun.name));
return QSE_NULL;
}
@ -3122,8 +3120,7 @@ static qse_awk_val_t* eval_expression (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
* whose message contains a formatting
* character. otherwise, the following way of
* setting the error information may not work */
qse_awk_rtx_seterror (
run, errnum, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, errnum, nde->line, QSE_NULL);
return QSE_NULL;
}
}
@ -3366,8 +3363,7 @@ static qse_awk_val_t* do_assignment_scalar (
if (qse_map_upsert (run->named,
var->id.name.ptr, var->id.name.len, val, 0) == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, var->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, var->line, QSE_NULL);
return QSE_NULL;
}
@ -3481,9 +3477,7 @@ static qse_awk_val_t* do_assignment_map (
qse_awk_rtx_refupval (run, tmp);
qse_awk_rtx_refdownval (run, tmp);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM,
var->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, var->line, QSE_NULL);
return QSE_NULL;
}
@ -3520,8 +3514,7 @@ static qse_awk_val_t* do_assignment_map (
else if (map->type != QSE_AWK_VAL_MAP)
{
/* variable assigned is not a map */
qse_awk_rtx_seterror (
run, QSE_AWK_ENOTIDX, var->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOTIDX, var->line, QSE_NULL);
return QSE_NULL;
}
@ -3565,15 +3558,13 @@ static qse_awk_val_t* do_assignment_pos (
if (n == -1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EPOSIDX, pos->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EPOSIDX, pos->line, QSE_NULL);
return QSE_NULL;
}
if (n == 1) lv = (qse_long_t)rv;
if (!IS_VALID_POSIDX(lv))
{
qse_awk_rtx_seterror (
run, QSE_AWK_EPOSIDX, pos->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EPOSIDX, pos->line, QSE_NULL);
return QSE_NULL;
}
@ -3818,11 +3809,8 @@ static qse_awk_val_t* eval_binop_in (
right->type != QSE_AWK_NDE_NAMED)
{
/* the compiler should have handled this case */
QSE_ASSERT (
!"should never happen - in needs a plain variable");
qse_awk_rtx_seterror (
run, QSE_AWK_EINTERN, right->line, QSE_NULL);
QSE_ASSERT (!"should never happen - it needs a plain variable");
qse_awk_rtx_seterror (run, QSE_AWK_EINTERN, right->line, QSE_NULL);
return QSE_NULL;
}
@ -4985,8 +4973,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
/*exp->left->type > QSE_AWK_NDE_ARGIDX) XXX */
exp->left->type > QSE_AWK_NDE_POS)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EOPERAND, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EOPERAND, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5032,11 +5019,6 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
if (n == -1)
{
qse_awk_rtx_refdownval (run, left);
/*
qse_awk_rtx_seterror (
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5096,11 +5078,6 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
if (n == -1)
{
qse_awk_rtx_refdownval (run, left);
/*
qse_awk_rtx_seterror (
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5126,12 +5103,9 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
}
else
{
QSE_ASSERT (
!"should never happen - invalid opcode");
QSE_ASSERT (!"should never happen - invalid opcode");
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_seterror (
run, QSE_AWK_EINTERN, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EINTERN, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5160,8 +5134,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
/*exp->left->type > QSE_AWK_NDE_ARGIDX) XXX */
exp->left->type > QSE_AWK_NDE_POS)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EOPERAND, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EOPERAND, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5227,11 +5200,6 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
if (n == -1)
{
qse_awk_rtx_refdownval (run, left);
/*
qse_awk_rtx_seterror (
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5337,11 +5305,6 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
if (n == -1)
{
qse_awk_rtx_refdownval (run, left);
/*
qse_awk_rtx_seterror (
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5393,12 +5356,9 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
}
else
{
QSE_ASSERT (
!"should never happen - invalid opcode");
QSE_ASSERT (!"should never happen - invalid opcode");
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_seterror (
run, QSE_AWK_EINTERN, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EINTERN, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5442,15 +5402,13 @@ static qse_awk_val_t* eval_fnc (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
/* intrinsic function */
if (call->nargs < call->what.fnc.arg.min)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EARGTF, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EARGTF, nde->line, QSE_NULL);
return QSE_NULL;
}
if (call->nargs > call->what.fnc.arg.max)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EARGTM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EARGTM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5591,16 +5549,14 @@ static qse_awk_val_t* __eval_call (
#endif
if (__raw_push(run,(void*)run->stack_base) == -1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
if (__raw_push(run,(void*)saved_stack_top) == -1)
{
__raw_pop (run);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5609,8 +5565,7 @@ static qse_awk_val_t* __eval_call (
{
__raw_pop (run);
__raw_pop (run);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5620,8 +5575,7 @@ static qse_awk_val_t* __eval_call (
__raw_pop (run);
__raw_pop (run);
__raw_pop (run);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5645,9 +5599,7 @@ static qse_awk_val_t* __eval_call (
if (__raw_push(run,qse_awk_val_nil) == -1)
{
UNWIND_RTX_STACK (run, nargs);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line,
QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -5804,8 +5756,7 @@ static qse_size_t push_arg_from_vals (
qse_awk_rtx_refdownval (rtx, pafv->args[nargs]);
UNWIND_RTX_STACK_ARG (rtx, nargs);
qse_awk_rtx_seterror (
rtx, QSE_AWK_ENOMEM, call->line, QSE_NULL);
qse_awk_rtx_seterror (rtx, QSE_AWK_ENOMEM, call->line, QSE_NULL);
return (qse_size_t)-1;
}
@ -5876,8 +5827,7 @@ static qse_size_t push_arg_from_nde (
qse_awk_rtx_refdownval (rtx, v);
UNWIND_RTX_STACK_ARG (rtx, nargs);
qse_awk_rtx_seterror (
rtx, QSE_AWK_ENOMEM, call->line, QSE_NULL);
qse_awk_rtx_seterror (rtx, QSE_AWK_ENOMEM, call->line, QSE_NULL);
return (qse_size_t)-1;
}
@ -5922,9 +5872,7 @@ static int get_reference (
tgt->id.name.len, qse_awk_val_nil, 0);
if (pair == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line,
QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return -1;
}
}
@ -5964,9 +5912,7 @@ static int get_reference (
tgt->id.name.len, qse_awk_val_nil, 0);
if (pair == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line,
QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return -1;
}
}
@ -6019,15 +5965,13 @@ static int get_reference (
if (n == -1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
return -1;
}
if (n == 1) lv = (qse_long_t)rv;
if (!IS_VALID_POSIDX(lv))
{
qse_awk_rtx_seterror (
run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
return -1;
}
@ -6066,8 +6010,7 @@ static qse_awk_val_t** get_reference_indexed (
}
else if ((*val)->type != QSE_AWK_VAL_MAP)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOTMAP, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOTMAP, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -6086,8 +6029,7 @@ static qse_awk_val_t** get_reference_indexed (
if (pair == QSE_NULL)
{
if (str != idxbuf) QSE_AWK_FREE (run->awk, str);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -6214,8 +6156,7 @@ static qse_awk_val_t* eval_indexed (
}
else if ((*val)->type != QSE_AWK_VAL_MAP)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOTMAP, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOTMAP, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -6244,8 +6185,7 @@ static qse_awk_val_t* eval_namedidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
tgt->id.name.ptr, tgt->id.name.len, qse_awk_val_nil, 0);
if (pair == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -6289,16 +6229,14 @@ static qse_awk_val_t* eval_pos (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, v);
if (n == -1)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
return QSE_NULL;
}
if (n == 1) lv = (qse_long_t)rv;
if (lv < 0)
{
qse_awk_rtx_seterror (
run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_EPOSIDX, nde->line, QSE_NULL);
return QSE_NULL;
}
if (lv == 0) v = run->inrec.d0;
@ -6382,8 +6320,7 @@ static qse_awk_val_t* eval_getline (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
if (qse_str_init (&buf, MMGR(run), DEF_BUF_CAPA) == QSE_NULL)
{
if (in != QSE_NULL) QSE_AWK_FREE (run->awk, in);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -6681,8 +6618,7 @@ static qse_char_t* idxnde_to_str (
if (qse_str_init (&idxstr, MMGR(run), DEF_BUF_CAPA) == QSE_NULL)
{
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}
@ -6705,9 +6641,7 @@ static qse_char_t* idxnde_to_str (
qse_awk_rtx_refdownval (run, idx);
qse_str_fini (&idxstr);
qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
qse_awk_rtx_seterror (run, QSE_AWK_ENOMEM, nde->line, QSE_NULL);
return QSE_NULL;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: std.c 250 2009-08-10 03:29:59Z hyunghwan.chung $
* $Id: std.c 256 2009-08-16 13:44:20Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -187,10 +187,7 @@ static qse_ssize_t sf_in_open (
qse_cstr_t ea;
ea.ptr = xtn->s.in.u.file;
ea.len = qse_strlen(ea.ptr);
qse_awk_seterror (
awk, QSE_AWK_EOPEN,
0, &ea
);
qse_awk_seterrnum (awk, QSE_AWK_EOPEN, &ea);
return -1;
}
@ -235,7 +232,7 @@ static qse_ssize_t sf_in_open (
);
if (dbuf == QSE_NULL)
{
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -261,7 +258,7 @@ static qse_ssize_t sf_in_open (
qse_cstr_t ea;
ea.ptr = arg->name;
ea.len = qse_strlen(ea.ptr);
qse_awk_seterror (awk, QSE_AWK_EOPEN, 0, &ea);
qse_awk_seterrnum (awk, QSE_AWK_EOPEN, &ea);
return -1;
}
@ -310,8 +307,7 @@ static qse_ssize_t sf_in_read (
qse_cstr_t ea;
ea.ptr = xtn->s.in.u.file;
ea.len = qse_strlen(ea.ptr);
qse_awk_seterror (
awk, QSE_AWK_EREAD, 0, &ea);
qse_awk_seterrnum (awk, QSE_AWK_EREAD, &ea);
}
return n;
}
@ -351,7 +347,7 @@ static qse_ssize_t sf_in_read (
qse_cstr_t ea;
ea.ptr = arg->name;
ea.len = qse_strlen(ea.ptr);
qse_awk_seterror (awk, QSE_AWK_EREAD, 0, &ea);
qse_awk_seterrnum (awk, QSE_AWK_EREAD, &ea);
}
return n;
}
@ -413,10 +409,7 @@ static qse_ssize_t sf_out (
qse_cstr_t ea;
ea.ptr = xtn->s.out.u.file;
ea.len = qse_strlen(ea.ptr);
qse_awk_seterror (
awk, QSE_AWK_EOPEN,
0, &ea
);
qse_awk_seterrnum (awk, QSE_AWK_EOPEN, &ea);
return -1;
}
}
@ -474,8 +467,7 @@ static qse_ssize_t sf_out (
qse_cstr_t ea;
ea.ptr = xtn->s.in.u.file;
ea.len = qse_strlen(ea.ptr);
qse_awk_seterror (
awk, QSE_AWK_EWRITE, 0, &ea);
qse_awk_seterrnum (awk, QSE_AWK_EWRITE, &ea);
}
return n;
@ -517,7 +509,7 @@ int qse_awk_parsestd (
if (in == QSE_NULL)
{
/* the input is a must */
qse_awk_seterrnum (awk, QSE_AWK_EINVAL);
qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL);
return -1;
}
@ -541,7 +533,7 @@ int qse_awk_parsestd (
break;
default:
qse_awk_seterrnum (awk, QSE_AWK_EINVAL);
qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL);
return -1;
}
xtn->s.in.type = in->type;
@ -572,7 +564,7 @@ int qse_awk_parsestd (
break;
default:
qse_awk_seterrnum (awk, QSE_AWK_EINVAL);
qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL);
return -1;
}
xtn->s.out.type = out->type;
@ -710,7 +702,7 @@ static qse_ssize_t awk_rio_file (
errarg.ptr = riod->name;
errarg.len = qse_strlen(riod->name);
qse_awk_rtx_seterror (rtx, QSE_AWK_EOPEN, 0, &errarg);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EOPEN, &errarg);
return -1;
}
@ -862,8 +854,8 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
* in an error message */
errarg.len = qse_strlen(out.u.cpldup.ptr);
qse_awk_rtx_seterror (
rtx, QSE_AWK_EIONMNL, 0, &errarg);
qse_awk_rtx_seterrnum (
rtx, QSE_AWK_EIONMNL, &errarg);
qse_awk_rtx_free (rtx, out.u.cpldup.ptr);
return -1;
@ -887,8 +879,8 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
errarg.ptr = file;
errarg.len = qse_strlen(file);
qse_awk_rtx_seterror (
rtx, QSE_AWK_EOPEN, 0, &errarg);
qse_awk_rtx_seterrnum (
rtx, QSE_AWK_EOPEN, &errarg);
qse_awk_rtx_free (rtx, out.u.cpldup.ptr);
return -1;
@ -959,8 +951,8 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
errarg.ptr = file;
errarg.len = qse_strlen(file);
qse_awk_rtx_seterror (
rtx, QSE_AWK_EOPEN, 0, &errarg);
qse_awk_rtx_seterrnum (
rtx, QSE_AWK_EOPEN, &errarg);
return -1;
}
}
@ -1109,7 +1101,7 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
awk, QSE_SIZEOF(*argvp) * (argc + 1));
if (argvp == QSE_NULL)
{
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM);
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
}
@ -1213,7 +1205,7 @@ static int fnc_math_1 (
if (r == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1266,7 +1258,7 @@ static int fnc_math_2 (
if (r == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1423,7 +1415,7 @@ static int fnc_int (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
r = qse_awk_rtx_makeintval (run, lv);
if (r == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1445,7 +1437,7 @@ static int fnc_rand (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
run, (qse_real_t)(rand() % RAND_MAX) / RAND_MAX);
if (r == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1493,7 +1485,7 @@ static int fnc_srand (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
r = qse_awk_rtx_makeintval (run, prev);
if (r == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -1579,11 +1571,7 @@ skip_system:
if (v->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str);
v = qse_awk_rtx_makeintval (run, (qse_long_t)n);
if (v == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
return -1;
}
if (v == QSE_NULL) return -1;
qse_awk_rtx_setretval (run, v);
return 0;