changed hawk_seterrnum() to be consistent with hawk_gem_seterrnum()

This commit is contained in:
hyung-hwan 2020-01-01 04:46:49 +00:00
parent 988dc83bf4
commit 05cb4dc080
13 changed files with 91 additions and 153 deletions

View File

@ -280,6 +280,7 @@ static void stop_run (int signo)
int e = errno; int e = errno;
#endif #endif
/*hawk_haltall(hawk_rtx_gethawk(app_rtx));*/
hawk_rtx_halt (app_rtx); hawk_rtx_halt (app_rtx);
#if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__) #if !defined(_WIN32) && !defined(__OS2__) && !defined(__DOS__)

View File

@ -49,7 +49,8 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum)
HAWK_T("I/O error"), HAWK_T("I/O error"),
HAWK_T("buffer full"), HAWK_T("buffer full"),
HAWK_T("encoding conversion error"), HAWK_T("encoding conversion error"),
HAWK_T("not directory"), HAWK_T("is a directory"),
HAWK_T("not a directory"),
HAWK_T("resource temporarily unavailable"), HAWK_T("resource temporarily unavailable"),
HAWK_T("interrupted"), HAWK_T("interrupted"),
HAWK_T("broken pipe"), HAWK_T("broken pipe"),
@ -256,11 +257,6 @@ const hawk_ooch_t* hawk_backuperrmsg (hawk_t* hawk)
return hawk->errmsg_backup; return hawk->errmsg_backup;
} }
void hawk_seterrnum (hawk_t* hawk, hawk_errnum_t errnum, const hawk_oocs_t* errarg)
{
hawk_seterror (hawk, errnum, errarg, HAWK_NULL);
}
void hawk_seterrinf (hawk_t* hawk, const hawk_errinf_t* errinf) void hawk_seterrinf (hawk_t* hawk, const hawk_errinf_t* errinf)
{ {
hawk->_gem.errnum = errinf->num; hawk->_gem.errnum = errinf->num;

View File

@ -105,7 +105,7 @@ static hawk_fnc_t* add_fnc (hawk_t* hawk, const hawk_ooch_t* name, const hawk_fn
ncs.len = hawk_count_oocstr(name); ncs.len = hawk_count_oocstr(name);
if (ncs.len <= 0) if (ncs.len <= 0)
{ {
hawk_seterrnum (hawk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL);
return HAWK_NULL; return HAWK_NULL;
} }
@ -115,7 +115,7 @@ static hawk_fnc_t* add_fnc (hawk_t* hawk, const hawk_ooch_t* name, const hawk_fn
if (hawk_findfncwithoocs(hawk, &ncs) != HAWK_NULL) if (hawk_findfncwithoocs(hawk, &ncs) != HAWK_NULL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_EEXIST, "unable to add existing function - %js", name); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EEXIST, HAWK_T("unable to add existing function - %js"), name);
return HAWK_NULL; return HAWK_NULL;
} }
@ -142,7 +142,7 @@ static hawk_fnc_t* add_fnc (hawk_t* hawk, const hawk_ooch_t* name, const hawk_fn
if (hawk_htb_insert(hawk->fnc.user, (hawk_ooch_t*)ncs.ptr, ncs.len, fnc, 0) == HAWK_NULL) if (hawk_htb_insert(hawk->fnc.user, (hawk_ooch_t*)ncs.ptr, ncs.len, fnc, 0) == HAWK_NULL)
{ {
const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); const hawk_ooch_t* bem = hawk_backuperrmsg(hawk);
hawk_seterrbfmt (hawk, HAWK_NULL, hawk_geterrnum(hawk), "unable to add function - %js - %js", name, bem); hawk_seterrfmt (hawk, HAWK_NULL, hawk_geterrnum(hawk), HAWK_T("unable to add function - %js - %js"), name, bem);
hawk_freemem (hawk, fnc); hawk_freemem (hawk, fnc);
fnc = HAWK_NULL; fnc = HAWK_NULL;
} }
@ -228,7 +228,7 @@ int hawk_delfncwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
#if defined(HAWK_OOCH_IS_BCH) #if defined(HAWK_OOCH_IS_BCH)
if (hawk_htb_delete(hawk->fnc.user, ncs.ptr, ncs.len) <= -1) if (hawk_htb_delete(hawk->fnc.user, ncs.ptr, ncs.len) <= -1)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such function - %hs", name); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such function - %hs"), name);
return -1; return -1;
} }
#else #else
@ -236,7 +236,7 @@ int hawk_delfncwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
if (!wcs.ptr) return -1; if (!wcs.ptr) return -1;
if (hawk_htb_delete(hawk->fnc.user, wcs.ptr, wcs.len) <= -1) if (hawk_htb_delete(hawk->fnc.user, wcs.ptr, wcs.len) <= -1)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such function - %hs", name); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such function - %hs"), name);
hawk_freemem (hawk, wcs.ptr); hawk_freemem (hawk, wcs.ptr);
return -1; return -1;
} }
@ -259,7 +259,7 @@ int hawk_delfncwithucstr (hawk_t* hawk, const hawk_uch_t* name)
if (!mbs.ptr) return -1; if (!mbs.ptr) return -1;
if (hawk_htb_delete(hawk->fnc.user, mbs.ptr, mbs.len) <= -1) if (hawk_htb_delete(hawk->fnc.user, mbs.ptr, mbs.len) <= -1)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such function - %ls", name); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such function - %ls"), name);
hawk_freemem (hawk, mbs.ptr); hawk_freemem (hawk, mbs.ptr);
return -1; return -1;
} }
@ -267,7 +267,7 @@ int hawk_delfncwithucstr (hawk_t* hawk, const hawk_uch_t* name)
#else #else
if (hawk_htb_delete(hawk->fnc.user, ncs.ptr, ncs.len) <= -1) if (hawk_htb_delete(hawk->fnc.user, ncs.ptr, ncs.len) <= -1)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such function - %ls", name); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such function - %ls"), name);
return -1; return -1;
} }
#endif #endif
@ -304,7 +304,7 @@ static hawk_fnc_t* find_fnc (hawk_t* awk, const hawk_oocs_t* name)
if ((awk->opt.trait & fnc->spec.trait) == fnc->spec.trait) return fnc; if ((awk->opt.trait & fnc->spec.trait) == fnc->spec.trait) return fnc;
} }
hawk_seterrbfmt (awk, HAWK_NULL, HAWK_ENOENT, "no such function - %js", name); hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such function - %js"), name);
return HAWK_NULL; return HAWK_NULL;
} }

