From 859a27db55855eeba6032fe5f9ff2814f7455d3b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 13 Dec 2019 08:26:54 +0000 Subject: [PATCH] pushing some common code to gem.c --- hawk/Makefile.in | 4 +- hawk/bin/main.c | 4 +- hawk/lib/Makefile.am | 2 + hawk/lib/Makefile.in | 53 +++--- hawk/lib/err.c | 61 +++--- hawk/lib/fnc.c | 76 ++++---- hawk/lib/gem.c | 126 ++++++++++++- hawk/lib/hawk-cmn.h | 12 ++ hawk/lib/hawk-gem.h | 122 ++++++++++++ hawk/lib/hawk-prv.h | 6 +- hawk/lib/hawk.c | 149 +-------------- hawk/lib/hawk.h | 324 +++++++++---------------------- hawk/lib/imap-imp.h | 2 +- hawk/lib/misc.c | 2 +- hawk/lib/mod-dir.c | 2 +- hawk/lib/mod-math.c | 10 +- hawk/lib/parse.c | 4 +- hawk/lib/rec.c | 18 +- hawk/lib/rio.c | 62 +++--- hawk/lib/run.c | 439 ++++++++++++++++--------------------------- hawk/lib/std.c | 38 ++-- hawk/lib/val-imp.h | 4 +- hawk/lib/val.c | 64 +++---- 23 files changed, 731 insertions(+), 853 deletions(-) create mode 100644 hawk/lib/hawk-gem.h diff --git a/hawk/Makefile.in b/hawk/Makefile.in index 389de403..5a5e8d6a 100644 --- a/hawk/Makefile.in +++ b/hawk/Makefile.in @@ -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) diff --git a/hawk/bin/main.c b/hawk/bin/main.c index 54870d57..6db859dd 100644 --- a/hawk/bin/main.c +++ b/hawk/bin/main.c @@ -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, diff --git a/hawk/lib/Makefile.am b/hawk/lib/Makefile.am index 45cb3cc6..a4a97083 100644 --- a/hawk/lib/Makefile.am +++ b/hawk/lib/Makefile.am @@ -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 \ diff --git a/hawk/lib/Makefile.in b/hawk/lib/Makefile.in index 0cb275f7..fde0dd21 100644 --- a/hawk/lib/Makefile.in +++ b/hawk/lib/Makefile.in @@ -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 diff --git a/hawk/lib/err.c b/hawk/lib/err.c index b6a99685..3f093a22 100644 --- a/hawk/lib/err.c +++ b/hawk/lib/err.c @@ -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); +} diff --git a/hawk/lib/fnc.c b/hawk/lib/fnc.c index 08511a76..87fe8fd2 100644 --- a/hawk/lib/fnc.c +++ b/hawk/lib/fnc.c @@ -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; diff --git a/hawk/lib/gem.c b/hawk/lib/gem.c index 955ab602..fe1af7db 100644 --- a/hawk/lib/gem.c +++ b/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; +} diff --git a/hawk/lib/hawk-cmn.h b/hawk/lib/hawk-cmn.h index f5fd7908..38eaad50 100644 --- a/hawk/lib/hawk-cmn.h +++ b/hawk/lib/hawk-cmn.h @@ -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; }; /* ========================================================================= diff --git a/hawk/lib/hawk-gem.h b/hawk/lib/hawk-gem.h new file mode 100644 index 00000000..a2151bf7 --- /dev/null +++ b/hawk/lib/hawk-gem.h @@ -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 + +#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 diff --git a/hawk/lib/hawk-prv.h b/hawk/lib/hawk-prv.h index 73572f64..3a40e4e8 100644 --- a/hawk/lib/hawk-prv.h +++ b/hawk/lib/hawk-prv.h @@ -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 diff --git a/hawk/lib/hawk.c b/hawk/lib/hawk.c index 2bfee6c0..5f3581b0 100644 --- a/hawk/lib/hawk.c +++ b/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) diff --git a/hawk/lib/hawk.h b/hawk/lib/hawk.h index c2ce6b3f..465ff7fc 100644 --- a/hawk/lib/hawk.h +++ b/hawk/lib/hawk.h @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -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 /* ----------------------------------------------------------------------- */ diff --git a/hawk/lib/imap-imp.h b/hawk/lib/imap-imp.h index 878f0cce..1939e625 100644 --- a/hawk/lib/imap-imp.h +++ b/hawk/lib/imap-imp.h @@ -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 */ diff --git a/hawk/lib/misc.c b/hawk/lib/misc.c index 78506f9c..6d6f628b 100644 --- a/hawk/lib/misc.c +++ b/hawk/lib/misc.c @@ -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) { diff --git a/hawk/lib/mod-dir.c b/hawk/lib/mod-dir.c index cceaadcf..3a24eed6 100644 --- a/hawk/lib/mod-dir.c +++ b/hawk/lib/mod-dir.c @@ -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); } diff --git a/hawk/lib/mod-math.c b/hawk/lib/mod-math.c index 293cc37d..5c672fae 100644 --- a/hawk/lib/mod-math.c +++ b/hawk/lib/mod-math.c @@ -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; diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index bc350847..e6b89a1c 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -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; } diff --git a/hawk/lib/rec.c b/hawk/lib/rec.c index e563f707..adb52cd0 100644 --- a/hawk/lib/rec.c +++ b/hawk/lib/rec.c @@ -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) { diff --git a/hawk/lib/rio.c b/hawk/lib/rio.c index 3aca6af7..f1feed29 100644 --- a/hawk/lib/rio.c +++ b/hawk/lib/rio.c @@ -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) diff --git a/hawk/lib/run.c b/hawk/lib/run.c index debd5d6a..190639f8 100644 --- a/hawk/lib/run.c +++ b/hawk/lib/run.c @@ -100,7 +100,7 @@ struct pafv_t #define SETERR_LOC(rtx,code,loc) SETERR_ARGX_LOC(rtx,code,HAWK_NULL,loc) #define SETERR_COD(rtx,code) SETERR_ARGX_LOC(rtx,code,HAWK_NULL,HAWK_NULL) -#define ADJERR_LOC(rtx,l) do { (rtx)->errloc = *(l); } while (0) +#define ADJERR_LOC(rtx,l) do { (rtx)->_gem.errloc = *(l); } while (0) static hawk_oow_t push_arg_from_vals (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, void* data); static hawk_oow_t push_arg_from_nde (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, void* data); @@ -223,7 +223,7 @@ static hawk_val_t* eval_printf (hawk_rtx_t* rtx, hawk_nde_t* nde); static int __raw_push (hawk_rtx_t* rtx, void* val); #define __raw_pop(rtx) \ do { \ - HAWK_ASSERT (hawk_rtx_getawk(rtx), (rtx)->stack_top > (rtx)->stack_base); \ + HAWK_ASSERT (hawk_rtx_gethawk(rtx), (rtx)->stack_top > (rtx)->stack_base); \ (rtx)->stack_top--; \ } while (0) @@ -248,7 +248,7 @@ HAWK_INLINE hawk_val_t* hawk_rtx_getarg (hawk_rtx_t* rtx, hawk_oow_t idx) HAWK_INLINE hawk_val_t* hawk_rtx_getgbl (hawk_rtx_t* rtx, int id) { - HAWK_ASSERT (hawk_rtx_getawk(rtx), id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls)); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls)); return RTX_STACK_GBL(rtx, id); } @@ -324,7 +324,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t { /* hawk_rtx_setgbl() has been called */ hawk_oocs_t ea; - ea.ptr = (hawk_ooch_t*)hawk_getgblname (rtx->awk, idx, &ea.len); + ea.ptr = (hawk_ooch_t*)hawk_getgblname(hawk_rtx_gethawk(rtx), idx, &ea.len); SETERR_ARGX (rtx, errnum, &ea); } @@ -344,7 +344,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t /* TODO: use global variable attribute. can it be a map? can it be a scalar? is it read-only???? */ hawk_oocs_t ea; - ea.ptr = (hawk_ooch_t*)hawk_getgblname (rtx->awk, idx, &ea.len); + ea.ptr = (hawk_ooch_t*)hawk_getgblname(hawk_rtx_gethawk(rtx), idx, &ea.len); SETERR_ARGX (rtx, HAWK_ENSCALARTOMAP, &ea); return -1; } @@ -416,7 +416,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t /* due to the expression evaluation rule, the * regular expression can not be an assigned value */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), vtype != HAWK_VAL_REX); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), vtype != HAWK_VAL_REX); out.type = HAWK_RTX_VALTOSTR_CPLDUP; if (hawk_rtx_valtostr (rtx, val, &out) <= -1) return -1; @@ -432,7 +432,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t void* rex, * irex; hawk_errnum_t errnum; - if (hawk_buildrex (rtx->awk, fs_ptr, fs_len, &errnum, &rex, &irex) <= -1) + if (hawk_buildrex (hawk_rtx_gethawk(rtx), fs_ptr, fs_len, &errnum, &rex, &irex) <= -1) { SETERR_COD (rtx, errnum); if (vtype != HAWK_VAL_STR) @@ -440,7 +440,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t return -1; } - if (rtx->gbl.fs[0]) hawk_freerex (rtx->awk, rtx->gbl.fs[0], rtx->gbl.fs[1]); + if (rtx->gbl.fs[0]) hawk_freerex (hawk_rtx_gethawk(rtx), rtx->gbl.fs[0], rtx->gbl.fs[1]); rtx->gbl.fs[0] = rex; rtx->gbl.fs[1] = irex; @@ -566,7 +566,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t /* due to the expression evaluation rule, the * regular expression can not be an assigned * value */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), vtype != HAWK_VAL_REX); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), vtype != HAWK_VAL_REX); out.type = HAWK_RTX_VALTOSTR_CPLDUP; if (hawk_rtx_valtostr(rtx, val, &out) <= -1) return -1; @@ -576,7 +576,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t if (rtx->gbl.rs[0]) { - hawk_freerex (rtx->awk, rtx->gbl.rs[0], rtx->gbl.rs[1]); + hawk_freerex (hawk_rtx_gethawk(rtx), rtx->gbl.rs[0], rtx->gbl.rs[1]); rtx->gbl.rs[0] = HAWK_NULL; rtx->gbl.rs[1] = HAWK_NULL; } @@ -587,7 +587,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t hawk_errnum_t errnum; /* compile the regular expression */ - if (hawk_buildrex(rtx->awk, rss.ptr, rss.len, &errnum, &rex, &irex) <= -1) + if (hawk_buildrex(hawk_rtx_gethawk(rtx), rss.ptr, rss.len, &errnum, &rex, &irex) <= -1) { SETERR_COD (rtx, errnum); if (vtype != HAWK_VAL_STR) hawk_rtx_freemem (rtx, rss.ptr); @@ -656,7 +656,7 @@ HAWK_INLINE void hawk_rtx_setretval (hawk_rtx_t* rtx, hawk_val_t* val) HAWK_INLINE int hawk_rtx_setgbl (hawk_rtx_t* rtx, int id, hawk_val_t* val) { - HAWK_ASSERT (hawk_rtx_getawk(rtx), id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls)); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls)); return set_global (rtx, id, HAWK_NULL, val, 0); } @@ -834,7 +834,7 @@ void hawk_rtx_close (hawk_rtx_t* rtx) */ fini_rtx (rtx, 1); - hawk_freemem (rtx->awk, rtx); + hawk_freemem (hawk_rtx_gethawk(rtx), rtx); } void hawk_rtx_halt (hawk_rtx_t* rtx) @@ -930,16 +930,16 @@ static int init_rtx (hawk_rtx_t* rtx, hawk_t* awk, hawk_rio_cbs_t* rio) rtx->inrec.maxflds = 0; rtx->inrec.d0 = hawk_val_nil; - if (hawk_ooecs_init(&rtx->inrec.line, hawk_rtx_getawk(rtx), DEF_BUF_CAPA) <= -1) goto oops_1; - if (hawk_ooecs_init(&rtx->inrec.linew, hawk_rtx_getawk(rtx), DEF_BUF_CAPA) <= -1) goto oops_2; - if (hawk_ooecs_init(&rtx->inrec.lineg, hawk_rtx_getawk(rtx), DEF_BUF_CAPA) <= -1) goto oops_3; - if (hawk_ooecs_init(&rtx->format.out, hawk_rtx_getawk(rtx), 256) <= -1) goto oops_4; - if (hawk_ooecs_init(&rtx->format.fmt, hawk_rtx_getawk(rtx), 256) <= -1) goto oops_5; + if (hawk_ooecs_init(&rtx->inrec.line, hawk_rtx_gethawk(rtx), DEF_BUF_CAPA) <= -1) goto oops_1; + if (hawk_ooecs_init(&rtx->inrec.linew, hawk_rtx_gethawk(rtx), DEF_BUF_CAPA) <= -1) goto oops_2; + if (hawk_ooecs_init(&rtx->inrec.lineg, hawk_rtx_gethawk(rtx), DEF_BUF_CAPA) <= -1) goto oops_3; + if (hawk_ooecs_init(&rtx->format.out, hawk_rtx_gethawk(rtx), 256) <= -1) goto oops_4; + if (hawk_ooecs_init(&rtx->format.fmt, hawk_rtx_gethawk(rtx), 256) <= -1) goto oops_5; - if (hawk_becs_init(&rtx->formatmbs.out, hawk_rtx_getawk(rtx), 256) <= -1) goto oops_6; - if (hawk_becs_init(&rtx->formatmbs.fmt, hawk_rtx_getawk(rtx), 256) <= -1) goto oops_7; + if (hawk_becs_init(&rtx->formatmbs.out, hawk_rtx_gethawk(rtx), 256) <= -1) goto oops_6; + if (hawk_becs_init(&rtx->formatmbs.fmt, hawk_rtx_gethawk(rtx), 256) <= -1) goto oops_7; - rtx->named = hawk_htb_open(hawk_rtx_getawk(rtx), HAWK_SIZEOF(rtx), 1024, 70, HAWK_SIZEOF(hawk_ooch_t), 1); + rtx->named = hawk_htb_open(hawk_rtx_gethawk(rtx), HAWK_SIZEOF(rtx), 1024, 70, HAWK_SIZEOF(hawk_ooch_t), 1); if (!rtx->named) goto oops_8; *(hawk_rtx_t**)hawk_htb_getxtn(rtx->named) = rtx; hawk_htb_setstyle (rtx->named, &style_for_named); @@ -1014,17 +1014,17 @@ static void fini_rtx (hawk_rtx_t* rtx, int fini_globals) /* close all pending io's */ /* TODO: what if this operation fails? */ hawk_rtx_cleario (rtx); - HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->rio.chain == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->rio.chain == HAWK_NULL); if (rtx->gbl.rs[0]) { - hawk_freerex (rtx->awk, rtx->gbl.rs[0], rtx->gbl.rs[1]); + hawk_freerex (hawk_rtx_gethawk(rtx), rtx->gbl.rs[0], rtx->gbl.rs[1]); rtx->gbl.rs[0] = HAWK_NULL; rtx->gbl.rs[1] = HAWK_NULL; } if (rtx->gbl.fs[0]) { - hawk_freerex (rtx->awk, rtx->gbl.fs[0], rtx->gbl.fs[1]); + hawk_freerex (hawk_rtx_gethawk(rtx), rtx->gbl.fs[0], rtx->gbl.fs[1]); rtx->gbl.fs[0] = HAWK_NULL; rtx->gbl.fs[1] = HAWK_NULL; } @@ -1101,7 +1101,7 @@ static void fini_rtx (hawk_rtx_t* rtx, int fini_globals) /* destroy the stack if necessary */ if (rtx->stack) { - HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->stack_top == 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->stack_top == 0); hawk_rtx_freemem (rtx, rtx->stack); rtx->stack = HAWK_NULL; @@ -1261,7 +1261,7 @@ static int defaultify_globals (hawk_rtx_t* rtx) hawk_rtx_refupval (rtx, tmp); - HAWK_ASSERT (hawk_rtx_getawk(rtx), RTX_STACK_GBL(rtx,gtab[i].idx) == hawk_val_nil); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), RTX_STACK_GBL(rtx,gtab[i].idx) == hawk_val_nil); if (hawk_rtx_setgbl(rtx, gtab[i].idx, tmp) == -1) { @@ -1297,8 +1297,8 @@ static void refdown_globals (hawk_rtx_t* run, int pop) static int init_globals (hawk_rtx_t* rtx) { /* the stack must be clean when this function is invoked */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->stack_base == 0); - HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->stack_top == 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->stack_base == 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->stack_top == 0); if (prepare_globals (rtx) == -1) return -1; if (update_fnr (rtx, 0, 0) == -1) goto oops; @@ -1361,7 +1361,7 @@ static void exit_stack_frame (hawk_rtx_t* run) { /* At this point, the current stack frame should have * the 4 entries pushed in enter_stack_frame(). */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), (run->stack_top-run->stack_base) == 4); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), (run->stack_top-run->stack_base) == 4); run->stack_top = (hawk_oow_t)run->stack[run->stack_base + 1]; run->stack_base = (hawk_oow_t)run->stack[run->stack_base + 0]; @@ -1386,7 +1386,7 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx) hawk_nde_blk_t* blk; blk = (hawk_nde_blk_t*)nde; - HAWK_ASSERT (hawk_rtx_getawk(rtx), blk->type == HAWK_NDE_BLK); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), blk->type == HAWK_NDE_BLK); rtx->active_block = blk; rtx->exit_level = EXIT_NONE; @@ -1431,7 +1431,7 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx) hawk_nde_blk_t* blk; blk = (hawk_nde_blk_t*)nde; - HAWK_ASSERT (hawk_rtx_getawk(rtx), blk->type == HAWK_NDE_BLK); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), blk->type == HAWK_NDE_BLK); rtx->active_block = blk; rtx->exit_level = EXIT_NONE; @@ -1458,7 +1458,7 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx) * pushed to the stack as asserted below. we didn't push any arguments * for BEGIN/pattern action/END block execution.*/ nargs = (hawk_oow_t)RTX_STACK_NARGS(rtx); - HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 0); for (i = 0; i < nargs; i++) hawk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i)); @@ -1552,7 +1552,7 @@ hawk_val_t* hawk_rtx_callfun (hawk_rtx_t* rtx, hawk_fun_t* fun, hawk_val_t* args struct pafv_t pafv/*= { args, nargs }*/; hawk_nde_fncall_t call; - HAWK_ASSERT (hawk_rtx_getawk(rtx), fun != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun != HAWK_NULL); pafv.args = args; pafv.nargs = nargs; @@ -1810,8 +1810,8 @@ static int run_pblock (hawk_rtx_t* rtx, hawk_chain_t* cha, hawk_oow_t bno) else { /* pattern, pattern { ... } */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), ptn->next->next == HAWK_NULL); - HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->pattern_range_state != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ptn->next->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->pattern_range_state != HAWK_NULL); if (rtx->pattern_range_state[bno] == 0) { @@ -1892,13 +1892,13 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) return 0; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->type == HAWK_NDE_BLK); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->type == HAWK_NDE_BLK); p = nde->body; nlcls = nde->nlcls; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("securing space for local variables nlcls = %d\n"), (int)nlcls); #endif @@ -1920,7 +1920,7 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) } #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("executing block statements\n")); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("executing block statements\n")); #endif while (p != HAWK_NULL && rtx->exit_level == EXIT_NONE) @@ -1935,7 +1935,7 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) /* pop off local variables */ #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("popping off local variables\n")); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("popping off local variables\n")); #endif nlcls = nde->nlcls; while (nlcls > 0) @@ -2075,7 +2075,7 @@ static int run_if (hawk_rtx_t* rtx, hawk_nde_if_t* nde) /* the test expression for the if statement cannot have * chained expressions. this should not be allowed by the * parser first of all */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->test->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL); test = eval_expression (rtx, nde->test); if (test == HAWK_NULL) return -1; @@ -2102,7 +2102,7 @@ static int run_while (hawk_rtx_t* rtx, hawk_nde_while_t* nde) { /* no chained expressions are allowed for the test * expression of the while statement */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->test->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL); while (1) { @@ -2146,7 +2146,7 @@ static int run_while (hawk_rtx_t* rtx, hawk_nde_while_t* nde) { /* no chained expressions are allowed for the test * expression of the while statement */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->test->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL); do { @@ -2190,7 +2190,7 @@ static int run_for (hawk_rtx_t* rtx, hawk_nde_for_t* nde) if (nde->init != HAWK_NULL) { - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->init->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->init->next == HAWK_NULL); ON_STATEMENT (rtx, nde->init); val = eval_expression(rtx,nde->init); @@ -2208,7 +2208,7 @@ static int run_for (hawk_rtx_t* rtx, hawk_nde_for_t* nde) /* no chained expressions for the test expression of * the for statement are allowed */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->test->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL); ON_STATEMENT (rtx, nde->test); test = eval_expression (rtx, nde->test); @@ -2249,7 +2249,7 @@ static int run_for (hawk_rtx_t* rtx, hawk_nde_for_t* nde) if (nde->incr != HAWK_NULL) { - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->incr->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->incr->next == HAWK_NULL); ON_STATEMENT (rtx, nde->incr); val = eval_expression (rtx, nde->incr); @@ -2327,11 +2327,11 @@ static int run_foreach (hawk_rtx_t* rtx, hawk_nde_foreach_t* nde) hawk_val_type_t rvtype; test = (hawk_nde_exp_t*)nde->test; - HAWK_ASSERT (hawk_rtx_getawk(rtx), test->type == HAWK_NDE_EXP_BIN && test->opcode == HAWK_BINOP_IN); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), test->type == HAWK_NDE_EXP_BIN && test->opcode == HAWK_BINOP_IN); /* chained expressions should not be allowed * by the parser first of all */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), test->right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), test->right->next == HAWK_NULL); rv = eval_expression(rtx, test->right); if (rv == HAWK_NULL) return -1; @@ -2382,7 +2382,7 @@ static int run_return (hawk_rtx_t* rtx, hawk_nde_return_t* nde) /* chained expressions should not be allowed * by the parser first of all */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->val->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->val->next == HAWK_NULL); val = eval_expression (rtx, nde->val); if (val == HAWK_NULL) return -1; @@ -2418,7 +2418,7 @@ static int run_exit (hawk_rtx_t* rtx, hawk_nde_exit_t* nde) /* chained expressions should not be allowed * by the parser first of all */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->val->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->val->next == HAWK_NULL); val = eval_expression (rtx, nde->val); if (val == HAWK_NULL) return -1; @@ -2533,7 +2533,7 @@ static int delete_indexed ( { hawk_val_t* idx; - HAWK_ASSERT (hawk_rtx_getawk(rtx), var->idx != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), var->idx != HAWK_NULL); idx = eval_expression (rtx, var->idx); if (idx == HAWK_NULL) return -1; @@ -2597,7 +2597,7 @@ static int run_delete_named (hawk_rtx_t* rtx, hawk_nde_var_t* var) /* if a named variable has an index part and a named indexed variable * doesn't have an index part, the program is definitely wrong */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), (var->type == HAWK_NDE_NAMED && var->idx == HAWK_NULL) || (var->type == HAWK_NDE_NAMEDIDX && var->idx != HAWK_NULL)); @@ -2636,7 +2636,7 @@ static int run_delete_named (hawk_rtx_t* rtx, hawk_nde_var_t* var) hawk_htb_t* map; val = (hawk_val_t*)HAWK_HTB_VPTR(pair); - HAWK_ASSERT (hawk_rtx_getawk(rtx), val != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL); if (HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_MAP) { @@ -2680,7 +2680,7 @@ static int run_delete_unnamed (hawk_rtx_t* rtx, hawk_nde_var_t* var) break; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), val != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL); vtype = HAWK_RTX_GETVALTYPE(rtx, val); if (vtype == HAWK_VAL_NIL) @@ -2779,7 +2779,7 @@ static int run_delete (hawk_rtx_t* rtx, hawk_nde_delete_t* nde) default: /* the delete statement cannot be called with other nodes than * the variables such as a named variable, a named indexed variable, etc */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - wrong target for delete"); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - wrong target for delete"); SETERR_LOC (rtx, HAWK_EBADARG, &var->loc); return -1; } @@ -2792,7 +2792,7 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var) { case HAWK_NDE_NAMED: /* if a named variable has an index part, something is definitely wrong */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), var->type == HAWK_NDE_NAMED && var->idx == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), var->type == HAWK_NDE_NAMED && var->idx == HAWK_NULL); /* a named variable can be reset if removed from a internal map to manage it */ @@ -2820,7 +2820,7 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var) break; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), val != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL); if (HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_NIL) { @@ -2845,7 +2845,7 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var) default: /* the reset statement can only be called with plain variables */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - wrong target for reset"); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - wrong target for reset"); SETERR_LOC (rtx, HAWK_EBADARG, &var->loc); return -1; } @@ -2863,7 +2863,7 @@ static int run_print (hawk_rtx_t* rtx, hawk_nde_print_t* nde) const hawk_ooch_t* dst; int n, xret = 0; - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), (nde->out_type == HAWK_OUT_PIPE && nde->out != HAWK_NULL) || (nde->out_type == HAWK_OUT_RWPIPE && nde->out != HAWK_NULL) || (nde->out_type == HAWK_OUT_FILE && nde->out != HAWK_NULL) || @@ -2941,7 +2941,7 @@ static int run_print (hawk_rtx_t* rtx, hawk_nde_print_t* nde) if (nde->args->type == HAWK_NDE_GRP) { /* parenthesized print */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->args->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->args->next == HAWK_NULL); head = ((hawk_nde_grp_t*)nde->args)->body; } else head = nde->args; @@ -3032,7 +3032,7 @@ static int run_printf (hawk_rtx_t* rtx, hawk_nde_print_t* nde) hawk_nde_t* head; int n, xret = 0; - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), (nde->out_type == HAWK_OUT_PIPE && nde->out != HAWK_NULL) || (nde->out_type == HAWK_OUT_RWPIPE && nde->out != HAWK_NULL) || (nde->out_type == HAWK_OUT_FILE && nde->out != HAWK_NULL) || @@ -3077,18 +3077,18 @@ static int run_printf (hawk_rtx_t* rtx, hawk_nde_print_t* nde) dst = (out == HAWK_NULL)? HAWK_T(""): out; /*( valid printf statement should have at least one argument. the parser must ensure this. */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->args != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->args != HAWK_NULL); if (nde->args->type == HAWK_NDE_GRP) { /* parenthesized print */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->args->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->args->next == HAWK_NULL); head = ((hawk_nde_grp_t*)nde->args)->body; } else head = nde->args; /* valid printf statement should have at least one argument. the parser must ensure this */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), head != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), head != HAWK_NULL); v = eval_expression(rtx, head); if (v == HAWK_NULL) goto oops_1; @@ -3242,7 +3242,7 @@ static hawk_val_t* eval_expression (hawk_rtx_t* rtx, hawk_nde_t* nde) else { /* the internal value representing $0 should always be of the string type once it has been set/updated. it is nil initially. */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE(rtx, rtx->inrec.d0) == HAWK_VAL_STR); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, rtx->inrec.d0) == HAWK_VAL_STR); vs.ptr = ((hawk_val_str_t*)rtx->inrec.d0)->val.ptr; vs.len = ((hawk_val_str_t*)rtx->inrec.d0)->val.len; } @@ -3306,7 +3306,7 @@ static hawk_val_t* eval_expression0 (hawk_rtx_t* rtx, hawk_nde_t* nde) hawk_val_t* v; - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->type >= HAWK_NDE_GRP && (nde->type - HAWK_NDE_GRP) < HAWK_COUNTOF(__evaluator)); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->type >= HAWK_NDE_GRP && (nde->type - HAWK_NDE_GRP) < HAWK_COUNTOF(__evaluator)); v = __evaluator[nde->type-HAWK_NDE_GRP](rtx, nde); @@ -3331,7 +3331,7 @@ static hawk_val_t* eval_group (hawk_rtx_t* rtx, hawk_nde_t* nde) #if 0 /* eval_binop_in evaluates the HAWK_NDE_GRP specially. * so this function should never be reached. */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - NDE_GRP only for in"); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - NDE_GRP only for in"); SETERR_LOC (rtx, HAWK_EINTERN, &nde->loc); return HAWK_NULL; #endif @@ -3351,7 +3351,7 @@ static hawk_val_t* eval_group (hawk_rtx_t* rtx, hawk_nde_t* nde) np = ((hawk_nde_grp_t*)nde)->body; - HAWK_ASSERT (hawk_rtx_getawk(rtx), np != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), np != HAWK_NULL); loop: val = eval_expression (rtx, np); @@ -3373,10 +3373,10 @@ static hawk_val_t* eval_assignment (hawk_rtx_t* rtx, hawk_nde_t* nde) hawk_val_t* val, * ret; hawk_nde_ass_t* ass = (hawk_nde_ass_t*)nde; - HAWK_ASSERT (hawk_rtx_getawk(rtx), ass->left != HAWK_NULL); - HAWK_ASSERT (hawk_rtx_getawk(rtx), ass->right != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->left != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->right != HAWK_NULL); - HAWK_ASSERT (hawk_rtx_getawk(rtx), ass->right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->right->next == HAWK_NULL); val = eval_expression (rtx, ass->right); if (val == HAWK_NULL) return HAWK_NULL; @@ -3404,7 +3404,7 @@ static hawk_val_t* eval_assignment (hawk_rtx_t* rtx, hawk_nde_t* nde) eval_binop_bor }; - HAWK_ASSERT (hawk_rtx_getawk(rtx), ass->left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->left->next == HAWK_NULL); val2 = eval_expression(rtx, ass->left); if (val2 == HAWK_NULL) { @@ -3414,9 +3414,9 @@ static hawk_val_t* eval_assignment (hawk_rtx_t* rtx, hawk_nde_t* nde) hawk_rtx_refupval (rtx, val2); - HAWK_ASSERT (hawk_rtx_getawk(rtx), ass->opcode >= 0); - HAWK_ASSERT (hawk_rtx_getawk(rtx), ass->opcode < HAWK_COUNTOF(binop_func)); - HAWK_ASSERT (hawk_rtx_getawk(rtx), binop_func[ass->opcode] != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->opcode >= 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->opcode < HAWK_COUNTOF(binop_func)); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), binop_func[ass->opcode] != HAWK_NULL); tmp = binop_func[ass->opcode](rtx, val2, val); if (tmp == HAWK_NULL) @@ -3479,7 +3479,7 @@ static hawk_val_t* do_assignment (hawk_rtx_t* rtx, hawk_nde_t* var, hawk_val_t* break; default: - HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - invalid variable type"); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid variable type"); errnum = HAWK_EINTERN; goto exit_on_error; } @@ -3495,14 +3495,14 @@ static hawk_val_t* do_assignment_nonidx (hawk_rtx_t* run, hawk_nde_var_t* var, h { hawk_val_type_t vtype; - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), var->type == HAWK_NDE_NAMED || var->type == HAWK_NDE_GBL || var->type == HAWK_NDE_LCL || var->type == HAWK_NDE_ARG ); - HAWK_ASSERT (hawk_rtx_getawk(rtx), var->idx == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), var->idx == HAWK_NULL); vtype = HAWK_RTX_GETVALTYPE (rtx, val); switch (var->type) @@ -3623,12 +3623,12 @@ static hawk_val_t* do_assignment_idx (hawk_rtx_t* rtx, hawk_nde_var_t* var, hawk hawk_oow_t len; hawk_ooch_t idxbuf[IDXBUFSIZE]; - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), (var->type == HAWK_NDE_NAMEDIDX || var->type == HAWK_NDE_GBLIDX || var->type == HAWK_NDE_LCLIDX || var->type == HAWK_NDE_ARGIDX) && var->idx != HAWK_NULL); - HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_MAP); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_MAP); retry: switch (var->type) @@ -3749,7 +3749,7 @@ retry: if (str == HAWK_NULL) return HAWK_NULL; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)map->ref, (int)map->type); #endif @@ -3869,7 +3869,7 @@ static hawk_val_t* eval_binary (hawk_rtx_t* run, hawk_nde_t* nde) hawk_nde_exp_t* exp = (hawk_nde_exp_t*)nde; hawk_val_t* left, * right, * res; - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->type == HAWK_NDE_EXP_BIN); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->type == HAWK_NDE_EXP_BIN); if (exp->opcode == HAWK_BINOP_LAND) { @@ -3894,13 +3894,13 @@ static hawk_val_t* eval_binary (hawk_rtx_t* run, hawk_nde_t* nde) } else { - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL); left = eval_expression (run, exp->left); if (left == HAWK_NULL) return HAWK_NULL; hawk_rtx_refupval (run, left); - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->right->next == HAWK_NULL); right = eval_expression (run, exp->right); if (right == HAWK_NULL) { @@ -3910,9 +3910,9 @@ static hawk_val_t* eval_binary (hawk_rtx_t* run, hawk_nde_t* nde) hawk_rtx_refupval (run, right); - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->opcode >= 0 && + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->opcode >= 0 && exp->opcode < HAWK_COUNTOF(binop_func)); - HAWK_ASSERT (hawk_rtx_getawk(rtx), binop_func[exp->opcode] != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), binop_func[exp->opcode] != HAWK_NULL); res = binop_func[exp->opcode] (run, left, right); if (res == HAWK_NULL) ADJERR_LOC (run, &nde->loc); @@ -3947,7 +3947,7 @@ static hawk_val_t* eval_binop_lor ( /* short-circuit evaluation required special treatment */ hawk_val_t* lv, * rv, * res; - HAWK_ASSERT (hawk_rtx_getawk(rtx), left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL); lv = eval_expression (run, left); if (lv == HAWK_NULL) return HAWK_NULL; @@ -3958,7 +3958,7 @@ static hawk_val_t* eval_binop_lor ( } else { - HAWK_ASSERT (hawk_rtx_getawk(rtx), right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL); rv = eval_expression (run, right); if (rv == HAWK_NULL) { @@ -3999,7 +3999,7 @@ static hawk_val_t* eval_binop_land (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_ /* short-circuit evaluation required special treatment */ hawk_val_t* lv, * rv, * res; - HAWK_ASSERT (hawk_rtx_getawk(rtx), left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL); lv = eval_expression (run, left); if (lv == HAWK_NULL) return HAWK_NULL; @@ -4010,7 +4010,7 @@ static hawk_val_t* eval_binop_land (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_ } else { - HAWK_ASSERT (hawk_rtx_getawk(rtx), right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL); rv = eval_expression (run, right); if (rv == HAWK_NULL) { @@ -4042,7 +4042,7 @@ static hawk_val_t* eval_binop_in (hawk_rtx_t* rtx, hawk_nde_t* left, hawk_nde_t* right->type != HAWK_NDE_NAMED) { /* the compiler should have handled this case */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - it needs a plain variable"); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - it needs a plain variable"); SETERR_LOC (rtx, HAWK_EINTERN, &right->loc); return HAWK_NULL; } @@ -4055,7 +4055,7 @@ static hawk_val_t* eval_binop_in (hawk_rtx_t* rtx, hawk_nde_t* left, hawk_nde_t* if (str == HAWK_NULL) return HAWK_NULL; /* evaluate the right-hand side of the operator */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL); rv = eval_expression (rtx, right); if (rv == HAWK_NULL) { @@ -4395,7 +4395,7 @@ static HAWK_INLINE int __cmp_flt_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va const hawk_ooch_t* end; hawk_flt_t rr; - rr = hawk_strxtoflt(rtx->awk, ((hawk_val_str_t*)right)->val.ptr, ((hawk_val_str_t*)right)->val.len, &end); + rr = hawk_strxtoflt(hawk_rtx_gethawk(rtx), ((hawk_val_str_t*)right)->val.ptr, ((hawk_val_str_t*)right)->val.len, &end); if (end == ((hawk_val_str_t*)right)->val.ptr + ((hawk_val_str_t*)right)->val.len) { return (((hawk_val_flt_t*)left)->val > rr)? 1: @@ -4422,7 +4422,7 @@ static HAWK_INLINE int __cmp_flt_mbs (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va const hawk_bch_t* end; hawk_flt_t rr; - rr = hawk_bcharstoflt(rtx->awk, ((hawk_val_mbs_t*)right)->val.ptr, ((hawk_val_mbs_t*)right)->val.len, &end); + rr = hawk_bcharstoflt(hawk_rtx_gethawk(rtx), ((hawk_val_mbs_t*)right)->val.ptr, ((hawk_val_mbs_t*)right)->val.len, &end); if (end == ((hawk_val_mbs_t*)right)->val.ptr + ((hawk_val_mbs_t*)right)->val.len) { return (((hawk_val_flt_t*)left)->val > rr)? 1: @@ -4492,13 +4492,13 @@ static HAWK_INLINE int __cmp_str_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va { hawk_int_t ll; - ll = hawk_strxtoint(rtx->awk, ls->val.ptr, ls->val.len, 0, HAWK_NULL); + ll = hawk_strxtoint(hawk_rtx_gethawk(rtx), ls->val.ptr, ls->val.len, 0, HAWK_NULL); if (rs->nstr == 1) { hawk_int_t rr; - rr = hawk_strxtoint(rtx->awk, rs->val.ptr, rs->val.len, 0, HAWK_NULL); + rr = hawk_strxtoint(hawk_rtx_gethawk(rtx), rs->val.ptr, rs->val.len, 0, HAWK_NULL); return (ll > rr)? 1: (ll < rr)? -1: 0; @@ -4507,9 +4507,9 @@ static HAWK_INLINE int __cmp_str_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va { hawk_flt_t rr; - HAWK_ASSERT (hawk_rtx_getawk(rtx), rs->nstr == 2); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rs->nstr == 2); - rr = hawk_strxtoflt(rtx->awk, rs->val.ptr, rs->val.len, HAWK_NULL); + rr = hawk_strxtoflt(hawk_rtx_gethawk(rtx), rs->val.ptr, rs->val.len, HAWK_NULL); return (ll > rr)? 1: (ll < rr)? -1: 0; @@ -4519,15 +4519,15 @@ static HAWK_INLINE int __cmp_str_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va { hawk_flt_t ll; - HAWK_ASSERT (hawk_rtx_getawk(rtx), ls->nstr == 2); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), ls->nstr == 2); - ll = hawk_strxtoflt(rtx->awk, ls->val.ptr, ls->val.len, HAWK_NULL); + ll = hawk_strxtoflt(hawk_rtx_gethawk(rtx), ls->val.ptr, ls->val.len, HAWK_NULL); if (rs->nstr == 1) { hawk_int_t rr; - rr = hawk_strxtoint(rtx->awk, rs->val.ptr, rs->val.len, 0, HAWK_NULL); + rr = hawk_strxtoint(hawk_rtx_gethawk(rtx), rs->val.ptr, rs->val.len, 0, HAWK_NULL); return (ll > rr)? 1: (ll < rr)? -1: 0; @@ -4536,9 +4536,9 @@ static HAWK_INLINE int __cmp_str_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va { hawk_flt_t rr; - HAWK_ASSERT (hawk_rtx_getawk(rtx), rs->nstr == 2); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rs->nstr == 2); - rr = hawk_strxtoflt(rtx->awk, rs->val.ptr, rs->val.len, HAWK_NULL); + rr = hawk_strxtoflt(hawk_rtx_gethawk(rtx), rs->val.ptr, rs->val.len, HAWK_NULL); return (ll > rr)? 1: (ll < rr)? -1: 0; @@ -4747,8 +4747,8 @@ static HAWK_INLINE int __cmp_val (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t* return -1; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), lvtype >= HAWK_VAL_NIL && lvtype <= HAWK_VAL_MAP); - HAWK_ASSERT (hawk_rtx_getawk(rtx), rvtype >= HAWK_VAL_NIL && rvtype <= HAWK_VAL_MAP); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), lvtype >= HAWK_VAL_NIL && lvtype <= HAWK_VAL_MAP); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rvtype >= HAWK_VAL_NIL && rvtype <= HAWK_VAL_MAP); /* mapping fomula and table layout assume: * HAWK_VAL_NIL = 0 @@ -4942,7 +4942,7 @@ static hawk_val_t* eval_binop_plus (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_ 1 1 = 3 */ n3 = n1 + (n2 << 1); - HAWK_ASSERT (hawk_rtx_getawk(rtx), n3 >= 0 && n3 <= 3); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), n3 >= 0 && n3 <= 3); return (n3 == 0)? hawk_rtx_makeintval(rtx,(hawk_int_t)l1+(hawk_int_t)l2): (n3 == 1)? hawk_rtx_makefltval(rtx,(hawk_flt_t)r1+(hawk_flt_t)l2): @@ -4966,7 +4966,7 @@ static hawk_val_t* eval_binop_minus (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val } n3 = n1 + (n2 << 1); - HAWK_ASSERT (hawk_rtx_getawk(rtx), n3 >= 0 && n3 <= 3); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), n3 >= 0 && n3 <= 3); return (n3 == 0)? hawk_rtx_makeintval(rtx,(hawk_int_t)l1-(hawk_int_t)l2): (n3 == 1)? hawk_rtx_makefltval(rtx,(hawk_flt_t)r1-(hawk_flt_t)l2): (n3 == 2)? hawk_rtx_makefltval(rtx,(hawk_flt_t)l1-(hawk_flt_t)r2): @@ -4989,7 +4989,7 @@ static hawk_val_t* eval_binop_mul (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t } n3 = n1 + (n2 << 1); - HAWK_ASSERT (hawk_rtx_getawk(rtx), n3 >= 0 && n3 <= 3); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), n3 >= 0 && n3 <= 3); return (n3 == 0)? hawk_rtx_makeintval(rtx,(hawk_int_t)l1*(hawk_int_t)l2): (n3 == 1)? hawk_rtx_makefltval(rtx,(hawk_flt_t)r1*(hawk_flt_t)l2): (n3 == 2)? hawk_rtx_makefltval(rtx,(hawk_flt_t)l1*(hawk_flt_t)r2): @@ -5109,7 +5109,7 @@ static hawk_val_t* eval_binop_mod (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t hawk_val_t* res; /* the mod function must be provided when the awk object is created to be able to calculate floating-pointer remainder */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->awk->prm.math.mod != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->awk->prm.math.mod != HAWK_NULL); n1 = hawk_rtx_valtonum(rtx, left, &l1, &r1); n2 = hawk_rtx_valtonum(rtx, right, &l2, &r2); @@ -5133,15 +5133,15 @@ static hawk_val_t* eval_binop_mod (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t break; case 1: - res = hawk_rtx_makefltval(rtx, rtx->awk->prm.math.mod(rtx->awk, (hawk_flt_t)r1, (hawk_flt_t)l2)); + res = hawk_rtx_makefltval(rtx, rtx->awk->prm.math.mod(hawk_rtx_gethawk(rtx), (hawk_flt_t)r1, (hawk_flt_t)l2)); break; case 2: - res = hawk_rtx_makefltval(rtx, rtx->awk->prm.math.mod(rtx->awk, (hawk_flt_t)l1, (hawk_flt_t)r2)); + res = hawk_rtx_makefltval(rtx, rtx->awk->prm.math.mod(hawk_rtx_gethawk(rtx), (hawk_flt_t)l1, (hawk_flt_t)r2)); break; case 3: - res = hawk_rtx_makefltval(rtx, rtx->awk->prm.math.mod(rtx->awk, (hawk_flt_t)r1, (hawk_flt_t)r2)); + res = hawk_rtx_makefltval(rtx, rtx->awk->prm.math.mod(hawk_rtx_gethawk(rtx), (hawk_flt_t)r1, (hawk_flt_t)r2)); break; } @@ -5215,9 +5215,7 @@ static hawk_val_t* eval_binop_exp (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t /* left - int, right - real */ res = hawk_rtx_makefltval ( rtx, - rtx->awk->prm.math.pow ( - rtx->awk, (hawk_flt_t)l1, (hawk_flt_t)r2 - ) + rtx->awk->prm.math.pow(hawk_rtx_gethawk(rtx), (hawk_flt_t)l1, (hawk_flt_t)r2) ); break; @@ -5225,9 +5223,7 @@ static hawk_val_t* eval_binop_exp (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t /* left - real, right - real */ res = hawk_rtx_makefltval ( rtx, - rtx->awk->prm.math.pow ( - rtx->awk, (hawk_flt_t)r1,(hawk_flt_t)r2 - ) + rtx->awk->prm.math.pow(hawk_rtx_gethawk(rtx), (hawk_flt_t)r1,(hawk_flt_t)r2) ); break; } @@ -5296,8 +5292,8 @@ static hawk_val_t* eval_binop_ma (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_t* { hawk_val_t* lv, * rv, * res; - HAWK_ASSERT (hawk_rtx_getawk(rtx), left->next == HAWK_NULL); - HAWK_ASSERT (hawk_rtx_getawk(rtx), right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL); lv = eval_expression (run, left); if (lv == HAWK_NULL) return HAWK_NULL; @@ -5325,8 +5321,8 @@ static hawk_val_t* eval_binop_nm (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_t* { hawk_val_t* lv, * rv, * res; - HAWK_ASSERT (hawk_rtx_getawk(rtx), left->next == HAWK_NULL); - HAWK_ASSERT (hawk_rtx_getawk(rtx), right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL); lv = eval_expression (run, left); if (lv == HAWK_NULL) return HAWK_NULL; @@ -5358,17 +5354,17 @@ static hawk_val_t* eval_unary (hawk_rtx_t* rtx, hawk_nde_t* nde) hawk_int_t l; hawk_flt_t r; - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->type == HAWK_NDE_EXP_UNR); - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left != HAWK_NULL && exp->right == HAWK_NULL); - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->opcode == HAWK_UNROP_PLUS || exp->opcode == HAWK_UNROP_MINUS || exp->opcode == HAWK_UNROP_LNOT || exp->opcode == HAWK_UNROP_BNOT); - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL); left = eval_expression (rtx, exp->left); if (left == HAWK_NULL) return HAWK_NULL; @@ -5432,8 +5428,8 @@ static hawk_val_t* eval_incpre (hawk_rtx_t* rtx, hawk_nde_t* nde) hawk_flt_t inc_val_flt; hawk_nde_exp_t* exp = (hawk_nde_exp_t*)nde; - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->type == HAWK_NDE_EXP_INCPRE); - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->left != HAWK_NULL && exp->right == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->type == HAWK_NDE_EXP_INCPRE); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left != HAWK_NULL && exp->right == HAWK_NULL); /* this way of checking if the l-value is assignable is * ugly as it is dependent on the node types defined in hawk.h @@ -5458,12 +5454,12 @@ static hawk_val_t* eval_incpre (hawk_rtx_t* rtx, hawk_nde_t* nde) } else { - HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - invalid opcode"); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid opcode"); SETERR_LOC (rtx, HAWK_EINTERN, &nde->loc); return HAWK_NULL; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL); left = eval_expression (rtx, exp->left); if (left == HAWK_NULL) return HAWK_NULL; @@ -5518,7 +5514,7 @@ static hawk_val_t* eval_incpre (hawk_rtx_t* rtx, hawk_nde_t* nde) } else /* if (n == 1) */ { - HAWK_ASSERT (hawk_rtx_getawk(rtx), n == 1); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), n == 1); res = hawk_rtx_makefltval (rtx, v2 + inc_val_flt); } @@ -5551,8 +5547,8 @@ static hawk_val_t* eval_incpst (hawk_rtx_t* rtx, hawk_nde_t* nde) hawk_flt_t inc_val_flt; hawk_nde_exp_t* exp = (hawk_nde_exp_t*)nde; - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->type == HAWK_NDE_EXP_INCPST); - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->left != HAWK_NULL && exp->right == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->type == HAWK_NDE_EXP_INCPST); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left != HAWK_NULL && exp->right == HAWK_NULL); /* this way of checking if the l-value is assignable is * ugly as it is dependent on the node types defined in hawk.h. @@ -5577,12 +5573,12 @@ static hawk_val_t* eval_incpst (hawk_rtx_t* rtx, hawk_nde_t* nde) } else { - HAWK_ASSERT (hawk_rtx_getawk(rtx), !"should never happen - invalid opcode"); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid opcode"); SETERR_LOC (rtx, HAWK_EINTERN, &nde->loc); return HAWK_NULL; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), exp->left->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL); left = eval_expression (rtx, exp->left); if (left == HAWK_NULL) return HAWK_NULL; @@ -5673,7 +5669,7 @@ static hawk_val_t* eval_incpst (hawk_rtx_t* rtx, hawk_nde_t* nde) } else /* if (n == 1) */ { - HAWK_ASSERT (hawk_rtx_getawk(rtx), n == 1); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), n == 1); res = hawk_rtx_makefltval (rtx, v2); if (res == HAWK_NULL) { @@ -5711,14 +5707,14 @@ static hawk_val_t* eval_cnd (hawk_rtx_t* run, hawk_nde_t* nde) hawk_val_t* tv, * v; hawk_nde_cnd_t* cnd = (hawk_nde_cnd_t*)nde; - HAWK_ASSERT (hawk_rtx_getawk(rtx), cnd->test->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), cnd->test->next == HAWK_NULL); tv = eval_expression (run, cnd->test); if (tv == HAWK_NULL) return HAWK_NULL; hawk_rtx_refupval (run, tv); - HAWK_ASSERT (hawk_rtx_getawk(rtx), cnd->left->next == HAWK_NULL && cnd->right->next == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), cnd->left->next == HAWK_NULL && cnd->right->next == HAWK_NULL); v = (hawk_rtx_valtobool(run, tv))? eval_expression(run, cnd->left): eval_expression(run, cnd->right); hawk_rtx_refdownval (run, tv); @@ -5730,7 +5726,7 @@ static hawk_val_t* eval_fncall_fnc (hawk_rtx_t* rtx, hawk_nde_t* nde) /* intrinsic function */ hawk_nde_fncall_t* call = (hawk_nde_fncall_t*)nde; /* the parser must make sure that the number of arguments is proper */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max); return __eval_call(rtx, nde, HAWK_NULL, push_arg_from_nde, (void*)call->u.fnc.spec.arg.spec, HAWK_NULL, HAWK_NULL); } @@ -5756,7 +5752,7 @@ static HAWK_INLINE hawk_val_t* eval_fncall_fun_ex (hawk_rtx_t* rtx, hawk_nde_t* } fun = (hawk_fun_t*)HAWK_HTB_VPTR(pair); - HAWK_ASSERT (hawk_rtx_getawk(rtx), fun != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun != HAWK_NULL); /* cache the search result */ call->u.fun.fun = fun; @@ -5885,13 +5881,13 @@ static hawk_val_t* __eval_call ( * --------------------- */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_top)); - HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_base)); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_top)); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_base)); saved_stack_top = rtx->stack_top; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("setting up function stack frame top=%zd base=%zd\n"), (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("setting up function stack frame top=%zd base=%zd\n"), (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); #endif if (__raw_push(rtx,(void*)rtx->stack_base) <= -1) @@ -5934,7 +5930,7 @@ static hawk_val_t* __eval_call ( return HAWK_NULL; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), nargs == call->nargs); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == call->nargs); if (fun) { @@ -5980,13 +5976,13 @@ static hawk_val_t* __eval_call ( RTX_STACK_NARGS(rtx) = (void*)nargs; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("running function body\n")); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("running function body\n")); #endif if (fun) { /* normal awk function */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), fun->body->type == HAWK_NDE_BLK); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun->body->type == HAWK_NDE_BLK); n = run_block(rtx,(hawk_nde_blk_t*)fun->body); } else @@ -5994,7 +5990,7 @@ static hawk_val_t* __eval_call ( n = 0; /* intrinsic function */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max); if (call->u.fnc.spec.impl) { @@ -6027,7 +6023,7 @@ static hawk_val_t* __eval_call ( /* refdown args in the rtx.stack */ nargs = (hawk_oow_t)RTX_STACK_NARGS(rtx); #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("block rtx complete nargs = %d\n"), (int)nargs); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("block rtx complete nargs = %d\n"), (int)nargs); #endif if (fun && fun->argspec && call->args && call->nargs > 0) /* hawk_rtx_callfun() sets up a fake call structure with nargs > 0 but args == HAWK_NULL */ @@ -6085,7 +6081,7 @@ static hawk_val_t* __eval_call ( } #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("got return value\n")); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("got return value\n")); #endif v = RTX_STACK_RETVAL(rtx); @@ -6140,7 +6136,7 @@ static hawk_val_t* __eval_call ( if (rtx->exit_level == EXIT_FUNCTION) rtx->exit_level = EXIT_NONE; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("returning from function top=%zd, base=%zd\n"), (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("returning from function top=%zd, base=%zd\n"), (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); #endif return (n == -1)? HAWK_NULL: v; } @@ -6261,7 +6257,7 @@ static hawk_oow_t push_arg_from_nde (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, v hawk_rtx_refupval (rtx, v); } - HAWK_ASSERT (hawk_rtx_getawk(rtx), call->nargs == nargs); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), call->nargs == nargs); return nargs; } @@ -6392,7 +6388,7 @@ static hawk_val_t** get_reference_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde, hawk_ooch_t idxbuf[IDXBUFSIZE]; hawk_val_type_t vtype; - HAWK_ASSERT (hawk_rtx_getawk(rtx), val != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL); vtype = HAWK_RTX_GETVALTYPE(rtx, *val); if (vtype == HAWK_VAL_NIL) @@ -6416,7 +6412,7 @@ static hawk_val_t** get_reference_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde, return HAWK_NULL; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->idx != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->idx != HAWK_NULL); len = HAWK_COUNTOF(idxbuf); str = idxnde_to_str (rtx, nde->idx, idxbuf, &len); @@ -6502,7 +6498,7 @@ static hawk_val_t* eval_fun (hawk_rtx_t* rtx, hawk_nde_t* nde) } fun = (hawk_fun_t*)HAWK_HTB_VPTR(pair); - HAWK_ASSERT (hawk_rtx_getawk(rtx), fun != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun != HAWK_NULL); } val = hawk_rtx_makefunval(rtx, fun); @@ -6540,7 +6536,7 @@ static hawk_val_t* eval_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde, hawk_val_ hawk_ooch_t idxbuf[IDXBUFSIZE]; hawk_val_type_t vtype; - HAWK_ASSERT (hawk_rtx_getawk(rtx), val != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL); vtype = HAWK_RTX_GETVALTYPE(rtx, *val); if (vtype == HAWK_VAL_NIL) @@ -6564,7 +6560,7 @@ static hawk_val_t* eval_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde, hawk_val_ return HAWK_NULL; } - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde->idx != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->idx != HAWK_NULL); len = HAWK_COUNTOF(idxbuf); str = idxnde_to_str(rtx, nde->idx, idxbuf, &len); @@ -6655,7 +6651,7 @@ static hawk_val_t* eval_getline (hawk_rtx_t* rtx, hawk_nde_t* nde) p = (hawk_nde_getline_t*)nde; - HAWK_ASSERT (hawk_rtx_getawk(rtx), + HAWK_ASSERT (hawk_rtx_gethawk(rtx), (p->in_type == HAWK_IN_PIPE && p->in != HAWK_NULL) || (p->in_type == HAWK_IN_RWPIPE && p->in != HAWK_NULL) || (p->in_type == HAWK_IN_FILE && p->in != HAWK_NULL) || @@ -6725,7 +6721,7 @@ read_console_again: { if (p->in_type == HAWK_IN_CONSOLE) { - HAWK_ASSERT (hawk_rtx_getawk(rtx), p->in == HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), p->in == HAWK_NULL); if (rtx->nrflt.limit > 0) { /* record filter based on record number(NR) */ @@ -6833,11 +6829,11 @@ read_again: } #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_getawk(rtx), HAWK_T("record len = %d str=[%.*s]\n"), (int)HAWK_OOECS_LEN(buf), (int)HAWK_OOECS_LEN(buf), HAWK_OOECS_PTR(buf)); + hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("record len = %d str=[%.*s]\n"), (int)HAWK_OOECS_LEN(buf), (int)HAWK_OOECS_LEN(buf), HAWK_OOECS_PTR(buf)); #endif if (n == 0) { - HAWK_ASSERT (hawk_rtx_getawk(rtx), HAWK_OOECS_LEN(buf) == 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LEN(buf) == 0); return 0; } @@ -6864,7 +6860,7 @@ static int shorten_record (hawk_rtx_t* rtx, hawk_oow_t nflds) hawk_ooecs_t tmp; hawk_val_type_t vtype; - HAWK_ASSERT (hawk_rtx_getawk(rtx), nflds <= rtx->inrec.nflds); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nflds <= rtx->inrec.nflds); if (nflds > 1) { @@ -6896,7 +6892,7 @@ static int shorten_record (hawk_rtx_t* rtx, hawk_oow_t nflds) } } - if (hawk_ooecs_init(&tmp, hawk_rtx_getawk(rtx), HAWK_OOECS_LEN(&rtx->inrec.line)) <= -1) + if (hawk_ooecs_init(&tmp, hawk_rtx_gethawk(rtx), HAWK_OOECS_LEN(&rtx->inrec.line)) <= -1) { if (ofs_free) hawk_rtx_freemem (rtx, ofs_free); if (nflds > 1) hawk_rtx_refdownval (rtx, v); @@ -6956,7 +6952,7 @@ static hawk_ooch_t* idxnde_to_str (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_ooch_t hawk_ooch_t* str; hawk_val_t* idx; - HAWK_ASSERT (hawk_rtx_getawk(rtx), nde != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde != HAWK_NULL); if (!nde->next) { @@ -6981,7 +6977,7 @@ static hawk_ooch_t* idxnde_to_str (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_ooch_t { str = out.u.cplcpy.ptr; *len = out.u.cplcpy.len; - HAWK_ASSERT (hawk_rtx_getawk(rtx), str == buf); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), str == buf); } } @@ -7013,7 +7009,7 @@ static hawk_ooch_t* idxnde_to_str (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_ooch_t out.type = HAWK_RTX_VALTOSTR_STRPCAT; out.u.strpcat = &idxstr; - if (hawk_ooecs_init(&idxstr, hawk_rtx_getawk(rtx), DEF_BUF_CAPA) <= -1) + if (hawk_ooecs_init(&idxstr, hawk_rtx_gethawk(rtx), DEF_BUF_CAPA) <= -1) { SETERR_LOC (rtx, HAWK_ENOMEM, &nde->loc); return HAWK_NULL; @@ -7133,7 +7129,7 @@ hawk_ooch_t* hawk_rtx_format ( } while(0) /* run->format.tmp.ptr should have been assigned a pointer to a block of memory before this function has been called */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), rtx->format.tmp.ptr != HAWK_NULL); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->format.tmp.ptr != HAWK_NULL); if (nargs_on_stack == (hawk_oow_t)-1) { @@ -7369,7 +7365,7 @@ wp_mod_main: if (wp[WP_WIDTH] != -1) { /* Width must be greater than 0 if specified */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), wp[WP_WIDTH] > 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), wp[WP_WIDTH] > 0); /* justification when width is specified. */ if (flags & FLAG_ZERO) @@ -7982,7 +7978,7 @@ hawk_bch_t* hawk_rtx_formatmbs ( } while(0) /* run->format.tmp.ptr should have been assigned a pointer to a block of memory before this function has been called */ - HAWK_ASSERT (hawk_rtx_getawk(awk), rtx->formatmbs.tmp.ptr != HAWK_NULL) + HAWK_ASSERT (hawk_rtx_gethawk(awk), rtx->formatmbs.tmp.ptr != HAWK_NULL) if (nargs_on_stack == (hawk_oow_t)-1) { @@ -8218,7 +8214,7 @@ wp_mod_main: if (wp[WP_WIDTH] != -1) { /* Width must be greater than 0 if specified */ - HAWK_ASSERT (hawk_rtx_getawk(rtx), wp[WP_WIDTH] > 0); + HAWK_ASSERT (hawk_rtx_gethawk(rtx), wp[WP_WIDTH] > 0); /* justification when width is specified. */ if (flags & FLAG_ZERO) @@ -8766,113 +8762,6 @@ void hawk_rtx_getnrflt (hawk_rtx_t* rtx, hawk_nrflt_t* nrflt) /* ------------------------------------------------------------------------- */ -void* hawk_rtx_allocmem (hawk_rtx_t* rtx, hawk_oow_t size) -{ - void* ptr = HAWK_MMGR_ALLOC(hawk_getmmgr(rtx->awk), size); - if (!ptr) hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); - return ptr; -} - -void* hawk_rtx_reallocmem (hawk_rtx_t* rtx, void* ptr, hawk_oow_t size) -{ - void* nptr = HAWK_MMGR_REALLOC(hawk_getmmgr(rtx->awk), ptr, size); - if (!nptr) hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); - return nptr; -} - -void* hawk_rtx_callocmem (hawk_rtx_t* rtx, hawk_oow_t size) -{ - void* ptr = HAWK_MMGR_ALLOC(hawk_getmmgr(rtx->awk), size); - if (ptr) HAWK_MEMSET (ptr, 0, size); - else hawk_rtx_seterrnum (rtx, HAWK_ENOMEM, HAWK_NULL); - return ptr; -} - -/* ------------------------------------------------------------------------- */ - -hawk_uch_t* hawk_rtx_dupucstr (hawk_rtx_t* rtx, 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_rtx_allocmem(rtx, (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_rtx_dupbcstr (hawk_rtx_t* rtx, 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_rtx_allocmem(rtx, (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_rtx_dupuchars (hawk_rtx_t* rtx, const hawk_uch_t* ucs, hawk_oow_t ucslen) -{ - hawk_uch_t* ptr; - - ptr = (hawk_uch_t*)hawk_rtx_allocmem(rtx, (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_rtx_dupbchars (hawk_rtx_t* rtx, const hawk_bch_t* bcs, hawk_oow_t bcslen) -{ - hawk_bch_t* ptr; - - ptr = (hawk_bch_t*)hawk_rtx_allocmem(rtx, (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_rtx_dupucs (hawk_rtx_t* rtx, const hawk_ucs_t* ucs) -{ - hawk_uch_t* ptr; - - ptr = (hawk_uch_t*)hawk_rtx_allocmem(rtx, (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_rtx_dupbcs (hawk_rtx_t* rtx, const hawk_bcs_t* bcs) -{ - hawk_bch_t* ptr; - - ptr = (hawk_bch_t*)hawk_rtx_allocmem(rtx, (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; -} - -/* ------------------------------------------------------------------------- */ - int hawk_rtx_convbtouchars (hawk_rtx_t* rtx, const hawk_bch_t* bcs, hawk_oow_t* bcslen, hawk_uch_t* ucs, hawk_oow_t* ucslen, int all) { /* length bound */ diff --git a/hawk/lib/std.c b/hawk/lib/std.c index c40f77af..794278a6 100644 --- a/hawk/lib/std.c +++ b/hawk/lib/std.c @@ -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; diff --git a/hawk/lib/val-imp.h b/hawk/lib/val-imp.h index 52811931..ee00987a 100644 --- a/hawk/lib/val-imp.h +++ b/hawk/lib/val-imp.h @@ -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 */ } diff --git a/hawk/lib/val.c b/hawk/lib/val.c index 1ed3bf9d..49e8842a 100644 --- a/hawk/lib/val.c +++ b/hawk/lib/val.c @@ -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));