added hcl_seterrbfmtloc() and hcl_seterrufmtloc()
All checks were successful
continuous-integration/drone/push Build is passing

added the errloc field to hcl_t to capture the exception location
This commit is contained in:
2024-04-05 01:26:02 +09:00
parent 4be0299de3
commit b91e48d2a1
5 changed files with 105 additions and 23 deletions

View File

@ -286,6 +286,12 @@ void hcl_seterrnum (hcl_t* hcl, hcl_errnum_t errnum)
if (hcl->shuterr) return;
hcl->errnum = errnum;
hcl->errmsg.len = 0;
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
}
void hcl_geterrloc (hcl_t* hcl, hcl_loc_t* loc)
{
if (loc) *loc = hcl->errloc;
}
void hcl_seterrbmsg (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* errmsg)
@ -293,7 +299,6 @@ void hcl_seterrbmsg (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* errmsg)
hcl_seterrbfmt(hcl, errnum, "%hs", errmsg);
}
void hcl_seterrumsg (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* errmsg)
{
hcl_seterrbfmt(hcl, errnum, "%ls", errmsg);
@ -363,6 +368,7 @@ void hcl_seterrbfmt (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* fmt, ...)
va_end (ap);
hcl->errnum = errnum;
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
}
void hcl_seterrufmt (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, ...)
@ -384,6 +390,7 @@ void hcl_seterrufmt (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, ...)
va_end (ap);
hcl->errnum = errnum;
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
}
@ -403,6 +410,7 @@ void hcl_seterrbfmtv (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* fmt, va_
hcl_bfmt_outv (&fo, fmt, ap);
hcl->errnum = errnum;
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
}
void hcl_seterrufmtv (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, va_list ap)
@ -421,9 +429,26 @@ void hcl_seterrufmtv (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, va_
hcl_ufmt_outv (&fo, fmt, ap);
hcl->errnum = errnum;
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
}
void hcl_seterrbfmtloc (hcl_t* hcl, hcl_errnum_t errnum, const hcl_loc_t* loc, const hcl_bch_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
hcl_seterrbfmtv (hcl, errnum, fmt, ap);
va_end (ap);
hcl->errloc = *loc;
}
void hcl_seterrufmtloc (hcl_t* hcl, hcl_errnum_t errnum, const hcl_loc_t* loc, const hcl_uch_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
hcl_seterrufmtv (hcl, errnum, fmt, ap);
va_end (ap);
hcl->errloc = *loc;
}
void hcl_seterrwithsyserr (hcl_t* hcl, int syserr_type, int syserr_code)
{