View File

@ -777,6 +777,7 @@ enum hawk_errnum_t
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 */
HAWK_EISDIR, /**< is directory */
HAWK_ENOTDIR, /**< not directory */ HAWK_ENOTDIR, /**< not directory */
HAWK_EAGAIN, /**< resource temporarily unavailable */ HAWK_EAGAIN, /**< resource temporarily unavailable */
HAWK_EINTR, /**< interrupted */ HAWK_EINTR, /**< interrupted */

View File

@ -165,7 +165,7 @@ int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm
prm->math.pow == HAWK_NULL || prm->math.pow == HAWK_NULL ||
prm->math.mod == HAWK_NULL) prm->math.mod == HAWK_NULL)
{ {
hawk_seterrnum (awk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL);
goto oops; goto oops;
} }
awk->prm = *prm; awk->prm = *prm;
@ -218,7 +218,7 @@ int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm
awk->fnc.user == HAWK_NULL || awk->fnc.user == HAWK_NULL ||
awk->modtab == HAWK_NULL) awk->modtab == HAWK_NULL)
{ {
hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM);
goto oops; goto oops;
} }
@ -511,7 +511,7 @@ int hawk_setopt (hawk_t* hawk, hawk_opt_t id, const void* value)
} }
hawk_seterrnum (hawk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL);
return -1; return -1;
} }
@ -556,14 +556,13 @@ int hawk_getopt (hawk_t* hawk, hawk_opt_t id, void* value)
}; };
hawk_seterrnum (hawk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL);
return -1; return -1;
} }
void hawk_haltall (hawk_t* awk) void hawk_haltall (hawk_t* awk)
{ {
awk->haltall = 1; awk->haltall = 1;
hawk_seterrnum (awk, HAWK_EINVAL, HAWK_NULL);
} }
hawk_ecb_t* hawk_popecb (hawk_t* awk) hawk_ecb_t* hawk_popecb (hawk_t* awk)

View File

