fixed bugs in awk

- added qse_awk_seterrinf() and qse_awk_geterrinf().
- deleted qse_awk_seterrmsg()
- fixed a bug in qse_awk_geterrmsg()
- fixed wrong handling of 'length'
- changed run_printf() to flush before returning
This commit is contained in:
hyung-hwan 2009-06-15 02:40:52 +00:00
parent ee8f5ee6dd
commit f9bf649924
11 changed files with 324 additions and 253 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 195 2009-06-10 13:18:25Z hyunghwan.chung $
* $Id: awk.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -146,21 +146,34 @@ static void unset_intr_run (void)
static qse_map_walk_t print_awk_value (
qse_map_t* map, qse_map_pair_t* pair, void* arg)
{
qse_awk_rtx_t* run = (qse_awk_rtx_t*)arg;
qse_awk_rtx_t* rtx = (qse_awk_rtx_t*)arg;
qse_char_t* str;
qse_size_t len;
qse_awk_errinf_t oerrinf;
str = qse_awk_rtx_valtocpldup (run, QSE_MAP_VPTR(pair), &len);
qse_awk_rtx_geterrinf (rtx, &oerrinf);
str = qse_awk_rtx_valtocpldup (rtx, QSE_MAP_VPTR(pair), &len);
if (str == QSE_NULL)
{
dprint (QSE_T("***OUT OF MEMORY***\n"));
if (qse_awk_rtx_geterrnum(rtx) == QSE_AWK_EVALTYPE)
{
dprint (QSE_T("%.*s = [not printable]\n"),
(int)QSE_MAP_KLEN(pair), QSE_MAP_KPTR(pair));
qse_awk_rtx_seterrinf (rtx, &oerrinf);
}
else
{
dprint (QSE_T("***OUT OF MEMORY***\n"));
}
}
else
{
dprint (QSE_T("%.*s = %.*s\n"),
(int)QSE_MAP_KLEN(pair), QSE_MAP_KPTR(pair),
(int)len, str);
qse_awk_free (qse_awk_rtx_getawk(run), str);
qse_awk_free (qse_awk_rtx_getawk(rtx), str);
}
return QSE_MAP_WALK_FORWARD;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 197 2009-06-12 02:59:59Z hyunghwan.chung $
* $Id: awk.h 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -173,10 +173,8 @@ typedef int (*qse_awk_sprintf_t) (
...
);
/****e* AWK/qse_awk_sio_cmd_t
* NAME
* qse_awk_sio_cmd_t - define source IO commands
* SYNOPSIS
/**
* The qse_awk_sio_cmd_t type defines source IO commands
*/
enum qse_awk_sio_cmd_t
{
@ -186,7 +184,6 @@ enum qse_awk_sio_cmd_t
QSE_AWK_SIO_WRITE = 3
};
typedef enum qse_awk_sio_cmd_t qse_awk_sio_cmd_t;
/******/
/****t* AWK/qse_awk_siof_t
* NAME
@ -539,7 +536,7 @@ enum qse_awk_errnum_t
QSE_AWK_EMAPTOSCALAR, /* cannot change a map to a scalar value */
QSE_AWK_ESCALARTOMAP, /* cannot change a scalar value to a map */
QSE_AWK_EMAPNOTALLOWED, /* a map is not allowed */
QSE_AWK_EVALTYPE, /* wrong value type */
QSE_AWK_EVALTYPE, /* invalid value type */
QSE_AWK_ERDELETE, /* delete called with a wrong target */
QSE_AWK_ERRESET, /* reset called with a wrong target */
QSE_AWK_ERNEXTBEG, /* next called from BEGIN */
@ -578,6 +575,16 @@ enum qse_awk_errnum_t
typedef enum qse_awk_errnum_t qse_awk_errnum_t;
struct qse_awk_errinf_t
{
qse_awk_errnum_t num;
qse_size_t lin;
qse_char_t msg[256];
};
typedef struct qse_awk_errinf_t qse_awk_errinf_t;
/**
* The qse_awk_errstr_t type defines a error string getter. It should return
* an error formatting string for an error number requested. A new string
@ -904,16 +911,19 @@ const qse_char_t* qse_awk_geterrmsg (
qse_awk_t* awk
);
void qse_awk_geterrinf (
qse_awk_t* awk,
qse_awk_errinf_t* errinf
);
void qse_awk_seterrnum (
qse_awk_t* awk,
qse_awk_errnum_t errnum
);
void qse_awk_seterrmsg (
qse_awk_t* awk,
qse_awk_errnum_t errnum,
qse_size_t errlin,
const qse_char_t* errmsg
void qse_awk_seterrinf (
qse_awk_t* awk,
const qse_awk_errinf_t* errinf
);
void qse_awk_geterror (
@ -1415,25 +1425,19 @@ void* qse_awk_rtx_getxtn (
);
/******/
/****f* AWK/qse_awk_rtx_getnvmap
* NAME
* qse_awk_rtx_getnvmap - get the map of named variables
* SYNOPSIS
/**
* The qse_awk_rtx_getnvmap() gets the map of named variables
*/
qse_map_t* qse_awk_rtx_getnvmap (
qse_awk_rtx_t* rtx
);
/******/
/****f* AWK/qse_awk_rtx_geterrnum
* NAME
* qse_awk_rtx_geterrnum - get an error code of a runtime context
* SYNOPSIS
/**
* The qse_awk_rtx_geterrnum() function gets an error code of a runtime context
*/
int qse_awk_rtx_geterrnum (
qse_awk_rtx_t* rtx
);
/******/
qse_size_t qse_awk_rtx_geterrlin (
qse_awk_rtx_t* rtx
@ -1443,16 +1447,9 @@ const qse_char_t* qse_awk_rtx_geterrmsg (
qse_awk_rtx_t* rtx
);
void qse_awk_rtx_seterrnum (
qse_awk_rtx_t* rtx,
qse_awk_errnum_t errnum
);
void qse_awk_rtx_seterrmsg (
void qse_awk_rtx_geterrinf (
qse_awk_rtx_t* rtx,
qse_awk_errnum_t errnum,
qse_size_t errlin,
const qse_char_t* errmsg
qse_awk_errinf_t* errinf
);
void qse_awk_rtx_geterror (
@ -1462,6 +1459,16 @@ void qse_awk_rtx_geterror (
const qse_char_t** errmsg
);
void qse_awk_rtx_seterrnum (
qse_awk_rtx_t* rtx,
qse_awk_errnum_t errnum
);
void qse_awk_rtx_seterrinf (
qse_awk_rtx_t* rtx,
const qse_awk_errinf_t* errinf
);
void qse_awk_rtx_seterror (
qse_awk_rtx_t* rtx,
qse_awk_errnum_t errnum,

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp 197 2009-06-12 02:59:59Z hyunghwan.chung $
* $Id: Awk.cpp 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -994,7 +994,14 @@ void Awk::Run::setErrorWithMessage (
ErrorNumber code, size_t line, const char_t* msg)
{
QSE_ASSERT (this->run != QSE_NULL);
qse_awk_rtx_seterrmsg (this->run, (errnum_t)code, line, msg);
qse_awk_errinf_t errinf;
errinf.num = (errnum_t)code;
errinf.lin = line;
qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg);
qse_awk_rtx_seterrinf (this->run, &errinf);
}
int Awk::Run::setGlobal (int id, long_t v)
@ -1129,7 +1136,13 @@ void Awk::setErrorWithMessage (ErrorNumber code, size_t line, const char_t* msg)
{
if (awk != QSE_NULL)
{
qse_awk_seterrmsg (awk, (errnum_t)code, line, msg);
qse_awk_errinf_t errinf;
errinf.num = (errnum_t)code;
errinf.lin = line;
qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg);
qse_awk_seterrinf (awk, &errinf);
retrieveError ();
}
else

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
* $Id: awk.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -153,8 +153,8 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_awk_prm_t* prm)
qse_lda_setscale (awk->parse.params, QSE_SIZEOF(qse_char_t));
awk->option = QSE_AWK_CLASSIC;
awk->errnum = QSE_AWK_ENOERR;
awk->errlin = 0;
awk->errinf.num = QSE_AWK_ENOERR;
awk->errinf.lin = 0;
awk->errstr = qse_awk_dflerrstr;
awk->stopall = QSE_FALSE;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 171 2009-06-01 09:34:34Z hyunghwan.chung $
* $Id: awk.h 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -231,10 +231,7 @@ struct qse_awk_t
/* housekeeping */
qse_awk_errstr_t errstr;
qse_awk_errnum_t errnum;
qse_size_t errlin;
qse_char_t errmsg[256];
qse_awk_errinf_t errinf;
qse_bool_t stopall;
};
@ -367,9 +364,7 @@ struct qse_awk_rtx_t
} max;
} depth;
qse_awk_errnum_t errnum;
qse_size_t errlin;
qse_char_t errmsg[256];
qse_awk_errinf_t errinf;
qse_awk_t* awk;
qse_awk_rcb_t rcb;

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c 195 2009-06-10 13:18:25Z hyunghwan.chung $
* $Id: err.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -181,47 +181,54 @@ void qse_awk_seterrstr (qse_awk_t* awk, qse_awk_errstr_t errstr)
int qse_awk_geterrnum (qse_awk_t* awk)
{
return awk->errnum;
return awk->errinf.num;
}
qse_size_t qse_awk_geterrlin (qse_awk_t* awk)
{
return awk->errlin;
return awk->errinf.lin;
}
const qse_char_t* qse_awk_geterrmsg (qse_awk_t* awk)
{
return (awk->errmsg[0] == QSE_T('\0'))?
qse_awk_geterrstr(awk)(awk,awk->errnum): awk->errmsg;
return (awk->errinf.msg[0] == QSE_T('\0'))?
qse_awk_geterrstr(awk)(awk,awk->errinf.num): awk->errinf.msg;
}
void qse_awk_geterrinf (qse_awk_t* awk, qse_awk_errinf_t* errinf)
{
QSE_MEMCPY (errinf, &awk->errinf, QSE_SIZEOF(*errinf));
if (errinf->msg[0] == QSE_T('\0'))
{
qse_strxcpy (errinf->msg, QSE_COUNTOF(errinf->msg),
qse_awk_geterrstr(awk)(awk,awk->errinf.num));
}
}
void qse_awk_geterror (
qse_awk_t* awk, qse_awk_errnum_t* errnum,
qse_size_t* errlin, const qse_char_t** errmsg)
{
if (errnum != QSE_NULL) *errnum = awk->errnum;
if (errlin != QSE_NULL) *errlin = awk->errlin;
if (errnum != QSE_NULL) *errnum = awk->errinf.num;
if (errlin != QSE_NULL) *errlin = awk->errinf.lin;
if (errmsg != QSE_NULL)
{
*errmsg = (awk->errmsg[0] == QSE_T('\0'))?
qse_awk_geterrstr(awk)(awk,awk->errnum):
awk->errmsg;
*errmsg = (awk->errinf.msg[0] == QSE_T('\0'))?
qse_awk_geterrstr(awk)(awk,awk->errinf.num):
awk->errinf.msg;
}
}
void qse_awk_seterrnum (qse_awk_t* awk, qse_awk_errnum_t errnum)
{
awk->errnum = errnum;
awk->errlin = 0;
awk->errmsg[0] = QSE_T('\0');
awk->errinf.num = errnum;
awk->errinf.lin = 0;
awk->errinf.msg[0] = QSE_T('\0');
}
void qse_awk_seterrmsg (qse_awk_t* awk,
qse_awk_errnum_t errnum, qse_size_t errlin, const qse_char_t* errmsg)
void qse_awk_seterrinf (qse_awk_t* awk, const qse_awk_errinf_t* errinf)
{
awk->errnum = errnum;
awk->errlin = errlin;
qse_strxcpy (awk->errmsg, QSE_COUNTOF(awk->errmsg), errmsg);
QSE_MEMCPY (&awk->errinf, errinf, QSE_SIZEOF(*errinf));
}
void qse_awk_seterror (
@ -230,68 +237,81 @@ void qse_awk_seterror (
{
const qse_char_t* errfmt;
awk->errnum = errnum;
awk->errlin = errlin;
awk->errinf.num = errnum;
awk->errinf.lin = errlin;
errfmt = qse_awk_geterrstr(awk)(awk,errnum);
QSE_ASSERT (errfmt != QSE_NULL);
qse_strxfncpy (awk->errmsg, QSE_COUNTOF(awk->errmsg), errfmt, errarg);
qse_strxfncpy (
awk->errinf.msg, QSE_COUNTOF(awk->errinf.msg),
errfmt, errarg
);
}
int qse_awk_rtx_geterrnum (qse_awk_rtx_t* rtx)
{
return rtx->errnum;
return rtx->errinf.num;
}
qse_size_t qse_awk_rtx_geterrlin (qse_awk_rtx_t* rtx)
{
return rtx->errlin;
return rtx->errinf.lin;
}
const qse_char_t* qse_awk_rtx_geterrmsg (qse_awk_rtx_t* rtx)
{
return (rtx->errmsg[0] == QSE_T('\0')) ?
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errnum): rtx->errmsg;
return (rtx->errinf.msg[0] == QSE_T('\0')) ?
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg;
}
void qse_awk_rtx_seterrnum (qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum)
void qse_awk_rtx_geterrinf (qse_awk_rtx_t* rtx, qse_awk_errinf_t* errinf)
{
rtx->errnum = errnum;
rtx->errlin = 0;
rtx->errmsg[0] = QSE_T('\0');
}
void qse_awk_rtx_seterrmsg (qse_awk_rtx_t* rtx,
qse_awk_errnum_t errnum, qse_size_t errlin, const qse_char_t* errmsg)
{
rtx->errnum = errnum;
rtx->errlin = errlin;
qse_strxcpy (rtx->errmsg, QSE_COUNTOF(rtx->errmsg), errmsg);
QSE_MEMCPY (errinf, &rtx->errinf, QSE_SIZEOF(*errinf));
if (errinf->msg[0] == QSE_T('\0'))
{
qse_strxcpy (errinf->msg, QSE_COUNTOF(errinf->msg),
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num));
}
}
void qse_awk_rtx_geterror (
qse_awk_rtx_t* rtx, qse_awk_errnum_t* errnum,
qse_size_t* errlin, const qse_char_t** errmsg)
{
if (errnum != QSE_NULL) *errnum = rtx->errnum;
if (errlin != QSE_NULL) *errlin = rtx->errlin;
if (errnum != QSE_NULL) *errnum = rtx->errinf.num;
if (errlin != QSE_NULL) *errlin = rtx->errinf.lin;
if (errmsg != QSE_NULL)
{
*errmsg = (rtx->errmsg[0] == QSE_T('\0'))?
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errnum): rtx->errmsg;
*errmsg = (rtx->errinf.msg[0] == QSE_T('\0'))?
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg;
}
}
void qse_awk_rtx_seterrnum (qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum)
{
rtx->errinf.num = errnum;
rtx->errinf.lin = 0;
rtx->errinf.msg[0] = QSE_T('\0');
}
void qse_awk_rtx_seterrinf (qse_awk_rtx_t* rtx, const qse_awk_errinf_t* errinf)
{
QSE_MEMCPY (&rtx->errinf, errinf, QSE_SIZEOF(*errinf));
}
void qse_awk_rtx_seterror (
qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum,
qse_size_t errlin, const qse_cstr_t* errarg)
{
const qse_char_t* errfmt;
rtx->errnum = errnum;
rtx->errlin = errlin;
rtx->errinf.num = errnum;
rtx->errinf.lin = errlin;
errfmt = qse_awk_geterrstr(rtx->awk)(rtx->awk,errnum);
QSE_ASSERT (errfmt != QSE_NULL);
qse_strxfncpy (rtx->errmsg, QSE_COUNTOF(rtx->errmsg), errfmt, errarg);
qse_strxfncpy (
rtx->errinf.msg, QSE_COUNTOF(rtx->errinf.msg),
errfmt, errarg
);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: fnc.c 195 2009-06-10 13:18:25Z hyunghwan.chung $
* $Id: fnc.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -37,22 +37,22 @@ static int fnc_sprintf (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static qse_awk_fnc_t sys_fnc[] =
{
/* io functions */
{ {QSE_T("close"), 5}, QSE_AWK_RIO, {1, 1, QSE_NULL}, fnc_close},
{ {QSE_T("fflush"), 6}, QSE_AWK_RIO, {0, 1, QSE_NULL}, fnc_fflush},
{ {QSE_T("close"), 5}, 0, QSE_AWK_RIO, {1, 1, QSE_NULL}, fnc_close},
{ {QSE_T("fflush"), 6}, 0, QSE_AWK_RIO, {0, 1, QSE_NULL}, fnc_fflush},
/* string functions */
{ {QSE_T("index"), 5}, 0, {2, 2, QSE_NULL}, fnc_index},
{ {QSE_T("substr"), 6}, 0, {2, 3, QSE_NULL}, fnc_substr},
{ {QSE_T("length"), 6}, 0, {1, 1, QSE_NULL}, fnc_length},
{ {QSE_T("split"), 5}, 0, {2, 3, QSE_T("vrv")}, fnc_split},
{ {QSE_T("tolower"), 7}, 0, {1, 1, QSE_NULL}, fnc_tolower},
{ {QSE_T("toupper"), 7}, 0, {1, 1, QSE_NULL}, fnc_toupper},
{ {QSE_T("gsub"), 4}, 0, {2, 3, QSE_T("xvr")}, fnc_gsub},
{ {QSE_T("sub"), 3}, 0, {2, 3, QSE_T("xvr")}, fnc_sub},
{ {QSE_T("match"), 5}, 0, {2, 2, QSE_T("vx")}, fnc_match},
{ {QSE_T("sprintf"), 7}, 0, {1, MAX, QSE_NULL}, fnc_sprintf},
{ {QSE_T("index"), 5}, 0, 0, {2, 2, QSE_NULL}, fnc_index},
{ {QSE_T("substr"), 6}, 0, 0, {2, 3, QSE_NULL}, fnc_substr},
{ {QSE_T("length"), 6}, 1, 0, {0, 1, QSE_NULL}, fnc_length},
{ {QSE_T("split"), 5}, 0, 0, {2, 3, QSE_T("vrv")}, fnc_split},
{ {QSE_T("tolower"), 7}, 0, 0, {1, 1, QSE_NULL}, fnc_tolower},
{ {QSE_T("toupper"), 7}, 0, 0, {1, 1, QSE_NULL}, fnc_toupper},
{ {QSE_T("gsub"), 4}, 0, 0, {2, 3, QSE_T("xvr")}, fnc_gsub},
{ {QSE_T("sub"), 3}, 0, 0, {2, 3, QSE_T("xvr")}, fnc_sub},
{ {QSE_T("match"), 5}, 0, 0, {2, 2, QSE_T("vx")}, fnc_match},
{ {QSE_T("sprintf"), 7}, 0, 0, {1, MAX, QSE_NULL}, fnc_sprintf},
{ {QSE_NULL, 0}, 0, {0, 0, QSE_NULL}, QSE_NULL}
{ {QSE_NULL, 0}, 0, 0, {0, 0, QSE_NULL}, QSE_NULL}
};
void* qse_awk_addfnc (
@ -280,7 +280,7 @@ static int fnc_close (
n = qse_awk_rtx_closeio (run, name);
/*
if (n == -1 && run->errnum != QSE_AWK_EIONONE)
if (n == -1 && run->errinf.num != QSE_AWK_EIONONE)
{
if (a0->type != QSE_AWK_VAL_STR)
QSE_AWK_FREE (run->awk, name);
@ -313,14 +313,14 @@ static int flush_io (
if (n2 == -1)
{
/*
if (run->errnum == QSE_AWK_EIOIMPL) n = -1;
else if (run->errnum == QSE_AWK_EIONONE)
if (run->errinf.num == QSE_AWK_EIOIMPL) n = -1;
else if (run->errinf.num == QSE_AWK_EIONONE)
{
if (n != 0) n = -2;
}
else n = -99;
*/
if (run->errnum == QSE_AWK_EIONONE)
if (run->errinf.num == QSE_AWK_EIONONE)
{
if (n != 0) n = -2;
}
@ -471,36 +471,44 @@ static int fnc_index (
}
static int fnc_length (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
qse_awk_rtx_t* rtx, const qse_char_t* fnm, qse_size_t fnl)
{
qse_size_t nargs;
qse_awk_val_t* v;
qse_char_t* str;
qse_size_t len;
nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1);
nargs = qse_awk_rtx_getnargs (rtx);
QSE_ASSERT (nargs >= 0 && nargs <= 1);
v = qse_awk_rtx_getarg (run, 0);
if (v->type == QSE_AWK_VAL_STR)
if (nargs == 0)
{
len = ((qse_awk_val_str_t*)v)->len;
/* get the length of $0 */
len = QSE_STR_LEN(&rtx->inrec.line);
}
else
{
str = qse_awk_rtx_valtocpldup (run, v, &len);
if (str == QSE_NULL) return -1;
QSE_AWK_FREE (run->awk, str);
v = qse_awk_rtx_getarg (rtx, 0);
if (v->type == QSE_AWK_VAL_STR)
{
len = ((qse_awk_val_str_t*)v)->len;
}
else
{
str = qse_awk_rtx_valtocpldup (rtx, v, &len);
if (str == QSE_NULL) return -1;
QSE_AWK_FREE (rtx->awk, str);
}
}
v = qse_awk_rtx_makeintval (run, len);
v = qse_awk_rtx_makeintval (rtx, len);
if (v == QSE_NULL)
{
/*qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM);*/
/*qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM);*/
return -1;
}
qse_awk_rtx_setretval (run, v);
qse_awk_rtx_setretval (rtx, v);
return 0;
}
@ -1045,7 +1053,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
if (a0->type != QSE_AWK_VAL_REX)
{
rex = QSE_AWK_BUILDREX (run->awk, a0_ptr, a0_len, &run->errnum);
rex = QSE_AWK_BUILDREX (run->awk, a0_ptr, a0_len, &run->errinf.num);
if (rex == QSE_NULL)
{
qse_str_fini (&new);
@ -1067,7 +1075,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
run->awk, rex, opt,
a2_ptr, a2_len,
cur_ptr, cur_len,
&mat, &run->errnum);
&mat, &run->errinf.num);
}
else n = 0;
@ -1261,7 +1269,7 @@ static int fnc_match (
}
}
rex = QSE_AWK_BUILDREX (run->awk, str1, len1, &run->errnum);
rex = QSE_AWK_BUILDREX (run->awk, str1, len1, &run->errinf.num);
if (rex == QSE_NULL)
{
if (a0->type != QSE_AWK_VAL_STR)
@ -1276,7 +1284,7 @@ static int fnc_match (
n = QSE_AWK_MATCHREX (
run->awk, rex, opt,
str0, len0, str0, len0,
&mat, &run->errnum
&mat, &run->errinf.num
);
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str0);

View File

@ -1,5 +1,5 @@
/*
* $Id: fnc.h 75 2009-02-22 14:10:34Z hyunghwan.chung $
* $Id: fnc.h 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -29,6 +29,8 @@ struct qse_awk_fnc_t
qse_size_t len;
} name;
int dfl0; /* if set, ($0) is assumed if () is missing.
* this ia mainly for the weird length() function */
int valid; /* the entry is valid when this option is set */
struct

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c 194 2009-06-09 13:07:42Z hyunghwan.chung $
* $Id: parse.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -199,7 +199,7 @@ static qse_awk_nde_t* parse_hashidx (
qse_size_t line);
static qse_awk_nde_t* parse_fncall (
qse_awk_t* awk, qse_char_t* name, qse_size_t name_len,
qse_awk_fnc_t* fnc, qse_size_t line);
qse_awk_fnc_t* fnc, qse_size_t line, int noarg);
static qse_awk_nde_t* parse_if (qse_awk_t* awk, qse_size_t line);
static qse_awk_nde_t* parse_while (qse_awk_t* awk, qse_size_t line);
static qse_awk_nde_t* parse_for (qse_awk_t* awk, qse_size_t line);
@ -365,7 +365,7 @@ static global_t gtab[] =
#define MATCH(awk,token_type) ((awk)->token.type == (token_type))
#define CLRERR(awk) qse_awk_seterrnum(awk,QSE_AWK_ENOERR)
#define ISNOERR(awk) ((awk)->errnum == QSE_AWK_ENOERR)
#define ISNOERR(awk) ((awk)->errinf.num == QSE_AWK_ENOERR)
#define SETERR(awk,code) qse_awk_seterrnum(awk,code)
#define SETERRLIN(awk,code,line) qse_awk_seterror(awk,code,line,QSE_NULL);
#define SETERRTOK(awk,code) \
@ -3200,6 +3200,17 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
if (!MATCH(awk,TOKEN_LPAREN))
{
if (fnc->dfl0)
{
/* handles a function that assumes ()
* when () is missing */
nde = parse_fncall (
awk, name_dup, name_len, fnc, line, 1);
if (nde == QSE_NULL)
QSE_AWK_FREE (awk, name_dup);
return (qse_awk_nde_t*)nde;
}
/* an intrinsic function should be in the form
* of the function call */
QSE_AWK_FREE (awk, name_dup);
@ -3207,7 +3218,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
return QSE_NULL;
}
nde = parse_fncall (awk, name_dup, name_len, fnc, line);
nde = parse_fncall (awk, name_dup, name_len, fnc, line, 0);
if (nde == QSE_NULL) QSE_AWK_FREE (awk, name_dup);
return (qse_awk_nde_t*)nde;
}
@ -3339,7 +3350,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
}
}
nde = parse_fncall (awk, name_dup, name_len, QSE_NULL, line);
nde = parse_fncall (awk, name_dup, name_len, QSE_NULL, line, 0);
if (nde == QSE_NULL) QSE_AWK_FREE (awk, name_dup);
return (qse_awk_nde_t*)nde;
}
@ -3597,17 +3608,18 @@ exit_func:
static qse_awk_nde_t* parse_fncall (
qse_awk_t* awk, qse_char_t* name, qse_size_t name_len,
qse_awk_fnc_t* fnc, qse_size_t line)
qse_awk_fnc_t* fnc, qse_size_t line, int noarg)
{
qse_awk_nde_t* head, * curr, * nde;
qse_awk_nde_call_t* call;
qse_size_t nargs;
if (get_token(awk) == -1) return QSE_NULL;
head = curr = QSE_NULL;
nargs = 0;
if (noarg) goto make_node;
if (get_token(awk) == -1) return QSE_NULL;
if (MATCH(awk,TOKEN_RPAREN))
{
/* no parameters to the function call */
@ -3660,6 +3672,7 @@ static qse_awk_nde_t* parse_fncall (
}
make_node:
call = (qse_awk_nde_call_t*)
QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_call_t));
if (call == QSE_NULL)

