changed the way to set error information in run.c

This commit is contained in:
hyung-hwan 2020-01-03 07:11:32 +00:00
parent 0fa5af5614
commit f4650746bb
4 changed files with 186 additions and 214 deletions

View File

@ -135,9 +135,9 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum)
HAWK_T("wrong position index"), HAWK_T("wrong position index"),
HAWK_T("too few arguments"), HAWK_T("too few arguments"),
HAWK_T("too many arguments"), HAWK_T("too many arguments"),
HAWK_T("function '${0}' not found"), HAWK_T("function not found"),
HAWK_T("non-function value in '${0}'"), HAWK_T("non-function value"),
HAWK_T("'${0}' not deletable"), HAWK_T("not deletable"),
HAWK_T("value not a map"), HAWK_T("value not a map"),
HAWK_T("right-hand side of the 'in' operator not a map"), HAWK_T("right-hand side of the 'in' operator not a map"),
HAWK_T("right-hand side of the 'in' operator not a map nor nil"), HAWK_T("right-hand side of the 'in' operator not a map nor nil"),
@ -145,12 +145,10 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum)
HAWK_T("cannot return a map"), /* EMAPRET */ HAWK_T("cannot return a map"), /* EMAPRET */
HAWK_T("cannot assign a map to a positional"), /* EMAPTOPOS */ HAWK_T("cannot assign a map to a positional"), /* EMAPTOPOS */
HAWK_T("cannot assign a map to an indexed variable"),/* EMAPTOIDX */ HAWK_T("cannot assign a map to an indexed variable"),/* EMAPTOIDX */
HAWK_T("cannot assign a map to a variable '${0}'"), /* EMAPTONVAR */ HAWK_T("cannot assign a map to a variable"), /* EMAPTOVAR */
HAWK_T("cannot change a map to a scalar"), /* EMAPTOSCALAR */ HAWK_T("cannot change a map to a scalar"), /* EMAPTOSCALAR */
HAWK_T("cannot change a map to another map"), /* EMAPTOMAP */
HAWK_T("cannot change a scalar to a map"), /* ESCALARTOMAP */ HAWK_T("cannot change a scalar to a map"), /* ESCALARTOMAP */
HAWK_T("cannot change a map '${0}' to another map"),/* ENMAPTOMAP */
HAWK_T("cannot change a map '${0}' to a scalar"), /* ENMAPTOSCALAR */
HAWK_T("cannot change a scalar '${0}' to a map"), /* ENSCALARTOMAP */
HAWK_T("invalid value to convert to a string"), HAWK_T("invalid value to convert to a string"),
HAWK_T("invalid value to convert to a number"), HAWK_T("invalid value to convert to a number"),
HAWK_T("invalid value to a character"), HAWK_T("invalid value to a character"),
@ -159,12 +157,11 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum)
HAWK_T("'next' called from END block"), HAWK_T("'next' called from END block"),
HAWK_T("'nextfile' called from BEGIN block"), HAWK_T("'nextfile' called from BEGIN block"),
HAWK_T("'nextfile' called from END block"), HAWK_T("'nextfile' called from END block"),
HAWK_T("intrinsic function handler for '${0}' failed"),
HAWK_T("wrong implementation of user-defined I/O handler"), HAWK_T("wrong implementation of user-defined I/O handler"),
HAWK_T("I/O handler returned an error"), HAWK_T("I/O handler returned an error"),
HAWK_T("no such I/O name found"), HAWK_T("no such I/O name found"),
HAWK_T("I/O name empty"), HAWK_T("I/O name empty"),
HAWK_T("I/O name '${0}' containing '\\0'"), HAWK_T("I/O name containing '\\0'"),
HAWK_T("not sufficient arguments to formatting sequence"), HAWK_T("not sufficient arguments to formatting sequence"),
HAWK_T("recursion detected in format conversion"), HAWK_T("recursion detected in format conversion"),
HAWK_T("invalid character in CONVFMT"), HAWK_T("invalid character in CONVFMT"),
@ -552,6 +549,7 @@ void hawk_rtx_seterror (hawk_rtx_t* rtx, hawk_errnum_t errnum, const hawk_oocs_t
void hawk_rtx_errortohawk (hawk_rtx_t* rtx, hawk_t* hawk) void hawk_rtx_errortohawk (hawk_rtx_t* rtx, hawk_t* hawk)
{ {
/* copy error information in 'rtx' to the 'hawk' object */
hawk->_gem.errnum = rtx->_gem.errnum; hawk->_gem.errnum = rtx->_gem.errnum;
hawk->_gem.errloc = rtx->_gem.errloc; hawk->_gem.errloc = rtx->_gem.errloc;
hawk_copy_oocstr (hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), rtx->_gem.errmsg); hawk_copy_oocstr (hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), rtx->_gem.errmsg);

View File

@ -773,8 +773,8 @@ enum hawk_errnum_t
HAWK_EBUSY, /**< system busy */ HAWK_EBUSY, /**< system busy */
HAWK_EPERM, /**< operation not permitted */ HAWK_EPERM, /**< operation not permitted */
HAWK_ENOSUP, /**< not supported */ HAWK_ENOSUP, /**< not supported */
HAWK_ENOENT, /**< '${0} not found */ HAWK_ENOENT, /**< not found */
HAWK_EEXIST, /**< '${0}' already exists */ HAWK_EEXIST, /**< already exists */
HAWK_EIOERR, /**< I/O error */ HAWK_EIOERR, /**< I/O error */
HAWK_EBUFFULL,/**< buffer full */ HAWK_EBUFFULL,/**< buffer full */
HAWK_EECERR, /**< encoding conversion error */ HAWK_EECERR, /**< encoding conversion error */
@ -866,9 +866,9 @@ enum hawk_errnum_t
HAWK_EPOSIDX, /**< wrong position index */ HAWK_EPOSIDX, /**< wrong position index */
HAWK_EARGTF, /**< too few arguments */ HAWK_EARGTF, /**< too few arguments */
HAWK_EARGTM, /**< too many arguments */ HAWK_EARGTM, /**< too many arguments */
HAWK_EFUNNF, /**< function '${0}' not found */ HAWK_EFUNNF, /**< function not found */
HAWK_ENOTFUN, /**< non-function value in '%{0}' */ HAWK_ENOTFUN, /**< non-function value */
HAWK_ENOTDEL, /**< '${0}' not deletable */ HAWK_ENOTDEL, /**< not deletable */
HAWK_ENOTMAP, /**< value not a map */ HAWK_ENOTMAP, /**< value not a map */
HAWK_ENOTMAPIN, /**< right-hand side of 'in' not a map */ HAWK_ENOTMAPIN, /**< right-hand side of 'in' not a map */
HAWK_ENOTMAPNILIN, /**< right-hand side of 'in' not a map nor nil */ HAWK_ENOTMAPNILIN, /**< right-hand side of 'in' not a map nor nil */
@ -876,12 +876,10 @@ enum hawk_errnum_t
HAWK_EMAPRET, /**< map cannot be returned */ HAWK_EMAPRET, /**< map cannot be returned */
HAWK_EMAPTOPOS, /**< map cannot be assigned to a positional */ HAWK_EMAPTOPOS, /**< map cannot be assigned to a positional */
HAWK_EMAPTOIDX, /**< map cannot be assigned to an indexed variable */ HAWK_EMAPTOIDX, /**< map cannot be assigned to an indexed variable */
HAWK_EMAPTONVAR, /**< map cannot be assigned to an variable '${0}' */ HAWK_EMAPTOVAR, /**< map cannot be assigned to a variable */
HAWK_EMAPTOSCALAR, /**< cannot change a map to a scalar value */ HAWK_EMAPTOSCALAR, /**< cannot change a map to a scalar value */
HAWK_EMAPTOMAP, /**< cannot change a map to another map */
HAWK_ESCALARTOMAP, /**< cannot change a scalar to a map */ HAWK_ESCALARTOMAP, /**< cannot change a scalar to a map */
HAWK_ENMAPTOMAP, /**< cannot change a map '${0}' to another map */
HAWK_ENMAPTOSCALAR, /**< cannot change a map '${0}' to a scalar */
HAWK_ENSCALARTOMAP, /**< cannot change a scalar '${0}' to a map */
HAWK_EVALTOSTR, /**< invalid value to convert to a string */ HAWK_EVALTOSTR, /**< invalid value to convert to a string */
HAWK_EVALTONUM, /**< invalid value to convert to a number */ HAWK_EVALTONUM, /**< invalid value to convert to a number */
HAWK_EVALTOCHR, /**< invalid value to convert to a character */ HAWK_EVALTOCHR, /**< invalid value to convert to a character */
@ -890,12 +888,11 @@ enum hawk_errnum_t
HAWK_ERNEXTEND, /**< 'next' called from END block */ HAWK_ERNEXTEND, /**< 'next' called from END block */
HAWK_ERNEXTFBEG, /**< 'nextfile' called from BEGIN block */ HAWK_ERNEXTFBEG, /**< 'nextfile' called from BEGIN block */
HAWK_ERNEXTFEND, /**< 'nextfile' called from END block */ HAWK_ERNEXTFEND, /**< 'nextfile' called from END block */
HAWK_EFNCIMPL, /**< intrinsic function handler for '${0}' failed */
HAWK_EIOUSER, /**< wrong user io handler implementation */ HAWK_EIOUSER, /**< wrong user io handler implementation */
HAWK_EIOIMPL, /**< I/O callback returned an error */ HAWK_EIOIMPL, /**< I/O callback returned an error */
HAWK_EIONMNF, /**< no such I/O name found */ HAWK_EIONMNF, /**< no such I/O name found */
HAWK_EIONMEM, /**< I/O name empty */ HAWK_EIONMEM, /**< I/O name empty */
HAWK_EIONMNL, /**< I/O name '${0}' containing '\\0' */ HAWK_EIONMNL, /**< I/O name containing '\\0' */
HAWK_EFMTARG, /**< not sufficient arguments to formatting sequence */ HAWK_EFMTARG, /**< not sufficient arguments to formatting sequence */
HAWK_EFMTCNV, /**< recursion detected in format conversion */ HAWK_EFMTCNV, /**< recursion detected in format conversion */
HAWK_ECONVFMTCHR, /**< invalid character in CONVFMT */ HAWK_ECONVFMTCHR, /**< invalid character in CONVFMT */

View File

@ -571,7 +571,7 @@ static int parse (hawk_t* awk)
/* see parse_fncall() for what is /* see parse_fncall() for what is
* stored into awk->tree.funs */ * stored into awk->tree.funs */
nde = (hawk_nde_t*)HAWK_HTB_VPTR(p); nde = (hawk_nde_t*)HAWK_HTB_VPTR(p);
SETERR_ARG_LOC (awk, HAWK_EFUNNF, HAWK_HTB_KPTR(p), HAWK_HTB_KLEN(p), &nde->loc); hawk_seterrfmt (awk, &nde->loc, HAWK_EFUNNF, HAWK_T("function '%.*js' not defined"), HAWK_HTB_KLEN(p), HAWK_HTB_KPTR(p));
goto oops; goto oops;
} }

File diff suppressed because it is too large Load Diff