@ -1598,12 +1598,11 @@ HAWK_EXPORT void hawk_geterrinf (
* error number \a errnum requires one or more arguments to format an * error number \a errnum requires one or more arguments to format an
* error message. * error message.
*/ */
HAWK_EXPORT void hawk_seterrnum ( #if defined(HAWK_HAVE_INLINE)
hawk_t* awk, /**< awk */ static HAWK_INLINE void hawk_seterrnum (hawk_t* hawk, hawk_loc_t* errloc, hawk_errnum_t errnum) { hawk_gem_seterrnum (hawk_getgem(hawk), errloc, errnum); }
hawk_errnum_t errnum, /**< error number */ #else
const hawk_oocs_t* errarg /**< argument array for formatting #define hawk_seterrnum(hawk, errloc, errnum) hawk_gem_seterrnum(hawk_getgem(hawk), errloc, errnum)
* an error message */ #endif
);
HAWK_EXPORT void hawk_seterrbfmt ( HAWK_EXPORT void hawk_seterrbfmt (
hawk_t* awk, hawk_t* awk,

View File

@ -412,10 +412,6 @@ static global_t gtab[] =
#define MATCH_TERMINATOR(awk) \ #define MATCH_TERMINATOR(awk) \
(MATCH_TERMINATOR_NORMAL(awk) || MATCH_TERMINATOR_RBRACE(awk)) (MATCH_TERMINATOR_NORMAL(awk) || MATCH_TERMINATOR_RBRACE(awk))
#define ISNOERR(awk) ((awk)->_gem.errnum == HAWK_ENOERR)
#define CLRERR(awk) hawk_seterror (awk, HAWK_ENOERR, HAWK_NULL, HAWK_NULL)
#define SETERR_TOK(awk,code) \ #define SETERR_TOK(awk,code) \
hawk_seterror (awk, code, HAWK_OOECS_OOCS((awk)->tok.name), &(awk)->tok.loc) hawk_seterror (awk, code, HAWK_OOECS_OOCS((awk)->tok.name), &(awk)->tok.loc)
@ -469,17 +465,11 @@ static int get_char (hawk_t* awk)
if (awk->sio.inp->b.pos >= awk->sio.inp->b.len) if (awk->sio.inp->b.pos >= awk->sio.inp->b.len)
{ {
CLRERR (awk);
n = awk->sio.inf( n = awk->sio.inf(
awk, HAWK_SIO_CMD_READ, awk->sio.inp, awk, HAWK_SIO_CMD_READ, awk->sio.inp,
awk->sio.inp->b.buf, HAWK_COUNTOF(awk->sio.inp->b.buf) awk->sio.inp->b.buf, HAWK_COUNTOF(awk->sio.inp->b.buf)
); );
if (n <= -1) if (n <= -1) return -1;
{
if (ISNOERR(awk))
SETERR_ARG (awk, HAWK_EREAD, HAWK_T("<SIN>"), 5);
return -1;
}
if (n == 0) if (n == 0)
{ {
@ -541,14 +531,11 @@ static int parse (hawk_t* awk)
HAWK_ASSERT (awk->sio.inf != HAWK_NULL); HAWK_ASSERT (awk->sio.inf != HAWK_NULL);
CLRERR (awk);
op = awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, awk->sio.inp, HAWK_NULL, 0); op = awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, awk->sio.inp, HAWK_NULL, 0);
if (op <= -1) if (op <= -1)
{ {
/* cannot open the source file. /* cannot open the source file.
* it doesn't even have to call CLOSE */ * it doesn't even have to call CLOSE */
if (ISNOERR(awk))
SETERR_ARG (awk, HAWK_EOPEN, HAWK_T("<SIN>"), 5);
return -1; return -1;
} }
@ -595,6 +582,7 @@ static int parse (hawk_t* awk)
} }
HAWK_ASSERT (awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls)); HAWK_ASSERT (awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls));
HAWK_ASSERT (awk->sio.inp == &awk->sio.arg);
ret = 0; ret = 0;
oops: oops:
@ -618,30 +606,11 @@ oops:
awk->sio.inp = prev; awk->sio.inp = prev;
} }
} }
else if (ret == 0)
{
/* no error occurred so far */
HAWK_ASSERT (awk->sio.inp == &awk->sio.arg);
CLRERR (awk);
}
if (awk->sio.inf(awk, HAWK_SIO_CMD_CLOSE, awk->sio.inp, HAWK_NULL, 0) != 0) if (awk->sio.inf(awk, HAWK_SIO_CMD_CLOSE, awk->sio.inp, HAWK_NULL, 0) != 0 && ret == 0) ret = -1;
{
if (ret == 0)
{
/* this is to keep the earlier error above
* that might be more critical than this */
if (ISNOERR(awk))
SETERR_ARG (awk, HAWK_ECLOSE, HAWK_T("<SIN>"), 5);
ret = -1;
}
}
if (ret <= -1)
{
/* clear the parse tree partially constructed on error */ /* clear the parse tree partially constructed on error */
hawk_clear (awk); if (ret <= -1) hawk_clear (awk);
}
return ret; return ret;
} }
@ -775,7 +744,6 @@ static int end_include (hawk_t* awk)
/* if it is an included file, close it and /* if it is an included file, close it and
* retry to read a character from an outer file */ * retry to read a character from an outer file */
CLRERR (awk);
x = awk->sio.inf(awk, HAWK_SIO_CMD_CLOSE, awk->sio.inp, HAWK_NULL, 0); x = awk->sio.inf(awk, HAWK_SIO_CMD_CLOSE, awk->sio.inp, HAWK_NULL, 0);
/* if closing has failed, still destroy the /* if closing has failed, still destroy the
@ -796,7 +764,6 @@ static int end_include (hawk_t* awk)
if (x != 0) if (x != 0)
{ {
/* the failure mentioned above is returned here */ /* the failure mentioned above is returned here */
if (ISNOERR(awk)) SETERR_ARG (awk, HAWK_ECLOSE, HAWK_T("<SIN>"), 5);
return -1; return -1;
} }
@ -884,11 +851,9 @@ static int begin_include (hawk_t* awk, int once)
/* let the argument's prev field point to the current */ /* let the argument's prev field point to the current */
arg->prev = awk->sio.inp; arg->prev = awk->sio.inp;
CLRERR (awk);
if (awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, arg, HAWK_NULL, 0) <= -1) if (awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, arg, HAWK_NULL, 0) <= -1)
{ {
if (ISNOERR(awk)) SETERR_TOK (awk, HAWK_EOPEN); ADJERR_LOC (awk, &awk->tok.loc);
else awk->_gem.errloc = awk->tok.loc; /* adjust error location */
goto oops; goto oops;
} }
@ -2048,7 +2013,7 @@ int hawk_delgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
if (hawk->tree.ngbls > hawk->tree.ngbls_base) if (hawk->tree.ngbls > hawk->tree.ngbls_base)
{ {
/* this function is not allow after hawk_parse is called */ /* this function is not allow after hawk_parse is called */
hawk_seterrnum (hawk, HAWK_EPERM, HAWK_NULL); hawk_seterrnum (hawk, HAWK_NULL, HAWK_EPERM);
return -1; return -1;
} }
@ -2056,7 +2021,7 @@ int hawk_delgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*hs", ncs.len, ncs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), ncs.len, ncs.ptr);
return -1; return -1;
} }
#else #else
@ -2065,7 +2030,7 @@ int hawk_delgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, wcs.ptr, wcs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, wcs.ptr, wcs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*ls", wcs.len, wcs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), wcs.len, wcs.ptr);
hawk_freemem (hawk, wcs.ptr); hawk_freemem (hawk, wcs.ptr);
return -1; return -1;
} }
@ -2099,7 +2064,7 @@ int hawk_delgblwithucstr (hawk_t* hawk, const hawk_uch_t* name)
if (hawk->tree.ngbls > hawk->tree.ngbls_base) if (hawk->tree.ngbls > hawk->tree.ngbls_base)
{ {
/* this function is not allow after hawk_parse is called */ /* this function is not allow after hawk_parse is called */
hawk_seterrnum (hawk, HAWK_EPERM, HAWK_NULL); hawk_seterrnum (hawk, HAWK_NULL, HAWK_EPERM);
return -1; return -1;
} }
@ -2109,7 +2074,7 @@ int hawk_delgblwithucstr (hawk_t* hawk, const hawk_uch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, mbs.ptr, mbs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, mbs.ptr, mbs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*hs", mbs.len, mbs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), mbs.len, mbs.ptr);
hawk_freemem (hawk, mbs.ptr); hawk_freemem (hawk, mbs.ptr);
return -1; return -1;
} }
@ -2118,7 +2083,7 @@ int hawk_delgblwithucstr (hawk_t* hawk, const hawk_uch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*ls", ncs.len, ncs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), ncs.len, ncs.ptr);
return -1; return -1;
} }
#endif #endif
@ -2151,7 +2116,7 @@ int hawk_findgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*hs", ncs.len, ncs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), ncs.len, ncs.ptr);
return -1; return -1;
} }
#else #else
@ -2160,7 +2125,7 @@ int hawk_findgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, wcs.ptr, wcs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, wcs.ptr, wcs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*ls", wcs.len, wcs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), wcs.len, wcs.ptr);
hawk_freemem (hawk, wcs.ptr); hawk_freemem (hawk, wcs.ptr);
return -1; return -1;
} }
@ -2185,7 +2150,7 @@ int hawk_findgblwithucstr (hawk_t* hawk, const hawk_uch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, mbs.ptr, mbs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, mbs.ptr, mbs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*hs", mbs.len, mbs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*hs"), mbs.len, mbs.ptr);
hawk_freemem (hawk, mbs.ptr); hawk_freemem (hawk, mbs.ptr);
return -1; return -1;
} }
@ -2194,7 +2159,7 @@ int hawk_findgblwithucstr (hawk_t* hawk, const hawk_uch_t* name)
n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len); n = hawk_arr_search(hawk->parse.gbls, HAWK_NUM_STATIC_GBLS, ncs.ptr, ncs.len);
if (n == HAWK_ARR_NIL) if (n == HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "no such global variable - %.*ls", ncs.len, ncs.ptr); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such global variable - %.*ls"), ncs.len, ncs.ptr);
return -1; return -1;
} }
#endif #endif
@ -2316,7 +2281,7 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop)
n = hawk_arr_search(awk->parse.lcls, nlcls, lcl.ptr, lcl.len); n = hawk_arr_search(awk->parse.lcls, nlcls, lcl.ptr, lcl.len);
if (n != HAWK_ARR_NIL) if (n != HAWK_ARR_NIL)
{ {
hawk_seterrbfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, "duplicate local variable - %.*js", lcl.len, lcl.ptr); hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable - %.*js"), lcl.len, lcl.ptr);
return HAWK_NULL; return HAWK_NULL;
} }
@ -2328,14 +2293,14 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop)
{ {
/* it is a conflict only if it is one of a /* it is a conflict only if it is one of a
* static global variable */ * static global variable */
hawk_seterrbfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, "duplicate local variable - %.*js", lcl.len, lcl.ptr); hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable - %.*js"), lcl.len, lcl.ptr);
return HAWK_NULL; return HAWK_NULL;
} }
} }
if (HAWK_ARR_SIZE(awk->parse.lcls) >= HAWK_MAX_LCLS) if (HAWK_ARR_SIZE(awk->parse.lcls) >= HAWK_MAX_LCLS)
{ {
hawk_seterrbfmt (awk, &awk->tok.loc, HAWK_ELCLTM, "too many local variables defined - %.*js", lcl.len, lcl.ptr); hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELCLTM, HAWK_T("too many local variables defined - %.*js"), lcl.len, lcl.ptr);
return HAWK_NULL; return HAWK_NULL;
} }
@ -3609,7 +3574,7 @@ static int fold_constants_for_binop (
case HAWK_BINOP_DIV: case HAWK_BINOP_DIV:
if (((hawk_nde_int_t*)right)->val == 0) if (((hawk_nde_int_t*)right)->val == 0)
{ {
hawk_seterrnum (awk, HAWK_EDIVBY0, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EDIVBY0);
fold = -2; /* error */ fold = -2; /* error */
} }
else if (INT_BINOP_INT(left,%,right)) else if (INT_BINOP_INT(left,%,right))
@ -3627,7 +3592,7 @@ static int fold_constants_for_binop (
case HAWK_BINOP_IDIV: case HAWK_BINOP_IDIV:
if (((hawk_nde_int_t*)right)->val == 0) if (((hawk_nde_int_t*)right)->val == 0)
{ {
hawk_seterrnum (awk, HAWK_EDIVBY0, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EDIVBY0);
fold = -2; /* error */ fold = -2; /* error */
} }
else else
@ -5455,12 +5420,10 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc
hawk_mod_sym_t sym; hawk_mod_sym_t sym;
hawk_fnc_t fnc; hawk_fnc_t fnc;
CLRERR (awk);
mod = query_module(awk, segs, nsegs, &sym); mod = query_module(awk, segs, nsegs, &sym);
if (mod == HAWK_NULL) if (mod == HAWK_NULL)
{ {
if (ISNOERR(awk)) SETERR_LOC (awk, HAWK_ENOSUP, xloc); ADJERR_LOC (awk, xloc);
else ADJERR_LOC (awk, xloc);
} }
else else
{ {
@ -6757,13 +6720,8 @@ static int deparse (hawk_t* awk)
HAWK_MEMSET (&awk->sio.arg, 0, HAWK_SIZEOF(awk->sio.arg)); HAWK_MEMSET (&awk->sio.arg, 0, HAWK_SIZEOF(awk->sio.arg));
CLRERR (awk);
op = awk->sio.outf(awk, HAWK_SIO_CMD_OPEN, &awk->sio.arg, HAWK_NULL, 0); op = awk->sio.outf(awk, HAWK_SIO_CMD_OPEN, &awk->sio.arg, HAWK_NULL, 0);
if (op <= -1) if (op <= -1) return -1;
{
if (ISNOERR(awk)) SETERR_ARG (awk, HAWK_EOPEN, HAWK_T("<SOUT>"), 6);
return -1;
}
#define EXIT_DEPARSE() do { n = -1; goto exit_deparse; } while(0) #define EXIT_DEPARSE() do { n = -1; goto exit_deparse; } while(0)
@ -6911,16 +6869,7 @@ static int deparse (hawk_t* awk)
if (flush_out (awk) <= -1) EXIT_DEPARSE (); if (flush_out (awk) <= -1) EXIT_DEPARSE ();
exit_deparse: exit_deparse:
if (n == 0) CLRERR (awk); if (awk->sio.outf(awk, HAWK_SIO_CMD_CLOSE, &awk->sio.arg, HAWK_NULL, 0) != 0 && n == 0) n = -1;
if (awk->sio.outf(awk, HAWK_SIO_CMD_CLOSE, &awk->sio.arg, HAWK_NULL, 0) != 0)
{
if (n == 0)
{
if (ISNOERR(awk)) SETERR_ARG (awk, HAWK_ECLOSE, HAWK_T("<SOUT>"), 6);
n = -1;
}
}
return n; return n;
} }
@ -7001,19 +6950,12 @@ static int flush_out (hawk_t* awk)
while (awk->sio.arg.b.pos < awk->sio.arg.b.len) while (awk->sio.arg.b.pos < awk->sio.arg.b.len)
{ {
CLRERR (awk);
n = awk->sio.outf ( n = awk->sio.outf (
awk, HAWK_SIO_CMD_WRITE, &awk->sio.arg, awk, HAWK_SIO_CMD_WRITE, &awk->sio.arg,
&awk->sio.arg.b.buf[awk->sio.arg.b.pos], &awk->sio.arg.b.buf[awk->sio.arg.b.pos],
awk->sio.arg.b.len - awk->sio.arg.b.pos awk->sio.arg.b.len - awk->sio.arg.b.pos
); );
if (n <= 0) if (n <= 0) return -1;
{
if (ISNOERR(awk))
SETERR_ARG (awk, HAWK_EWRITE, HAWK_T("<SOUT>"), 6);
return -1;
}
awk->sio.arg.b.pos += n; awk->sio.arg.b.pos += n;
} }
@ -7176,7 +7118,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg
pair = hawk_rbt_insert(awk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md)); pair = hawk_rbt_insert(awk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md));
if (pair == HAWK_NULL) if (pair == HAWK_NULL)
{ {
hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM);
return HAWK_NULL; return HAWK_NULL;
} }
@ -7190,7 +7132,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg
goto done; goto done;
} }
#endif #endif
hawk_seterrnum (awk, HAWK_ENOERR, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR);
/* attempt to find an external module */ /* attempt to find an external module */
HAWK_MEMSET (&spec, 0, HAWK_SIZEOF(spec)); HAWK_MEMSET (&spec, 0, HAWK_SIZEOF(spec));
@ -7233,7 +7175,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg
load = awk->prm.modgetsym(awk, md.handle, &buf[0]); load = awk->prm.modgetsym(awk, md.handle, &buf[0]);
if (!load) if (!load)
{ {
hawk_seterrnum (awk, HAWK_ENOERR, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR);
/* attempt hawk_mod_xxx_ */ /* attempt hawk_mod_xxx_ */
buf[13 + buflen] = HAWK_T('_'); buf[13 + buflen] = HAWK_T('_');
@ -7261,7 +7203,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg
pair = hawk_rbt_insert (awk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md)); pair = hawk_rbt_insert (awk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md));
if (pair == HAWK_NULL) if (pair == HAWK_NULL)
{ {
hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM);
awk->prm.modclose (awk, md.handle); awk->prm.modclose (awk, md.handle);
return HAWK_NULL; return HAWK_NULL;
} }
@ -7276,7 +7218,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg
} }
done: done:
hawk_seterrnum (awk, HAWK_ENOERR, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR);
n = mdp->mod.query(&mdp->mod, awk, segs[1].ptr, sym); n = mdp->mod.query(&mdp->mod, awk, segs[1].ptr, sym);
if (n <= -1) if (n <= -1)
{ {

View File

@ -103,10 +103,8 @@ static int split_record (hawk_rtx_t* rtx)
hawk_val_type_t fsvtype; hawk_val_type_t fsvtype;
hawk_ooch_t* fs_ptr, * fs_free; hawk_ooch_t* fs_ptr, * fs_free;
hawk_oow_t fs_len; hawk_oow_t fs_len;
hawk_errnum_t errnum;
int how; int how;
/* inrec should be cleared before split_record is called */ /* inrec should be cleared before split_record is called */
HAWK_ASSERT (rtx->inrec.nflds == 0); HAWK_ASSERT (rtx->inrec.nflds == 0);

View File

@ -222,7 +222,6 @@ static HAWK_INLINE int resolve_rs (hawk_rtx_t* rtx, hawk_val_t* rs, hawk_oocs_t*
static HAWK_INLINE int match_long_rs (hawk_rtx_t* rtx, hawk_ooecs_t* buf, hawk_rio_arg_t* p) static HAWK_INLINE int match_long_rs (hawk_rtx_t* rtx, hawk_ooecs_t* buf, hawk_rio_arg_t* p)
{ {
hawk_oocs_t match; hawk_oocs_t match;
hawk_errnum_t errnum;
int ret; int ret;
HAWK_ASSERT (rtx->gbl.rs[0] != HAWK_NULL); HAWK_ASSERT (rtx->gbl.rs[0] != HAWK_NULL);

View File

@ -749,7 +749,7 @@ hawk_rtx_t* hawk_rtx_open (hawk_t* awk, hawk_oow_t xtnsize, hawk_rio_cbs_t* rio)
struct module_init_ctx_t mic; struct module_init_ctx_t mic;
/* clear the awk error code */ /* clear the awk error code */
hawk_seterrnum (awk, HAWK_ENOERR, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR);
/* check if the code has ever been parsed */ /* check if the code has ever been parsed */
if (awk->tree.ngbls == 0 && if (awk->tree.ngbls == 0 &&
@ -758,7 +758,7 @@ hawk_rtx_t* hawk_rtx_open (hawk_t* awk, hawk_oow_t xtnsize, hawk_rio_cbs_t* rio)
awk->tree.chain_size == 0 && awk->tree.chain_size == 0 &&
hawk_htb_getsize(awk->tree.funs) == 0) hawk_htb_getsize(awk->tree.funs) == 0)
{ {
hawk_seterrnum (awk, HAWK_EPERM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EPERM);
return HAWK_NULL; return HAWK_NULL;
} }

View File

@ -294,7 +294,7 @@ static void* std_mod_open_checked (hawk_t* awk, const hawk_mod_spec_t* spec)
{ {
/* hawk_stdmodstartup() must have failed upon start-up. /* hawk_stdmodstartup() must have failed upon start-up.
* return failure immediately */ * return failure immediately */
hawk_seterrnum (awk, HAWK_ENOIMPL, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOIMPL);
return HAWK_NULL; return HAWK_NULL;
} }
@ -327,7 +327,7 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec)
{ {
/* the only failure of lt_dladvise_init() seems to be caused /* the only failure of lt_dladvise_init() seems to be caused
* by memory allocation failured */ * by memory allocation failured */
hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM);
return HAWK_NULL; return HAWK_NULL;
} }
@ -457,7 +457,7 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec)
return h; return h;
#else #else
hawk_seterrnum (awk, HAWK_ENOIMPL, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOIMPL);
return HAWK_NULL; return HAWK_NULL;
#endif #endif
} }
@ -902,7 +902,7 @@ static hawk_sio_t* open_sio (hawk_t* hawk, const hawk_ooch_t* file, int flags)
if (sio == HAWK_NULL) if (sio == HAWK_NULL)
{ {
const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); const hawk_ooch_t* bem = hawk_backuperrmsg(hawk);
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_EOPEN, "unable to open %js - %js", file, bem); hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), file, bem);
} }
return sio; return sio;
} }
@ -914,7 +914,7 @@ static hawk_sio_t* open_sio_rtx (hawk_rtx_t* rtx, const hawk_ooch_t* file, int f
if (sio == HAWK_NULL) if (sio == HAWK_NULL)
{ {
const hawk_ooch_t* bem = hawk_rtx_backuperrmsg(rtx); const hawk_ooch_t* bem = hawk_rtx_backuperrmsg(rtx);
hawk_rtx_seterrbfmt (rtx, HAWK_NULL, HAWK_EOPEN, "unable to open %js - %js", file, bem); hawk_rtx_seterrfmt (rtx, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), file, bem);
} }
return sio; return sio;
} }
@ -933,7 +933,7 @@ static hawk_sio_t* open_sio_std (hawk_t* awk, hawk_sio_std_t std, int flags)
if (sio == HAWK_NULL) if (sio == HAWK_NULL)
{ {
const hawk_ooch_t* bem = hawk_backuperrmsg(awk); const hawk_ooch_t* bem = hawk_backuperrmsg(awk);
hawk_seterrbfmt (awk, HAWK_NULL, HAWK_EOPEN, "unable to open %js - %js", &sio_std_names[std], bem); hawk_seterrfmt (awk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), &sio_std_names[std], bem);
} }
return sio; return sio;
} }
@ -946,7 +946,7 @@ static hawk_sio_t* open_sio_std_rtx (hawk_rtx_t* rtx, hawk_sio_std_t std, int fl
if (sio == HAWK_NULL) if (sio == HAWK_NULL)
{ {
const hawk_ooch_t* bem = hawk_rtx_backuperrmsg(rtx); const hawk_ooch_t* bem = hawk_rtx_backuperrmsg(rtx);
hawk_rtx_seterrbfmt (rtx, HAWK_NULL, HAWK_EOPEN, "unable to open %js - %js", &sio_std_names[std], bem); hawk_rtx_seterrfmt (rtx, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), &sio_std_names[std], bem);
} }
return sio; return sio;
} }
@ -1050,7 +1050,7 @@ static int open_parsestd (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow
return 0; return 0;
default: default:
hawk_seterrnum (awk, HAWK_EINTERN, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN);
return -1; return -1;
} }
} }
@ -1167,7 +1167,7 @@ static hawk_ooi_t sf_in_open (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn)
const hawk_ooch_t* bem; const hawk_ooch_t* bem;
fail: fail:
bem = hawk_backuperrmsg(awk); bem = hawk_backuperrmsg(awk);
hawk_seterrbfmt (awk, HAWK_NULL, HAWK_EOPEN, "unable to open %js - %js", arg->name, bem); hawk_seterrfmt (awk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), arg->name, bem);
return -1; return -1;
} }
@ -1237,9 +1237,9 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
const hawk_uch_t* path; const hawk_uch_t* path;
path = xtn->s.in.x[xtn->s.in.xindex].u.fileu.path; path = xtn->s.in.x[xtn->s.in.xindex].u.fileu.path;
if (path) if (path)
hawk_seterrbfmt (awk, HAWK_NULL, HAWK_EREAD, "unable to read %ls - %js", path, bem); hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %ls - %js"), path, bem);
else else
hawk_seterrbfmt (awk, HAWK_NULL, HAWK_EREAD, "unable to read %js - %js", sio_std_names[HAWK_SIO_STDIN].ptr, bem); hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), sio_std_names[HAWK_SIO_STDIN].ptr, bem);
} }
break; break;
@ -1255,9 +1255,9 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
const hawk_bch_t* path; const hawk_bch_t* path;
path = xtn->s.in.x[xtn->s.in.xindex].u.fileb.path; path = xtn->s.in.x[xtn->s.in.xindex].u.fileb.path;
if (path) if (path)
hawk_seterrbfmt (awk, HAWK_NULL, HAWK_EREAD, "unable to read %hs - %js", path, bem); hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %hs - %js"), path, bem);
else else
hawk_seterrbfmt (awk, HAWK_NULL, HAWK_EREAD, "unable to read %js - %js", sio_std_names[HAWK_SIO_STDIN].ptr, bem); hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), sio_std_names[HAWK_SIO_STDIN].ptr, bem);
} }
break; break;
@ -1283,7 +1283,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
wcslen = size; wcslen = size;
if ((m = hawk_conv_bchars_to_uchars_with_cmgr(xtn->s.in.u.bcs.ptr, &mbslen, data, &wcslen, hawk_getcmgr(awk), 0)) <= -1 && m != -2) if ((m = hawk_conv_bchars_to_uchars_with_cmgr(xtn->s.in.u.bcs.ptr, &mbslen, data, &wcslen, hawk_getcmgr(awk), 0)) <= -1 && m != -2)
{ {
hawk_seterrnum (awk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL);
n = -1; n = -1;
} }
else else
@ -1305,7 +1305,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
mbslen = size; mbslen = size;
if ((m = hawk_conv_uchars_to_bchars_with_cmgr(xtn->s.in.u.ucs.ptr, &wcslen, data, &mbslen, hawk_getcmgr(awk))) <= -1 && m != -2) if ((m = hawk_conv_uchars_to_bchars_with_cmgr(xtn->s.in.u.ucs.ptr, &wcslen, data, &mbslen, hawk_getcmgr(awk))) <= -1 && m != -2)
{ {
hawk_seterrnum (awk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL);
n = -1; n = -1;
} }
else else
@ -1321,7 +1321,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
default: default:
/* this should never happen */ /* this should never happen */
hawk_seterrnum (awk, HAWK_EINTERN, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN);
n = -1; n = -1;
break; break;
} }
@ -1355,12 +1355,11 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
HAWK_ASSERT (arg->handle != HAWK_NULL); HAWK_ASSERT (arg->handle != HAWK_NULL);
n = hawk_sio_getoochars(arg->handle, data, size); n = hawk_sio_getoochars(arg->handle, data, size);
if (n <= -1) if (n <= -1)
{ {
hawk_oocs_t ea; const hawk_ooch_t* bem = hawk_backuperrmsg(awk);
ea.ptr = (hawk_ooch_t*)arg->name; hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), arg->name, bem);
ea.len = hawk_count_oocstr(ea.ptr);
hawk_seterrnum (awk, HAWK_EREAD, &ea);
} }
return n; return n;
} }
@ -1382,7 +1381,7 @@ static hawk_ooi_t sf_in (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, h
return sf_in_read(awk, arg, data, size, xtn); return sf_in_read(awk, arg, data, size, xtn);
default: default:
hawk_seterrnum (awk, HAWK_EINTERN, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN);
return -1; return -1;
} }
} }
@ -1509,11 +1508,11 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
n = hawk_sio_putoochars(xtn->s.out.u.file.sio, data, size); n = hawk_sio_putoochars(xtn->s.out.u.file.sio, data, size);
if (n <= -1) if (n <= -1)
{ {
hawk_oocs_t ea; const hawk_ooch_t* ioname;
ea.ptr = (hawk_ooch_t*)xtn->s.out.x->u.file.path; const hawk_ooch_t* bem = hawk_backuperrmsg(awk);
if (ea.ptr == HAWK_NULL) ea.ptr = sio_std_names[HAWK_SIO_STDOUT].ptr; ioname = xtn->s.out.x->u.file.path;
ea.len = hawk_count_oocstr(ea.ptr); if (!ioname) ioname = sio_std_names[HAWK_SIO_STDOUT].ptr;
hawk_seterrnum (awk, HAWK_EWRITE, &ea); hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to write to %js - %js"), ioname, bem);
} }
return n; return n;
} }
@ -1523,7 +1522,7 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
if (size > HAWK_TYPE_MAX(hawk_ooi_t)) size = HAWK_TYPE_MAX(hawk_ooi_t); if (size > HAWK_TYPE_MAX(hawk_ooi_t)) size = HAWK_TYPE_MAX(hawk_ooi_t);
if (hawk_ooecs_ncat(xtn->s.out.u.oocs.buf, data, size) == (hawk_oow_t)-1) if (hawk_ooecs_ncat(xtn->s.out.u.oocs.buf, data, size) == (hawk_oow_t)-1)
{ {
hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM);
return -1; return -1;
} }
return size; return size;
@ -1543,7 +1542,7 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
orglen = hawk_becs_getlen(xtn->s.out.u.bcs.buf); orglen = hawk_becs_getlen(xtn->s.out.u.bcs.buf);
if (hawk_becs_setlen(xtn->s.out.u.bcs.buf, orglen + mbslen) == (hawk_oow_t)-1) if (hawk_becs_setlen(xtn->s.out.u.bcs.buf, orglen + mbslen) == (hawk_oow_t)-1)
{ {
hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM);
return -1; return -1;
} }
@ -1568,7 +1567,7 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
orglen = hawk_becs_getlen(xtn->s.out.u.ucs.buf); orglen = hawk_becs_getlen(xtn->s.out.u.ucs.buf);
if (hawk_uecs_setlen(xtn->s.out.u.ucs.buf, orglen + wcslen) == (hawk_oow_t)-1) if (hawk_uecs_setlen(xtn->s.out.u.ucs.buf, orglen + wcslen) == (hawk_oow_t)-1)
{ {
hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM);
return -1; return -1;
} }
@ -1591,7 +1590,7 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
break; break;
} }
hawk_seterrnum (awk, HAWK_EINTERN, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN);
return -1; return -1;
} }
@ -1610,7 +1609,7 @@ int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out)
{ {
/* the input is a must. at least 1 file or 1 string /* the input is a must. at least 1 file or 1 string
* must be specified */ * must be specified */
hawk_seterrnum (awk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL);
return -1; return -1;
} }
@ -1627,7 +1626,7 @@ int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out)
out->type != HAWK_PARSESTD_BCS && out->type != HAWK_PARSESTD_BCS &&
out->type != HAWK_PARSESTD_UCS) out->type != HAWK_PARSESTD_UCS)
{ {
hawk_seterrnum (awk, HAWK_EINVAL, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL);
return -1; return -1;
} }
sio.out = sf_out; sio.out = sf_out;
@ -1944,7 +1943,7 @@ static hawk_ooi_t awk_rio_file (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_ar
if (handle == HAWK_NULL) if (handle == HAWK_NULL)
{ {
const hawk_ooch_t* bem = hawk_rtx_backuperrmsg(rtx); const hawk_ooch_t* bem = hawk_rtx_backuperrmsg(rtx);
hawk_rtx_seterrbfmt (rtx, HAWK_NULL, HAWK_EOPEN, "unable to open %js - %js", riod->name, bem); hawk_rtx_seterrfmt (rtx, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), riod->name, bem);
return -1; return -1;
} }
@ -2093,7 +2092,7 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
if (hawk_count_oocstr(as.ptr) < as.len) if (hawk_count_oocstr(as.ptr) < as.len)
{ {
/* the name contains one or more '\0' */ /* the name contains one or more '\0' */
hawk_rtx_seterrfmt (rtx, HAWK_NULL, HAWK_EIONMNL, HAWK_T("I/O name beginning with '%js' of length %zu containing '\\0'"), as.ptr, as.len); hawk_rtx_seterrfmt (rtx, HAWK_NULL, HAWK_EIONMNL, HAWK_T("invalid I/O name beginning with '%js' of length %zu containing '\\0'"), as.ptr, as.len);
hawk_rtx_freevaloocstr (rtx, v, as.ptr); hawk_rtx_freevaloocstr (rtx, v, as.ptr);
return -1; return -1;
} }

