pushing some common code to gem.c
This commit is contained in:
parent
043a24a4ea
commit
859a27db55
@ -166,8 +166,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \
|
||||
$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \
|
||||
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
|
||||
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
|
||||
ac/compile ac/config.guess ac/config.sub ac/install-sh \
|
||||
ac/ltmain.sh ac/missing
|
||||
ac/compile ac/config.guess ac/config.sub ac/depcomp \
|
||||
ac/install-sh ac/ltmain.sh ac/missing
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
|
@ -408,7 +408,7 @@ static void dprint_return (hawk_rtx_t* rtx, hawk_val_t* ret)
|
||||
else
|
||||
{
|
||||
dprint (HAWK_T("[RETURN] - [%.*s]\n"), (int)len, str);
|
||||
hawk_freemem (hawk_rtx_getawk(rtx), str);
|
||||
hawk_freemem (hawk_rtx_gethawk(rtx), str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -944,7 +944,7 @@ static void print_hawk_rtx_error (hawk_rtx_t* rtx)
|
||||
/* TODO: proper logging mask */
|
||||
printf ("print_hawk_rtx_error... TODO: \n");
|
||||
/*
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), 0,
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), 0,
|
||||
HAWK_T("ERROR: CODE %d LINE %zu COLUMN %zu %s%s%s- %s\n"),
|
||||
hawk_rtx_geterrnum(rtx),
|
||||
(hawk_oow_t)loc->line,
|
||||
|
@ -53,6 +53,7 @@ pkginclude_HEADERS = \
|
||||
hawk-cmn.h \
|
||||
hawk-ecs.h \
|
||||
hawk-fmt.h \
|
||||
hawk-gem.h \
|
||||
hawk-htb.h \
|
||||
hawk-rbt.h \
|
||||
hawk-pack1.h \
|
||||
@ -82,6 +83,7 @@ libhawk_la_SOURCES = \
|
||||
fnc-prv.h \
|
||||
fnc.c \
|
||||
htb.c \
|
||||
gem.c \
|
||||
hawk-prv.h \
|
||||
hawk.c \
|
||||
mb8.c \
|
||||
|
@ -160,15 +160,15 @@ am__DEPENDENCIES_1 =
|
||||
am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
|
||||
$(am__DEPENDENCIES_3)
|
||||
am__libhawk_la_SOURCES_DIST = hawk.h hawk-chr.h hawk-cmn.h hawk-ecs.h \
|
||||
hawk-fmt.h hawk-htb.h hawk-rbt.h hawk-pack1.h hawk-pma.h \
|
||||
hawk-utl.h hawk-std.h hawk-tre.h hawk-unpack.h arr.c chr.c \
|
||||
ecs-imp.h ecs.c err-prv.h err.c fmt-imp.h fmt.c fnc-prv.h \
|
||||
fnc.c htb.c hawk-prv.h hawk.c mb8.c misc-imp.h misc-prv.h \
|
||||
misc.c parse-prv.h parse.c pma.c rbt.c rec.c rio-prv.h rio.c \
|
||||
run-prv.h run.c tre-prv.h tre-ast.c tre-ast.h tre-compile.c \
|
||||
tre-compile.h tre-match-bt.c tre-match-pa.c tre-match-ut.h \
|
||||
tre-parse.c tre-parse.h tre-stack.c tre-stack.h tre.c \
|
||||
tree-prv.h tree.c utf16.c utf8.c utl-sort.c utl-str.c \
|
||||
hawk-fmt.h hawk-gem.h hawk-htb.h hawk-rbt.h hawk-pack1.h \
|
||||
hawk-pma.h hawk-utl.h hawk-std.h hawk-tre.h hawk-unpack.h \
|
||||
arr.c chr.c ecs-imp.h ecs.c err-prv.h err.c fmt-imp.h fmt.c \
|
||||
fnc-prv.h fnc.c htb.c gem.c hawk-prv.h hawk.c mb8.c misc-imp.h \
|
||||
misc-prv.h misc.c parse-prv.h parse.c pma.c rbt.c rec.c \
|
||||
rio-prv.h rio.c run-prv.h run.c tre-prv.h tre-ast.c tre-ast.h \
|
||||
tre-compile.c tre-compile.h tre-match-bt.c tre-match-pa.c \
|
||||
tre-match-ut.h tre-parse.c tre-parse.h tre-stack.c tre-stack.h \
|
||||
tre.c tree-prv.h tree.c utf16.c utf8.c utl-sort.c utl-str.c \
|
||||
utl-sys.c utl.c val-imp.h val-prv.h val.c hawk-cli.h \
|
||||
hawk-fio.h hawk-mtx.h hawk-pio.h hawk-sio.h hawk-tio.h cli.c \
|
||||
fio.c mtx.c pio.c sio.c syscall.h syserr.h tio.c std-prv.h \
|
||||
@ -179,14 +179,14 @@ am__objects_1 =
|
||||
am_libhawk_la_OBJECTS = $(am__objects_1) libhawk_la-arr.lo \
|
||||
libhawk_la-chr.lo libhawk_la-ecs.lo libhawk_la-err.lo \
|
||||
libhawk_la-fmt.lo libhawk_la-fnc.lo libhawk_la-htb.lo \
|
||||
libhawk_la-hawk.lo libhawk_la-mb8.lo libhawk_la-misc.lo \
|
||||
libhawk_la-parse.lo libhawk_la-pma.lo libhawk_la-rbt.lo \
|
||||
libhawk_la-rec.lo libhawk_la-rio.lo libhawk_la-run.lo \
|
||||
libhawk_la-tre-ast.lo libhawk_la-tre-compile.lo \
|
||||
libhawk_la-tre-match-bt.lo libhawk_la-tre-match-pa.lo \
|
||||
libhawk_la-tre-parse.lo libhawk_la-tre-stack.lo \
|
||||
libhawk_la-tre.lo libhawk_la-tree.lo libhawk_la-utf16.lo \
|
||||
libhawk_la-utf8.lo libhawk_la-utl-sort.lo \
|
||||
libhawk_la-gem.lo libhawk_la-hawk.lo libhawk_la-mb8.lo \
|
||||
libhawk_la-misc.lo libhawk_la-parse.lo libhawk_la-pma.lo \
|
||||
libhawk_la-rbt.lo libhawk_la-rec.lo libhawk_la-rio.lo \
|
||||
libhawk_la-run.lo libhawk_la-tre-ast.lo \
|
||||
libhawk_la-tre-compile.lo libhawk_la-tre-match-bt.lo \
|
||||
libhawk_la-tre-match-pa.lo libhawk_la-tre-parse.lo \
|
||||
libhawk_la-tre-stack.lo libhawk_la-tre.lo libhawk_la-tree.lo \
|
||||
libhawk_la-utf16.lo libhawk_la-utf8.lo libhawk_la-utl-sort.lo \
|
||||
libhawk_la-utl-str.lo libhawk_la-utl-sys.lo libhawk_la-utl.lo \
|
||||
libhawk_la-val.lo libhawk_la-cli.lo libhawk_la-fio.lo \
|
||||
libhawk_la-mtx.lo libhawk_la-pio.lo libhawk_la-sio.lo \
|
||||
@ -226,9 +226,9 @@ am__depfiles_remade = ./$(DEPDIR)/libhawk_la-arr.Plo \
|
||||
./$(DEPDIR)/libhawk_la-chr.Plo ./$(DEPDIR)/libhawk_la-cli.Plo \
|
||||
./$(DEPDIR)/libhawk_la-ecs.Plo ./$(DEPDIR)/libhawk_la-err.Plo \
|
||||
./$(DEPDIR)/libhawk_la-fio.Plo ./$(DEPDIR)/libhawk_la-fmt.Plo \
|
||||
./$(DEPDIR)/libhawk_la-fnc.Plo ./$(DEPDIR)/libhawk_la-hawk.Plo \
|
||||
./$(DEPDIR)/libhawk_la-htb.Plo ./$(DEPDIR)/libhawk_la-mb8.Plo \
|
||||
./$(DEPDIR)/libhawk_la-misc.Plo \
|
||||
./$(DEPDIR)/libhawk_la-fnc.Plo ./$(DEPDIR)/libhawk_la-gem.Plo \
|
||||
./$(DEPDIR)/libhawk_la-hawk.Plo ./$(DEPDIR)/libhawk_la-htb.Plo \
|
||||
./$(DEPDIR)/libhawk_la-mb8.Plo ./$(DEPDIR)/libhawk_la-misc.Plo \
|
||||
./$(DEPDIR)/libhawk_la-mod-math.Plo \
|
||||
./$(DEPDIR)/libhawk_la-mod-str.Plo \
|
||||
./$(DEPDIR)/libhawk_la-mtx.Plo \
|
||||
@ -516,6 +516,7 @@ pkginclude_HEADERS = \
|
||||
hawk-cmn.h \
|
||||
hawk-ecs.h \
|
||||
hawk-fmt.h \
|
||||
hawk-gem.h \
|
||||
hawk-htb.h \
|
||||
hawk-rbt.h \
|
||||
hawk-pack1.h \
|
||||
@ -527,7 +528,7 @@ pkginclude_HEADERS = \
|
||||
|
||||
pkglib_LTLIBRARIES = libhawk.la $(am__append_5)
|
||||
libhawk_la_SOURCES = $(pkginclude_HEADERS) arr.c chr.c ecs-imp.h ecs.c \
|
||||
err-prv.h err.c fmt-imp.h fmt.c fnc-prv.h fnc.c htb.c \
|
||||
err-prv.h err.c fmt-imp.h fmt.c fnc-prv.h fnc.c htb.c gem.c \
|
||||
hawk-prv.h hawk.c mb8.c misc-imp.h misc-prv.h misc.c \
|
||||
parse-prv.h parse.c pma.c rbt.c rec.c rio-prv.h rio.c \
|
||||
run-prv.h run.c tre-prv.h tre-ast.c tre-ast.h tre-compile.c \
|
||||
@ -662,6 +663,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-fio.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-fmt.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-fnc.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-gem.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-hawk.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-htb.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-mb8.Plo@am__quote@ # am--include-marker
|
||||
@ -776,6 +778,13 @@ libhawk_la-htb.lo: htb.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhawk_la-htb.lo `test -f 'htb.c' || echo '$(srcdir)/'`htb.c
|
||||
|
||||
libhawk_la-gem.lo: gem.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhawk_la-gem.lo -MD -MP -MF $(DEPDIR)/libhawk_la-gem.Tpo -c -o libhawk_la-gem.lo `test -f 'gem.c' || echo '$(srcdir)/'`gem.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-gem.Tpo $(DEPDIR)/libhawk_la-gem.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gem.c' object='libhawk_la-gem.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhawk_la-gem.lo `test -f 'gem.c' || echo '$(srcdir)/'`gem.c
|
||||
|
||||
libhawk_la-hawk.lo: hawk.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhawk_la-hawk.lo -MD -MP -MF $(DEPDIR)/libhawk_la-hawk.Tpo -c -o libhawk_la-hawk.lo `test -f 'hawk.c' || echo '$(srcdir)/'`hawk.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-hawk.Tpo $(DEPDIR)/libhawk_la-hawk.Plo
|
||||
@ -1208,6 +1217,7 @@ distclean: distclean-am
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-fio.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-fmt.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-fnc.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-gem.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-hawk.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-htb.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-mb8.Plo
|
||||
@ -1295,6 +1305,7 @@ maintainer-clean: maintainer-clean-am
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-fio.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-fmt.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-fnc.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-gem.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-hawk.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-htb.Plo
|
||||
-rm -f ./$(DEPDIR)/libhawk_la-mb8.Plo
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include "hawk-prv.h"
|
||||
|
||||
static hawk_loc_t _nullloc = { 0, 0, HAWK_NULL };
|
||||
|
||||
const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum)
|
||||
{
|
||||
static const hawk_ooch_t* errstr[] =
|
||||
@ -188,7 +190,7 @@ void hawk_seterrstr (hawk_t* hawk, hawk_errstr_t errstr)
|
||||
|
||||
const hawk_loc_t* hawk_geterrloc (hawk_t* hawk)
|
||||
{
|
||||
return &hawk->errloc;
|
||||
return &hawk->_gem.errloc;
|
||||
}
|
||||
|
||||
const hawk_bch_t* hawk_geterrbmsg (hawk_t* hawk)
|
||||
@ -228,7 +230,7 @@ const hawk_uch_t* hawk_geterrumsg (hawk_t* hawk)
|
||||
void hawk_geterrinf (hawk_t* hawk, hawk_errinf_t* errinf)
|
||||
{
|
||||
errinf->num = hawk->_gem.errnum;
|
||||
errinf->loc = hawk->errloc;
|
||||
errinf->loc = hawk->_gem.errloc;
|
||||
hawk_copy_oocstr (errinf->msg, HAWK_COUNTOF(errinf->msg), (hawk->_gem.errmsg[0] == '\0'? hawk_geterrstr(hawk)(hawk, hawk->_gem.errnum): hawk->_gem.errmsg));
|
||||
}
|
||||
|
||||
@ -236,7 +238,7 @@ void hawk_geterror (hawk_t* hawk, hawk_errnum_t* errnum, const hawk_ooch_t** err
|
||||
{
|
||||
if (errnum) *errnum = hawk->_gem.errnum;
|
||||
if (errmsg) *errmsg = (hawk->_gem.errmsg[0] == '\0')? hawk_geterrstr(hawk)(hawk, hawk->_gem.errnum): hawk->_gem.errmsg;
|
||||
if (errloc) *errloc = hawk->errloc;
|
||||
if (errloc) *errloc = hawk->_gem.errloc;
|
||||
}
|
||||
|
||||
const hawk_ooch_t* hawk_backuperrmsg (hawk_t* hawk)
|
||||
@ -254,7 +256,7 @@ void hawk_seterrinf (hawk_t* hawk, const hawk_errinf_t* errinf)
|
||||
{
|
||||
hawk->_gem.errnum = errinf->num;
|
||||
hawk_copy_oocstr(hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errinf->msg);
|
||||
hawk->errloc = errinf->loc;
|
||||
hawk->_gem.errloc = errinf->loc;
|
||||
}
|
||||
|
||||
static int err_bchars (hawk_fmtout_t* fmtout, const hawk_bch_t* ptr, hawk_oow_t len)
|
||||
@ -322,8 +324,7 @@ void hawk_seterrbfmt (hawk_t* hawk, hawk_errnum_t errnum, hawk_loc_t* errloc, co
|
||||
va_end (ap);
|
||||
|
||||
hawk->_gem.errnum = errnum;
|
||||
if (errloc) hawk->errloc = *errloc;
|
||||
else HAWK_MEMSET (&hawk->errloc, 0, HAWK_SIZEOF(hawk->errloc));
|
||||
hawk->_gem.errloc = (errloc? *errloc: _nullloc);
|
||||
}
|
||||
|
||||
void hawk_seterrufmt (hawk_t* hawk, hawk_errnum_t errnum, hawk_loc_t* errloc, const hawk_uch_t* errfmt, ...)
|
||||
@ -346,8 +347,7 @@ void hawk_seterrufmt (hawk_t* hawk, hawk_errnum_t errnum, hawk_loc_t* errloc, co
|
||||
va_end (ap);
|
||||
|
||||
hawk->_gem.errnum = errnum;
|
||||
if (errloc) hawk->errloc = *errloc;
|
||||
else HAWK_MEMSET (&hawk->errloc, 0, HAWK_SIZEOF(hawk->errloc));
|
||||
hawk->_gem.errloc = (errloc? *errloc: _nullloc);
|
||||
}
|
||||
|
||||
void hawk_seterror (hawk_t* hawk, hawk_errnum_t errnum, const hawk_oocs_t* errarg, const hawk_loc_t* errloc)
|
||||
@ -364,26 +364,25 @@ void hawk_seterror (hawk_t* hawk, hawk_errnum_t errnum, const hawk_oocs_t* errar
|
||||
*/
|
||||
hawk_copy_oocstr(hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt);
|
||||
/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */
|
||||
if (errloc) hawk->errloc = *errloc;
|
||||
else HAWK_MEMSET (&hawk->errloc, 0, HAWK_SIZEOF(hawk->errloc));
|
||||
hawk->_gem.errloc = (errloc? *errloc: _nullloc);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
const hawk_loc_t* hawk_rtx_geterrloc (hawk_rtx_t* rtx)
|
||||
{
|
||||
return &rtx->errloc;
|
||||
return &rtx->_gem.errloc;
|
||||
}
|
||||
|
||||
const hawk_bch_t* hawk_rtx_geterrbmsg (hawk_rtx_t* rtx)
|
||||
{
|
||||
#if defined(MOO_OOCH_IS_BCH)
|
||||
return (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(awk)(rtx->awk, rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
return (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(awk)(hawk_rtx_gethawk(rtx), rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
#else
|
||||
const hawk_ooch_t* msg;
|
||||
hawk_oow_t wcslen, mbslen;
|
||||
|
||||
msg = (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(rtx->awk)(rtx->awk, rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
msg = (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
|
||||
mbslen = HAWK_COUNTOF(rtx->berrmsg);
|
||||
hawk_conv_ucstr_to_bcstr_with_cmgr (msg, &wcslen, rtx->berrmsg, &mbslen, hawk_rtx_getcmgr(rtx));
|
||||
@ -398,29 +397,29 @@ const hawk_uch_t* hawk_rtx_geterrumsg (hawk_rtx_t* rtx)
|
||||
const hawk_ooch_t* msg;
|
||||
hawk_oow_t wcslen, mbslen;
|
||||
|
||||
msg = (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(rtx->awk)(rtx->awk, rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
msg = (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
|
||||
wcslen = HAWK_COUNTOF(rtx->uerrmsg);
|
||||
hawk_conv_bcstr_to_ucstr_with_cmgr (msg, &mbslen, rtx->uerrmsg, &wcslen, hawk_rtx_getcmgr(rtx), 1);
|
||||
|
||||
return rtx->uerrmsg;
|
||||
#else
|
||||
return (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(rtx->awk)(rtx->awk, rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
return (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
#endif
|
||||
}
|
||||
|
||||
void hawk_rtx_geterrinf (hawk_rtx_t* rtx, hawk_errinf_t* errinf)
|
||||
{
|
||||
errinf->num = rtx->_gem.errnum;
|
||||
errinf->loc = rtx->errloc;
|
||||
hawk_copy_oocstr (errinf->msg, HAWK_COUNTOF(errinf->msg), (rtx->_gem.errmsg[0] == '\0'? hawk_geterrstr(rtx->awk)(rtx->awk, rtx->_gem.errnum): rtx->_gem.errmsg));
|
||||
errinf->loc = rtx->_gem.errloc;
|
||||
hawk_copy_oocstr (errinf->msg, HAWK_COUNTOF(errinf->msg), (rtx->_gem.errmsg[0] == '\0'? hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), rtx->_gem.errnum): rtx->_gem.errmsg));
|
||||
}
|
||||
|
||||
void hawk_rtx_geterror (hawk_rtx_t* rtx, hawk_errnum_t* errnum, const hawk_ooch_t** errmsg, hawk_loc_t* errloc)
|
||||
{
|
||||
if (errnum) *errnum = rtx->_gem.errnum;
|
||||
if (errmsg) *errmsg = (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(rtx->awk)(rtx->awk, rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
if (errloc) *errloc = rtx->errloc;
|
||||
if (errmsg) *errmsg = (rtx->_gem.errmsg[0] == '\0')? hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), rtx->_gem.errnum): rtx->_gem.errmsg;
|
||||
if (errloc) *errloc = rtx->_gem.errloc;
|
||||
}
|
||||
|
||||
const hawk_ooch_t* hawk_rtx_backuperrmsg (hawk_rtx_t* rtx)
|
||||
@ -438,7 +437,7 @@ void hawk_rtx_seterrinf (hawk_rtx_t* rtx, const hawk_errinf_t* errinf)
|
||||
{
|
||||
rtx->_gem.errnum = errinf->num;
|
||||
hawk_copy_oocstr(rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errinf->msg);
|
||||
rtx->errloc = errinf->loc;
|
||||
rtx->_gem.errloc = errinf->loc;
|
||||
}
|
||||
|
||||
|
||||
@ -506,8 +505,7 @@ void hawk_rtx_seterrbfmt (hawk_rtx_t* rtx, hawk_errnum_t errnum, const hawk_loc_
|
||||
va_end (ap);
|
||||
|
||||
rtx->_gem.errnum = errnum;
|
||||
if (errloc) rtx->errloc = *errloc;
|
||||
else HAWK_MEMSET (&rtx->errloc, 0, HAWK_SIZEOF(rtx->errloc));
|
||||
rtx->_gem.errloc = (errloc? *errloc: _nullloc);
|
||||
}
|
||||
|
||||
void hawk_rtx_seterrufmt (hawk_rtx_t* rtx, hawk_errnum_t errnum, const hawk_loc_t* errloc, const hawk_uch_t* errfmt, ...)
|
||||
@ -530,8 +528,7 @@ void hawk_rtx_seterrufmt (hawk_rtx_t* rtx, hawk_errnum_t errnum, const hawk_loc_
|
||||
va_end (ap);
|
||||
|
||||
rtx->_gem.errnum = errnum;
|
||||
if (errloc) rtx->errloc = *errloc;
|
||||
else HAWK_MEMSET (&rtx->errloc, 0, HAWK_SIZEOF(rtx->errloc));
|
||||
rtx->_gem.errloc = (errloc? *errloc: _nullloc);
|
||||
}
|
||||
|
||||
|
||||
@ -542,20 +539,28 @@ void hawk_rtx_seterror (hawk_rtx_t* rtx, hawk_errnum_t errnum, const hawk_oocs_t
|
||||
|
||||
rtx->_gem.errnum = errnum;
|
||||
|
||||
errfmt = hawk_geterrstr(rtx->awk)(rtx->awk, errnum);
|
||||
errfmt = hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), errnum);
|
||||
HAWK_ASSERT (awk, errfmt != HAWK_NULL);
|
||||
/* TODO: this change is buggy... copying won't process arguments...
|
||||
qse_strxfncpy (rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errfmt, errarg);
|
||||
*/
|
||||
hawk_copy_oocstr(rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errfmt);
|
||||
/* TODO: remove awk_rtx_seterror() and substitute hawk_rtx_seterrfmt()/seterrbfmt()/seterrufmt() */
|
||||
if (errloc) rtx->errloc = *errloc;
|
||||
else HAWK_MEMSET (&rtx->errloc, 0, HAWK_SIZEOF(rtx->errloc));
|
||||
rtx->_gem.errloc = (errloc? *errloc: _nullloc);
|
||||
}
|
||||
|
||||
void hawk_rtx_errortohawk (hawk_rtx_t* rtx, hawk_t* hawk)
|
||||
{
|
||||
hawk->_gem.errnum = rtx->_gem.errnum;
|
||||
hawk->errloc = rtx->errloc;
|
||||
hawk->_gem.errloc = rtx->_gem.errloc;
|
||||
hawk_copy_oocstr (hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), rtx->_gem.errmsg);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
void hawk_gem_seterrnum (hawk_gem_t* gem, const hawk_loc_t* errloc, hawk_errnum_t errnum)
|
||||
{
|
||||
gem->errnum = errnum;
|
||||
gem->errmsg[0] = '\0';
|
||||
gem->errloc = (errloc? *errloc: _nullloc);
|
||||
}
|
||||
|
@ -350,11 +350,11 @@ static int fnc_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_oow_t len, optlen = 0;
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 1 || nargs == 2);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 1 || nargs == 2);
|
||||
|
||||
a0 = hawk_rtx_getarg (rtx, 0);
|
||||
if (nargs >= 2) a1 = hawk_rtx_getarg(rtx, 1);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), a0 != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a0 != HAWK_NULL);
|
||||
|
||||
name = hawk_rtx_getvaloocstr(rtx, a0, &len);
|
||||
if (name == HAWK_NULL) return -1;
|
||||
@ -462,7 +462,7 @@ static int fnc_fflush (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int n;
|
||||
|
||||
nargs = hawk_rtx_getnargs (rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 0 || nargs == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 0 || nargs == 1);
|
||||
|
||||
if (nargs == 0)
|
||||
{
|
||||
@ -692,7 +692,7 @@ int hawk_fnc_length (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_oow_t len;
|
||||
|
||||
nargs = hawk_rtx_getnargs (rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs >= 0 && nargs <= 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 0 && nargs <= 1);
|
||||
|
||||
if (nargs == 0)
|
||||
{
|
||||
@ -743,7 +743,7 @@ int hawk_fnc_substr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int n;
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs >= 2 && nargs <= 3);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 3);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
a1 = hawk_rtx_getarg(rtx, 1);
|
||||
@ -821,14 +821,14 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
str.len = 0;
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs >= 2 && nargs <= 3);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 3);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
a1 = hawk_rtx_getarg(rtx, 1);
|
||||
a2 = (nargs >= 3)? hawk_rtx_getarg (rtx, 2): HAWK_NULL;
|
||||
|
||||
a1_vtype = HAWK_RTX_GETVALTYPE (rtx, a1);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), a1_vtype == HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a1_vtype == HAWK_VAL_REF);
|
||||
|
||||
str.ptr = hawk_rtx_getvaloocstr(rtx, a0, &str.len);
|
||||
if (str.ptr == HAWK_NULL) goto oops;
|
||||
@ -890,9 +890,9 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int x;
|
||||
|
||||
if (rtx->gbl.ignorecase)
|
||||
x = hawk_buildrex(hawk_rtx_getawk(rtx), fs.ptr, fs.len, &errnum, HAWK_NULL, &fs_rex);
|
||||
x = hawk_buildrex(hawk_rtx_gethawk(rtx), fs.ptr, fs.len, &errnum, HAWK_NULL, &fs_rex);
|
||||
else
|
||||
x = hawk_buildrex(hawk_rtx_getawk(rtx), fs.ptr, fs.len, &errnum, &fs_rex, HAWK_NULL);
|
||||
x = hawk_buildrex(hawk_rtx_gethawk(rtx), fs.ptr, fs.len, &errnum, &fs_rex, HAWK_NULL);
|
||||
|
||||
if (x <= -1)
|
||||
{
|
||||
@ -942,7 +942,7 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
break;
|
||||
}
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
|
||||
|
||||
/* create the field string - however, the split function must
|
||||
* create a numeric string if the string is a number */
|
||||
@ -952,7 +952,7 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
|
||||
/* put it into the map */
|
||||
key_len = hawk_int_to_oocstr(++nflds, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), key_len != (hawk_oow_t)-1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), key_len != (hawk_oow_t)-1);
|
||||
|
||||
if (hawk_rtx_setmapvalfld(rtx, t1, key_buf, key_len, t2) == HAWK_NULL)
|
||||
{
|
||||
@ -972,9 +972,9 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
if (fs_rex_free)
|
||||
{
|
||||
if (rtx->gbl.ignorecase)
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), HAWK_NULL, fs_rex_free);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), HAWK_NULL, fs_rex_free);
|
||||
else
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), fs_rex_free, HAWK_NULL);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), fs_rex_free, HAWK_NULL);
|
||||
}
|
||||
|
||||
/*nflds--;*/
|
||||
@ -994,9 +994,9 @@ oops:
|
||||
if (fs_rex_free)
|
||||
{
|
||||
if (rtx->gbl.ignorecase)
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), HAWK_NULL, fs_rex_free);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), HAWK_NULL, fs_rex_free);
|
||||
else
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), fs_rex_free, HAWK_NULL);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), fs_rex_free, HAWK_NULL);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@ -1008,7 +1008,7 @@ int hawk_fnc_tolower (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_val_t* a0, * r;
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 1);
|
||||
|
||||
a0 = hawk_rtx_getarg (rtx, 0);
|
||||
if (HAWK_RTX_GETVALTYPE(rtx, a0) == HAWK_VAL_MBS)
|
||||
@ -1046,7 +1046,7 @@ int hawk_fnc_toupper (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_val_t* a0, * r;
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 1);
|
||||
|
||||
a0 = hawk_rtx_getarg (rtx, 0);
|
||||
if (HAWK_RTX_GETVALTYPE(rtx, a0) == HAWK_VAL_MBS)
|
||||
@ -1104,14 +1104,14 @@ static int __substitute (hawk_rtx_t* rtx, hawk_int_t max_count)
|
||||
s1.len = 0;
|
||||
|
||||
nargs = hawk_rtx_getnargs (rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs >= 2 && nargs <= 3);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 3);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
a1 = hawk_rtx_getarg(rtx, 1);
|
||||
a2 = (nargs >= 3)? hawk_rtx_getarg(rtx, 2): HAWK_NULL;
|
||||
|
||||
a0_vtype = HAWK_RTX_GETVALTYPE (rtx, a0);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), a2 == HAWK_NULL || HAWK_RTX_GETVALTYPE(rtx, a2) == HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a2 == HAWK_NULL || HAWK_RTX_GETVALTYPE(rtx, a2) == HAWK_VAL_REF);
|
||||
|
||||
if (a0_vtype == HAWK_VAL_REX)
|
||||
{
|
||||
@ -1145,7 +1145,7 @@ static int __substitute (hawk_rtx_t* rtx, hawk_int_t max_count)
|
||||
s2_free = (hawk_ooch_t*)s2.ptr;
|
||||
}
|
||||
|
||||
if (hawk_ooecs_init (&new, hawk_rtx_getawk(rtx), s2.len) <= -1)
|
||||
if (hawk_ooecs_init (&new, hawk_rtx_gethawk(rtx), s2.len) <= -1)
|
||||
{
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
goto oops;
|
||||
@ -1158,9 +1158,9 @@ static int __substitute (hawk_rtx_t* rtx, hawk_int_t max_count)
|
||||
int x;
|
||||
|
||||
if (rtx->gbl.ignorecase)
|
||||
x = hawk_buildrex (hawk_rtx_getawk(rtx), s0.ptr, s0.len, &errnum, HAWK_NULL, &rex);
|
||||
x = hawk_buildrex (hawk_rtx_gethawk(rtx), s0.ptr, s0.len, &errnum, HAWK_NULL, &rex);
|
||||
else
|
||||
x = hawk_buildrex (hawk_rtx_getawk(rtx), s0.ptr, s0.len, &errnum, &rex, HAWK_NULL);
|
||||
x = hawk_buildrex (hawk_rtx_gethawk(rtx), s0.ptr, s0.len, &errnum, &rex, HAWK_NULL);
|
||||
|
||||
if (x <= -1)
|
||||
{
|
||||
@ -1190,7 +1190,7 @@ static int __substitute (hawk_rtx_t* rtx, hawk_int_t max_count)
|
||||
if (max_count == 0 || sub_count < max_count)
|
||||
{
|
||||
n = hawk_matchrex (
|
||||
hawk_rtx_getawk(rtx), rex, rtx->gbl.ignorecase,
|
||||
hawk_rtx_gethawk(rtx), rex, rtx->gbl.ignorecase,
|
||||
&s2, &cur, &mat, HAWK_NULL, &errnum
|
||||
);
|
||||
}
|
||||
@ -1275,9 +1275,9 @@ static int __substitute (hawk_rtx_t* rtx, hawk_int_t max_count)
|
||||
if (rex_free)
|
||||
{
|
||||
if (rtx->gbl.ignorecase)
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), HAWK_NULL, rex_free);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), HAWK_NULL, rex_free);
|
||||
else
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), rex_free, HAWK_NULL);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), rex_free, HAWK_NULL);
|
||||
rex_free = HAWK_NULL;
|
||||
}
|
||||
|
||||
@ -1320,9 +1320,9 @@ oops:
|
||||
if (rex_free)
|
||||
{
|
||||
if (rtx->gbl.ignorecase)
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), HAWK_NULL, rex_free);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), HAWK_NULL, rex_free);
|
||||
else
|
||||
hawk_freerex (hawk_rtx_getawk(rtx), rex_free, HAWK_NULL);
|
||||
hawk_freerex (hawk_rtx_gethawk(rtx), rex_free, HAWK_NULL);
|
||||
}
|
||||
if (new_inited) hawk_ooecs_fini (&new);
|
||||
if (s2_free) hawk_rtx_freemem (rtx, s2_free);
|
||||
@ -1354,7 +1354,7 @@ int hawk_fnc_match (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_ooecs_t* tmpbuf = HAWK_NULL;
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs >= 2 && nargs <= 4);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 4);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
a1 = hawk_rtx_getarg(rtx, 1);
|
||||
@ -1421,7 +1421,7 @@ int hawk_fnc_match (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_oow_t i, xlen;
|
||||
hawk_val_t* tv;
|
||||
|
||||
tmpbuf = hawk_ooecs_open(hawk_rtx_getawk(rtx), 0, 64);
|
||||
tmpbuf = hawk_ooecs_open(hawk_rtx_gethawk(rtx), 0, 64);
|
||||
if (!tmpbuf) goto oops;
|
||||
|
||||
x2 = hawk_rtx_makemapval(rtx);
|
||||
@ -1496,7 +1496,7 @@ int hawk_fnc_sprintf (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_val_t* a0;
|
||||
|
||||
nargs = hawk_rtx_getnargs (rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs > 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs > 0);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
if (HAWK_RTX_GETVALTYPE(rtx, a0) == HAWK_VAL_MBS)
|
||||
@ -1506,14 +1506,14 @@ int hawk_fnc_sprintf (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_bcs_t cs0;
|
||||
hawk_bcs_t x;
|
||||
|
||||
if (hawk_becs_init(&out, hawk_rtx_getawk(rtx), 256) <= -1)
|
||||
if (hawk_becs_init(&out, hawk_rtx_gethawk(rtx), 256) <= -1)
|
||||
{
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
goto oops_mbs;
|
||||
}
|
||||
out_inited = 1;
|
||||
|
||||
if (hawk_becs_init(&fbu, hawk_rtx_getawk(rtx), 256) <= -1)
|
||||
if (hawk_becs_init(&fbu, hawk_rtx_gethawk(rtx), 256) <= -1)
|
||||
{
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
goto oops_mbs;
|
||||
@ -1547,14 +1547,14 @@ int hawk_fnc_sprintf (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
hawk_oocs_t cs0;
|
||||
hawk_oocs_t x;
|
||||
|
||||
if (hawk_ooecs_init(&out, hawk_rtx_getawk(rtx), 256) <= -1)
|
||||
if (hawk_ooecs_init(&out, hawk_rtx_gethawk(rtx), 256) <= -1)
|
||||
{
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
goto oops;
|
||||
}
|
||||
out_inited = 1;
|
||||
|
||||
if (hawk_ooecs_init(&fbu, hawk_rtx_getawk(rtx), 256) <= -1)
|
||||
if (hawk_ooecs_init(&fbu, hawk_rtx_gethawk(rtx), 256) <= -1)
|
||||
{
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
goto oops;
|
||||
@ -1592,7 +1592,7 @@ static int fnc_int (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int n;
|
||||
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 1);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
|
||||
@ -1696,7 +1696,7 @@ static HAWK_INLINE int __fnc_asort (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi,
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
a0_type = HAWK_RTX_GETVALTYPE(rtx, a0);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), a0_type == HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a0_type == HAWK_VAL_REF);
|
||||
|
||||
v_type = hawk_rtx_getrefvaltype(rtx, (hawk_val_ref_t*)a0);
|
||||
if (v_type != HAWK_VAL_MAP)
|
||||
@ -1712,7 +1712,7 @@ static HAWK_INLINE int __fnc_asort (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi,
|
||||
}
|
||||
|
||||
a0_val = hawk_rtx_getrefval(rtx, (hawk_val_ref_t*)a0);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE(rtx, a0_val) == HAWK_VAL_MAP);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, a0_val) == HAWK_VAL_MAP);
|
||||
|
||||
if (nargs >= 2)
|
||||
{
|
||||
@ -1744,7 +1744,7 @@ static HAWK_INLINE int __fnc_asort (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi,
|
||||
if (!hawk_rtx_getfirstmapvalitr(rtx, a0_val, &itr)) goto done; /* map empty */
|
||||
|
||||
msz = hawk_htb_getsize(((hawk_val_map_t*)a0_val)->map);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), msz > 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), msz > 0);
|
||||
|
||||
va = (hawk_val_t**)hawk_rtx_allocmem(rtx, msz * HAWK_SIZEOF(*va));
|
||||
if (!va) return -1;
|
||||
|
126
hawk/lib/gem.c
126
hawk/lib/gem.c
@ -24,10 +24,12 @@
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "hawk-prv.h"
|
||||
|
||||
void* hawk_gem_allocmem (hawk_gem_t* gem, hawk_oow_t size)
|
||||
{
|
||||
void* ptr = HAWK_MMGR_ALLOC(gem->mmgr, size);
|
||||
if (!ptr) hawk_gem_seterrnum (gem, HAWK_ENOMEM, HAWK_NULL);
|
||||
if (!ptr) hawk_gem_seterrnum (gem, HAWK_NULL, HAWK_ENOMEM);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@ -35,14 +37,132 @@ void* hawk_gem_callocmem (hawk_gem_t* gem, hawk_oow_t size)
|
||||
{
|
||||
void* ptr = HAWK_MMGR_ALLOC(gem->mmgr, size);
|
||||
if (ptr) HAWK_MEMSET (ptr, 0, size);
|
||||
else hawk_gem_seterrnum (gem, HAWK_ENOMEM, HAWK_NULL);
|
||||
else hawk_gem_seterrnum (gem, HAWK_NULL, HAWK_ENOMEM);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* hawk_gem_reallocmem (hawk_gem_t* gem, void* ptr, hawk_oow_t size)
|
||||
{
|
||||
void* nptr = HAWK_MMGR_REALLOC(gem->mmgr, ptr, size);
|
||||
if (!nptr) hawk_gem_seterrnum (gem, HAWK_ENOMEM, HAWK_NULL);
|
||||
if (!nptr) hawk_gem_seterrnum (gem, HAWK_NULL, HAWK_ENOMEM);
|
||||
return nptr;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
hawk_uch_t* hawk_gem_dupucstr (hawk_gem_t* gem, const hawk_uch_t* ucs, hawk_oow_t* _ucslen)
|
||||
{
|
||||
hawk_uch_t* ptr;
|
||||
hawk_oow_t ucslen;
|
||||
|
||||
ucslen = hawk_count_ucstr(ucs);
|
||||
ptr = (hawk_uch_t*)hawk_gem_allocmem(gem, (ucslen + 1) * HAWK_SIZEOF(hawk_uch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_uchars (ptr, ucs, ucslen);
|
||||
ptr[ucslen] = '\0';
|
||||
|
||||
if (_ucslen) *_ucslen = ucslen;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_gem_dupbcstr (hawk_gem_t* gem, const hawk_bch_t* bcs, hawk_oow_t* _bcslen)
|
||||
{
|
||||
hawk_bch_t* ptr;
|
||||
hawk_oow_t bcslen;
|
||||
|
||||
bcslen = hawk_count_bcstr(bcs);
|
||||
ptr = (hawk_bch_t*)hawk_gem_allocmem(gem, (bcslen + 1) * HAWK_SIZEOF(hawk_bch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_bchars (ptr, bcs, bcslen);
|
||||
ptr[bcslen] = '\0';
|
||||
|
||||
if (_bcslen) *_bcslen = bcslen;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
hawk_uch_t* hawk_gem_dupuchars (hawk_gem_t* gem, const hawk_uch_t* ucs, hawk_oow_t ucslen)
|
||||
{
|
||||
hawk_uch_t* ptr;
|
||||
|
||||
ptr = (hawk_uch_t*)hawk_gem_allocmem(gem, (ucslen + 1) * HAWK_SIZEOF(hawk_uch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_uchars (ptr, ucs, ucslen);
|
||||
ptr[ucslen] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_gem_dupbchars (hawk_gem_t* gem, const hawk_bch_t* bcs, hawk_oow_t bcslen)
|
||||
{
|
||||
hawk_bch_t* ptr;
|
||||
|
||||
ptr = (hawk_bch_t*)hawk_gem_allocmem(gem, (bcslen + 1) * HAWK_SIZEOF(hawk_bch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_bchars (ptr, bcs, bcslen);
|
||||
ptr[bcslen] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_uch_t* hawk_gem_dupucs (hawk_gem_t* gem, const hawk_ucs_t* ucs)
|
||||
{
|
||||
hawk_uch_t* ptr;
|
||||
|
||||
ptr = (hawk_uch_t*)hawk_gem_allocmem(gem, (ucs->len + 1) * HAWK_SIZEOF(hawk_uch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_uchars (ptr, ucs->ptr, ucs->len);
|
||||
ptr[ucs->len] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_gem_dupbcs (hawk_gem_t* gem, const hawk_bcs_t* bcs)
|
||||
{
|
||||
hawk_bch_t* ptr;
|
||||
|
||||
ptr = (hawk_bch_t*)hawk_gem_allocmem(gem, (bcs->len + 1) * HAWK_SIZEOF(hawk_bch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_bchars (ptr, bcs->ptr, bcs->len);
|
||||
ptr[bcs->len] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_uch_t* hawk_gem_dupucstrarr (hawk_gem_t* gem, const hawk_uch_t* str[], hawk_oow_t* len)
|
||||
{
|
||||
hawk_uch_t* buf, * ptr;
|
||||
hawk_oow_t i;
|
||||
hawk_oow_t capa = 0;
|
||||
|
||||
for (i = 0; str[i]; i++) capa += hawk_count_ucstr(str[i]);
|
||||
|
||||
buf = (hawk_uch_t*)hawk_gem_allocmem(gem, (capa + 1) * HAWK_SIZEOF(*buf));
|
||||
if (!buf) return HAWK_NULL;
|
||||
|
||||
ptr = buf;
|
||||
for (i = 0; str[i]; i++) ptr += hawk_copy_ucstr_unlimited(ptr, str[i]);
|
||||
|
||||
if (len) *len = capa;
|
||||
return buf;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_gem_dupbcstrarr (hawk_gem_t* gem, const hawk_bch_t* str[], hawk_oow_t* len)
|
||||
{
|
||||
hawk_bch_t* buf, * ptr;
|
||||
hawk_oow_t i;
|
||||
hawk_oow_t capa = 0;
|
||||
|
||||
for (i = 0; str[i]; i++) capa += hawk_count_bcstr(str[i]);
|
||||
|
||||
buf = (hawk_bch_t*)hawk_gem_allocmem(gem, (capa + 1) * HAWK_SIZEOF(*buf));
|
||||
if (!buf) return HAWK_NULL;
|
||||
|
||||
ptr = buf;
|
||||
for (i = 0; str[i]; i++) ptr += hawk_copy_bcstr_unlimited(ptr, str[i]);
|
||||
|
||||
if (len) *len = capa;
|
||||
return buf;
|
||||
}
|
||||
|
@ -908,12 +908,24 @@ enum hawk_errnum_t
|
||||
};
|
||||
typedef enum hawk_errnum_t hawk_errnum_t;
|
||||
|
||||
/**
|
||||
* The hawk_loc_t type defines a structure to hold location.
|
||||
*/
|
||||
struct hawk_loc_t
|
||||
{
|
||||
hawk_oow_t line; /**< line */
|
||||
hawk_oow_t colm; /**< column */
|
||||
const hawk_ooch_t* file; /**< file specified in @include */
|
||||
};
|
||||
typedef struct hawk_loc_t hawk_loc_t;
|
||||
|
||||
struct hawk_gem_t
|
||||
{
|
||||
hawk_mmgr_t* mmgr;
|
||||
hawk_cmgr_t* cmgr;
|
||||
hawk_errnum_t errnum;
|
||||
hawk_ooch_t errmsg[HAWK_ERRMSG_CAPA];
|
||||
hawk_loc_t errloc;
|
||||
};
|
||||
|
||||
/* =========================================================================
|
||||
|
122
hawk/lib/hawk-gem.h
Normal file
122
hawk/lib/hawk-gem.h
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _HAWK_GEM_H_
|
||||
#define _HAWK_GEM_H_
|
||||
|
||||
#include <hawk-cmn.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void* hawk_gem_allocmem (
|
||||
hawk_gem_t* gem,
|
||||
hawk_oow_t size
|
||||
);
|
||||
|
||||
void* hawk_gem_callocmem (
|
||||
hawk_gem_t* gem,
|
||||
hawk_oow_t size
|
||||
);
|
||||
|
||||
void* hawk_gem_reallocmem (
|
||||
hawk_gem_t* gem,
|
||||
void* ptr,
|
||||
hawk_oow_t size
|
||||
);
|
||||
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
static HAWK_INLINE void hawk_gem_freemem (hawk_gem_t* gem, void* ptr) { HAWK_MMGR_FREE (gem->mmgr, ptr); }
|
||||
#else
|
||||
#define hawk_gem_freemem(gem, ptr) HAWK_MMGR_FREE((gem)->mmgr, ptr);
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_gem_dupucstr (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_uch_t* ucs,
|
||||
hawk_oow_t* _ucslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_gem_dupbcstr (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_bch_t* bcs,
|
||||
hawk_oow_t* _bcslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_gem_dupuchars (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_uch_t* ucs,
|
||||
hawk_oow_t ucslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_gem_dupbchars (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_bch_t* bcs,
|
||||
hawk_oow_t bcslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_gem_dupucs (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_ucs_t* ucs
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_gem_dupbcs (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_bcs_t* bcs
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_gem_dupucstrarr (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_uch_t* str[],
|
||||
hawk_oow_t* len
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_gem_dupbcstrarr (
|
||||
hawk_gem_t* gem,
|
||||
const hawk_bch_t* str[],
|
||||
hawk_oow_t* len
|
||||
);
|
||||
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
# define hawk_gem_dupoocstr hawk_gem_dupucstr
|
||||
# define hawk_gem_dupoochars hawk_gem_dupuchars
|
||||
# define hawk_gem_dupoocs hawk_gem_dupucs
|
||||
# define hawk_gem_dupoocstrarr hawk_gem_dupucstrarr
|
||||
#else
|
||||
# define hawk_gem_dupoocstr hawk_gem_dupbcstr
|
||||
# define hawk_gem_dupoochars hawk_gem_dupbchars
|
||||
# define hawk_gem_dupoocs hawk_gem_dupbcs
|
||||
# define hawk_gem_dupoocstrarr hawk_gem_dupbcstrarr
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -309,7 +309,6 @@ struct hawk_t
|
||||
|
||||
/* housekeeping */
|
||||
hawk_errstr_t errstr;
|
||||
hawk_loc_t errloc;
|
||||
hawk_oow_t errmsg_len; /* used by errbfmt() and errufmt(). don't rely on this. some other funtions don't set this properly */
|
||||
hawk_ooch_t errmsg_backup[HAWK_ERRMSG_CAPA];
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
@ -451,7 +450,6 @@ struct hawk_rtx_t
|
||||
hawk_oow_t expr; /* expression */
|
||||
} depth;
|
||||
|
||||
hawk_loc_t errloc;
|
||||
hawk_oow_t errmsg_len; /* used by errbfmt() and errufmt(). don't rely on this. some other funtions don't set this properly */
|
||||
hawk_ooch_t errmsg_backup[HAWK_ERRMSG_CAPA];
|
||||
#if defined(HAWK_OOCH_IS_BCH)
|
||||
@ -488,6 +486,10 @@ extern "C" {
|
||||
int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm_t* prm);
|
||||
void hawk_fini (hawk_t* awk);
|
||||
|
||||
|
||||
/* TODO: should i make this public? */
|
||||
void hawk_gem_seterrnum (hawk_gem_t* gem, const hawk_loc_t* errloc, hawk_errnum_t errnum);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
149
hawk/lib/hawk.c
149
hawk/lib/hawk.c
@ -151,9 +151,9 @@ int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm
|
||||
/* initialize error handling fields */
|
||||
awk->_gem.errnum = HAWK_ENOERR;
|
||||
awk->_gem.errmsg[0] = '\0';
|
||||
awk->errloc.line = 0;
|
||||
awk->errloc.colm = 0;
|
||||
awk->errloc.file = HAWK_NULL;
|
||||
awk->_gem.errloc.line = 0;
|
||||
awk->_gem.errloc.colm = 0;
|
||||
awk->_gem.errloc.file = HAWK_NULL;
|
||||
awk->errstr = hawk_dflerrstr;
|
||||
awk->haltall = 0;
|
||||
|
||||
@ -536,149 +536,6 @@ void hawk_pushecb (hawk_t* awk, hawk_ecb_t* ecb)
|
||||
awk->ecb = ecb;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void* hawk_allocmem (hawk_t* awk, hawk_oow_t size)
|
||||
{
|
||||
void* ptr = HAWK_MMGR_ALLOC(hawk_getmmgr(awk), size);
|
||||
if (!ptr) hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* hawk_callocmem (hawk_t* awk, hawk_oow_t size)
|
||||
{
|
||||
void* ptr = HAWK_MMGR_ALLOC(hawk_getmmgr(awk), size);
|
||||
if (ptr) HAWK_MEMSET (ptr, 0, size);
|
||||
else hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* hawk_reallocmem (hawk_t* awk, void* ptr, hawk_oow_t size)
|
||||
{
|
||||
void* nptr = HAWK_MMGR_REALLOC(hawk_getmmgr(awk), ptr, size);
|
||||
if (!nptr) hawk_seterrnum (awk, HAWK_ENOMEM, HAWK_NULL);
|
||||
return nptr;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
hawk_uch_t* hawk_dupucstr (hawk_t* hawk, const hawk_uch_t* ucs, hawk_oow_t* _ucslen)
|
||||
{
|
||||
hawk_uch_t* ptr;
|
||||
hawk_oow_t ucslen;
|
||||
|
||||
ucslen = hawk_count_ucstr(ucs);
|
||||
ptr = (hawk_uch_t*)hawk_allocmem(hawk, (ucslen + 1) * HAWK_SIZEOF(hawk_uch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_uchars (ptr, ucs, ucslen);
|
||||
ptr[ucslen] = '\0';
|
||||
|
||||
if (_ucslen) *_ucslen = ucslen;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_dupbcstr (hawk_t* hawk, const hawk_bch_t* bcs, hawk_oow_t* _bcslen)
|
||||
{
|
||||
hawk_bch_t* ptr;
|
||||
hawk_oow_t bcslen;
|
||||
|
||||
bcslen = hawk_count_bcstr(bcs);
|
||||
ptr = (hawk_bch_t*)hawk_allocmem(hawk, (bcslen + 1) * HAWK_SIZEOF(hawk_bch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_bchars (ptr, bcs, bcslen);
|
||||
ptr[bcslen] = '\0';
|
||||
|
||||
if (_bcslen) *_bcslen = bcslen;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_uch_t* hawk_dupuchars (hawk_t* hawk, const hawk_uch_t* ucs, hawk_oow_t ucslen)
|
||||
{
|
||||
hawk_uch_t* ptr;
|
||||
|
||||
ptr = (hawk_uch_t*)hawk_allocmem(hawk, (ucslen + 1) * HAWK_SIZEOF(hawk_uch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_uchars (ptr, ucs, ucslen);
|
||||
ptr[ucslen] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_dupbchars (hawk_t* hawk, const hawk_bch_t* bcs, hawk_oow_t bcslen)
|
||||
{
|
||||
hawk_bch_t* ptr;
|
||||
|
||||
ptr = (hawk_bch_t*)hawk_allocmem(hawk, (bcslen + 1) * HAWK_SIZEOF(hawk_bch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_bchars (ptr, bcs, bcslen);
|
||||
ptr[bcslen] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_uch_t* hawk_dupucs (hawk_t* hawk, const hawk_ucs_t* ucs)
|
||||
{
|
||||
hawk_uch_t* ptr;
|
||||
|
||||
ptr = (hawk_uch_t*)hawk_allocmem(hawk, (ucs->len + 1) * HAWK_SIZEOF(hawk_uch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_uchars (ptr, ucs->ptr, ucs->len);
|
||||
ptr[ucs->len] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_dupbcs (hawk_t* hawk, const hawk_bcs_t* bcs)
|
||||
{
|
||||
hawk_bch_t* ptr;
|
||||
|
||||
ptr = (hawk_bch_t*)hawk_allocmem(hawk, (bcs->len + 1) * HAWK_SIZEOF(hawk_bch_t));
|
||||
if (!ptr) return HAWK_NULL;
|
||||
|
||||
hawk_copy_bchars (ptr, bcs->ptr, bcs->len);
|
||||
ptr[bcs->len] = '\0';
|
||||
return ptr;
|
||||
}
|
||||
|
||||
hawk_uch_t* hawk_dupucstrarr (hawk_t* hawk, const hawk_uch_t* str[], hawk_oow_t* len)
|
||||
{
|
||||
hawk_uch_t* buf, * ptr;
|
||||
hawk_oow_t i;
|
||||
hawk_oow_t capa = 0;
|
||||
|
||||
for (i = 0; str[i]; i++) capa += hawk_count_ucstr(str[i]);
|
||||
|
||||
buf = (hawk_uch_t*)hawk_allocmem(hawk, (capa + 1) * HAWK_SIZEOF(*buf));
|
||||
if (!buf) return HAWK_NULL;
|
||||
|
||||
ptr = buf;
|
||||
for (i = 0; str[i]; i++) ptr += hawk_copy_ucstr_unlimited(ptr, str[i]);
|
||||
|
||||
if (len) *len = capa;
|
||||
return buf;
|
||||
}
|
||||
|
||||
hawk_bch_t* hawk_dupbcstrarr (hawk_t* hawk, const hawk_bch_t* str[], hawk_oow_t* len)
|
||||
{
|
||||
hawk_bch_t* buf, * ptr;
|
||||
hawk_oow_t i;
|
||||
hawk_oow_t capa = 0;
|
||||
|
||||
for (i = 0; str[i]; i++) capa += hawk_count_bcstr(str[i]);
|
||||
|
||||
buf = (hawk_bch_t*)hawk_allocmem(hawk, (capa + 1) * HAWK_SIZEOF(*buf));
|
||||
if (!buf) return HAWK_NULL;
|
||||
|
||||
ptr = buf;
|
||||
for (i = 0; str[i]; i++) ptr += hawk_copy_bcstr_unlimited(ptr, str[i]);
|
||||
|
||||
if (len) *len = capa;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
int hawk_convbtouchars (hawk_t* hawk, const hawk_bch_t* bcs, hawk_oow_t* bcslen, hawk_uch_t* ucs, hawk_oow_t* ucslen, int all)
|
||||
|
324
hawk/lib/hawk.h
324
hawk/lib/hawk.h
@ -29,6 +29,7 @@
|
||||
|
||||
#include <hawk-cmn.h>
|
||||
#include <hawk-ecs.h>
|
||||
#include <hawk-gem.h>
|
||||
#include <hawk-htb.h>
|
||||
#include <hawk-utl.h>
|
||||
#include <stdarg.h>
|
||||
@ -125,17 +126,6 @@ struct hawk_rtx_alt_t
|
||||
HAWK_RTX_HDR;
|
||||
};
|
||||
|
||||
/**
|
||||
* The hawk_loc_t type defines a structure to hold location.
|
||||
*/
|
||||
struct hawk_loc_t
|
||||
{
|
||||
hawk_oow_t line; /**< line */
|
||||
hawk_oow_t colm; /**< column */
|
||||
const hawk_ooch_t* file; /**< file specified in @include */
|
||||
};
|
||||
typedef struct hawk_loc_t hawk_loc_t;
|
||||
|
||||
/**
|
||||
* The #HAWK_VAL_HDR defines the common header for a value.
|
||||
* Three common fields are:
|
||||
@ -1439,23 +1429,17 @@ HAWK_EXPORT void hawk_close (
|
||||
);
|
||||
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
/**
|
||||
* The hawk_getxtn() function returns the pointer to the extension area
|
||||
* placed behind the actual awk object.
|
||||
*/
|
||||
static HAWK_INLINE void* hawk_getxtn (hawk_t* awk) { return (void*)((hawk_uint8_t*)awk + ((hawk_alt_t*)awk)->_instsize); }
|
||||
/**
|
||||
* The hawk_getmmgr() function gets the memory manager used in
|
||||
* hawk_open().
|
||||
*/
|
||||
static HAWK_INLINE hawk_mmgr_t* hawk_getmmgr (hawk_t* awk) { return ((hawk_alt_t*)awk)->_gem.mmgr; }
|
||||
static HAWK_INLINE hawk_cmgr_t* hawk_getcmgr (hawk_t* awk) { return ((hawk_alt_t*)awk)->_gem.cmgr; }
|
||||
static HAWK_INLINE void hawk_setcmgr (hawk_t* awk, hawk_cmgr_t* cmgr) { ((hawk_alt_t*)awk)->_gem.cmgr = cmgr; }
|
||||
static HAWK_INLINE void* hawk_getxtn (hawk_t* hawk) { return (void*)((hawk_uint8_t*)hawk + ((hawk_alt_t*)hawk)->_instsize); }
|
||||
static HAWK_INLINE hawk_gem_t* hawk_getgem (hawk_t* hawk) { return &((hawk_alt_t*)hawk)->_gem; }
|
||||
static HAWK_INLINE hawk_mmgr_t* hawk_getmmgr (hawk_t* hawk) { return ((hawk_alt_t*)hawk)->_gem.mmgr; }
|
||||
static HAWK_INLINE hawk_cmgr_t* hawk_getcmgr (hawk_t* hawk) { return ((hawk_alt_t*)hawk)->_gem.cmgr; }
|
||||
static HAWK_INLINE void hawk_setcmgr (hawk_t* hawk, hawk_cmgr_t* cmgr) { ((hawk_alt_t*)hawk)->_gem.cmgr = cmgr; }
|
||||
#else
|
||||
# define hawk_getxtn(awk) ((void*)((hawk_uint8_t*)awk + ((hawk_alt_t*)awk)->_instsize))
|
||||
# define hawk_getmmgr(awk) (((hawk_alt_t*)(awk))->_gem.mmgr)
|
||||
# define hawk_getcmgr(awk) (((hawk_alt_t*)(awk))->_gem.cmgr)
|
||||
# define hawk_setcmgr(awk,_cmgr) (((hawk_alt_t*)(awk))->_gem.cmgr = (_cmgr))
|
||||
#define hawk_getxtn(awk) ((void*)((hawk_uint8_t*)hawk + ((hawk_alt_t*)hawk)->_instsize))
|
||||
#define hawk_getgem(awk) (&((hawk_alt_t*)(hawk))->_gem)
|
||||
#define hawk_getmmgr(awk) (((hawk_alt_t*)(hawk))->_gem.mmgr)
|
||||
#define hawk_getcmgr(awk) (((hawk_alt_t*)(hawk))->_gem.cmgr)
|
||||
#define hawk_setcmgr(awk,_cmgr) (((hawk_alt_t*)(hawk))->_gem.cmgr = (_cmgr))
|
||||
#endif /* HAWK_HAVE_INLINE */
|
||||
|
||||
/**
|
||||
@ -1856,94 +1840,39 @@ HAWK_EXPORT int hawk_parse (
|
||||
hawk_sio_cbs_t* sio /**< source script I/O handler */
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_allocmem() function allocates dynamic memory.
|
||||
* \return a pointer to a memory block on success, #HAWK_NULL on failure
|
||||
*/
|
||||
HAWK_EXPORT void* hawk_allocmem (
|
||||
hawk_t* awk, /**< awk */
|
||||
hawk_oow_t size /**< size of memory to allocate in bytes */
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_reallocmem() function resizes a dynamic memory block.
|
||||
* \return a pointer to a memory block on success, #HAWK_NULL on failure
|
||||
*/
|
||||
HAWK_EXPORT void* hawk_reallocmem (
|
||||
hawk_t* awk, /**< awk */
|
||||
void* ptr, /**< memory block */
|
||||
hawk_oow_t size /**< new block size in bytes */
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_callocmem() function allocates a memory block of
|
||||
* the size of \a size bytes and initializes it with 0.
|
||||
* \return a pointer to a memory block on success, #HAWK_NULL on failure
|
||||
*/
|
||||
HAWK_EXPORT void* hawk_callocmem (
|
||||
hawk_t* awk, /**< awk */
|
||||
hawk_oow_t size /**< size of memory to allocate in bytes */
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_freemem() function frees dynamic memory allocated.
|
||||
*/
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
static HAWK_INLINE void hawk_freemem (hawk_t* awk, void* ptr)
|
||||
{
|
||||
HAWK_MMGR_FREE (hawk_getmmgr(awk), ptr);
|
||||
}
|
||||
static HAWK_INLINE void* hawk_allocmem (hawk_t* hawk, hawk_oow_t size) { return hawk_gem_allocmem(hawk_getgem(hawk), size); }
|
||||
static HAWK_INLINE void* hawk_reallocmem (hawk_t* hawk, void* ptr, hawk_oow_t size) { return hawk_gem_reallocmem(hawk_getgem(hawk), ptr, size); }
|
||||
static HAWK_INLINE void* hawk_callocmem (hawk_t* hawk, hawk_oow_t size) { return hawk_gem_callocmem(hawk_getgem(hawk), size); }
|
||||
static HAWK_INLINE void hawk_freemem (hawk_t* hawk, void* ptr) { hawk_gem_freemem (hawk_getgem(hawk), ptr); }
|
||||
#else
|
||||
# define hawk_freemem(awk, ptr) HAWK_MMGR_FREE(hawk_getmmgr(awk), ptr);
|
||||
#define hawk_allocmem(hawk, size) hawk_gem_allocmem(hawk_getgem(hawk), size)
|
||||
#define hawk_reallocmem(hawk, ptr, size) hawk_gem_reallocmem(hawk_getgem(hawk), ptr, size)
|
||||
#define hawk_callocmem(hawk, size) hawk_gem_callocmem(hawk_getgem(hawk), size)
|
||||
#define hawk_freemem(hawk, ptr) hawk_gem_freemem(hawk_getgem(hawk), ptr)
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_dupucstr (
|
||||
hawk_t* hawk,
|
||||
const hawk_uch_t* ucs,
|
||||
hawk_oow_t* _ucslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_dupbcstr (
|
||||
hawk_t* hawk,
|
||||
const hawk_bch_t* bcs,
|
||||
hawk_oow_t* _bcslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_dupuchars (
|
||||
hawk_t* hawk,
|
||||
const hawk_uch_t* ucs,
|
||||
hawk_oow_t ucslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_dupbchars (
|
||||
hawk_t* hawk,
|
||||
const hawk_bch_t* bcs,
|
||||
hawk_oow_t bcslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_dupucs (
|
||||
hawk_t* hawk,
|
||||
const hawk_ucs_t* ucs
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_dupbcs (
|
||||
hawk_t* hawk,
|
||||
const hawk_bcs_t* bcs
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_dupucstrarr (
|
||||
hawk_t* hawk,
|
||||
const hawk_uch_t* str[],
|
||||
hawk_oow_t* len
|
||||
);
|
||||
|
||||
hawk_bch_t* hawk_dupbcstrarr (
|
||||
hawk_t* hawk,
|
||||
const hawk_bch_t* str[],
|
||||
hawk_oow_t* len
|
||||
);
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
static HAWK_INLINE hawk_uch_t* hawk_dupucstr (hawk_t* hawk, const hawk_uch_t* ucs, hawk_oow_t* ucslen) { return hawk_gem_dupucstr(hawk_getgem(hawk), ucs, ucslen); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_dupbcstr (hawk_t* hawk, const hawk_bch_t* bcs, hawk_oow_t* bcslen) { return hawk_gem_dupbcstr(hawk_getgem(hawk), bcs, bcslen); }
|
||||
static HAWK_INLINE hawk_uch_t* hawk_dupuchars (hawk_t* hawk, const hawk_uch_t* ucs, hawk_oow_t ucslen) { return hawk_gem_dupuchars(hawk_getgem(hawk), ucs, ucslen); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_dupbchars (hawk_t* hawk, const hawk_bch_t* bcs, hawk_oow_t bcslen) { return hawk_gem_dupbchars(hawk_getgem(hawk), bcs, bcslen); }
|
||||
static HAWK_INLINE hawk_uch_t* hawk_dupucs (hawk_t* hawk, const hawk_ucs_t* ucs) { return hawk_gem_dupucs(hawk_getgem(hawk), ucs); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_dupbcs (hawk_t* hawk, const hawk_bcs_t* bcs) { return hawk_gem_dupbcs(hawk_getgem(hawk), bcs); }
|
||||
static HAWK_INLINE hawk_uch_t* hawk_dupucstrarr (hawk_t* hawk, const hawk_uch_t* strs[], hawk_oow_t* len) { return hawk_gem_dupucstrarr(hawk_getgem(hawk), strs, len); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_dupbcstrarr (hawk_t* hawk, const hawk_bch_t* strs[], hawk_oow_t* len) { return hawk_gem_dupbcstrarr(hawk_getgem(hawk), strs, len); }
|
||||
#else
|
||||
#define hawk_dupucstr(hawk, ucs, ucslen) hawk_gem_dupucstr(hawk_getgem(hawk), ucs, ucslen)
|
||||
#define hawk_dupbcstr(hawk, bcs, bcslen) hawk_gem_dupbcstr(hawk_getgem(hawk), bcs, bcslen)
|
||||
#define hawk_dupuchars(hawk, ucs, ucslen) hawk_gem_dupuchars(hawk_getgem(hawk), ucs, ucslen)
|
||||
#define hawk_dupbchars(hawk, bcs, bcslen) hawk_gem_dupbchars(hawk_getgem(hawk), bcs, bcslen)
|
||||
#define hawk_dupucs(hawk, ucs) hawk_gem_dupucs(hawk_getgem(hawk), ucs)
|
||||
#define hawk_dupbcs(hawk, bcs) hawk_gem_dupbcs(hawk_getgem(hawk), bcs)
|
||||
#define hawk_dupucstrarr(hawk, strs, len) hawk_gem_dupucstrarr(hawk_getgem(hawk), strs, len)
|
||||
#define hawk_dupbcstrarr(hawk, strs, len) hawk_gem_dupbcstrarr(hawk_getgem(hawk), strs, len)
|
||||
#endif
|
||||
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
# define hawk_dupoocstr hawk_dupucstr
|
||||
@ -2204,6 +2133,22 @@ HAWK_EXPORT void hawk_rtx_close (
|
||||
hawk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
static HAWK_INLINE hawk_t* hawk_rtx_gethawk (hawk_rtx_t* rtx) { return ((hawk_rtx_alt_t*)rtx)->awk; }
|
||||
static HAWK_INLINE void* hawk_rtx_getxtn (hawk_rtx_t* rtx) { return (void*)((hawk_uint8_t*)rtx + ((hawk_rtx_alt_t*)rtx)->_instsize); }
|
||||
static HAWK_INLINE hawk_gem_t* hawk_rtx_getgem (hawk_rtx_t* rtx) { return &((hawk_rtx_alt_t*)rtx)->_gem; }
|
||||
static HAWK_INLINE hawk_mmgr_t* hawk_rtx_getmmgr (hawk_rtx_t* rtx) { return ((hawk_rtx_alt_t*)rtx)->_gem.mmgr; }
|
||||
static HAWK_INLINE hawk_cmgr_t* hawk_rtx_getcmgr (hawk_rtx_t* rtx) { return ((hawk_rtx_alt_t*)rtx)->_gem.cmgr; }
|
||||
static HAWK_INLINE void hawk_rtx_setcmgr (hawk_rtx_t* rtx, hawk_cmgr_t* cmgr) { ((hawk_rtx_alt_t*)rtx)->_gem.cmgr = cmgr; }
|
||||
#else
|
||||
#define hawk_rtx_gethawk(rtx) (((hawk_rtx_alt_t*)(rtx))->awk)
|
||||
#define hawk_rtx_getxtn(rtx) ((void*)((hawk_uint8_t*)rtx + ((hawk_rtx_alt_t*)rtx)->_instsize))
|
||||
#define hawk_rtx_getgem(rtx) (&((hawk_rtx_alt_t*)(rtx))->_gem)
|
||||
#define hawk_rtx_getmmgr(rtx) (((hawk_rtx_alt_t*)(rtx))->_gem.mmgr)
|
||||
#define hawk_rtx_getcmgr(rtx) (((hawk_rtx_alt_t*)(rtx))->_gem.cmgr)
|
||||
#define hawk_rtx_setcmgr(rtx,_cmgr) (((hawk_rtx_alt_t*)(rtx))->_gem.cmgr = (_cmgr))
|
||||
#endif /* HAWK_HAVE_INLINE */
|
||||
|
||||
/**
|
||||
* The hawk_rtx_loop() function executes the BEGIN block, pattern-action
|
||||
* blocks and the END blocks in an AWK program. It returns the global return
|
||||
@ -2484,54 +2429,11 @@ HAWK_EXPORT int hawk_rtx_setfilename (
|
||||
* The hawk_rtx_setofilename() function sets OFILENAME.
|
||||
*/
|
||||
HAWK_EXPORT int hawk_rtx_setofilename (
|
||||
hawk_rtx_t* rtx, /**< runtime context */
|
||||
hawk_rtx_t* rtx, /**< runtime context */
|
||||
const hawk_ooch_t* str, /**< name pointer */
|
||||
hawk_oow_t len /**< name length */
|
||||
hawk_oow_t len /**< name length */
|
||||
);
|
||||
|
||||
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
|
||||
/**
|
||||
* The hawk_rtx_getxtn() function gets the pointer to the extension area
|
||||
* created with hawk_rtx_open().
|
||||
*/
|
||||
static HAWK_INLINE void* hawk_rtx_getxtn (hawk_rtx_t* rtx)
|
||||
{
|
||||
return (void*)((hawk_uint8_t*)rtx + ((hawk_rtx_alt_t*)rtx)->_instsize);
|
||||
}
|
||||
|
||||
/**
|
||||
* The hawk_rtx_getawk() function gets the owner of a runtime context \a rtx.
|
||||
* \return owner of a runtime context \a rtx.
|
||||
*/
|
||||
static HAWK_INLINE hawk_t* hawk_rtx_getawk (hawk_rtx_t* rtx)
|
||||
{
|
||||
return ((hawk_rtx_alt_t*)rtx)->awk;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hawk_rtx_getmmgr() function gets the memory manager of a runtime
|
||||
* context.
|
||||
*/
|
||||
static HAWK_INLINE hawk_mmgr_t* hawk_rtx_getmmgr (hawk_rtx_t* rtx)
|
||||
{
|
||||
return hawk_getmmgr(hawk_rtx_getawk(rtx));
|
||||
}
|
||||
|
||||
static HAWK_INLINE hawk_cmgr_t* hawk_rtx_getcmgr (hawk_rtx_t* rtx)
|
||||
{
|
||||
return hawk_getcmgr(hawk_rtx_getawk(rtx));
|
||||
}
|
||||
|
||||
#else
|
||||
# define hawk_rtx_getxtn(rtx) ((void*)((hawk_uint8_t*)rtx + ((hawk_rtx_alt_t*)rtx)->_instsize))
|
||||
# define hawk_rtx_getawk(rtx) (((hawk_rtx_alt_t*)(rtx))->awk)
|
||||
# define hawk_rtx_getmmgr(rtx) (hawk_getmmgr(hawk_rtx_getawk(rtx)))
|
||||
# define hawk_rtx_getcmgr(rtx) (hawk_getcmgr(hawk_rtx_getawk(rtx)))
|
||||
|
||||
#endif /* HAWK_HAVE_INLINE */
|
||||
|
||||
/**
|
||||
* The hawk_rtx_getnvmap() gets the map of named variables
|
||||
*/
|
||||
@ -3330,95 +3232,51 @@ HAWK_EXPORT void hawk_rtx_getnrflt (
|
||||
hawk_nrflt_t* nrflt
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_rtx_allocmem() function allocats a memory block of \a size bytes
|
||||
* using the memory manager associated with a runtime context \a rtx.
|
||||
* \return the pointer to a memory block on success, #HAWK_NULL on failure.
|
||||
*/
|
||||
HAWK_EXPORT void* hawk_rtx_allocmem (
|
||||
hawk_rtx_t* rtx, /**< runtime context */
|
||||
hawk_oow_t size /**< block size in bytes */
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_rtx_reallocmem() function resizes a memory block pointed to
|
||||
* by \a ptr to \a size bytes using the memory manager associated with
|
||||
* a runtime context \a rtx.
|
||||
* \return the pointer to a memory block on success, #HAWK_NULL on failure.
|
||||
*/
|
||||
HAWK_EXPORT void* hawk_rtx_reallocmem (
|
||||
hawk_rtx_t* rtx, /**< runtime context */
|
||||
void* ptr, /**< memory block */
|
||||
hawk_oow_t size /**< block size in bytes */
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_rtx_callocmem() function allocates a memory block of
|
||||
* the size of \a size bytes and initializes it with 0.
|
||||
* \return a pointer to a memory block on success, #HAWK_NULL on failure
|
||||
*/
|
||||
HAWK_EXPORT void* hawk_rtx_callocmem (
|
||||
hawk_rtx_t* rtx, /**< runtime context */
|
||||
hawk_oow_t size /**< block size in bytes */
|
||||
);
|
||||
|
||||
/**
|
||||
* The hawk_rtx_freemem() function frees a memory block pointed to by \a ptr
|
||||
* using the memory manager of a runtime ocntext \a rtx.
|
||||
*/
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
static HAWK_INLINE void hawk_rtx_freemem (hawk_rtx_t* rtx, void* ptr)
|
||||
{
|
||||
hawk_freemem (((hawk_rtx_alt_t*)rtx)->awk, ptr);
|
||||
}
|
||||
static HAWK_INLINE void* hawk_rtx_allocmem (hawk_rtx_t* rtx, hawk_oow_t size) { return hawk_gem_allocmem(hawk_rtx_getgem(rtx), size); }
|
||||
static HAWK_INLINE void* hawk_rtx_reallocmem (hawk_rtx_t* rtx, void* ptr, hawk_oow_t size) { return hawk_gem_reallocmem(hawk_rtx_getgem(rtx), ptr, size); }
|
||||
static HAWK_INLINE void* hawk_rtx_callocmem (hawk_rtx_t* rtx, hawk_oow_t size) { return hawk_gem_callocmem(hawk_rtx_getgem(rtx), size); }
|
||||
static HAWK_INLINE void hawk_rtx_freemem (hawk_rtx_t* rtx, void* ptr) { hawk_gem_freemem (hawk_rtx_getgem(rtx), ptr); }
|
||||
#else
|
||||
# define hawk_rtx_freemem(rtx,ptr) hawk_freemem(((hawk_rtx_alt_t*)rtx)->awk, ptr)
|
||||
#define hawk_rtx_allocmem(rtx, size) hawk_gem_allocmem(hawk_rtx_getgem(rtx), size)
|
||||
#define hawk_rtx_reallocmem(rtx, ptr, size) hawk_gem_reallocmem(hawk_rtx_getgem(rtx), ptr, size)
|
||||
#define hawk_rtx_callocmem(rtx, size) hawk_gem_callocmem(hawk_rtx_getgem(rtx), size)
|
||||
#define hawk_rtx_freemem(rtx, ptr) hawk_gem_freemem(hawk_rtx_getgem(rtx), ptr)
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_rtx_dupucstr (
|
||||
hawk_rtx_t* hawk,
|
||||
const hawk_uch_t* ucs,
|
||||
hawk_oow_t* _ucslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_rtx_dupbcstr (
|
||||
hawk_rtx_t* hawk,
|
||||
const hawk_bch_t* bcs,
|
||||
hawk_oow_t* _bcslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_rtx_dupuchars (
|
||||
hawk_rtx_t* hawk,
|
||||
const hawk_uch_t* ucs,
|
||||
hawk_oow_t ucslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_rtx_dupbchars (
|
||||
hawk_rtx_t* rtx,
|
||||
const hawk_bch_t* bcs,
|
||||
hawk_oow_t bcslen
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_uch_t* hawk_rtx_dupucs (
|
||||
hawk_rtx_t* rtx,
|
||||
const hawk_ucs_t* ucs
|
||||
);
|
||||
|
||||
HAWK_EXPORT hawk_bch_t* hawk_rtx_dupbcs (
|
||||
hawk_rtx_t* rtx,
|
||||
const hawk_bcs_t* bcs
|
||||
);
|
||||
#if defined(HAWK_HAVE_INLINE)
|
||||
static HAWK_INLINE hawk_uch_t* hawk_rtx_dupucstr (hawk_rtx_t* rtx, const hawk_uch_t* ucs, hawk_oow_t* ucslen) { return hawk_gem_dupucstr(hawk_rtx_getgem(rtx), ucs, ucslen); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcstr (hawk_rtx_t* rtx, const hawk_bch_t* bcs, hawk_oow_t* bcslen) { return hawk_gem_dupbcstr(hawk_rtx_getgem(rtx), bcs, bcslen); }
|
||||
static HAWK_INLINE hawk_uch_t* hawk_rtx_dupuchars (hawk_rtx_t* rtx, const hawk_uch_t* ucs, hawk_oow_t ucslen) { return hawk_gem_dupuchars(hawk_rtx_getgem(rtx), ucs, ucslen); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbchars (hawk_rtx_t* rtx, const hawk_bch_t* bcs, hawk_oow_t bcslen) { return hawk_gem_dupbchars(hawk_rtx_getgem(rtx), bcs, bcslen); }
|
||||
static HAWK_INLINE hawk_uch_t* hawk_rtx_dupucs (hawk_rtx_t* rtx, const hawk_ucs_t* ucs) { return hawk_gem_dupucs(hawk_rtx_getgem(rtx), ucs); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcs (hawk_rtx_t* rtx, const hawk_bcs_t* bcs) { return hawk_gem_dupbcs(hawk_rtx_getgem(rtx), bcs); }
|
||||
static HAWK_INLINE hawk_uch_t* hawk_rtx_dupucstrarr (hawk_rtx_t* rtx, const hawk_uch_t* strs[], hawk_oow_t* len) { return hawk_gem_dupucstrarr(hawk_rtx_getgem(rtx), strs, len); }
|
||||
static HAWK_INLINE hawk_bch_t* hawk_rtx_dupbcstrarr (hawk_rtx_t* rtx, const hawk_bch_t* strs[], hawk_oow_t* len) { return hawk_gem_dupbcstrarr(hawk_rtx_getgem(rtx), strs, len); }
|
||||
#else
|
||||
#define hawk_rtx_dupucstr(rtx, ucs, ucslen) hawk_gem_dupucstr(hawk_rtx_getgem(rtx), ucs, ucslen)
|
||||
#define hawk_rtx_dupbcstr(rtx, bcs, bcslen) hawk_gem_dupbcstr(hawk_rtx_getgem(rtx), bcs, bcslen)
|
||||
#define hawk_rtx_dupuchars(rtx, ucs, ucslen) hawk_gem_dupuchars(hawk_rtx_getgem(rtx), ucs, ucslen)
|
||||
#define hawk_rtx_dupbchars(rtx, bcs, bcslen) hawk_gem_dupbchars(hawk_rtx_getgem(rtx), bcs, bcslen)
|
||||
#define hawk_rtx_dupucs(rtx, ucs) hawk_gem_dupucs(hawk_rtx_getgem(rtx), ucs)
|
||||
#define hawk_rtx_dupbcs(rtx, bcs) hawk_gem_dupbcs(hawk_rtx_getgem(rtx), bcs)
|
||||
#define hawk_rtx_dupucstrarr(rtx, strs, len) hawk_gem_dupucstrarr(hawk_rtx_getgem(rtx), strs, len)
|
||||
#define hawk_rtx_dupbcstrarr(rtx, strs, len) hawk_gem_dupbcstrarr(hawk_rtx_getgem(rtx), strs, len)
|
||||
#endif
|
||||
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
# define hawk_rtx_dupoocstr hawk_rtx_dupucstr
|
||||
# define hawk_rtx_dupoochars hawk_rtx_dupuchars
|
||||
# define hawk_rtx_dupoocs hawk_rtx_dupucs
|
||||
# define hawk_rtx_dupoocstr hawk_rtx_dupucstr
|
||||
# define hawk_rtx_dupoochars hawk_rtx_dupuchars
|
||||
# define hawk_rtx_dupoocs hawk_rtx_dupucs
|
||||
# define hawk_rtx_dupoocstrarr hawk_rtx_dupucstrarr
|
||||
#else
|
||||
# define hawk_rtx_dupoocstr hawk_rtx_dupbcstr
|
||||
# define hawk_rtx_dupoochars hawk_rtx_dupbchars
|
||||
# define hawk_rtx_dupoocs hawk_rtx_dupbcs
|
||||
# define hawk_rtx_dupoocstr hawk_rtx_dupbcstr
|
||||
# define hawk_rtx_dupoochars hawk_rtx_dupbchars
|
||||
# define hawk_rtx_dupoocs hawk_rtx_dupbcs
|
||||
# define hawk_rtx_dupoocstrarr hawk_rtx_dupbcstrarr
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
@ -95,7 +95,7 @@ static __IMAP_NODE_T* __MAKE_IMAP_NODE (hawk_rtx_t* rtx, __IMAP_LIST_T* list)
|
||||
list->map.high++;
|
||||
}
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), list->map.tab[node->id] == HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), list->map.tab[node->id] == HAWK_NULL);
|
||||
list->map.tab[node->id] = node;
|
||||
|
||||
/* append it to the tail */
|
||||
|
@ -336,7 +336,7 @@ hawk_ooch_t* hawk_rtx_strxntokbyrex (
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), n == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), n == 1);
|
||||
|
||||
if (match.len == 0)
|
||||
{
|
||||
|
@ -221,7 +221,7 @@ static HAWK_INLINE dir_list_t* rtx_to_list (hawk_rtx_t* rtx, const hawk_fnc_info
|
||||
{
|
||||
hawk_rbt_pair_t* pair;
|
||||
pair = hawk_rbt_search((hawk_rbt_t*)fi->mod->ctx, &rtx, HAWK_SIZEOF(rtx));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), pair != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), pair != HAWK_NULL);
|
||||
return (dir_list_t*)HAWK_RBT_VPTR(pair);
|
||||
}
|
||||
|
||||
|
@ -76,14 +76,14 @@ static int fnc_math_1 (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, hawk_math1_t
|
||||
int n;
|
||||
|
||||
nargs = hawk_rtx_getnargs (rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 1);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
|
||||
n = hawk_rtx_valtoflt(rtx, a0, &rv);
|
||||
if (n <= -1) return -1;
|
||||
|
||||
r = hawk_rtx_makefltval (rtx, f (hawk_rtx_getawk(rtx), rv));
|
||||
r = hawk_rtx_makefltval (rtx, f (hawk_rtx_gethawk(rtx), rv));
|
||||
if (r == HAWK_NULL) return -1;
|
||||
|
||||
hawk_rtx_setretval (rtx, r);
|
||||
@ -99,7 +99,7 @@ static int fnc_math_2 (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, hawk_math2_t
|
||||
int n;
|
||||
|
||||
nargs = hawk_rtx_getnargs (rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 2);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 2);
|
||||
|
||||
a0 = hawk_rtx_getarg(rtx, 0);
|
||||
a1 = hawk_rtx_getarg(rtx, 1);
|
||||
@ -110,7 +110,7 @@ static int fnc_math_2 (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, hawk_math2_t
|
||||
n = hawk_rtx_valtoflt (rtx, a1, &rv1);
|
||||
if (n <= -1) return -1;
|
||||
|
||||
r = hawk_rtx_makefltval (rtx, f (hawk_rtx_getawk(rtx), rv0, rv1));
|
||||
r = hawk_rtx_makefltval (rtx, f (hawk_rtx_gethawk(rtx), rv0, rv1));
|
||||
if (r == HAWK_NULL) return -1;
|
||||
|
||||
hawk_rtx_setretval (rtx, r);
|
||||
@ -556,7 +556,7 @@ static int fnc_srand (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
|
||||
modctx = (modctx_t*)fi->mod->ctx;
|
||||
nargs = hawk_rtx_getnargs(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 0 || nargs == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 0 || nargs == 1);
|
||||
|
||||
prev = modctx->seed;
|
||||
|
||||
|
@ -435,7 +435,7 @@ static global_t gtab[] =
|
||||
|
||||
#define SETERR_ARG(awk,code,ep,el) SETERR_ARG_LOC(awk,code,ep,el,HAWK_NULL)
|
||||
|
||||
#define ADJERR_LOC(rtx,l) do { (awk)->errloc = *(l); } while (0)
|
||||
#define ADJERR_LOC(rtx,l) do { (awk)->_gem.errloc = *(l); } while (0)
|
||||
|
||||
static HAWK_INLINE int is_plain_var (hawk_nde_t* nde)
|
||||
{
|
||||
@ -829,7 +829,7 @@ static int begin_include (hawk_t* awk, int once)
|
||||
if (awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, arg, HAWK_NULL, 0) <= -1)
|
||||
{
|
||||
if (ISNOERR(awk)) SETERR_TOK (awk, HAWK_EOPEN);
|
||||
else awk->errloc = awk->tok.loc; /* adjust error location */
|
||||
else awk->_gem.errloc = awk->tok.loc; /* adjust error location */
|
||||
goto oops;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ int hawk_rtx_setrec (hawk_rtx_t* rtx, hawk_oow_t idx, const hawk_oocs_t* str)
|
||||
return -1;
|
||||
}
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, rtx->inrec.d0) == HAWK_VAL_NIL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, rtx->inrec.d0) == HAWK_VAL_NIL);
|
||||
/* d0 should be cleared before the next line is reached
|
||||
* as it doesn't call hawk_rtx_refdownval on rtx->inrec.d0 */
|
||||
rtx->inrec.d0 = v;
|
||||
@ -109,7 +109,7 @@ static int split_record (hawk_rtx_t* rtx)
|
||||
|
||||
|
||||
/* inrec should be cleared before split_record is called */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->inrec.nflds == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->inrec.nflds == 0);
|
||||
|
||||
/* get FS */
|
||||
fs = hawk_rtx_getgbl (rtx, HAWK_GBL_FS);
|
||||
@ -198,7 +198,7 @@ static int split_record (hawk_rtx_t* rtx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
|
||||
|
||||
nflds++;
|
||||
len = HAWK_OOECS_LEN(&rtx->inrec.line) - (p - HAWK_OOECS_PTR(&rtx->inrec.line));
|
||||
@ -288,7 +288,7 @@ static int split_record (hawk_rtx_t* rtx)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
|
||||
|
||||
#if 1
|
||||
if (rtx->inrec.nflds >= rtx->inrec.maxflds)
|
||||
@ -361,11 +361,11 @@ int hawk_rtx_clrrec (hawk_rtx_t* run, int skip_inrec_line)
|
||||
|
||||
if (run->inrec.nflds > 0)
|
||||
{
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), run->inrec.flds != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->inrec.flds != HAWK_NULL);
|
||||
|
||||
for (i = 0; i < run->inrec.nflds; i++)
|
||||
{
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), run->inrec.flds[i].val != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->inrec.flds[i].val != HAWK_NULL);
|
||||
hawk_rtx_refdownval (run, run->inrec.flds[i].val);
|
||||
}
|
||||
run->inrec.nflds = 0;
|
||||
@ -380,7 +380,7 @@ int hawk_rtx_clrrec (hawk_rtx_t* run, int skip_inrec_line)
|
||||
}
|
||||
}
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), run->inrec.nflds == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->inrec.nflds == 0);
|
||||
if (!skip_inrec_line) hawk_ooecs_clear (&run->inrec.line);
|
||||
|
||||
return n;
|
||||
@ -394,7 +394,7 @@ static int recomp_record_fields (hawk_rtx_t* rtx, hawk_oow_t lv, const hawk_oocs
|
||||
/* recomposes the record and the fields when $N has been assigned
|
||||
* a new value and recomputes NF accordingly */
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), lv > 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), lv > 0);
|
||||
max = (lv > rtx->inrec.nflds)? lv: rtx->inrec.nflds;
|
||||
|
||||
nflds = rtx->inrec.nflds;
|
||||
@ -488,7 +488,7 @@ static int recomp_record_fields (hawk_rtx_t* rtx, hawk_oow_t lv, const hawk_oocs
|
||||
}
|
||||
|
||||
v = hawk_rtx_getgbl (rtx, HAWK_GBL_NF);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, v) == HAWK_VAL_INT);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, v) == HAWK_VAL_INT);
|
||||
|
||||
if (HAWK_RTX_GETINTFROMVAL (rtx, v)!= max)
|
||||
{
|
||||
|
@ -101,9 +101,9 @@ static int find_rio_in (
|
||||
hawk_rio_impl_t handler;
|
||||
int io_type, io_mode, io_mask;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
|
||||
|
||||
/* translate the in_type into the relevant io type and mode */
|
||||
io_type = in_type_map[in_type];
|
||||
@ -225,8 +225,8 @@ static HAWK_INLINE int match_long_rs (hawk_rtx_t* run, hawk_ooecs_t* buf, hawk_r
|
||||
hawk_errnum_t errnum;
|
||||
int ret;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), run->gbl.rs[0] != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), run->gbl.rs[1] != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->gbl.rs[0] != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->gbl.rs[1] != HAWK_NULL);
|
||||
|
||||
ret = hawk_matchrex (
|
||||
run->awk, run->gbl.rs[run->gbl.ignorecase],
|
||||
@ -246,7 +246,7 @@ static HAWK_INLINE int match_long_rs (hawk_rtx_t* run, hawk_ooecs_t* buf, hawk_r
|
||||
* as the previous call to this function.
|
||||
* A match in this case must end at the end of
|
||||
* the current record buffer */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx),
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
|
||||
HAWK_OOECS_PTR(buf) + HAWK_OOECS_LEN(buf) ==
|
||||
match.ptr + match.len
|
||||
);
|
||||
@ -435,9 +435,9 @@ int hawk_rtx_readio (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name, hawk
|
||||
/* CR must have come from the previous
|
||||
* read. drop CR that must be found at
|
||||
* the end of the record buffer. */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), end_pos == start_pos);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_OOECS_LEN(buf) > 0);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_OOECS_LASTCHAR(buf) == HAWK_T('\r'));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), end_pos == start_pos);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LEN(buf) > 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LASTCHAR(buf) == HAWK_T('\r'));
|
||||
HAWK_OOECS_LEN(buf)--;
|
||||
}
|
||||
}
|
||||
@ -473,7 +473,7 @@ int hawk_rtx_readio (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name, hawk
|
||||
{
|
||||
/* shrink the line length and the record
|
||||
* by dropping of CR before NL */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), line_len > 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), line_len > 0);
|
||||
line_len--;
|
||||
|
||||
/* we don't drop CR from the record buffer
|
||||
@ -649,9 +649,9 @@ static int prepare_for_write_io_data (hawk_rtx_t* rtx, int out_type, const hawk_
|
||||
hawk_rio_impl_t handler;
|
||||
int io_type, io_mode, io_mask, n;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
|
||||
/* translate the out_type into the relevant io type and mode */
|
||||
io_type = out_type_map[out_type];
|
||||
@ -810,9 +810,9 @@ int hawk_rtx_flushio (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* name)
|
||||
hawk_ooi_t n;
|
||||
int ok = 0;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
|
||||
/* translate the out_type into the relevant I/O type and mode */
|
||||
io_type = out_type_map[out_type];
|
||||
@ -866,9 +866,9 @@ int hawk_rtx_nextio_read (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name)
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
hawk_ooi_t n;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
|
||||
|
||||
/* translate the in_type into the relevant I/O type and mode */
|
||||
io_type = in_type_map[in_type];
|
||||
@ -892,7 +892,7 @@ int hawk_rtx_nextio_read (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name)
|
||||
if (!p)
|
||||
{
|
||||
/* something is totally wrong */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - cannot find the relevant rio entry");
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - cannot find the relevant rio entry");
|
||||
hawk_rtx_seterrnum (rtx, HAWK_EINTERN, HAWK_NULL);
|
||||
return -1;
|
||||
}
|
||||
@ -941,9 +941,9 @@ int hawk_rtx_nextio_write (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* nam
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
hawk_ooi_t n;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
|
||||
/* translate the out_type into the relevant I/O type and mode */
|
||||
io_type = out_type_map[out_type];
|
||||
@ -967,7 +967,7 @@ int hawk_rtx_nextio_write (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* nam
|
||||
if (!p)
|
||||
{
|
||||
/* something is totally wrong */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - cannot find the relevant rio entry");
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - cannot find the relevant rio entry");
|
||||
|
||||
hawk_rtx_seterrnum (rtx, HAWK_EINTERN, HAWK_NULL);
|
||||
return -1;
|
||||
@ -1011,9 +1011,9 @@ int hawk_rtx_closio_read (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name)
|
||||
hawk_rio_impl_t handler;
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
|
||||
|
||||
/* translate the in_type into the relevant I/O type and mode */
|
||||
io_type = in_type_map[in_type];
|
||||
@ -1068,9 +1068,9 @@ int hawk_rtx_closio_write (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* nam
|
||||
hawk_rio_impl_t handler;
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
|
||||
|
||||
/* translate the out_type into the relevant io type and mode */
|
||||
io_type = out_type_map[out_type];
|
||||
@ -1150,7 +1150,7 @@ int hawk_rtx_closeio (hawk_rtx_t* rtx, const hawk_ooch_t* name, const hawk_ooch_
|
||||
}
|
||||
else
|
||||
{
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), opt[0] == HAWK_T('w'));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), opt[0] == HAWK_T('w'));
|
||||
if (p->type & IO_MASK_RDWR)
|
||||
{
|
||||
if (p->rwcstate != HAWK_RIO_CMD_CLOSE_READ)
|
||||
|
439
hawk/lib/run.c
439
hawk/lib/run.c
File diff suppressed because it is too large
Load Diff
@ -608,7 +608,7 @@ static hawk_sio_t* open_sio (hawk_t* awk, const hawk_ooch_t* file, int flags)
|
||||
static hawk_sio_t* open_sio_rtx (hawk_rtx_t* rtx, const hawk_ooch_t* file, int flags)
|
||||
{
|
||||
hawk_sio_t* sio;
|
||||
sio = hawk_sio_open(hawk_rtx_getawk(rtx), 0, file, flags);
|
||||
sio = hawk_sio_open(hawk_rtx_gethawk(rtx), 0, file, flags);
|
||||
if (sio == HAWK_NULL)
|
||||
{
|
||||
hawk_oocs_t errarg;
|
||||
@ -638,7 +638,7 @@ static hawk_sio_t* open_sio_std_rtx (hawk_rtx_t* rtx, hawk_sio_std_t std, int fl
|
||||
{
|
||||
hawk_sio_t* sio;
|
||||
|
||||
sio = hawk_sio_openstd(hawk_rtx_getawk(rtx), 0, std, flags);
|
||||
sio = hawk_sio_openstd(hawk_rtx_gethawk(rtx), 0, std, flags);
|
||||
if (sio == HAWK_NULL) hawk_rtx_seterrnum (rtx, HAWK_EOPEN, &sio_std_names[std]);
|
||||
return sio;
|
||||
}
|
||||
@ -1479,7 +1479,7 @@ static hawk_ooi_t pio_handler_open (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
|
||||
}
|
||||
|
||||
handle = hawk_pio_open (
|
||||
hawk_rtx_getawk(rtx),
|
||||
hawk_rtx_gethawk(rtx),
|
||||
0,
|
||||
riod->name,
|
||||
flags | HAWK_PIO_SHELL | HAWK_PIO_TEXT | HAWK_PIO_IGNOREECERR
|
||||
@ -1628,7 +1628,7 @@ static hawk_ooi_t awk_rio_file (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_ar
|
||||
return -1;
|
||||
}
|
||||
|
||||
handle = hawk_sio_open(hawk_rtx_getawk(rtx), 0, riod->name, flags);
|
||||
handle = hawk_sio_open(hawk_rtx_gethawk(rtx), 0, riod->name, flags);
|
||||
if (handle == HAWK_NULL)
|
||||
{
|
||||
hawk_oocs_t errarg;
|
||||
@ -1686,7 +1686,7 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
|
||||
{
|
||||
/* if no input files is specified,
|
||||
* open the standard input */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), rxtn->c.in.index == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->c.in.index == 0);
|
||||
|
||||
if (rxtn->c.in.count == 0)
|
||||
{
|
||||
@ -1758,19 +1758,19 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
|
||||
* { print $0; }' file1 file2
|
||||
*/
|
||||
argv = hawk_rtx_getgbl(rtx, xtn->gbl_argv);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), argv != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, argv) == HAWK_VAL_MAP);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), argv != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, argv) == HAWK_VAL_MAP);
|
||||
|
||||
map = ((hawk_val_map_t*)argv)->map;
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), map != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), map != HAWK_NULL);
|
||||
|
||||
ibuflen = hawk_int_to_oocstr (rxtn->c.in.index + 1, 10, HAWK_NULL, ibuf, HAWK_COUNTOF(ibuf));
|
||||
|
||||
pair = hawk_htb_search(map, ibuf, ibuflen);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), pair != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), pair != HAWK_NULL);
|
||||
|
||||
v = HAWK_HTB_VPTR(pair);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), v != HAWK_NULL);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), v != HAWK_NULL);
|
||||
|
||||
as.ptr = hawk_rtx_getvaloocstr(rtx, v, &as.len);
|
||||
if (as.ptr == HAWK_NULL) return -1;
|
||||
@ -1836,7 +1836,7 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
|
||||
{
|
||||
if (rxtn->c.out.files == HAWK_NULL)
|
||||
{
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), rxtn->c.out.index == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->c.out.index == 0);
|
||||
|
||||
if (rxtn->c.out.count == 0)
|
||||
{
|
||||
@ -2041,7 +2041,7 @@ static int build_argcv (
|
||||
}
|
||||
|
||||
key_len = hawk_int_to_oocstr (argc, 10, HAWK_NULL, key, HAWK_COUNTOF(key));
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), key_len != (hawk_oow_t)-1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), key_len != (hawk_oow_t)-1);
|
||||
|
||||
hawk_rtx_refupval (rtx, v_tmp);
|
||||
|
||||
@ -2128,8 +2128,8 @@ static int build_environ (hawk_rtx_t* rtx, int gbl_id, env_char_t* envarr[])
|
||||
* variaables are not under control, call mbstowcsalldup() instead
|
||||
* to go on despite encoding failure */
|
||||
|
||||
kptr = hawk_dupbtoucstr(hawk_rtx_getawk(rtx), envarr[count], &klen, 1);
|
||||
vptr = hawk_dupbtoucstr(hawk_rtx_getawk(rtx), eq + 1, HAWK_NULL, 1);
|
||||
kptr = hawk_dupbtoucstr(hawk_rtx_gethawk(rtx), envarr[count], &klen, 1);
|
||||
vptr = hawk_dupbtoucstr(hawk_rtx_gethawk(rtx), eq + 1, HAWK_NULL, 1);
|
||||
if (kptr == HAWK_NULL || vptr == HAWK_NULL)
|
||||
{
|
||||
if (kptr) hawk_rtx_freemem (rtx, kptr);
|
||||
@ -2147,8 +2147,8 @@ static int build_environ (hawk_rtx_t* rtx, int gbl_id, env_char_t* envarr[])
|
||||
|
||||
*eq = HAWK_UT('\0');
|
||||
|
||||
kptr = hawk_duputobcstr(hawk_rtx_getawk(rtx), envarr[count], &klen);
|
||||
vptr = hawk_duputobcstr(hawk_rtx_getawk(rtx), eq + 1, HAWK_NULL);
|
||||
kptr = hawk_duputobcstr(hawk_rtx_gethawk(rtx), envarr[count], &klen);
|
||||
vptr = hawk_duputobcstr(hawk_rtx_gethawk(rtx), eq + 1, HAWK_NULL);
|
||||
if (kptr == HAWK_NULL || vptr == HAWK_NULL)
|
||||
{
|
||||
if (kptr) hawk_rtx_freemem (rtx, kptr);
|
||||
@ -2511,7 +2511,7 @@ static int fnc_setioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
int tmout;
|
||||
|
||||
rxtn = GET_RXTN(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), rxtn->cmgrtab_inited == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->cmgrtab_inited == 1);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
@ -2633,7 +2633,7 @@ static int fnc_getioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
ioattr_t ioattr_buf;
|
||||
|
||||
rxtn = GET_RXTN(rtx);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), rxtn->cmgrtab_inited == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->cmgrtab_inited == 1);
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
@ -2717,7 +2717,7 @@ hawk_cmgr_t* hawk_rtx_getiocmgrstd (hawk_rtx_t* rtx, const hawk_ooch_t* ioname)
|
||||
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||
ioattr_t* ioattr;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), rxtn->cmgrtab_inited == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->cmgrtab_inited == 1);
|
||||
|
||||
ioattr = get_ioattr(&rxtn->cmgrtab, ioname, hawk_count_oocstr(ioname));
|
||||
if (ioattr) return ioattr->cmgr;
|
||||
|
@ -35,13 +35,13 @@ int awk_rtx_strtonum (hawk_rtx_t* rtx, int option, const char_t* ptr, hawk_oow_t
|
||||
int base = HAWK_RTX_STRTONUN_GET_OPTION_BASE(option);
|
||||
|
||||
end = ptr + len;
|
||||
*l = awk_strxtoint(rtx->awk, ptr, len, base, &endptr);
|
||||
*l = awk_strxtoint(hawk_rtx_gethawk(rtx), ptr, len, base, &endptr);
|
||||
if (endptr < end)
|
||||
{
|
||||
if (*endptr == _T('.') || *endptr == _T('E') || *endptr == _T('e'))
|
||||
{
|
||||
handle_float:
|
||||
*r = awk_strxtoflt(rtx->awk, ptr, len, &endptr);
|
||||
*r = awk_strxtoflt(hawk_rtx_gethawk(rtx), ptr, len, &endptr);
|
||||
if (strict && endptr < end) return -1;
|
||||
return 1; /* flt */
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ hawk_val_t* hawk_rtx_makeintval (hawk_rtx_t* rtx, hawk_int_t v)
|
||||
val->nde = HAWK_NULL;
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("makeintval => %jd [%p] - [%O]\n"), (hawk_intmax_t)v, val, val);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("makeintval => %jd [%p] - [%O]\n"), (hawk_intmax_t)v, val, val);
|
||||
#endif
|
||||
return (hawk_val_t*)val;
|
||||
}
|
||||
@ -154,7 +154,7 @@ hawk_val_t* hawk_rtx_makefltval (hawk_rtx_t* rtx, hawk_flt_t v)
|
||||
val->nde = HAWK_NULL;
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("makefltval => %Lf [%p] - [%O]\n"), (double)v, val, val);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("makefltval => %Lf [%p] - [%O]\n"), (double)v, val, val);
|
||||
#endif
|
||||
return (hawk_val_t*)val;
|
||||
}
|
||||
@ -200,7 +200,7 @@ init:
|
||||
val->val.ptr[val->val.len] = '\0';
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("make_str_val => %p - [%O]\n"), val, val);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("make_str_val => %p - [%O]\n"), val, val);
|
||||
#endif
|
||||
return (hawk_val_t*)val;
|
||||
}
|
||||
@ -316,7 +316,7 @@ hawk_val_t* hawk_rtx_makenstrvalwithuchars (hawk_rtx_t* rtx, const hawk_uch_t* p
|
||||
{
|
||||
/* set the numeric string flag if a string
|
||||
* can be converted to a number */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), x == 0 || x == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), x == 0 || x == 1);
|
||||
v->nstr = x + 1; /* long -> 1, real -> 2 */
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ hawk_val_t* hawk_rtx_makenstrvalwithbchars (hawk_rtx_t* rtx, const hawk_bch_t* p
|
||||
{
|
||||
/* set the numeric string flag if a string
|
||||
* can be converted to a number */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), x == 0 || x == 1);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), x == 0 || x == 1);
|
||||
v->nstr = x + 1; /* long -> 1, real -> 2 */
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ static void free_mapval (hawk_htb_t* map, void* dptr, hawk_oow_t dlen)
|
||||
hawk_rtx_t* rtx = *(hawk_rtx_t**)hawk_htb_getxtn(map);
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("refdown in map free - [%O]\n"), dptr);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("refdown in map free - [%O]\n"), dptr);
|
||||
#endif
|
||||
|
||||
hawk_rtx_refdownval (rtx, dptr);
|
||||
@ -443,7 +443,7 @@ static void same_mapval (hawk_htb_t* map, void* dptr, hawk_oow_t dlen)
|
||||
{
|
||||
hawk_rtx_t* run = *(hawk_rtx_t**)hawk_htb_getxtn(map);
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("refdown nofree in map free - [%O]\n"), dptr);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("refdown nofree in map free - [%O]\n"), dptr);
|
||||
#endif
|
||||
hawk_rtx_refdownval_nofree (run, dptr);
|
||||
}
|
||||
@ -500,7 +500,7 @@ hawk_val_t* hawk_rtx_makemapval (hawk_rtx_t* rtx)
|
||||
val->fcb = 0;
|
||||
val->map = (hawk_htb_t*)(val + 1);
|
||||
|
||||
if (hawk_htb_init(val->map, hawk_rtx_getawk(rtx), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1) <= -1)
|
||||
if (hawk_htb_init(val->map, hawk_rtx_gethawk(rtx), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1) <= -1)
|
||||
{
|
||||
hawk_rtx_freemem (rtx, val);
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
@ -581,7 +581,7 @@ hawk_val_t* hawk_rtx_setmapvalfld (
|
||||
hawk_rtx_t* rtx, hawk_val_t* map,
|
||||
const hawk_ooch_t* kptr, hawk_oow_t klen, hawk_val_t* v)
|
||||
{
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
|
||||
if (hawk_htb_upsert (
|
||||
((hawk_val_map_t*)map)->map,
|
||||
@ -606,7 +606,7 @@ hawk_val_t* hawk_rtx_getmapvalfld (
|
||||
{
|
||||
hawk_htb_pair_t* pair;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
|
||||
pair = hawk_htb_search(((hawk_val_map_t*)map)->map, kptr, klen);
|
||||
if (pair == HAWK_NULL)
|
||||
@ -627,7 +627,7 @@ hawk_val_t* hawk_rtx_getmapvalfld (
|
||||
hawk_val_map_itr_t* hawk_rtx_getfirstmapvalitr (
|
||||
hawk_rtx_t* rtx, hawk_val_t* map, hawk_val_map_itr_t* itr)
|
||||
{
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
itr->pair = hawk_htb_getfirstpair (((hawk_val_map_t*)map)->map, &itr->buckno);
|
||||
return itr->pair? itr: HAWK_NULL;
|
||||
}
|
||||
@ -635,7 +635,7 @@ hawk_val_map_itr_t* hawk_rtx_getfirstmapvalitr (
|
||||
hawk_val_map_itr_t* hawk_rtx_getnextmapvalitr (
|
||||
hawk_rtx_t* rtx, hawk_val_t* map, hawk_val_map_itr_t* itr)
|
||||
{
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
|
||||
itr->pair = hawk_htb_getnextpair (((hawk_val_map_t*)map)->map, itr->pair, &itr->buckno);
|
||||
return itr->pair? itr: HAWK_NULL;
|
||||
}
|
||||
@ -719,7 +719,7 @@ void hawk_rtx_freeval (hawk_rtx_t* rtx, hawk_val_t* val, int cache)
|
||||
if (IS_STATICVAL(val)) return;
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("freeing [cache=%d] - [%O]\n"), cache, val);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("freeing [cache=%d] - [%O]\n"), cache, val);
|
||||
#endif
|
||||
|
||||
vtype = HAWK_RTX_GETVALTYPE (rtx, val);
|
||||
@ -820,7 +820,7 @@ void hawk_rtx_refupval (hawk_rtx_t* rtx, hawk_val_t* val)
|
||||
if (IS_STATICVAL(val)) return;
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("ref up [ptr=%p] [count=%d] - [%O]\n"), val, (int)val->ref, val);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("ref up [ptr=%p] [count=%d] - [%O]\n"), val, (int)val->ref, val);
|
||||
#endif
|
||||
val->ref++;
|
||||
}
|
||||
@ -833,11 +833,11 @@ void hawk_rtx_refdownval (hawk_rtx_t* rtx, hawk_val_t* val)
|
||||
if (IS_STATICVAL(val)) return;
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("ref down [ptr=%p] [count=%d] - [%O]\n"), val, (int)val->ref, val);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("ref down [ptr=%p] [count=%d] - [%O]\n"), val, (int)val->ref, val);
|
||||
#endif
|
||||
|
||||
/* the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), val->ref > 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val->ref > 0);
|
||||
|
||||
|
||||
val->ref--;
|
||||
@ -855,7 +855,7 @@ void hawk_rtx_refdownval_nofree (hawk_rtx_t* rtx, hawk_val_t* val)
|
||||
if (IS_STATICVAL(val)) return;
|
||||
|
||||
/* the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), val->ref > 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val->ref > 0);
|
||||
|
||||
val->ref--;
|
||||
}
|
||||
@ -909,7 +909,7 @@ static int val_ref_to_bool (hawk_rtx_t* rtx, const hawk_val_ref_t* ref)
|
||||
/* A reference value is not able to point to another
|
||||
* refernce value for the way values are represented
|
||||
* in HAWKAWK */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
|
||||
|
||||
/* make a recursive call back to the caller */
|
||||
return hawk_rtx_valtobool(rtx, *xref);
|
||||
@ -949,7 +949,7 @@ int hawk_rtx_valtobool (hawk_rtx_t* rtx, const hawk_val_t* val)
|
||||
}
|
||||
|
||||
/* the type of a value should be one of HAWK_VAL_XXX enumerators defined in hawk-prv.h */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - invalid value type");
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid value type");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1119,7 +1119,7 @@ static int val_int_to_str (hawk_rtx_t* rtx, const hawk_val_int_t* v, hawk_rtx_va
|
||||
* and cpl are the same type. the following
|
||||
* assertion at least ensure that they have
|
||||
* the same size. */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
|
||||
|
||||
case HAWK_RTX_VALTOSTR_CPLCPY:
|
||||
if (rlen >= out->u.cplcpy.len)
|
||||
@ -1149,7 +1149,7 @@ static int val_int_to_str (hawk_rtx_t* rtx, const hawk_val_int_t* v, hawk_rtx_va
|
||||
hawk_oow_t n;
|
||||
|
||||
hawk_ooecs_clear (out->u.strp);
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_OOECS_LEN(out->u.strp) == 0);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LEN(out->u.strp) == 0);
|
||||
|
||||
/* point to the beginning of the buffer */
|
||||
tmp = HAWK_OOECS_PTR(out->u.strp);
|
||||
@ -1226,14 +1226,14 @@ static int val_flt_to_str (hawk_rtx_t* rtx, const hawk_val_flt_t* v, hawk_rtx_va
|
||||
tmp_len = rtx->gbl.convfmt.len;
|
||||
}
|
||||
|
||||
if (hawk_ooecs_init(&buf, hawk_rtx_getawk(rtx), 256) <= -1)
|
||||
if (hawk_ooecs_init(&buf, hawk_rtx_gethawk(rtx), 256) <= -1)
|
||||
{
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
return -1;
|
||||
}
|
||||
buf_inited = 1;
|
||||
|
||||
if (hawk_ooecs_init(&fbu, hawk_rtx_getawk(rtx), 256) <= -1)
|
||||
if (hawk_ooecs_init(&fbu, hawk_rtx_gethawk(rtx), 256) <= -1)
|
||||
{
|
||||
hawk_ooecs_fini (&buf);
|
||||
hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL);
|
||||
@ -1252,7 +1252,7 @@ static int val_flt_to_str (hawk_rtx_t* rtx, const hawk_val_flt_t* v, hawk_rtx_va
|
||||
* and cpl are the same type. the following
|
||||
* assertion at least ensure that they have
|
||||
* the same size. */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
|
||||
|
||||
case HAWK_RTX_VALTOSTR_CPLCPY:
|
||||
if (out->u.cplcpy.len <= tmp_len)
|
||||
@ -1369,7 +1369,7 @@ static int val_ref_to_str (hawk_rtx_t* rtx, const hawk_val_ref_t* ref, hawk_rtx_
|
||||
/* A reference value is not able to point to another
|
||||
* refernce value for the way values are represented
|
||||
* in HAWKAWK */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref) != HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref) != HAWK_VAL_REF);
|
||||
|
||||
/* make a recursive call back to the caller */
|
||||
return hawk_rtx_valtostr (rtx, *xref, out);
|
||||
@ -1436,7 +1436,7 @@ int hawk_rtx_valtostr (hawk_rtx_t* rtx, const hawk_val_t* v, hawk_rtx_valtostr_o
|
||||
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T(">>WRONG VALUE TYPE [%d] in hawk_rtx_valtostr\n"), v->type);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T(">>WRONG VALUE TYPE [%d] in hawk_rtx_valtostr\n"), v->type);
|
||||
#endif
|
||||
hawk_rtx_seterrnum (rtx, HAWK_EVALTOSTR, HAWK_NULL);
|
||||
return -1;
|
||||
@ -1662,7 +1662,7 @@ static int val_ref_to_num (hawk_rtx_t* rtx, const hawk_val_ref_t* ref, hawk_int_
|
||||
/* A reference value is not able to point to another
|
||||
* refernce value for the way values are represented
|
||||
* in HAWKAWK */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE(rtx, *xref) != HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, *xref) != HAWK_VAL_REF);
|
||||
|
||||
/* make a recursive call back to the caller */
|
||||
return hawk_rtx_valtonum(rtx, *xref, l, r);
|
||||
@ -1740,7 +1740,7 @@ int hawk_rtx_valtonum (hawk_rtx_t* rtx, const hawk_val_t* v, hawk_int_t* l, hawk
|
||||
}
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T(">>WRONG VALUE TYPE [%d] in hawk_rtx_valtonum()\n"), v->type);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T(">>WRONG VALUE TYPE [%d] in hawk_rtx_valtonum()\n"), v->type);
|
||||
#endif
|
||||
|
||||
hawk_rtx_seterrnum (rtx, HAWK_EVALTONUM, HAWK_NULL);
|
||||
@ -1865,7 +1865,7 @@ hawk_int_t hawk_rtx_hashval (hawk_rtx_t* rtx, hawk_val_t* v)
|
||||
default:
|
||||
|
||||
#if defined(DEBUG_VAL)
|
||||
hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T(">>WRONG VALUE TYPE [%d] in hawk_rtx_hashval()\n"), v->type);
|
||||
hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T(">>WRONG VALUE TYPE [%d] in hawk_rtx_hashval()\n"), v->type);
|
||||
#endif
|
||||
hawk_rtx_seterrnum (rtx, HAWK_EHASHVAL, HAWK_NULL);
|
||||
return -1;
|
||||
@ -1902,7 +1902,7 @@ hawk_val_type_t hawk_rtx_getrefvaltype (hawk_rtx_t* rtx, hawk_val_ref_t* ref)
|
||||
* refernce value for the way values are represented
|
||||
* in HAWKAWK */
|
||||
v = *xref;
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE(rtx, v) != HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, v) != HAWK_VAL_REF);
|
||||
return HAWK_RTX_GETVALTYPE(rtx, v);
|
||||
}
|
||||
}
|
||||
@ -1932,7 +1932,7 @@ hawk_val_t* hawk_rtx_getrefval (hawk_rtx_t* rtx, hawk_val_ref_t* ref)
|
||||
/* A reference value is not able to point to another
|
||||
* refernce value for the way values are represented
|
||||
* in HAWKAWK */
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
|
||||
return *xref;
|
||||
}
|
||||
}
|
||||
@ -2076,7 +2076,7 @@ static hawk_htb_walk_t print_pair (hawk_htb_t* map, hawk_htb_pair_t* pair, void*
|
||||
{
|
||||
hawk_rtx_t* run = (hawk_rtx_t*)arg;
|
||||
|
||||
HAWK_ASSERT (hawk_rtx_getawk(rtx), run == *(hawk_rtx_t**)hawk_htb_getxtn(map));
|
||||
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run == *(hawk_rtx_t**)hawk_htb_getxtn(map));
|
||||
|
||||
hawk_errputstrf (HAWK_T(" %.*s=>"),
|
||||
(int)HAWK_HTB_KLEN(pair), HAWK_HTB_KPTR(pair));
|
||||
|
Loading…
Reference in New Issue
Block a user