View File

@ -1,5 +1,5 @@
/*
* $Id: rio.c 195 2009-06-10 13:18:25Z hyunghwan.chung $
* $Id: rio.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -166,7 +166,7 @@ int qse_awk_rtx_readio (
QSE_AWK_FREE (run->awk, p->name);
QSE_AWK_FREE (run->awk, p);
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
{
/* if the error number has not been
* set by the user handler */
@ -246,7 +246,7 @@ int qse_awk_rtx_readio (
p, p->in.buf, QSE_COUNTOF(p->in.buf));
if (n <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
{
/* if the error number has not been
* set by the user handler */
@ -278,7 +278,7 @@ int qse_awk_rtx_readio (
((run->gbl.ignorecase)? QSE_REX_MATCH_IGNORECASE: 0),
QSE_STR_PTR(buf), QSE_STR_LEN(buf),
QSE_STR_PTR(buf), QSE_STR_LEN(buf),
&match, &run->errnum);
&match, &run->errinf.num);
if (n == -1)
{
ret = -1;
@ -366,7 +366,7 @@ int qse_awk_rtx_readio (
((run->gbl.ignorecase)? QSE_REX_MATCH_IGNORECASE: 0),
QSE_STR_PTR(buf), QSE_STR_LEN(buf),
QSE_STR_PTR(buf), QSE_STR_LEN(buf),
&match, &run->errnum);
&match, &run->errinf.num);
if (n == -1)
{
ret = -1;
@ -519,7 +519,7 @@ int qse_awk_rtx_writeio_str (
QSE_AWK_FREE (run->awk, p->name);
QSE_AWK_FREE (run->awk, p);
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
@ -560,7 +560,7 @@ int qse_awk_rtx_writeio_str (
n = handler (run, QSE_AWK_RIO_WRITE, p, str, len);
if (n <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
@ -616,7 +616,7 @@ int qse_awk_rtx_flushio (
if (n <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
}
@ -685,7 +685,7 @@ int qse_awk_rtx_nextio_read (
n = handler (run, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
}
@ -763,7 +763,7 @@ int qse_awk_rtx_nextio_write (
n = handler (run, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
}
@ -881,7 +881,7 @@ int qse_awk_rtx_closio_write (
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR);
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
}
@ -922,7 +922,7 @@ int qse_awk_rtx_closeio (qse_awk_rtx_t* run, const qse_char_t* name)
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
return -1;
}
@ -963,7 +963,7 @@ void qse_awk_rtx_cleario (qse_awk_rtx_t* run)
n = handler (run, QSE_AWK_RIO_CLOSE, run->rio.chain, QSE_NULL, 0);
if (n <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL);
/* TODO: some warnings need to be shown??? */
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 195 2009-06-10 13:18:25Z hyunghwan.chung $
* $Id: run.c 199 2009-06-14 08:40:52Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -375,7 +375,7 @@ static int set_global (
/* TODO: use safebuild */
rex = QSE_AWK_BUILDREX (
run->awk, fs_ptr, fs_len, &run->errnum);
run->awk, fs_ptr, fs_len, &run->errinf.num);
if (rex == QSE_NULL)
{
if (val->type != QSE_AWK_VAL_STR)
@ -423,7 +423,7 @@ static int set_global (
if (shorten_record (run, (qse_size_t)lv) == -1)
{
/* adjust the error line */
if (var != QSE_NULL) run->errlin = var->line;
if (var != QSE_NULL) run->errinf.lin = var->line;
return -1;
}
}
@ -518,7 +518,7 @@ static int set_global (
/* compile the regular expression */
/* TODO: use safebuild */
rex = QSE_AWK_BUILDREX (
run->awk, rs_ptr, rs_len, &run->errnum);
run->awk, rs_ptr, rs_len, &run->errinf.num);
if (rex == QSE_NULL)
{
if (val->type != QSE_AWK_VAL_STR)
@ -676,9 +676,9 @@ qse_awk_rtx_t* qse_awk_rtx_open (
}
/* clear the run error */
rtx->errnum = QSE_AWK_ENOERR;
rtx->errlin = 0;
rtx->errmsg[0] = QSE_T('\0');
rtx->errinf.num = QSE_AWK_ENOERR;
rtx->errinf.lin = 0;
rtx->errinf.msg[0] = QSE_T('\0');
if (init_globals (rtx, arg) == -1)
{
@ -751,9 +751,9 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
rtx->vmgr.rchunk = QSE_NULL;
rtx->vmgr.rfree = QSE_NULL;
rtx->errnum = QSE_AWK_ENOERR;
rtx->errlin = 0;
rtx->errmsg[0] = QSE_T('\0');
rtx->errinf.num = QSE_AWK_ENOERR;
rtx->errinf.lin = 0;
rtx->errinf.msg[0] = QSE_T('\0');
rtx->inrec.buf_pos = 0;
rtx->inrec.buf_len = 0;
@ -1328,7 +1328,7 @@ static int run_bpae_loop (qse_awk_rtx_t* rtx)
ret = rtx->rcb.on_enter (rtx, rtx->rcb.data);
if (ret <= -1)
{
if (rtx->errnum == QSE_AWK_ENOMEM)
if (rtx->errinf.num == QSE_AWK_ENOMEM)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EUNKNOWN);
ret = -1;
}
@ -1349,15 +1349,15 @@ static int run_bpae_loop (qse_awk_rtx_t* rtx)
if (run_block (rtx, blk) == -1) ret = -1;
}
if (ret == -1 && rtx->errnum == QSE_AWK_ENOERR)
if (ret == -1 && rtx->errinf.num == QSE_AWK_ENOERR)
{
/* an error is returned with no error number set.
* this feature is used by eval_expression() to
* abort the evaluation when exit() is executed
* during function evaluation */
ret = 0;
rtx->errlin = 0;
rtx->errmsg[0] = QSE_T('\0');
rtx->errinf.lin = 0;
rtx->errinf.msg[0] = QSE_T('\0');
}
/* run pattern block loops */
@ -1369,15 +1369,15 @@ static int run_bpae_loop (qse_awk_rtx_t* rtx)
if (run_pattern_blocks(rtx) == -1) ret = -1;
}
if (ret == -1 && rtx->errnum == QSE_AWK_ENOERR)
if (ret == -1 && rtx->errinf.num == QSE_AWK_ENOERR)
{
/* an error is returned with no error number set.
* this feature is used by eval_expression() to
* abort the evaluation when exit() is executed
* during function evaluation */
ret = 0;
rtx->errlin = 0;
rtx->errmsg[0] = QSE_T('\0');
rtx->errinf.lin = 0;
rtx->errinf.msg[0] = QSE_T('\0');
}
/* execute END blocks. the first END block is executed if the
@ -1402,15 +1402,15 @@ static int run_bpae_loop (qse_awk_rtx_t* rtx)
}
}
if (ret == -1 && rtx->errnum == QSE_AWK_ENOERR)
if (ret == -1 && rtx->errinf.num == QSE_AWK_ENOERR)
{
/* an error is returned with no error number set.
* this feature is used by eval_expression() to
* abort the evaluation when exit() is executed
* during function evaluation */
ret = 0;
rtx->errlin = 0;
rtx->errmsg[0] = QSE_T('\0');
rtx->errinf.lin = 0;
rtx->errinf.msg[0] = QSE_T('\0');
}
/* derefrence all arguments. however, there should be no arguments
@ -1567,13 +1567,13 @@ static int run_pattern_blocks (qse_awk_rtx_t* run)
if (run->awk->tree.chain != QSE_NULL) \
{ \
if (run->awk->tree.chain->pattern != QSE_NULL) \
run->errlin = run->awk->tree.chain->pattern->line; \
run->errinf.lin = run->awk->tree.chain->pattern->line; \
else if (run->awk->tree.chain->action != QSE_NULL) \
run->errlin = run->awk->tree.chain->action->line; \
run->errinf.lin = run->awk->tree.chain->action->line; \
} \
else if (run->awk->tree.end != QSE_NULL) \
{ \
run->errlin = run->awk->tree.end->line; \
run->errinf.lin = run->awk->tree.end->line; \
}
run->inrec.buf_pos = 0;
@ -1764,7 +1764,7 @@ static int run_block0 (qse_awk_rtx_t* run, qse_awk_nde_blk_t* nde)
qse_awk_rtx_refdownval (run, run->inrec.d0);
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -1776,7 +1776,7 @@ static int run_block0 (qse_awk_rtx_t* run, qse_awk_nde_blk_t* nde)
qse_awk_rtx_refdownval (run, run->inrec.d0);
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2199,7 +2199,7 @@ static qse_map_walk_t walk_foreach (
if (str == QSE_NULL)
{
/* adjust the error line */
w->rtx->errlin = w->var->line;
w->rtx->errinf.lin = w->var->line;
w->ret = -1;
return QSE_MAP_WALK_STOP;
}
@ -2396,7 +2396,7 @@ static int run_nextinfile (qse_awk_rtx_t* run, qse_awk_nde_nextfile_t* nde)
if (n == -1)
{
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2410,7 +2410,7 @@ static int run_nextinfile (qse_awk_rtx_t* run, qse_awk_nde_nextfile_t* nde)
/* FNR resets to 0, NR remains the same */
if (update_fnr (run, 0, run->gbl.nr) == -1)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2429,7 +2429,7 @@ static int run_nextoutfile (qse_awk_rtx_t* run, qse_awk_nde_nextfile_t* nde)
if (n == -1)
{
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2481,7 +2481,7 @@ static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde)
if (tmp == QSE_NULL)
{
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2554,7 +2554,7 @@ static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde)
if (key == QSE_NULL)
{
/* change the error line */
run->errlin = var->line;
run->errinf.lin = var->line;
return -1;
}
@ -2601,7 +2601,7 @@ static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde)
if (tmp == QSE_NULL)
{
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2616,7 +2616,7 @@ static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde)
qse_awk_rtx_refupval (run, tmp);
qse_awk_rtx_refdownval (run, tmp);
run->errlin = var->line;
run->errinf.lin = var->line;
return -1;
}
}
@ -2682,7 +2682,7 @@ static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde)
if (key == QSE_NULL)
{
run->errlin = var->line;
run->errinf.lin = var->line;
return -1;
}
@ -2799,7 +2799,7 @@ static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
{
qse_awk_rtx_refdownval (run, v);
/* change the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
out = vsout.u.cpldup.ptr;
@ -2843,13 +2843,13 @@ static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
run, nde->out_type, dst,
QSE_STR_PTR(&run->inrec.line),
QSE_STR_LEN(&run->inrec.line));
if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/)
if (n <= -1 /*&& run->errinf.num != QSE_AWK_EIOIMPL*/)
{
if (out != QSE_NULL)
QSE_AWK_FREE (run->awk, out);
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
}
@ -2875,13 +2875,13 @@ static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
run, nde->out_type, dst,
run->gbl.ofs.ptr,
run->gbl.ofs.len);
if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/)
if (n <= -1 /*&& run->errinf.num != QSE_AWK_EIOIMPL*/)
{
if (out != QSE_NULL)
QSE_AWK_FREE (run->awk, out);
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
}
@ -2896,14 +2896,14 @@ static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
qse_awk_rtx_refupval (run, v);
n = qse_awk_rtx_writeio_val (run, nde->out_type, dst, v);
if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/)
if (n <= -1 /*&& run->errinf.num != QSE_AWK_EIOIMPL*/)
{
if (out != QSE_NULL)
QSE_AWK_FREE (run->awk, out);
qse_awk_rtx_refdownval (run, v);
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2915,12 +2915,12 @@ static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
n = qse_awk_rtx_writeio_str (
run, nde->out_type, dst,
run->gbl.ors.ptr, run->gbl.ors.len);
if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/)
if (n <= -1 /*&& run->errinf.num != QSE_AWK_EIOIMPL*/)
{
if (out != QSE_NULL) QSE_AWK_FREE (run->awk, out);
/* change the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
@ -2959,7 +2959,7 @@ static int run_printf (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
if (qse_awk_rtx_valtostr (run, v, &vsout) == QSE_NULL)
{
qse_awk_rtx_refdownval (run, v);
run->errlin = nde->line; /* change the error line */
run->errinf.lin = nde->line; /* change the error line */
return -1;
}
out = vsout.u.cpldup.ptr;
@ -3019,13 +3019,13 @@ static int run_printf (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
/* the remaining arguments are ignored as the format cannot
* contain any % characters */
n = qse_awk_rtx_writeio_val (run, nde->out_type, dst, v);
if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/)
if (n <= -1 /*&& run->errinf.num != QSE_AWK_EIOIMPL*/)
{
if (out != QSE_NULL) QSE_AWK_FREE (run->awk, out);
qse_awk_rtx_refdownval (run, v);
/* change the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
}
@ -3042,7 +3042,7 @@ static int run_printf (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
qse_awk_rtx_refdownval (run, v);
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return -1;
}
}
@ -3051,7 +3051,7 @@ static int run_printf (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde)
if (out != QSE_NULL) QSE_AWK_FREE (run->awk, out);
/*skip_write:*/
return 0;
return qse_awk_rtx_flushio (run, nde->out_type, dst);
}
static int output_formatted (
@ -3067,7 +3067,7 @@ static int output_formatted (
if (ptr == QSE_NULL) return -1;
n = qse_awk_rtx_writeio_str (run, out_type, dst, ptr, len);
if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/) return -1;
if (n <= -1 /*&& run->errinf.num != QSE_AWK_EIOIMPL*/) return -1;
return 0;
}
@ -3085,7 +3085,7 @@ static qse_awk_val_t* eval_expression (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
* clears the error number. run_main will
* detect this condition and treat it as a
* non-error condition.*/
run->errnum = QSE_AWK_ENOERR;
run->errinf.num = QSE_AWK_ENOERR;
return QSE_NULL;
}
#endif
@ -3140,7 +3140,7 @@ static qse_awk_val_t* eval_expression (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
if (v == QSE_NULL)
{
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -3195,7 +3195,7 @@ static qse_awk_val_t* eval_expression0 (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
* clears the error number. run_main will
* detect this condition and treat it as a
* non-error condition.*/
run->errnum = QSE_AWK_ENOERR;
run->errinf.num = QSE_AWK_ENOERR;
return QSE_NULL;
}
@ -3389,7 +3389,7 @@ static qse_awk_val_t* do_assignment_scalar (
if (set_global (run, var->id.idxa, var, val) == -1)
{
/* adjust error line */
run->errlin = var->line;
run->errinf.lin = var->line;
return QSE_NULL;
}
}
@ -3481,7 +3481,7 @@ static qse_awk_val_t* do_assignment_map (
if (tmp == QSE_NULL)
{
/* adjust error line */
run->errlin = var->line;
run->errinf.lin = var->line;
return QSE_NULL;
}
@ -3515,7 +3515,7 @@ static qse_awk_val_t* do_assignment_map (
qse_awk_rtx_refdownval (run, tmp);
/* change error line */
run->errlin = var->line;
run->errinf.lin = var->line;
return QSE_NULL;
}
qse_awk_rtx_refdownval (run, tmp);
@ -3608,7 +3608,7 @@ static qse_awk_val_t* do_assignment_pos (
if (qse_awk_rtx_valtostr (run, val, &out) == QSE_NULL)
{
/* change error line */
run->errlin = pos->line;
run->errinf.lin = pos->line;
return QSE_NULL;
}
@ -3714,7 +3714,7 @@ static qse_awk_val_t* eval_binary (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
if (res == QSE_NULL)
{
/* change the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
}
qse_awk_rtx_refdownval (run, left);
@ -3734,7 +3734,7 @@ static qse_awk_val_t* eval_binop_lor (
qse_awk_rtx_valtobool(run left) || qse_awk_rtx_valtobool(run,right));
if (res == QSE_NULL)
{
run->errlin = left->line;
run->errinf.lin = left->line;
return QSE_NULL;
}
@ -3783,7 +3783,7 @@ static qse_awk_val_t* eval_binop_land (
qse_awk_rtx_valtobool(run,left) && qse_awk_rtx_valtobool(run,right));
if (res == QSE_NULL)
{
run->errlin = left->line;
run->errinf.lin = left->line;
return QSE_NULL;
}
@ -4812,7 +4812,7 @@ static qse_awk_val_t* eval_binop_match0 (
QSE_AWK_FREE (run->awk, rex_code);
/* adjust error line */
run->errlin = lline;
run->errinf.lin = lline;
return QSE_NULL;
}
}
@ -4852,7 +4852,7 @@ static qse_awk_val_t* eval_binop_match0 (
QSE_AWK_FREE (run->awk, rex_code);
/* adjust error line */
run->errlin = lline;
run->errinf.lin = lline;
return QSE_NULL;
}
@ -4930,7 +4930,7 @@ static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
exit_func:
qse_awk_rtx_refdownval (run, left);
if (res == QSE_NULL) run->errlin = nde->line;
if (res == QSE_NULL) run->errinf.lin = nde->line;
return res;
}
@ -4970,7 +4970,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -4982,7 +4982,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5001,7 +5001,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5019,7 +5019,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5034,7 +5034,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5046,7 +5046,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5065,7 +5065,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5083,7 +5083,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5145,7 +5145,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5155,7 +5155,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5167,7 +5167,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5177,7 +5177,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5196,7 +5196,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5207,7 +5207,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5217,7 +5217,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5229,7 +5229,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5239,7 +5239,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5255,7 +5255,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5265,7 +5265,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5277,7 +5277,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5287,7 +5287,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5306,7 +5306,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
run, QSE_AWK_EOPERAND, nde->line,
QSE_NULL);
*/
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5317,7 +5317,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5327,7 +5327,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5339,7 +5339,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_rtx_refdownval (run, left);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -5349,7 +5349,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_awk_rtx_refdownval (run, left);
qse_awk_rtx_freeval (run, res, QSE_TRUE);
/* adjust error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
}
@ -5647,7 +5647,7 @@ static qse_awk_val_t* __eval_call (
if (call->what.fnc.handler != QSE_NULL)
{
run->errnum = QSE_AWK_ENOERR;
run->errinf.num = QSE_AWK_ENOERR;
/* NOTE: oname is used when the handler is invoked.
* name might be differnt from oname if
@ -5659,7 +5659,7 @@ static qse_awk_val_t* __eval_call (
if (n <= -1)
{
if (run->errnum == QSE_AWK_ENOERR)
if (run->errinf.num == QSE_AWK_ENOERR)
{
/* the handler has not set the error.
* fix it */
@ -5670,7 +5670,7 @@ static qse_awk_val_t* __eval_call (
else
{
/* adjust the error line */
run->errlin = nde->line;
run->errinf.lin = nde->line;
}
/* correct the return code just in case */
@ -5696,7 +5696,7 @@ static qse_awk_val_t* __eval_call (
v = STACK_RETVAL(run);
if (n == -1)
{
if (run->errnum == QSE_AWK_ENOERR && errhandler != QSE_NULL)
if (run->errinf.num == QSE_AWK_ENOERR && errhandler != QSE_NULL)
{
/* errhandler is passed only when __eval_call() is
* invoked from qse_awk_rtx_call(). Under this
@ -5709,7 +5709,7 @@ static qse_awk_val_t* __eval_call (
* decremented, it can't get the return value
* if it turns out to be terminated by exit().
* The return value could be destroyed by then.
* Unlikely, run_bpae_loop() just checks if run->errnum
* Unlikely, run_bpae_loop() just checks if run->errinf.num
* is QSE_AWK_ENOERR and gets STACK_RETVAL_GBL(run)
* to determine if it is terminated by exit().
*
@ -6020,7 +6020,7 @@ static qse_awk_val_t** get_reference_indexed (
tmp = qse_awk_rtx_makemapval (run);
if (tmp == QSE_NULL)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -6069,7 +6069,7 @@ static qse_awk_val_t* eval_int (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
val = qse_awk_rtx_makeintval (run, ((qse_awk_nde_int_t*)nde)->val);
if (val == QSE_NULL)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
((qse_awk_val_int_t*)val)->nde = nde;
@ -6084,7 +6084,7 @@ static qse_awk_val_t* eval_real (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
val = qse_awk_rtx_makerealval (run, ((qse_awk_nde_real_t*)nde)->val);
if (val == QSE_NULL)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
((qse_awk_val_real_t*)val)->nde = nde;
@ -6101,7 +6101,7 @@ static qse_awk_val_t* eval_str (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
((qse_awk_nde_str_t*)nde)->len);
if (val == QSE_NULL)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -6118,7 +6118,7 @@ static qse_awk_val_t* eval_rex (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
((qse_awk_nde_rex_t*)nde)->code);
if (val == QSE_NULL)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -6168,7 +6168,7 @@ static qse_awk_val_t* eval_indexed (
tmp = qse_awk_rtx_makemapval (run);
if (tmp == QSE_NULL)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -6382,7 +6382,7 @@ static qse_awk_val_t* eval_getline (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
qse_str_fini (&buf);
if (v == QSE_NULL)
{
run->errlin = nde->line;
run->errinf.lin = nde->line;
return QSE_NULL;
}
@ -6402,7 +6402,7 @@ static qse_awk_val_t* eval_getline (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
skip_read:
res = qse_awk_rtx_makeintval (run, n);
if (res == QSE_NULL) run->errlin = nde->line;
if (res == QSE_NULL) run->errinf.lin = nde->line;
return res;
}
@ -6621,7 +6621,7 @@ static qse_char_t* idxnde_to_str (
if (qse_awk_rtx_valtostr (run, idx, &out) == QSE_NULL)
{
qse_awk_rtx_refdownval (run, idx);
run->errlin = nde->line; /* adjust error line */
run->errinf.lin = nde->line; /* adjust error line */
return QSE_NULL;
}