View File

@ -148,6 +148,7 @@
case EBUSY: return _SYSERRNUM__(obj2, EBUSY); \ case EBUSY: return _SYSERRNUM__(obj2, EBUSY); \
case EACCES: return __SYSERRNUM__(obj2, EACCES); \ case EACCES: return __SYSERRNUM__(obj2, EACCES); \
case EPERM: return __SYSERRNUM__(obj2, EPERM); \ case EPERM: return __SYSERRNUM__(obj2, EPERM); \
case EISDIR: return __SYSERRNUM__(obj2, EISDIR); \
case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \ case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \
case ENXIO: \ case ENXIO: \
case ENODEV: \ case ENODEV: \
@ -176,6 +177,7 @@
case EBUSY: return __SYSERRNUM__(obj2, EBUSY); \ case EBUSY: return __SYSERRNUM__(obj2, EBUSY); \
case EACCES: return __SYSERRNUM__(obj2, EACCES); \ case EACCES: return __SYSERRNUM__(obj2, EACCES); \
case EPERM: return __SYSERRNUM__(obj2, EPERM); \ case EPERM: return __SYSERRNUM__(obj2, EPERM); \
case EISDIR: return __SYSERRNUM__(obj2, EISDIR); \
case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \ case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \
case ENXIO: \ case ENXIO: \
case ENODEV: \ case ENODEV: \
@ -203,6 +205,7 @@
case EBUSY: return __SYSERRNUM__(obj2, EBUSY); \ case EBUSY: return __SYSERRNUM__(obj2, EBUSY); \
case EACCES: return __SYSERRNUM__(obj2, EACCES); \ case EACCES: return __SYSERRNUM__(obj2, EACCES); \
case EPERM: return __SYSERRNUM__(obj2, EPERM); \ case EPERM: return __SYSERRNUM__(obj2, EPERM); \
case EISDIR: return __SYSERRNUM__(obj2, EISDIR); \
case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \ case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \
case ENXIO: \ case ENXIO: \
case ENODEV: \ case ENODEV: \
@ -230,6 +233,7 @@
case EBUSY: return __SYSERRNUM__(obj2, EBUSY); \ case EBUSY: return __SYSERRNUM__(obj2, EBUSY); \
case EACCES: return __SYSERRNUM__(obj2, EACCES); \ case EACCES: return __SYSERRNUM__(obj2, EACCES); \
case EPERM: return __SYSERRNUM__(obj2, EPERM); \ case EPERM: return __SYSERRNUM__(obj2, EPERM); \
case EISDIR: return __SYSERRNUM__(obj2, EISDIR); \
case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \ case ENOTDIR: return __SYSERRNUM__(obj2, ENOTDIR); \
case ENXIO: \ case ENXIO: \
case ENODEV: \ case ENODEV: \

View File

@ -762,7 +762,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
default: default:
{ {
hawk_seterrnum (awk, HAWK_EINTERN, HAWK_NULL); hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN);
return -1; return -1;
} }
} }