From c3d137a5c27501c6624cb69130fc09cb40e2f36e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 16 Apr 2020 03:42:30 +0000 Subject: [PATCH] added %check to the rpm spec file. renamed awk to hawk updated copyright years --- hawk/bin/main.c | 4 +- hawk/lib/Hawk.cpp | 240 +-- hawk/lib/Hawk.hpp | 36 +- hawk/lib/HawkStd.cpp | 12 +- hawk/lib/HawkStd.hpp | 2 +- hawk/lib/arr.c | 2 +- hawk/lib/chr.c | 2 +- hawk/lib/dir.c | 2 +- hawk/lib/ecs-imp.h | 2 +- hawk/lib/ecs.c | 2 +- hawk/lib/err-prv.h | 2 +- hawk/lib/err-sys.c | 2 +- hawk/lib/err.c | 2 +- hawk/lib/fio.c | 2 +- hawk/lib/fmt-imp.h | 2 +- hawk/lib/fnc-prv.h | 6 +- hawk/lib/fnc.c | 68 +- hawk/lib/gem-nwif.c | 2 +- hawk/lib/gem-nwif2.c | 2 +- hawk/lib/gem-skad.c | 2 +- hawk/lib/gem.c | 2 +- hawk/lib/hawk-arr.h | 2 +- hawk/lib/hawk-chr.h | 2 +- hawk/lib/hawk-cmn.h | 2 +- hawk/lib/hawk-dir.h | 2 +- hawk/lib/hawk-ecs.h | 2 +- hawk/lib/hawk-fio.h | 2 +- hawk/lib/hawk-fmt.h | 2 +- hawk/lib/hawk-gem.h | 2 +- hawk/lib/hawk-htb.h | 2 +- hawk/lib/hawk-map.h | 2 +- hawk/lib/hawk-mtx.h | 2 +- hawk/lib/hawk-pack1.h | 2 +- hawk/lib/hawk-pio.h | 2 +- hawk/lib/hawk-prv.h | 8 +- hawk/lib/hawk-rbt.h | 2 +- hawk/lib/hawk-sio.h | 2 +- hawk/lib/hawk-std.h | 20 +- hawk/lib/hawk-tio.h | 2 +- hawk/lib/hawk-tre.h | 2 +- hawk/lib/hawk-unpack.h | 2 +- hawk/lib/hawk-utl.h | 2 +- hawk/lib/hawk.c | 388 ++--- hawk/lib/hawk.h | 138 +- hawk/lib/htb.c | 2 +- hawk/lib/idmap-imp.h | 2 +- hawk/lib/mb8.c | 2 +- hawk/lib/misc-prv.h | 2 +- hawk/lib/misc.c | 2 +- hawk/lib/mod-hawk.c | 10 +- hawk/lib/mod-hawk.h | 4 +- hawk/lib/mod-math.c | 56 +- hawk/lib/mod-math.h | 4 +- hawk/lib/mod-str.c | 10 +- hawk/lib/mod-str.h | 4 +- hawk/lib/mod-sys.c | 18 +- hawk/lib/mod-sys.h | 4 +- hawk/lib/mtx.c | 2 +- hawk/lib/parse-prv.h | 2 +- hawk/lib/parse.c | 3226 +++++++++++++++++++-------------------- hawk/lib/pio.c | 2 +- hawk/lib/rbt.c | 2 +- hawk/lib/rec.c | 2 +- hawk/lib/rio-prv.h | 2 +- hawk/lib/rio.c | 2 +- hawk/lib/run-prv.h | 2 +- hawk/lib/run.c | 56 +- hawk/lib/sio.c | 2 +- hawk/lib/std-prv.h | 16 +- hawk/lib/std.c | 362 ++--- hawk/lib/syscall.h | 2 +- hawk/lib/tio.c | 2 +- hawk/lib/tre-ast.c | 2 +- hawk/lib/tre-ast.h | 2 +- hawk/lib/tre-compile.c | 2 +- hawk/lib/tre-compile.h | 2 +- hawk/lib/tre-match-bt.c | 2 +- hawk/lib/tre-match-pa.c | 2 +- hawk/lib/tre-match-ut.h | 2 +- hawk/lib/tre-mem.c | 2 +- hawk/lib/tre-mem.h | 2 +- hawk/lib/tre-parse.c | 2 +- hawk/lib/tre-parse.h | 2 +- hawk/lib/tre-prv.h | 2 +- hawk/lib/tre-stack.c | 2 +- hawk/lib/tre-stack.h | 2 +- hawk/lib/tre.c | 2 +- hawk/lib/tree-prv.h | 10 +- hawk/lib/tree.c | 852 +++++------ hawk/lib/utf16.c | 2 +- hawk/lib/utf8.c | 2 +- hawk/lib/utl-ass.c | 2 +- hawk/lib/utl-skad.c | 2 +- hawk/lib/utl-skad.h | 2 +- hawk/lib/utl-sort.c | 2 +- hawk/lib/utl-str.c | 2 +- hawk/lib/utl-sys.c | 2 +- hawk/lib/utl.c | 2 +- hawk/lib/val-prv.h | 4 +- hawk/lib/val.c | 26 +- hawk/mod/mod-mysql.c | 2 +- hawk/mod/mod-mysql.h | 2 +- hawk/mod/mod-uci.c | 2 +- hawk/mod/mod-uci.h | 2 +- hawk/pkgs/hawk.spec.in | 3 + 105 files changed, 2872 insertions(+), 2869 deletions(-) diff --git a/hawk/bin/main.c b/hawk/bin/main.c index 5fd80048..4ea9ad58 100644 --- a/hawk/bin/main.c +++ b/hawk/bin/main.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -464,7 +464,7 @@ static void on_statement (hawk_rtx_t* rtx, hawk_nde_t* nde) static void print_version (const hawk_bch_t* argv0) { printf ("%s %s\n", hawk_get_base_name_bcstr(argv0), HAWK_PACKAGE_VERSION); - printf ("Copyright 2006-2019 Chung, Hyung-Hwan\n"); + printf ("Copyright 2006-2020 Chung, Hyung-Hwan\n"); } static void print_error (const hawk_bch_t* fmt, ...) diff --git a/hawk/lib/Hawk.cpp b/hawk/lib/Hawk.cpp index 97057deb..7e7106d1 100644 --- a/hawk/lib/Hawk.cpp +++ b/hawk/lib/Hawk.cpp @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -324,47 +324,47 @@ void Hawk::Value::operator delete[] (void* ptr) } #endif -Hawk::Value::Value (): run (HAWK_NULL), val (hawk_get_awk_nil_val()) +Hawk::Value::Value (): run(HAWK_NULL), val(hawk_get_nil_val()) { - cached.str.ptr = HAWK_NULL; - cached.str.len = 0; - cached.mbs.ptr = HAWK_NULL; - cached.mbs.len = 0; + this->cached.str.ptr = HAWK_NULL; + this->cached.str.len = 0; + this->cached.mbs.ptr = HAWK_NULL; + this->cached.mbs.len = 0; } -Hawk::Value::Value (Run& run): run (&run), val (hawk_get_awk_nil_val()) +Hawk::Value::Value (Run& run): run(&run), val(hawk_get_nil_val()) { - cached.str.ptr = HAWK_NULL; - cached.str.len = 0; - cached.mbs.ptr = HAWK_NULL; - cached.mbs.len = 0; + this->cached.str.ptr = HAWK_NULL; + this->cached.str.len = 0; + this->cached.mbs.ptr = HAWK_NULL; + this->cached.mbs.len = 0; } -Hawk::Value::Value (Run* run): run (run), val (hawk_get_awk_nil_val()) +Hawk::Value::Value (Run* run): run(run), val(hawk_get_nil_val()) { - cached.str.ptr = HAWK_NULL; - cached.str.len = 0; - cached.mbs.ptr = HAWK_NULL; - cached.mbs.len = 0; + this->cached.str.ptr = HAWK_NULL; + this->cached.str.len = 0; + this->cached.mbs.ptr = HAWK_NULL; + this->cached.mbs.len = 0; } Hawk::Value::Value (const Value& v): run(v.run), val(v.val) { - if (run) hawk_rtx_refupval (run->rtx, val); + if (this->run) hawk_rtx_refupval (this->run->rtx, this->val); - cached.str.ptr = HAWK_NULL; - cached.str.len = 0; - cached.mbs.ptr = HAWK_NULL; - cached.mbs.len = 0; + this->cached.str.ptr = HAWK_NULL; + this->cached.str.len = 0; + this->cached.mbs.ptr = HAWK_NULL; + this->cached.mbs.len = 0; } Hawk::Value::~Value () { - if (run != HAWK_NULL) + if (this->run) { - hawk_rtx_refdownval (run->rtx, val); - if (cached.str.ptr) hawk_rtx_freemem (run->rtx, cached.str.ptr); - if (cached.mbs.ptr) hawk_rtx_freemem (run->rtx, cached.mbs.ptr); + hawk_rtx_refdownval (this->run->rtx, val); + if (this->cached.str.ptr) hawk_rtx_freemem (this->run->rtx, cached.str.ptr); + if (this->cached.mbs.ptr) hawk_rtx_freemem (this->run->rtx, cached.mbs.ptr); } } @@ -372,52 +372,52 @@ Hawk::Value& Hawk::Value::operator= (const Value& v) { if (this == &v) return *this; - if (run) + if (this->run) { - hawk_rtx_refdownval (run->rtx, val); - if (cached.str.ptr) + hawk_rtx_refdownval (this->run->rtx, this->val); + if (this->cached.str.ptr) { - hawk_rtx_freemem (run->rtx, cached.str.ptr); - cached.str.ptr = HAWK_NULL; - cached.str.len = 0; + hawk_rtx_freemem (this->run->rtx, this->cached.str.ptr); + this->cached.str.ptr = HAWK_NULL; + this->cached.str.len = 0; } - if (cached.mbs.ptr) + if (this->cached.mbs.ptr) { - hawk_rtx_freemem (run->rtx, cached.mbs.ptr); - cached.mbs.ptr = HAWK_NULL; - cached.mbs.len = 0; + hawk_rtx_freemem (this->run->rtx, this->cached.mbs.ptr); + this->cached.mbs.ptr = HAWK_NULL; + this->cached.mbs.len = 0; } } - run = v.run; - val = v.val; + this->run = v.run; + this->val = v.val; - if (run) hawk_rtx_refupval (run->rtx, val); + if (this->run) hawk_rtx_refupval (this->run->rtx, this->val); return *this; } void Hawk::Value::clear () { - if (run) + if (this->run) { - hawk_rtx_refdownval (run->rtx, val); + hawk_rtx_refdownval (this->run->rtx, this->val); - if (cached.str.ptr) + if (this->cached.str.ptr) { - hawk_rtx_freemem (run->rtx, cached.str.ptr); - cached.str.ptr = HAWK_NULL; - cached.str.len = 0; + hawk_rtx_freemem (this->run->rtx, this->cached.str.ptr); + this->cached.str.ptr = HAWK_NULL; + this->cached.str.len = 0; } - if (cached.mbs.ptr) + if (this->cached.mbs.ptr) { - hawk_rtx_freemem (run->rtx, cached.mbs.ptr); - cached.mbs.ptr = HAWK_NULL; - cached.mbs.len = 0; + hawk_rtx_freemem (this->run->rtx, this->cached.mbs.ptr); + this->cached.mbs.ptr = HAWK_NULL; + this->cached.mbs.len = 0; } - run = HAWK_NULL; - val = hawk_get_awk_nil_val(); + this->run = HAWK_NULL; + this->val = hawk_get_nil_val(); } } @@ -1365,8 +1365,8 @@ const hawk_ooch_t* Hawk::getErrorString (hawk_errnum_t num) const const hawk_ooch_t* Hawk::xerrstr (hawk_t* a, hawk_errnum_t num) { - Hawk* awk = *(Hawk**)GET_XTN(a); - return awk->getErrorString(num); + Hawk* hawk = *(Hawk**)GET_XTN(a); + return hawk->getErrorString(num); } hawk_errnum_t Hawk::getErrorNumber () const @@ -1518,15 +1518,15 @@ void Hawk::retrieveError (Run* run) hawk_rtx_geterrinf (run->rtx, &errinf); } -static void fini_xtn (hawk_t* awk) +static void fini_xtn (hawk_t* hawk) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); xtn->hawk->uponClosing (); } -static void clear_xtn (hawk_t* awk) +static void clear_xtn (hawk_t* hawk) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); xtn->hawk->uponClearing (); } @@ -1556,7 +1556,7 @@ int Hawk::open () this->hawk->_instsize += HAWK_SIZEOF(xtn_t); - // associate this Hawk object with the underlying awk object + // associate this Hawk object with the underlying hawk object xtn_t* xtn = (xtn_t*)GET_XTN(this->hawk); xtn->hawk = this; xtn->ecb.close = fini_xtn; @@ -2112,14 +2112,14 @@ int Hawk::xstrs_t::add (hawk_t* hawk, const hawk_bch_t* arg, hawk_oow_t len) return 0; } -void Hawk::xstrs_t::clear (hawk_t* awk) +void Hawk::xstrs_t::clear (hawk_t* hawk) { if (this->ptr != HAWK_NULL) { while (this->len > 0) - hawk_freemem (awk, this->ptr[--this->len].ptr); + hawk_freemem (hawk, this->ptr[--this->len].ptr); - hawk_freemem (awk, this->ptr); + hawk_freemem (hawk, this->ptr); this->ptr = HAWK_NULL; this->capa = 0; } @@ -2392,7 +2392,7 @@ hawk_ooi_t Hawk::writeSource (hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* hawk_ooi_t Hawk::pipeHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) { rxtn_t* rxtn = GET_RXTN(rtx); - Hawk* awk = rxtn->run->hawk; + Hawk* hawk = rxtn->run->hawk; HAWK_ASSERT ((riod->type & 0xFF) == HAWK_RIO_PIPE); @@ -2400,29 +2400,29 @@ hawk_ooi_t Hawk::pipeHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_ try { - if (awk->pipe_handler) + if (hawk->pipe_handler) { switch (cmd) { case HAWK_RIO_CMD_OPEN: - return awk->pipe_handler->open(pipe); + return hawk->pipe_handler->open(pipe); case HAWK_RIO_CMD_CLOSE: - return awk->pipe_handler->close(pipe); + return hawk->pipe_handler->close(pipe); case HAWK_RIO_CMD_READ: - return awk->pipe_handler->read(pipe, (hawk_ooch_t*)data, count); + return hawk->pipe_handler->read(pipe, (hawk_ooch_t*)data, count); case HAWK_RIO_CMD_READ_BYTES: - return awk->pipe_handler->readBytes(pipe, (hawk_bch_t*)data, count); + return hawk->pipe_handler->readBytes(pipe, (hawk_bch_t*)data, count); case HAWK_RIO_CMD_WRITE: - return awk->pipe_handler->write(pipe, (const hawk_ooch_t*)data, count); + return hawk->pipe_handler->write(pipe, (const hawk_ooch_t*)data, count); case HAWK_RIO_CMD_WRITE_BYTES: - return awk->pipe_handler->writeBytes(pipe, (const hawk_bch_t*)data, count); + return hawk->pipe_handler->writeBytes(pipe, (const hawk_bch_t*)data, count); case HAWK_RIO_CMD_FLUSH: - return awk->pipe_handler->flush(pipe); + return hawk->pipe_handler->flush(pipe); default: hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EINTERN); @@ -2434,25 +2434,25 @@ hawk_ooi_t Hawk::pipeHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_ switch (cmd) { case HAWK_RIO_CMD_OPEN: - return awk->openPipe(pipe); + return hawk->openPipe(pipe); case HAWK_RIO_CMD_CLOSE: - return awk->closePipe(pipe); + return hawk->closePipe(pipe); case HAWK_RIO_CMD_READ: - return awk->readPipe(pipe, (hawk_ooch_t*)data, count); + return hawk->readPipe(pipe, (hawk_ooch_t*)data, count); case HAWK_RIO_CMD_READ_BYTES: - return awk->readPipeBytes(pipe, (hawk_bch_t*)data, count); + return hawk->readPipeBytes(pipe, (hawk_bch_t*)data, count); case HAWK_RIO_CMD_WRITE: - return awk->writePipe(pipe, (const hawk_ooch_t*)data, count); + return hawk->writePipe(pipe, (const hawk_ooch_t*)data, count); case HAWK_RIO_CMD_WRITE_BYTES: - return awk->writePipeBytes(pipe, (const hawk_bch_t*)data, count); + return hawk->writePipeBytes(pipe, (const hawk_bch_t*)data, count); case HAWK_RIO_CMD_FLUSH: - return awk->flushPipe(pipe); + return hawk->flushPipe(pipe); default: hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EINTERN); @@ -2469,7 +2469,7 @@ hawk_ooi_t Hawk::pipeHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_ hawk_ooi_t Hawk::fileHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) { rxtn_t* rxtn = GET_RXTN(rtx); - Hawk* awk = rxtn->run->hawk; + Hawk* hawk = rxtn->run->hawk; HAWK_ASSERT ((riod->type & 0xFF) == HAWK_RIO_FILE); @@ -2477,29 +2477,29 @@ hawk_ooi_t Hawk::fileHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_ try { - if (awk->file_handler) + if (hawk->file_handler) { switch (cmd) { case HAWK_RIO_CMD_OPEN: - return awk->file_handler->open(file); + return hawk->file_handler->open(file); case HAWK_RIO_CMD_CLOSE: - return awk->file_handler->close(file); + return hawk->file_handler->close(file); case HAWK_RIO_CMD_READ: - return awk->file_handler->read(file, (hawk_ooch_t*)data, count); + return hawk->file_handler->read(file, (hawk_ooch_t*)data, count); case HAWK_RIO_CMD_READ_BYTES: - return awk->file_handler->readBytes(file, (hawk_bch_t*)data, count); + return hawk->file_handler->readBytes(file, (hawk_bch_t*)data, count); case HAWK_RIO_CMD_WRITE: - return awk->file_handler->write(file, (const hawk_ooch_t*)data, count); + return hawk->file_handler->write(file, (const hawk_ooch_t*)data, count); case HAWK_RIO_CMD_WRITE_BYTES: - return awk->file_handler->writeBytes(file, (const hawk_bch_t*)data, count); + return hawk->file_handler->writeBytes(file, (const hawk_bch_t*)data, count); case HAWK_RIO_CMD_FLUSH: - return awk->file_handler->flush(file); + return hawk->file_handler->flush(file); default: hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EINTERN); @@ -2511,25 +2511,25 @@ hawk_ooi_t Hawk::fileHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_ switch (cmd) { case HAWK_RIO_CMD_OPEN: - return awk->openFile(file); + return hawk->openFile(file); case HAWK_RIO_CMD_CLOSE: - return awk->closeFile(file); + return hawk->closeFile(file); case HAWK_RIO_CMD_READ: - return awk->readFile(file, (hawk_ooch_t*)data, count); + return hawk->readFile(file, (hawk_ooch_t*)data, count); case HAWK_RIO_CMD_READ_BYTES: - return awk->readFileBytes(file, (hawk_bch_t*)data, count); + return hawk->readFileBytes(file, (hawk_bch_t*)data, count); case HAWK_RIO_CMD_WRITE: - return awk->writeFile(file, (const hawk_ooch_t*)data, count); + return hawk->writeFile(file, (const hawk_ooch_t*)data, count); case HAWK_RIO_CMD_WRITE_BYTES: - return awk->writeFileBytes(file, (const hawk_bch_t*)data, count); + return hawk->writeFileBytes(file, (const hawk_bch_t*)data, count); case HAWK_RIO_CMD_FLUSH: - return awk->flushFile(file); + return hawk->flushFile(file); default: hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EINTERN); @@ -2546,7 +2546,7 @@ hawk_ooi_t Hawk::fileHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_ hawk_ooi_t Hawk::consoleHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) { rxtn_t* rxtn = GET_RXTN(rtx); - Hawk* awk = rxtn->run->hawk; + Hawk* hawk = rxtn->run->hawk; HAWK_ASSERT ((riod->type & 0xFF) == HAWK_RIO_CONSOLE); @@ -2554,31 +2554,31 @@ hawk_ooi_t Hawk::consoleHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_a try { - if (awk->console_handler) + if (hawk->console_handler) { switch (cmd) { case HAWK_RIO_CMD_OPEN: - return awk->console_handler->open(console); + return hawk->console_handler->open(console); case HAWK_RIO_CMD_CLOSE: - return awk->console_handler->close(console); + return hawk->console_handler->close(console); case HAWK_RIO_CMD_READ: - return awk->console_handler->read(console, (hawk_ooch_t*)data, count); + return hawk->console_handler->read(console, (hawk_ooch_t*)data, count); case HAWK_RIO_CMD_READ_BYTES: - return awk->console_handler->readBytes(console, (hawk_bch_t*)data, count); + return hawk->console_handler->readBytes(console, (hawk_bch_t*)data, count); case HAWK_RIO_CMD_WRITE: - return awk->console_handler->write(console, (const hawk_ooch_t*)data, count); + return hawk->console_handler->write(console, (const hawk_ooch_t*)data, count); case HAWK_RIO_CMD_WRITE_BYTES: - return awk->console_handler->writeBytes(console, (const hawk_bch_t*)data, count); + return hawk->console_handler->writeBytes(console, (const hawk_bch_t*)data, count); case HAWK_RIO_CMD_FLUSH: - return awk->console_handler->flush(console); + return hawk->console_handler->flush(console); case HAWK_RIO_CMD_NEXT: - return awk->console_handler->next(console); + return hawk->console_handler->next(console); default: hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EINTERN); @@ -2590,28 +2590,28 @@ hawk_ooi_t Hawk::consoleHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_a switch (cmd) { case HAWK_RIO_CMD_OPEN: - return awk->openConsole(console); + return hawk->openConsole(console); case HAWK_RIO_CMD_CLOSE: - return awk->closeConsole(console); + return hawk->closeConsole(console); case HAWK_RIO_CMD_READ: - return awk->readConsole(console, (hawk_ooch_t*)data, count); + return hawk->readConsole(console, (hawk_ooch_t*)data, count); case HAWK_RIO_CMD_READ_BYTES: - return awk->readConsoleBytes(console, (hawk_bch_t*)data, count); + return hawk->readConsoleBytes(console, (hawk_bch_t*)data, count); case HAWK_RIO_CMD_WRITE: - return awk->writeConsole(console, (const hawk_ooch_t*)data, count); + return hawk->writeConsole(console, (const hawk_ooch_t*)data, count); case HAWK_RIO_CMD_WRITE_BYTES: - return awk->writeConsoleBytes(console, (const hawk_bch_t*)data, count); + return hawk->writeConsoleBytes(console, (const hawk_bch_t*)data, count); case HAWK_RIO_CMD_FLUSH: - return awk->flushConsole(console); + return hawk->flushConsole(console); case HAWK_RIO_CMD_NEXT: - return awk->nextConsole(console); + return hawk->nextConsole(console); default: hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EINTERN); @@ -2763,33 +2763,33 @@ int Hawk::functionHandler (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) return rxtn->run->hawk->dispatch_function(rxtn->run, fi); } -hawk_flt_t Hawk::pow (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) +hawk_flt_t Hawk::pow (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); return xtn->hawk->pow(x, y); } -hawk_flt_t Hawk::mod (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) +hawk_flt_t Hawk::mod (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); return xtn->hawk->mod(x, y); } -void* Hawk::modopen (hawk_t* awk, const hawk_mod_spec_t* spec) +void* Hawk::modopen (hawk_t* hawk, const hawk_mod_spec_t* spec) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); return xtn->hawk->modopen(spec); } -void Hawk::modclose (hawk_t* awk, void* handle) +void Hawk::modclose (hawk_t* hawk, void* handle) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); xtn->hawk->modclose (handle); } -void* Hawk::modgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name) +void* Hawk::modgetsym (hawk_t* hawk, void* handle, const hawk_ooch_t* name) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); return xtn->hawk->modgetsym(handle, name); } ///////////////////////////////// diff --git a/hawk/lib/Hawk.hpp b/hawk/lib/Hawk.hpp index 96e5d380..aa64af0e 100644 --- a/hawk/lib/Hawk.hpp +++ b/hawk/lib/Hawk.hpp @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -1160,8 +1160,8 @@ public: friend class RIOBase; friend class Console; - Run (Hawk* awk); - Run (Hawk* awk, hawk_rtx_t* run); + Run (Hawk* hawk); + Run (Hawk* hawk, hawk_rtx_t* run); ~Run (); public: @@ -1301,7 +1301,7 @@ public: /// /// The uponClosing() function is called back after Hawk::close() /// has cleared most of the internal data but before destroying - /// the underlying awk object. This maps to the close callback + /// the underlying hawk object. This maps to the close callback /// of #hawk_ecb_t. /// virtual void uponClosing (); @@ -1605,7 +1605,7 @@ public: /// handler object. An external pipe handler can be implemented /// outside this class without overriding various pipe functions. /// Note that an external pipe handler must outlive an outer - /// awk object. + /// hawk object. /// void setPipeHandler (Pipe::Handler* handler) { @@ -1627,7 +1627,7 @@ public: /// handler object. An external file handler can be implemented /// outside this class without overriding various file functions. /// Note that an external file handler must outlive an outer - /// awk object. + /// hawk object. /// void setFileHandler (File::Handler* handler) { @@ -1649,7 +1649,7 @@ public: /// handler object. An external file handler can be implemented /// outside this class without overriding various console functions. /// Note that an external console handler must outlive an outer - /// awk object. + /// hawk object. /// void setConsoleHandler (Console::Handler* handler) { @@ -1721,10 +1721,10 @@ protected: // static glue members for various handlers static hawk_ooi_t readSource ( - hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, + hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t count); static hawk_ooi_t writeSource ( - hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, + hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t count); static hawk_ooi_t pipeHandler ( @@ -1740,12 +1740,12 @@ protected: static int functionHandler (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi); - static hawk_flt_t pow (hawk_t* awk, hawk_flt_t x, hawk_flt_t y); - static hawk_flt_t mod (hawk_t* awk, hawk_flt_t x, hawk_flt_t y); + static hawk_flt_t pow (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y); + static hawk_flt_t mod (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y); - static void* modopen (hawk_t* awk, const hawk_mod_spec_t* spec); - static void modclose (hawk_t* awk, void* handle); - static void* modgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name); + static void* modopen (hawk_t* hawk, const hawk_mod_spec_t* spec); + static void modclose (hawk_t* hawk, void* handle); + static void* modgetsym (hawk_t* hawk, void* handle, const hawk_ooch_t* name); public: // use these with care @@ -1771,7 +1771,7 @@ protected: class FunctionMap: public HashTable { public: - FunctionMap (Hawk* awk): hawk(hawk) {} + FunctionMap (Hawk* hawk): hawk(hawk) {} protected: Hawk* hawk; @@ -1791,10 +1791,10 @@ protected: { xstrs_t (): ptr (HAWK_NULL), len (0), capa (0) {} - int add (hawk_t* awk, const hawk_uch_t* arg, hawk_oow_t len); - int add (hawk_t* awk, const hawk_bch_t* arg, hawk_oow_t len); + int add (hawk_t* hawk, const hawk_uch_t* arg, hawk_oow_t len); + int add (hawk_t* hawk, const hawk_bch_t* arg, hawk_oow_t len); - void clear (hawk_t* awk); + void clear (hawk_t* hawk); hawk_oocs_t* ptr; hawk_oow_t len; diff --git a/hawk/lib/HawkStd.cpp b/hawk/lib/HawkStd.cpp index 5db883c2..989020c7 100644 --- a/hawk/lib/HawkStd.cpp +++ b/hawk/lib/HawkStd.cpp @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -79,7 +79,7 @@ static hawk_sio_t* open_sio (Hawk* hawk, HawkStd::Run* run, const hawk_ooch_t* f { hawk_sio_t* sio; - //sio = hawk_sio_open ((run? ((Hawk::awk_t*)*(Hawk*)*run)->mmgr: awk->getMmgr()), 0, file, flags); + //sio = hawk_sio_open ((run? ((Hawk::hawk_t*)*(Hawk*)*run)->mmgr: hawk->getMmgr()), 0, file, flags); sio = hawk_sio_open((run? (hawk_gem_t*)*run: (hawk_gem_t*)*hawk), 0, file, flags); if (sio == HAWK_NULL) { @@ -109,7 +109,7 @@ static hawk_sio_t* open_sio_std (Hawk* hawk, HawkStd::Run* run, hawk_sio_std_t s HAWK_T("stderr"), }; - //sio = hawk_sio_openstd ((run? ((Hawk::awk_t*)*(Hawk*)*run)->mmgr: awk->getMmgr()), 0, std, flags); + //sio = hawk_sio_openstd ((run? ((Hawk::hawk_t*)*(Hawk*)*run)->mmgr: hawk->getMmgr()), 0, std, flags); sio = hawk_sio_openstd((run? (hawk_gem_t*)*run: (hawk_gem_t*)*hawk), 0, std, flags); if (sio == HAWK_NULL) { @@ -122,7 +122,7 @@ static hawk_sio_t* open_sio_std (Hawk* hawk, HawkStd::Run* run, hawk_sio_std_t s else { const hawk_ooch_t* bem = hawk_backuperrmsg((hawk_t*)*hawk); - //awk->formatError (HAWK_EOPEN, HAWK_NULL, HAWK_T("unable to open %js - %js"), std_names[std], bem); + //hawk->formatError (HAWK_EOPEN, HAWK_NULL, HAWK_T("unable to open %js - %js"), std_names[std], bem); hawk_seterrfmt ((hawk_t*)*hawk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), std_names[std], bem); } } @@ -184,7 +184,7 @@ void HawkStd::close () // but Hawk::close() still needs to call some module's fini and // unload functions. So it must be done in HawkStd::uponClosing() // which is called after modules have been unloaded but while - // the underlying awk object is still alive. + // the underlying hawk object is still alive. // // See HawkStd::uponClosing() below. // @@ -971,7 +971,7 @@ nextfile: * if an argument has a special form of var=val, it is treated specially * * on the command-line - * hawk -f a.awk a=20 /etc/passwd + * hawk -f a.hawk a=20 /etc/passwd * or via ARGV * hawk 'BEGIN { ARGV[1] = "a=20"; } * { print a $1; }' dummy /etc/hosts diff --git a/hawk/lib/HawkStd.hpp b/hawk/lib/HawkStd.hpp index c2553301..23853fd2 100644 --- a/hawk/lib/HawkStd.hpp +++ b/hawk/lib/HawkStd.hpp @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/arr.c b/hawk/lib/arr.c index 67989475..16117c61 100644 --- a/hawk/lib/arr.c +++ b/hawk/lib/arr.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/chr.c b/hawk/lib/chr.c index 28eb96f6..565f85e9 100644 --- a/hawk/lib/chr.c +++ b/hawk/lib/chr.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/dir.c b/hawk/lib/dir.c index 61952dc2..cb28958d 100644 --- a/hawk/lib/dir.c +++ b/hawk/lib/dir.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/ecs-imp.h b/hawk/lib/ecs-imp.h index 21b5cad1..2d22f522 100644 --- a/hawk/lib/ecs-imp.h +++ b/hawk/lib/ecs-imp.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/ecs.c b/hawk/lib/ecs.c index 4222f76b..2fff85ea 100644 --- a/hawk/lib/ecs.c +++ b/hawk/lib/ecs.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/err-prv.h b/hawk/lib/err-prv.h index 3de0a193..7b378f62 100644 --- a/hawk/lib/err-prv.h +++ b/hawk/lib/err-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/err-sys.c b/hawk/lib/err-sys.c index 423b69e1..961f0f49 100644 --- a/hawk/lib/err-sys.c +++ b/hawk/lib/err-sys.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/err.c b/hawk/lib/err.c index 095e3158..e7170e49 100644 --- a/hawk/lib/err.c +++ b/hawk/lib/err.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/fio.c b/hawk/lib/fio.c index 08c5ffc4..cc9fea32 100644 --- a/hawk/lib/fio.c +++ b/hawk/lib/fio.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/fmt-imp.h b/hawk/lib/fmt-imp.h index 2c49c7d8..08995d8b 100644 --- a/hawk/lib/fmt-imp.h +++ b/hawk/lib/fmt-imp.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/fnc-prv.h b/hawk/lib/fnc-prv.h index 83f45442..5ff19777 100644 --- a/hawk/lib/fnc-prv.h +++ b/hawk/lib/fnc-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -48,8 +48,8 @@ struct hawk_fnc_t extern "C" { #endif -hawk_fnc_t* hawk_findfncwithbcs (hawk_t* awk, const hawk_bcs_t* name); -hawk_fnc_t* hawk_findfncwithucs (hawk_t* awk, const hawk_ucs_t* name); +hawk_fnc_t* hawk_findfncwithbcs (hawk_t* hawk, const hawk_bcs_t* name); +hawk_fnc_t* hawk_findfncwithucs (hawk_t* hawk, const hawk_ucs_t* name); #if defined(HAWK_OOCH_IS_BCH) # define hawk_findfncwithoocs hawk_findfncwithbcs diff --git a/hawk/lib/fnc.c b/hawk/lib/fnc.c index 5eb1453c..2e97af01 100644 --- a/hawk/lib/fnc.c +++ b/hawk/lib/fnc.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -153,10 +153,10 @@ static hawk_fnc_t* add_fnc (hawk_t* hawk, const hawk_ooch_t* name, const hawk_fn return fnc; } -hawk_fnc_t* hawk_addfncwithbcstr (hawk_t* awk, const hawk_bch_t* name, const hawk_fnc_mspec_t* spec) +hawk_fnc_t* hawk_addfncwithbcstr (hawk_t* hawk, const hawk_bch_t* name, const hawk_fnc_mspec_t* spec) { #if defined(HAWK_OOCH_IS_BCH) - return add_fnc(awk, name, spec); + return add_fnc(hawk, name, spec); #else hawk_ucs_t wcs; hawk_fnc_t* fnc; @@ -167,26 +167,26 @@ hawk_fnc_t* hawk_addfncwithbcstr (hawk_t* awk, const hawk_bch_t* name, const haw HAWK_MEMCPY (&wspec, spec, HAWK_SIZEOF(wspec)); if (spec->arg.spec) { - wcs.ptr = hawk_dupbtoucstr(awk, spec->arg.spec, &wcs.len, 0); + wcs.ptr = hawk_dupbtoucstr(hawk, spec->arg.spec, &wcs.len, 0); if (HAWK_UNLIKELY(!wcs.ptr)) return HAWK_NULL; wspec.arg.spec = wcs.ptr; } - wcs.ptr = hawk_dupbtoucstr(awk, name, &wcs.len, 0); + wcs.ptr = hawk_dupbtoucstr(hawk, name, &wcs.len, 0); if (HAWK_UNLIKELY(!wcs.ptr)) { - if (wspec.arg.spec) hawk_freemem (awk, (hawk_uch_t*)wspec.arg.spec); + if (wspec.arg.spec) hawk_freemem (hawk, (hawk_uch_t*)wspec.arg.spec); return HAWK_NULL; } - fnc = add_fnc(awk, wcs.ptr, &wspec); - hawk_freemem (awk, wcs.ptr); - if (wspec.arg.spec) hawk_freemem (awk, (hawk_uch_t*)wspec.arg.spec); + fnc = add_fnc(hawk, wcs.ptr, &wspec); + hawk_freemem (hawk, wcs.ptr); + if (wspec.arg.spec) hawk_freemem (hawk, (hawk_uch_t*)wspec.arg.spec); return fnc; #endif } -hawk_fnc_t* hawk_addfncwithucstr (hawk_t* awk, const hawk_uch_t* name, const hawk_fnc_wspec_t* spec) +hawk_fnc_t* hawk_addfncwithucstr (hawk_t* hawk, const hawk_uch_t* name, const hawk_fnc_wspec_t* spec) { #if defined(HAWK_OOCH_IS_BCH) hawk_bcs_t mbs; @@ -198,24 +198,24 @@ hawk_fnc_t* hawk_addfncwithucstr (hawk_t* awk, const hawk_uch_t* name, const haw HAWK_MEMCPY (&mspec, spec, HAWK_SIZEOF(mspec)); if (spec->arg.spec) { - mbs.ptr = hawk_duputobcstr(awk, spec->arg.spec, &mbs.len); + mbs.ptr = hawk_duputobcstr(hawk, spec->arg.spec, &mbs.len); if (HAWK_UNLIKELY(!mbs.ptr)) return HAWK_NULL; mspec.arg.spec = mbs.ptr; } - mbs.ptr = hawk_duputobcstr(awk, name, &mbs.len); + mbs.ptr = hawk_duputobcstr(hawk, name, &mbs.len); if (HAWK_UNLIKELY(!mbs.ptr)) { - if (mspec.arg.spec) hawk_freemem (awk, (hawk_bch_t*)mspec.arg.spec); + if (mspec.arg.spec) hawk_freemem (hawk, (hawk_bch_t*)mspec.arg.spec); return HAWK_NULL; } - fnc = add_fnc(awk, mbs.ptr, &mspec); - hawk_freemem (awk, mbs.ptr); - if (mspec.arg.spec) hawk_freemem (awk, (hawk_bch_t*)mspec.arg.spec); + fnc = add_fnc(hawk, mbs.ptr, &mspec); + hawk_freemem (hawk, mbs.ptr); + if (mspec.arg.spec) hawk_freemem (hawk, (hawk_bch_t*)mspec.arg.spec); return fnc; #else - return add_fnc(awk, name, spec); + return add_fnc(hawk, name, spec); #endif } @@ -277,12 +277,12 @@ int hawk_delfncwithucstr (hawk_t* hawk, const hawk_uch_t* name) return 0; } -void hawk_clrfnc (hawk_t* awk) +void hawk_clrfnc (hawk_t* hawk) { - hawk_htb_clear (awk->fnc.user); + hawk_htb_clear (hawk->fnc.user); } -static hawk_fnc_t* find_fnc (hawk_t* awk, const hawk_oocs_t* name) +static hawk_fnc_t* find_fnc (hawk_t* hawk, const hawk_oocs_t* name) { hawk_htb_pair_t* pair; int i; @@ -294,51 +294,51 @@ static hawk_fnc_t* find_fnc (hawk_t* awk, const hawk_oocs_t* name) */ for (i = 0; i < HAWK_COUNTOF(sysfnctab); i++) { - if ((awk->opt.trait & sysfnctab[i].spec.trait) != sysfnctab[i].spec.trait) continue; + if ((hawk->opt.trait & sysfnctab[i].spec.trait) != sysfnctab[i].spec.trait) continue; if (hawk_comp_oochars(sysfnctab[i].name.ptr, sysfnctab[i].name.len, name->ptr, name->len, 0) == 0) return &sysfnctab[i]; } - pair = hawk_htb_search(awk->fnc.user, name->ptr, name->len); + pair = hawk_htb_search(hawk->fnc.user, name->ptr, name->len); if (pair) { hawk_fnc_t* fnc; fnc = (hawk_fnc_t*)HAWK_HTB_VPTR(pair); - if ((awk->opt.trait & fnc->spec.trait) == fnc->spec.trait) return fnc; + if ((hawk->opt.trait & fnc->spec.trait) == fnc->spec.trait) return fnc; } - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such function - %js"), name); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("no such function - %js"), name); return HAWK_NULL; } -hawk_fnc_t* hawk_findfncwithbcs (hawk_t* awk, const hawk_bcs_t* name) +hawk_fnc_t* hawk_findfncwithbcs (hawk_t* hawk, const hawk_bcs_t* name) { #if defined(HAWK_OOCH_IS_BCH) - return find_fnc(awk, name); + return find_fnc(hawk, name); #else hawk_ucs_t wcs; hawk_fnc_t* fnc; - wcs.ptr = hawk_dupbtouchars(awk, name->ptr, name->len, &wcs.len, 0); + wcs.ptr = hawk_dupbtouchars(hawk, name->ptr, name->len, &wcs.len, 0); if (HAWK_UNLIKELY(!wcs.ptr)) return HAWK_NULL; - fnc = find_fnc(awk, &wcs); - hawk_freemem (awk, wcs.ptr); + fnc = find_fnc(hawk, &wcs); + hawk_freemem (hawk, wcs.ptr); return fnc; #endif } -hawk_fnc_t* hawk_findfncwithucs (hawk_t* awk, const hawk_ucs_t* name) +hawk_fnc_t* hawk_findfncwithucs (hawk_t* hawk, const hawk_ucs_t* name) { #if defined(HAWK_OOCH_IS_BCH) hawk_bcs_t mbs; hawk_fnc_t* fnc; - mbs.ptr = hawk_duputobchars(awk, name->ptr, name->len, &mbs.len); + mbs.ptr = hawk_duputobchars(hawk, name->ptr, name->len, &mbs.len); if (HAWK_UNLIKELY(!mbs.ptr)) return HAWK_NULL; - fnc = find_fnc(awk, &mbs); - hawk_freemem (awk, mbs.ptr); + fnc = find_fnc(hawk, &mbs); + hawk_freemem (hawk, mbs.ptr); return fnc; #else - return find_fnc(awk, name); + return find_fnc(hawk, name); #endif } diff --git a/hawk/lib/gem-nwif.c b/hawk/lib/gem-nwif.c index e60d153a..9cd503a0 100644 --- a/hawk/lib/gem-nwif.c +++ b/hawk/lib/gem-nwif.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/gem-nwif2.c b/hawk/lib/gem-nwif2.c index bf294cc2..d207d62a 100644 --- a/hawk/lib/gem-nwif2.c +++ b/hawk/lib/gem-nwif2.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/gem-skad.c b/hawk/lib/gem-skad.c index 5c802603..41db34d1 100644 --- a/hawk/lib/gem-skad.c +++ b/hawk/lib/gem-skad.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/gem.c b/hawk/lib/gem.c index e9f56556..0bb73886 100644 --- a/hawk/lib/gem.c +++ b/hawk/lib/gem.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-arr.h b/hawk/lib/hawk-arr.h index fbb9907d..db8e4861 100644 --- a/hawk/lib/hawk-arr.h +++ b/hawk/lib/hawk-arr.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-chr.h b/hawk/lib/hawk-chr.h index a4205788..df17e56c 100644 --- a/hawk/lib/hawk-chr.h +++ b/hawk/lib/hawk-chr.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-cmn.h b/hawk/lib/hawk-cmn.h index 1e79c308..3df7991e 100644 --- a/hawk/lib/hawk-cmn.h +++ b/hawk/lib/hawk-cmn.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-dir.h b/hawk/lib/hawk-dir.h index e38f75a9..9de524f0 100644 --- a/hawk/lib/hawk-dir.h +++ b/hawk/lib/hawk-dir.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-ecs.h b/hawk/lib/hawk-ecs.h index 2358915f..8d88d66e 100644 --- a/hawk/lib/hawk-ecs.h +++ b/hawk/lib/hawk-ecs.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-fio.h b/hawk/lib/hawk-fio.h index 63b7029c..34519895 100644 --- a/hawk/lib/hawk-fio.h +++ b/hawk/lib/hawk-fio.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-fmt.h b/hawk/lib/hawk-fmt.h index 8a7dca52..8241e8ef 100644 --- a/hawk/lib/hawk-fmt.h +++ b/hawk/lib/hawk-fmt.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-gem.h b/hawk/lib/hawk-gem.h index a1b75a74..81d13fc6 100644 --- a/hawk/lib/hawk-gem.h +++ b/hawk/lib/hawk-gem.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-htb.h b/hawk/lib/hawk-htb.h index 08e87dc6..18da4b3d 100644 --- a/hawk/lib/hawk-htb.h +++ b/hawk/lib/hawk-htb.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-map.h b/hawk/lib/hawk-map.h index 7a456f34..cea87670 100644 --- a/hawk/lib/hawk-map.h +++ b/hawk/lib/hawk-map.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-mtx.h b/hawk/lib/hawk-mtx.h index 0adf193d..2629618d 100644 --- a/hawk/lib/hawk-mtx.h +++ b/hawk/lib/hawk-mtx.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-pack1.h b/hawk/lib/hawk-pack1.h index dbe29480..4d786b94 100644 --- a/hawk/lib/hawk-pack1.h +++ b/hawk/lib/hawk-pack1.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-pio.h b/hawk/lib/hawk-pio.h index 494349c7..1ab604c3 100644 --- a/hawk/lib/hawk-pio.h +++ b/hawk/lib/hawk-pio.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-prv.h b/hawk/lib/hawk-prv.h index 2d208119..30889828 100644 --- a/hawk/lib/hawk-prv.h +++ b/hawk/lib/hawk-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -174,7 +174,7 @@ struct hawk_tree_t hawk_oow_t ngbls; /* total number of globals */ hawk_oow_t ngbls_base; /* number of intrinsic globals */ hawk_oocs_t cur_fun; - hawk_htb_t* funs; /* awk function map */ + hawk_htb_t* funs; /* hawk function map */ hawk_nde_t* begin; hawk_nde_t* begin_tail; @@ -576,8 +576,8 @@ static HAWK_INLINE void HAWK_RTX_STACK_POP (hawk_rtx_t* rtx) extern "C" { #endif -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); +int hawk_init (hawk_t* hawk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm_t* prm); +void hawk_fini (hawk_t* hawk); #if defined(__cplusplus) } diff --git a/hawk/lib/hawk-rbt.h b/hawk/lib/hawk-rbt.h index f73d03eb..c9d69c4c 100644 --- a/hawk/lib/hawk-rbt.h +++ b/hawk/lib/hawk-rbt.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-sio.h b/hawk/lib/hawk-sio.h index f3e27891..eae0e09a 100644 --- a/hawk/lib/hawk-sio.h +++ b/hawk/lib/hawk-sio.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-std.h b/hawk/lib/hawk-std.h index 868c07f1..8abf2dd9 100644 --- a/hawk/lib/hawk-std.h +++ b/hawk/lib/hawk-std.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -31,8 +31,8 @@ /** \file * This file defines functions and data types that help you create - * an awk interpreter with less effort. It is designed to be as close - * to conventional awk implementations as possible. + * an hawk interpreter with less effort. It is designed to be as close + * to conventional hawk implementations as possible. * * The source script handler does not evaluate a file name of the "var=val" * form as an assignment expression. Instead, it just treats it as a @@ -105,7 +105,7 @@ struct hawk_parsestd_t * pointer and the length of a deparsed source string. The output * string is dynamically allocated. You don't need to set these * fields before calling hawk_parsestd() because they are set - * by hawk_parsestd() and valid while the relevant awk object + * by hawk_parsestd() and valid while the relevant hawk object * is alive. You must free the memory chunk pointed to by the * ptr field with hawk_freemem() once you're done with it to * avoid memory leaks. @@ -123,7 +123,7 @@ extern "C" { #endif /** - * The hawk_openstd() function creates an awk object using the default + * The hawk_openstd() function creates an hawk object using the default * memory manager and primitive functions. Besides, it adds a set of * standard intrinsic functions like atan, system, etc. Use this function * over hawk_open() if you don't need finer-grained customization. @@ -134,7 +134,7 @@ HAWK_EXPORT hawk_t* hawk_openstd ( ); /** - * The hawk_openstdwithmmgr() function creates an awk object with a + * The hawk_openstdwithmmgr() function creates an hawk object with a * user-defined memory manager. It is equivalent to hawk_openstd(), * except that you can specify your own memory manager. */ @@ -159,7 +159,7 @@ HAWK_EXPORT hawk_t* hawk_openstdwithmmgr ( * in[0].u.str.len = hawk_count_oocstr(in.u.str.ptr); * in[1].type = HAWK_PARSESTD_NULL; * out.type = HAWK_PARSESTD_OOCS; - * n = hawk_parsestd (awk, in, &out); + * n = hawk_parsestd (hawk, in, &out); * if (n >= 0) * { * hawk_printf (HAWK_T("%s\n"), out.u.str.ptr); @@ -168,7 +168,7 @@ HAWK_EXPORT hawk_t* hawk_openstdwithmmgr ( * \endcode */ HAWK_EXPORT int hawk_parsestd ( - hawk_t* awk, + hawk_t* hawk, hawk_parsestd_t in[], hawk_parsestd_t* out ); @@ -180,7 +180,7 @@ HAWK_EXPORT int hawk_parsestd ( * streams created with \a icf and \a ocf if it is not #HAWK_NULL. */ HAWK_EXPORT hawk_rtx_t* hawk_rtx_openstdwithbcstr ( - hawk_t* awk, + hawk_t* hawk, hawk_oow_t xtnsize, const hawk_bch_t* id, hawk_bch_t* icf[], @@ -195,7 +195,7 @@ HAWK_EXPORT hawk_rtx_t* hawk_rtx_openstdwithbcstr ( * streams created with \a icf and \a ocf if it is not #HAWK_NULL. */ HAWK_EXPORT hawk_rtx_t* hawk_rtx_openstdwithucstr ( - hawk_t* awk, + hawk_t* hawk, hawk_oow_t xtnsize, const hawk_uch_t* id, hawk_uch_t* icf[], diff --git a/hawk/lib/hawk-tio.h b/hawk/lib/hawk-tio.h index 2eecf10a..60bffe09 100644 --- a/hawk/lib/hawk-tio.h +++ b/hawk/lib/hawk-tio.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-tre.h b/hawk/lib/hawk-tre.h index b745b04c..b8721a9a 100644 --- a/hawk/lib/hawk-tre.h +++ b/hawk/lib/hawk-tre.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-unpack.h b/hawk/lib/hawk-unpack.h index 585ba214..cc536bed 100644 --- a/hawk/lib/hawk-unpack.h +++ b/hawk/lib/hawk-unpack.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk-utl.h b/hawk/lib/hawk-utl.h index e243ada8..af4a757e 100644 --- a/hawk/lib/hawk-utl.h +++ b/hawk/lib/hawk-utl.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/hawk.c b/hawk/lib/hawk.c index 7125666f..445495cb 100644 --- a/hawk/lib/hawk.c +++ b/hawk/lib/hawk.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -28,22 +28,22 @@ static void free_fun (hawk_htb_t* map, void* vptr, hawk_oow_t vlen) { - hawk_t* awk = *(hawk_t**)(map + 1); + hawk_t* hawk = *(hawk_t**)(map + 1); hawk_fun_t* f = (hawk_fun_t*)vptr; /* f->name doesn't have to be freed */ - /*hawk_freemem (awk, f->name);*/ + /*hawk_freemem (hawk, f->name);*/ - if (f->argspec) hawk_freemem (awk, f->argspec); - hawk_clrpt (awk, f->body); - hawk_freemem (awk, f); + if (f->argspec) hawk_freemem (hawk, f->argspec); + hawk_clrpt (hawk, f->body); + hawk_freemem (hawk, f); } static void free_fnc (hawk_htb_t* map, void* vptr, hawk_oow_t vlen) { - hawk_t* awk = *(hawk_t**)(map + 1); + hawk_t* hawk = *(hawk_t**)(map + 1); hawk_fnc_t* f = (hawk_fnc_t*)vptr; - hawk_freemem (awk, f); + hawk_freemem (hawk, f); } static int init_token (hawk_t* hawk, hawk_tok_t* tok) @@ -79,25 +79,25 @@ static void clear_token (hawk_tok_t* tok) hawk_t* hawk_open (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t* cmgr, const hawk_prm_t* prm, hawk_errnum_t* errnum) { - hawk_t* awk; + hawk_t* hawk; - awk = (hawk_t*)HAWK_MMGR_ALLOC(mmgr, HAWK_SIZEOF(hawk_t) + xtnsize); - if (awk) + hawk = (hawk_t*)HAWK_MMGR_ALLOC(mmgr, HAWK_SIZEOF(hawk_t) + xtnsize); + if (hawk) { int xret; - xret = hawk_init(awk, mmgr, cmgr, prm); + xret = hawk_init(hawk, mmgr, cmgr, prm); if (xret <= -1) { - if (errnum) *errnum = hawk_geterrnum(awk); - HAWK_MMGR_FREE (mmgr, awk); - awk = HAWK_NULL; + if (errnum) *errnum = hawk_geterrnum(hawk); + HAWK_MMGR_FREE (mmgr, hawk); + hawk = HAWK_NULL; } - else HAWK_MEMSET (awk + 1, 0, xtnsize); + else HAWK_MEMSET (hawk + 1, 0, xtnsize); } else if (errnum) *errnum = HAWK_ENOMEM; - return awk; + return hawk; } void hawk_close (hawk_t* hawk) @@ -106,7 +106,7 @@ void hawk_close (hawk_t* hawk) HAWK_MMGR_FREE (hawk_getmmgr(hawk), hawk); } -int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm_t* prm) +int hawk_init (hawk_t* hawk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm_t* prm) { static hawk_htb_style_t treefuncbs = { @@ -141,21 +141,21 @@ int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm }; /* zero out the object */ - HAWK_MEMSET (awk, 0, HAWK_SIZEOF(*awk)); + HAWK_MEMSET (hawk, 0, HAWK_SIZEOF(*hawk)); /* remember the memory manager */ - awk->_instsize = HAWK_SIZEOF(*awk); - awk->_gem.mmgr = mmgr; - awk->_gem.cmgr = cmgr; + hawk->_instsize = HAWK_SIZEOF(*hawk); + hawk->_gem.mmgr = mmgr; + hawk->_gem.cmgr = cmgr; /* initialize error handling fields */ - awk->_gem.errnum = HAWK_ENOERR; - awk->_gem.errmsg[0] = '\0'; - awk->_gem.errloc.line = 0; - awk->_gem.errloc.colm = 0; - awk->_gem.errloc.file = HAWK_NULL; - awk->errstr = hawk_dfl_errstr; - awk->haltall = 0; + hawk->_gem.errnum = HAWK_ENOERR; + hawk->_gem.errmsg[0] = '\0'; + hawk->_gem.errloc.line = 0; + hawk->_gem.errloc.colm = 0; + hawk->_gem.errloc.file = HAWK_NULL; + hawk->errstr = hawk_dfl_errstr; + hawk->haltall = 0; /* progagate the primitive functions */ HAWK_ASSERT (prm != HAWK_NULL); @@ -165,265 +165,265 @@ int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm prm->math.pow == HAWK_NULL || prm->math.mod == HAWK_NULL) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); goto oops; } - awk->prm = *prm; + hawk->prm = *prm; - if (init_token(awk, &awk->ptok) <= -1 || - init_token(awk, &awk->tok) <= -1 || - init_token(awk, &awk->ntok) <= -1) goto oops; + if (init_token(hawk, &hawk->ptok) <= -1 || + init_token(hawk, &hawk->tok) <= -1 || + init_token(hawk, &hawk->ntok) <= -1) goto oops; - awk->opt.trait = HAWK_MODERN; + hawk->opt.trait = HAWK_MODERN; #if defined(__WIN32__) || defined(_OS2) || defined(__DOS__) - awk->opt.trait |= HAWK_CRLF; + hawk->opt.trait |= HAWK_CRLF; #endif - awk->opt.rtx_stack_limit = HAWK_DFL_RTX_STACK_LIMIT; - awk->opt.log_mask = HAWK_LOG_ALL_LEVELS | HAWK_LOG_ALL_TYPES; - awk->opt.log_maxcapa = HAWK_DFL_LOG_MAXCAPA; + hawk->opt.rtx_stack_limit = HAWK_DFL_RTX_STACK_LIMIT; + hawk->opt.log_mask = HAWK_LOG_ALL_LEVELS | HAWK_LOG_ALL_TYPES; + hawk->opt.log_maxcapa = HAWK_DFL_LOG_MAXCAPA; - awk->log.capa = HAWK_ALIGN_POW2(1, HAWK_LOG_CAPA_ALIGN); - awk->log.ptr = hawk_allocmem(awk, (awk->log.capa + 1) * HAWK_SIZEOF(*awk->log.ptr)); - if (!awk->log.ptr) goto oops; + hawk->log.capa = HAWK_ALIGN_POW2(1, HAWK_LOG_CAPA_ALIGN); + hawk->log.ptr = hawk_allocmem(hawk, (hawk->log.capa + 1) * HAWK_SIZEOF(*hawk->log.ptr)); + if (!hawk->log.ptr) goto oops; - awk->tree.ngbls = 0; - awk->tree.ngbls_base = 0; - awk->tree.begin = HAWK_NULL; - awk->tree.begin_tail = HAWK_NULL; - awk->tree.end = HAWK_NULL; - awk->tree.end_tail = HAWK_NULL; - awk->tree.chain = HAWK_NULL; - awk->tree.chain_tail = HAWK_NULL; - awk->tree.chain_size = 0; + hawk->tree.ngbls = 0; + hawk->tree.ngbls_base = 0; + hawk->tree.begin = HAWK_NULL; + hawk->tree.begin_tail = HAWK_NULL; + hawk->tree.end = HAWK_NULL; + hawk->tree.end_tail = HAWK_NULL; + hawk->tree.chain = HAWK_NULL; + hawk->tree.chain_tail = HAWK_NULL; + hawk->tree.chain_size = 0; /* TODO: initial map size?? */ - awk->tree.funs = hawk_htb_open(hawk_getgem(awk), HAWK_SIZEOF(awk), 512, 70, HAWK_SIZEOF(hawk_ooch_t), 1); - awk->parse.funs = hawk_htb_open(hawk_getgem(awk), HAWK_SIZEOF(awk), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1); - awk->parse.named = hawk_htb_open(hawk_getgem(awk), HAWK_SIZEOF(awk), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1); + hawk->tree.funs = hawk_htb_open(hawk_getgem(hawk), HAWK_SIZEOF(hawk), 512, 70, HAWK_SIZEOF(hawk_ooch_t), 1); + hawk->parse.funs = hawk_htb_open(hawk_getgem(hawk), HAWK_SIZEOF(hawk), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1); + hawk->parse.named = hawk_htb_open(hawk_getgem(hawk), HAWK_SIZEOF(hawk), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1); - awk->parse.gbls = hawk_arr_open(hawk_getgem(awk), HAWK_SIZEOF(awk), 128); - awk->parse.lcls = hawk_arr_open(hawk_getgem(awk), HAWK_SIZEOF(awk), 64); - awk->parse.params = hawk_arr_open(hawk_getgem(awk), HAWK_SIZEOF(awk), 32); + hawk->parse.gbls = hawk_arr_open(hawk_getgem(hawk), HAWK_SIZEOF(hawk), 128); + hawk->parse.lcls = hawk_arr_open(hawk_getgem(hawk), HAWK_SIZEOF(hawk), 64); + hawk->parse.params = hawk_arr_open(hawk_getgem(hawk), HAWK_SIZEOF(hawk), 32); - awk->fnc.sys = HAWK_NULL; - awk->fnc.user = hawk_htb_open(hawk_getgem(awk), HAWK_SIZEOF(awk), 512, 70, HAWK_SIZEOF(hawk_ooch_t), 1); - awk->modtab = hawk_rbt_open(hawk_getgem(awk), 0, HAWK_SIZEOF(hawk_ooch_t), 1); + hawk->fnc.sys = HAWK_NULL; + hawk->fnc.user = hawk_htb_open(hawk_getgem(hawk), HAWK_SIZEOF(hawk), 512, 70, HAWK_SIZEOF(hawk_ooch_t), 1); + hawk->modtab = hawk_rbt_open(hawk_getgem(hawk), 0, HAWK_SIZEOF(hawk_ooch_t), 1); - if (awk->tree.funs == HAWK_NULL || - awk->parse.funs == HAWK_NULL || - awk->parse.named == HAWK_NULL || - awk->parse.gbls == HAWK_NULL || - awk->parse.lcls == HAWK_NULL || - awk->parse.params == HAWK_NULL || - awk->fnc.user == HAWK_NULL || - awk->modtab == HAWK_NULL) + if (hawk->tree.funs == HAWK_NULL || + hawk->parse.funs == HAWK_NULL || + hawk->parse.named == HAWK_NULL || + hawk->parse.gbls == HAWK_NULL || + hawk->parse.lcls == HAWK_NULL || + hawk->parse.params == HAWK_NULL || + hawk->fnc.user == HAWK_NULL || + hawk->modtab == HAWK_NULL) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOMEM); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_ENOMEM); goto oops; } - *(hawk_t**)(awk->tree.funs + 1) = awk; - hawk_htb_setstyle (awk->tree.funs, &treefuncbs); + *(hawk_t**)(hawk->tree.funs + 1) = hawk; + hawk_htb_setstyle (hawk->tree.funs, &treefuncbs); - *(hawk_t**)(awk->parse.funs + 1) = awk; - hawk_htb_setstyle (awk->parse.funs, hawk_get_htb_style(HAWK_HTB_STYLE_INLINE_KEY_COPIER)); + *(hawk_t**)(hawk->parse.funs + 1) = hawk; + hawk_htb_setstyle (hawk->parse.funs, hawk_get_htb_style(HAWK_HTB_STYLE_INLINE_KEY_COPIER)); - *(hawk_t**)(awk->parse.named + 1) = awk; - hawk_htb_setstyle (awk->parse.named, hawk_get_htb_style(HAWK_HTB_STYLE_INLINE_KEY_COPIER)); + *(hawk_t**)(hawk->parse.named + 1) = hawk; + hawk_htb_setstyle (hawk->parse.named, hawk_get_htb_style(HAWK_HTB_STYLE_INLINE_KEY_COPIER)); - *(hawk_t**)(awk->parse.gbls + 1) = awk; - hawk_arr_setscale (awk->parse.gbls, HAWK_SIZEOF(hawk_ooch_t)); - hawk_arr_setcopier (awk->parse.gbls, HAWK_ARR_COPIER_INLINE); + *(hawk_t**)(hawk->parse.gbls + 1) = hawk; + hawk_arr_setscale (hawk->parse.gbls, HAWK_SIZEOF(hawk_ooch_t)); + hawk_arr_setcopier (hawk->parse.gbls, HAWK_ARR_COPIER_INLINE); - *(hawk_t**)(awk->parse.lcls + 1) = awk; - hawk_arr_setscale (awk->parse.lcls, HAWK_SIZEOF(hawk_ooch_t)); - hawk_arr_setcopier (awk->parse.lcls, HAWK_ARR_COPIER_INLINE); + *(hawk_t**)(hawk->parse.lcls + 1) = hawk; + hawk_arr_setscale (hawk->parse.lcls, HAWK_SIZEOF(hawk_ooch_t)); + hawk_arr_setcopier (hawk->parse.lcls, HAWK_ARR_COPIER_INLINE); - *(hawk_t**)(awk->parse.params + 1) = awk; - hawk_arr_setscale (awk->parse.params, HAWK_SIZEOF(hawk_ooch_t)); - hawk_arr_setcopier (awk->parse.params, HAWK_ARR_COPIER_INLINE); + *(hawk_t**)(hawk->parse.params + 1) = hawk; + hawk_arr_setscale (hawk->parse.params, HAWK_SIZEOF(hawk_ooch_t)); + hawk_arr_setcopier (hawk->parse.params, HAWK_ARR_COPIER_INLINE); - *(hawk_t**)(awk->fnc.user + 1) = awk; - hawk_htb_setstyle (awk->fnc.user, &fncusercbs); + *(hawk_t**)(hawk->fnc.user + 1) = hawk; + hawk_htb_setstyle (hawk->fnc.user, &fncusercbs); - hawk_rbt_setstyle (awk->modtab, hawk_get_rbt_style(HAWK_RBT_STYLE_INLINE_COPIERS)); + hawk_rbt_setstyle (hawk->modtab, hawk_get_rbt_style(HAWK_RBT_STYLE_INLINE_COPIERS)); - if (hawk_initgbls(awk) <= -1) goto oops; + if (hawk_initgbls(hawk) <= -1) goto oops; return 0; oops: - if (awk->modtab) hawk_rbt_close (awk->modtab); - if (awk->fnc.user) hawk_htb_close (awk->fnc.user); - if (awk->parse.params) hawk_arr_close (awk->parse.params); - if (awk->parse.lcls) hawk_arr_close (awk->parse.lcls); - if (awk->parse.gbls) hawk_arr_close (awk->parse.gbls); - if (awk->parse.named) hawk_htb_close (awk->parse.named); - if (awk->parse.funs) hawk_htb_close (awk->parse.funs); - if (awk->tree.funs) hawk_htb_close (awk->tree.funs); - fini_token (&awk->ntok); - fini_token (&awk->tok); - fini_token (&awk->ptok); - if (awk->log.ptr) hawk_freemem (awk, awk->log.ptr); - awk->log.capa = 0; + if (hawk->modtab) hawk_rbt_close (hawk->modtab); + if (hawk->fnc.user) hawk_htb_close (hawk->fnc.user); + if (hawk->parse.params) hawk_arr_close (hawk->parse.params); + if (hawk->parse.lcls) hawk_arr_close (hawk->parse.lcls); + if (hawk->parse.gbls) hawk_arr_close (hawk->parse.gbls); + if (hawk->parse.named) hawk_htb_close (hawk->parse.named); + if (hawk->parse.funs) hawk_htb_close (hawk->parse.funs); + if (hawk->tree.funs) hawk_htb_close (hawk->tree.funs); + fini_token (&hawk->ntok); + fini_token (&hawk->tok); + fini_token (&hawk->ptok); + if (hawk->log.ptr) hawk_freemem (hawk, hawk->log.ptr); + hawk->log.capa = 0; return -1; } -void hawk_fini (hawk_t* awk) +void hawk_fini (hawk_t* hawk) { hawk_ecb_t* ecb; int i; - hawk_clear (awk); - /*hawk_clrfnc (awk);*/ + hawk_clear (hawk); + /*hawk_clrfnc (hawk);*/ - if (awk->log.len > 0) + if (hawk->log.len > 0) { - int shuterr = awk->shuterr; - awk->shuterr = 1; - awk->prm.logwrite (awk, awk->log.last_mask, awk->log.ptr, awk->log.len); - awk->shuterr = shuterr; + int shuterr = hawk->shuterr; + hawk->shuterr = 1; + hawk->prm.logwrite (hawk, hawk->log.last_mask, hawk->log.ptr, hawk->log.len); + hawk->shuterr = shuterr; } - for (ecb = awk->ecb; ecb; ecb = ecb->next) - if (ecb->close) ecb->close (awk); + for (ecb = hawk->ecb; ecb; ecb = ecb->next) + if (ecb->close) ecb->close (hawk); - hawk_rbt_close (awk->modtab); - hawk_htb_close (awk->fnc.user); + hawk_rbt_close (hawk->modtab); + hawk_htb_close (hawk->fnc.user); - hawk_arr_close (awk->parse.params); - hawk_arr_close (awk->parse.lcls); - hawk_arr_close (awk->parse.gbls); - hawk_htb_close (awk->parse.named); - hawk_htb_close (awk->parse.funs); + hawk_arr_close (hawk->parse.params); + hawk_arr_close (hawk->parse.lcls); + hawk_arr_close (hawk->parse.gbls); + hawk_htb_close (hawk->parse.named); + hawk_htb_close (hawk->parse.funs); - hawk_htb_close (awk->tree.funs); + hawk_htb_close (hawk->tree.funs); - fini_token (&awk->ntok); - fini_token (&awk->tok); - fini_token (&awk->ptok); + fini_token (&hawk->ntok); + fini_token (&hawk->tok); + fini_token (&hawk->ptok); - if (awk->parse.incl_hist.ptr) hawk_freemem (awk, awk->parse.incl_hist.ptr); - hawk_clearsionames (awk); + if (hawk->parse.incl_hist.ptr) hawk_freemem (hawk, hawk->parse.incl_hist.ptr); + hawk_clearsionames (hawk); /* destroy dynamically allocated options */ - for (i = 0; i < HAWK_COUNTOF(awk->opt.mod); i++) + for (i = 0; i < HAWK_COUNTOF(hawk->opt.mod); i++) { - if (awk->opt.mod[i].ptr) hawk_freemem (awk, awk->opt.mod[i].ptr); + if (hawk->opt.mod[i].ptr) hawk_freemem (hawk, hawk->opt.mod[i].ptr); } - if (awk->log.len > 0) + if (hawk->log.len > 0) { /* flush pending log message that could be generated by the fini * callbacks. however, the actual logging might not be produced at * this point because one of the callbacks could arrange to stop * logging */ - int shuterr = awk->shuterr; - awk->shuterr = 1; - awk->prm.logwrite (awk, awk->log.last_mask, awk->log.ptr, awk->log.len); - awk->shuterr = shuterr; + int shuterr = hawk->shuterr; + hawk->shuterr = 1; + hawk->prm.logwrite (hawk, hawk->log.last_mask, hawk->log.ptr, hawk->log.len); + hawk->shuterr = shuterr; } - if (awk->log.ptr) + if (hawk->log.ptr) { - hawk_freemem (awk, awk->log.ptr); - awk->log.capa = 0; - awk->log.len = 0; + hawk_freemem (hawk, hawk->log.ptr); + hawk->log.capa = 0; + hawk->log.len = 0; } } static hawk_rbt_walk_t unload_module (hawk_rbt_t* rbt, hawk_rbt_pair_t* pair, void* ctx) { - hawk_t* awk = (hawk_t*)ctx; + hawk_t* hawk = (hawk_t*)ctx; hawk_mod_data_t* md; md = HAWK_RBT_VPTR(pair); - if (md->mod.unload) md->mod.unload (&md->mod, awk); - if (md->handle) awk->prm.modclose (awk, md->handle); + if (md->mod.unload) md->mod.unload (&md->mod, hawk); + if (md->handle) hawk->prm.modclose (hawk, md->handle); return HAWK_RBT_WALK_FORWARD; } -void hawk_clear (hawk_t* awk) +void hawk_clear (hawk_t* hawk) { hawk_ecb_t* ecb; - for (ecb = awk->ecb; ecb; ecb = ecb->next) + for (ecb = hawk->ecb; ecb; ecb = ecb->next) { - if (ecb->clear) ecb->clear (awk); + if (ecb->clear) ecb->clear (hawk); } - awk->haltall = 0; + hawk->haltall = 0; - clear_token (&awk->tok); - clear_token (&awk->ntok); - clear_token (&awk->ptok); + clear_token (&hawk->tok); + clear_token (&hawk->ntok); + clear_token (&hawk->ptok); /* clear all loaded modules */ - hawk_rbt_walk (awk->modtab, unload_module, awk); - hawk_rbt_clear (awk->modtab); + hawk_rbt_walk (hawk->modtab, unload_module, hawk); + hawk_rbt_clear (hawk->modtab); - HAWK_ASSERT (HAWK_ARR_SIZE(awk->parse.gbls) == awk->tree.ngbls); + HAWK_ASSERT (HAWK_ARR_SIZE(hawk->parse.gbls) == hawk->tree.ngbls); /* delete all non-builtin global variables */ hawk_arr_delete ( - awk->parse.gbls, awk->tree.ngbls_base, - HAWK_ARR_SIZE(awk->parse.gbls) - awk->tree.ngbls_base); + hawk->parse.gbls, hawk->tree.ngbls_base, + HAWK_ARR_SIZE(hawk->parse.gbls) - hawk->tree.ngbls_base); - hawk_arr_clear (awk->parse.lcls); - hawk_arr_clear (awk->parse.params); - hawk_htb_clear (awk->parse.named); - hawk_htb_clear (awk->parse.funs); + hawk_arr_clear (hawk->parse.lcls); + hawk_arr_clear (hawk->parse.params); + hawk_htb_clear (hawk->parse.named); + hawk_htb_clear (hawk->parse.funs); - awk->parse.nlcls_max = 0; - awk->parse.depth.block = 0; - awk->parse.depth.loop = 0; - awk->parse.depth.expr = 0; - awk->parse.depth.incl = 0; - awk->parse.pragma.trait = (awk->opt.trait & (HAWK_IMPLICIT | HAWK_MULTILINESTR | HAWK_STRIPRECSPC | HAWK_STRIPSTRSPC)); /* implicit on if you didn't mask it off in awk->opt.trait with hawk_setopt */ - awk->parse.pragma.rtx_stack_limit = 0; - awk->parse.pragma.entry[0] = '\0'; + hawk->parse.nlcls_max = 0; + hawk->parse.depth.block = 0; + hawk->parse.depth.loop = 0; + hawk->parse.depth.expr = 0; + hawk->parse.depth.incl = 0; + hawk->parse.pragma.trait = (hawk->opt.trait & (HAWK_IMPLICIT | HAWK_MULTILINESTR | HAWK_STRIPRECSPC | HAWK_STRIPSTRSPC)); /* implicit on if you didn't mask it off in hawk->opt.trait with hawk_setopt */ + hawk->parse.pragma.rtx_stack_limit = 0; + hawk->parse.pragma.entry[0] = '\0'; - awk->parse.incl_hist.count =0; + hawk->parse.incl_hist.count =0; /* clear parse trees */ - /*awk->tree.ngbls_base = 0; - awk->tree.ngbls = 0; */ - awk->tree.ngbls = awk->tree.ngbls_base; + /*hawk->tree.ngbls_base = 0; + hawk->tree.ngbls = 0; */ + hawk->tree.ngbls = hawk->tree.ngbls_base; - awk->tree.cur_fun.ptr = HAWK_NULL; - awk->tree.cur_fun.len = 0; - hawk_htb_clear (awk->tree.funs); + hawk->tree.cur_fun.ptr = HAWK_NULL; + hawk->tree.cur_fun.len = 0; + hawk_htb_clear (hawk->tree.funs); - if (awk->tree.begin) + if (hawk->tree.begin) { - hawk_clrpt (awk, awk->tree.begin); - awk->tree.begin = HAWK_NULL; - awk->tree.begin_tail = HAWK_NULL; + hawk_clrpt (hawk, hawk->tree.begin); + hawk->tree.begin = HAWK_NULL; + hawk->tree.begin_tail = HAWK_NULL; } - if (awk->tree.end) + if (hawk->tree.end) { - hawk_clrpt (awk, awk->tree.end); - awk->tree.end = HAWK_NULL; - awk->tree.end_tail = HAWK_NULL; + hawk_clrpt (hawk, hawk->tree.end); + hawk->tree.end = HAWK_NULL; + hawk->tree.end_tail = HAWK_NULL; } - while (awk->tree.chain) + while (hawk->tree.chain) { - hawk_chain_t* next = awk->tree.chain->next; - if (awk->tree.chain->pattern) hawk_clrpt (awk, awk->tree.chain->pattern); - if (awk->tree.chain->action) hawk_clrpt (awk, awk->tree.chain->action); - hawk_freemem (awk, awk->tree.chain); - awk->tree.chain = next; + hawk_chain_t* next = hawk->tree.chain->next; + if (hawk->tree.chain->pattern) hawk_clrpt (hawk, hawk->tree.chain->pattern); + if (hawk->tree.chain->action) hawk_clrpt (hawk, hawk->tree.chain->action); + hawk_freemem (hawk, hawk->tree.chain); + hawk->tree.chain = next; } - awk->tree.chain_tail = HAWK_NULL; - awk->tree.chain_size = 0; + hawk->tree.chain_tail = HAWK_NULL; + hawk->tree.chain_size = 0; /* this table must not be cleared here as there can be a reference * to an entry of this table from errinf.loc.file when hawk_parse() * failed. this table is cleared in hawk_parse(). - * hawk_claersionames (awk); + * hawk_claersionames (hawk); */ } @@ -563,22 +563,22 @@ int hawk_getopt (hawk_t* hawk, hawk_opt_t id, void* value) return -1; } -void hawk_haltall (hawk_t* awk) +void hawk_haltall (hawk_t* hawk) { - awk->haltall = 1; + hawk->haltall = 1; } -hawk_ecb_t* hawk_popecb (hawk_t* awk) +hawk_ecb_t* hawk_popecb (hawk_t* hawk) { - hawk_ecb_t* top = awk->ecb; - if (top) awk->ecb = top->next; + hawk_ecb_t* top = hawk->ecb; + if (top) hawk->ecb = top->next; return top; } -void hawk_pushecb (hawk_t* awk, hawk_ecb_t* ecb) +void hawk_pushecb (hawk_t* hawk, hawk_ecb_t* ecb) { - ecb->next = awk->ecb; - awk->ecb = ecb; + ecb->next = hawk->ecb; + hawk->ecb = ecb; } /* ------------------------------------------------------------------------ */ diff --git a/hawk/lib/hawk.h b/hawk/lib/hawk.h index 0f7e9592..0583d46f 100644 --- a/hawk/lib/hawk.h +++ b/hawk/lib/hawk.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -60,7 +60,7 @@ * hawk_sio_cbs_t sio; // need to initialize it with callback functions * hawk_rio_cbs_t rio; // need to initialize it with callback functions * - * awk = hawk_open(mmgr, 0, prm); // create an interpreter + * hawk = hawk_open(mmgr, 0, prm); // create an interpreter * hawk_parse (hawk, &sio); // parse a script * rtx = hawk_rtx_open(hawk, 0, &rio); // create a runtime context * retv = hawk_rtx_loop(rtx); // run a standard AWK loop @@ -465,12 +465,12 @@ typedef struct hawk_val_fun_t hawk_val_fun_t; /* ------------------------------------------------------------------------ */ typedef hawk_flt_t (*hawk_math1_t) ( - hawk_t* awk, + hawk_t* hawk, hawk_flt_t x ); typedef hawk_flt_t (*hawk_math2_t) ( - hawk_t* awk, + hawk_t* hawk, hawk_flt_t x, hawk_flt_t y ); @@ -488,18 +488,18 @@ struct hawk_mod_spec_t }; typedef void* (*hawk_mod_open_t) ( - hawk_t* awk, + hawk_t* hawk, const hawk_mod_spec_t* spec ); typedef void* (*hawk_mod_getsym_t) ( - hawk_t* awk, + hawk_t* hawk, void* handle, const hawk_ooch_t* name ); typedef void (*hawk_mod_close_t) ( - hawk_t* awk, + hawk_t* hawk, void* handle ); @@ -516,13 +516,13 @@ typedef void (*hawk_log_write_t) ( #if 0 typedef void* (*hawk_buildrex_t) ( - hawk_t* awk, + hawk_t* hawk, const hawk_ooch_t* ptn, hawk_oow_t len ); typedef int (*hawk_matchrex_t) ( - hawk_t* awk, + hawk_t* hawk, void* code, int option, const hawk_ooch_t* str, @@ -532,12 +532,12 @@ typedef int (*hawk_matchrex_t) ( ); typedef void (*hawk_freerex_t) ( - hawk_t* awk, + hawk_t* hawk, void* code ); typedef int (*hawk_isemptyrex_t) ( - hawk_t* awk, + hawk_t* hawk, void* code ); #endif @@ -626,7 +626,7 @@ struct hawk_sio_arg_t * The hawk_sio_impl_t type defines a source IO function */ typedef hawk_ooi_t (*hawk_sio_impl_t) ( - hawk_t* awk, + hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, @@ -779,7 +779,7 @@ typedef struct hawk_prm_t hawk_prm_t; * * \code * hawk_ooi_t in ( - * hawk_t* awk, hawk_sio_cmd_t cmd, + * hawk_t* hawk, hawk_sio_cmd_t cmd, * hawk_sio_arg_t* arg, * hawk_ooch_t* buf, hawk_oow_t size) * { @@ -789,7 +789,7 @@ typedef struct hawk_prm_t hawk_prm_t; * } * * hawk_ooi_t out ( - * hawk_t* awk, hawk_sio_cmd_t cmd, + * hawk_t* hawk, hawk_sio_cmd_t cmd, * hawk_sio_arg_t* arg, * hawk_ooch_t* data, hawk_oow_t size) * { @@ -957,19 +957,19 @@ struct hawk_fnc_info_t typedef int (*hawk_mod_load_t) ( hawk_mod_t* mod, - hawk_t* awk + hawk_t* hawk ); typedef int (*hawk_mod_query_t) ( hawk_mod_t* mod, - hawk_t* awk, + hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym ); typedef void (*hawk_mod_unload_t) ( hawk_mod_t* mod, - hawk_t* awk + hawk_t* hawk ); typedef int (*hawk_mod_init_t) ( @@ -1033,21 +1033,21 @@ struct hawk_mod_sym_t /** * The hawk_ecb_close_t type defines the callback function - * called when an awk object is closed. The hawk_close() function + * called when an hawk object is closed. The hawk_close() function * calls this callback function after having called hawk_clear() * but before actual closing. */ typedef void (*hawk_ecb_close_t) ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** * The hawk_ecb_clear_t type defines the callback function - * called when an awk object is cleared. The hawk_clear() function + * called when an hawk object is cleared. The hawk_clear() function * calls this calllback function before it performs actual clearing. */ typedef void (*hawk_ecb_clear_t) ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** @@ -1306,7 +1306,7 @@ typedef struct hawk_errinf_t hawk_errinf_t; * The hawk_errstr_t type defines an error string getter. It should return * an error formatting string for an error number requested. A new string * should contain the same number of positional parameters (${X}) as in the - * default error formatting string. You can set a new getter into an awk + * default error formatting string. You can set a new getter into an hawk * object with the hawk_seterrstr() function to customize an error string. */ typedef const hawk_ooch_t* (*hawk_errstr_t) ( @@ -1481,7 +1481,7 @@ HAWK_EXPORT hawk_t* hawk_open ( * The hawk_close() function destroys a hawk_t object. */ HAWK_EXPORT void hawk_close ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); #if defined(HAWK_HAVE_INLINE) @@ -1504,7 +1504,7 @@ static HAWK_INLINE void hawk_setcmgr (hawk_t* hawk, hawk_cmgr_t* cmgr) { ((hawk_ * structure specified by \a prm. */ HAWK_EXPORT void hawk_getprm ( - hawk_t* awk, + hawk_t* hawk, hawk_prm_t* prm ); @@ -1513,26 +1513,26 @@ HAWK_EXPORT void hawk_getprm ( * functions. */ HAWK_EXPORT void hawk_setprm ( - hawk_t* awk, + hawk_t* hawk, const hawk_prm_t* prm ); /** - * The hawk_clear() clears the internal state of \a awk. If you want to + * The hawk_clear() clears the internal state of \a hawk. If you want to * reuse a hawk_t instance that finished being used, you may call * hawk_clear() instead of destroying and creating a new * #hawk_t instance using hawk_close() and hawk_open(). */ HAWK_EXPORT void hawk_clear ( - hawk_t* awk + hawk_t* hawk ); /** * The hawk_geterrstr() gets an error string getter. */ HAWK_EXPORT hawk_errstr_t hawk_geterrstr ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** @@ -1542,9 +1542,9 @@ HAWK_EXPORT hawk_errstr_t hawk_geterrstr ( */ #if defined(HAWK_HAVE_INLINE) -static HAWK_INLINE hawk_errnum_t hawk_geterrnum (hawk_t* awk) { return ((hawk_alt_t*)awk)->_gem.errnum; } +static HAWK_INLINE hawk_errnum_t hawk_geterrnum (hawk_t* hawk) { return ((hawk_alt_t*)hawk)->_gem.errnum; } #else -# define hawk_geterrnum(awk) (((hawk_alt_t*)(awk))->_gem.errnum) +# define hawk_geterrnum(hawk) (((hawk_alt_t*)(hawk))->_gem.errnum) #endif /** @@ -1552,7 +1552,7 @@ static HAWK_INLINE hawk_errnum_t hawk_geterrnum (hawk_t* awk) { return ((hawk_al * last error has occurred. */ HAWK_EXPORT const hawk_loc_t* hawk_geterrloc ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** @@ -1562,7 +1562,7 @@ HAWK_EXPORT const hawk_loc_t* hawk_geterrloc ( * \return error message */ HAWK_EXPORT const hawk_bch_t* hawk_geterrbmsg ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** @@ -1572,7 +1572,7 @@ HAWK_EXPORT const hawk_bch_t* hawk_geterrbmsg ( * \return error message */ HAWK_EXPORT const hawk_uch_t* hawk_geterrumsg ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); @@ -1584,16 +1584,16 @@ HAWK_EXPORT const hawk_uch_t* hawk_geterrumsg ( HAWK_EXPORT const hawk_ooch_t* hawk_backuperrmsg ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** * The hawk_geterrinf() function copies error information into memory - * pointed to by \a errinf from \a awk. + * pointed to by \a errinf from \a hawk. */ HAWK_EXPORT void hawk_geterrinf ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ hawk_errinf_t* errinf /**< error information buffer */ ); @@ -1610,7 +1610,7 @@ static HAWK_INLINE void hawk_seterrnum (hawk_t* hawk, const hawk_loc_t* errloc, #endif HAWK_EXPORT void hawk_seterrbfmt ( - hawk_t* awk, + hawk_t* hawk, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_bch_t* errfmt, @@ -1618,7 +1618,7 @@ HAWK_EXPORT void hawk_seterrbfmt ( ); HAWK_EXPORT void hawk_seterrufmt ( - hawk_t* awk, + hawk_t* hawk, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_uch_t* errfmt, @@ -1626,7 +1626,7 @@ HAWK_EXPORT void hawk_seterrufmt ( ); HAWK_EXPORT void hawk_seterrbvfmt ( - hawk_t* awk, + hawk_t* hawk, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_bch_t* errfmt, @@ -1634,7 +1634,7 @@ HAWK_EXPORT void hawk_seterrbvfmt ( ); HAWK_EXPORT void hawk_seterruvfmt ( - hawk_t* awk, + hawk_t* hawk, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_uch_t* errfmt, @@ -1655,7 +1655,7 @@ HAWK_EXPORT void hawk_seterruvfmt ( * it automatically formatted. */ HAWK_EXPORT void hawk_seterrinf ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ const hawk_errinf_t* errinf /**< error information */ ); @@ -1664,7 +1664,7 @@ HAWK_EXPORT void hawk_seterrinf ( * The hawk_geterror() function gets error information via parameters. */ HAWK_EXPORT void hawk_geterror ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ hawk_errnum_t* errnum, /**< error number */ const hawk_ooch_t** errmsg, /**< error message */ hawk_loc_t* errloc /**< error location */ @@ -1677,7 +1677,7 @@ HAWK_EXPORT void hawk_geterror ( * \return 0 on success, -1 on failure */ HAWK_EXPORT int hawk_getopt ( - hawk_t* awk, + hawk_t* hawk, hawk_opt_t id, void* value ); @@ -1689,25 +1689,25 @@ HAWK_EXPORT int hawk_getopt ( * \return 0 on success, -1 on failure */ HAWK_EXPORT int hawk_setopt ( - hawk_t* awk, + hawk_t* hawk, hawk_opt_t id, const void* value ); /** - * The hawk_popecb() function pops an awk event callback set + * The hawk_popecb() function pops an hawk event callback set * and returns the pointer to it. If no callback set can be popped, * it returns #HAWK_NULL. */ HAWK_EXPORT hawk_ecb_t* hawk_popecb ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** * The hawk_pushecb() function register a runtime callback set. */ HAWK_EXPORT void hawk_pushecb ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ hawk_ecb_t* ecb /**< callback set */ ); @@ -1781,7 +1781,7 @@ HAWK_EXPORT int hawk_findgblwithucstr ( * The hawk_addfncwithbcstr() function adds an intrinsic function. */ HAWK_EXPORT hawk_fnc_t* hawk_addfncwithbcstr ( - hawk_t* awk, + hawk_t* hawk, const hawk_bch_t* name, const hawk_fnc_mspec_t* spec ); @@ -1790,7 +1790,7 @@ HAWK_EXPORT hawk_fnc_t* hawk_addfncwithbcstr ( * The hawk_addfncwithucstr() function adds an intrinsic function. */ HAWK_EXPORT hawk_fnc_t* hawk_addfncwithucstr ( - hawk_t* awk, + hawk_t* hawk, const hawk_uch_t* name, const hawk_fnc_wspec_t* spec ); @@ -1800,7 +1800,7 @@ HAWK_EXPORT hawk_fnc_t* hawk_addfncwithucstr ( * \return 0 on success, -1 on failure */ HAWK_EXPORT int hawk_delfncwithbcstr ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ const hawk_bch_t* name /**< function name */ ); @@ -1809,7 +1809,7 @@ HAWK_EXPORT int hawk_delfncwithbcstr ( * \return 0 on success, -1 on failure */ HAWK_EXPORT int hawk_delfncwithucstr ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ const hawk_uch_t* name /**< function name */ ); @@ -1825,7 +1825,7 @@ HAWK_EXPORT int hawk_delfncwithucstr ( * The hawk_clrfnc() function deletes all intrinsic functions */ HAWK_EXPORT void hawk_clrfnc ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** @@ -1836,12 +1836,12 @@ HAWK_EXPORT void hawk_clrfnc ( * below: * * \code - * n = sio->in(awk, HAWK_SIO_CMD_OPEN); + * n = sio->in(hawk, HAWK_SIO_CMD_OPEN); * if (n >= 0) * { * while (n > 0) - * n = sio->in (awk, HAWK_SIO_CMD_READ, buf, buf_size); - * sio->in (awk, HAWK_SIO_CMD_CLOSE); + * n = sio->in (hawk, HAWK_SIO_CMD_READ, buf, buf_size); + * sio->in (hawk, HAWK_SIO_CMD_CLOSE); * } * \endcode * @@ -1854,12 +1854,12 @@ HAWK_EXPORT void hawk_clrfnc ( * calling \a sio->out as shown below: * * \code - * n = sio->out (awk, HAWK_SIO_CMD_OPEN); + * n = sio->out (hawk, HAWK_SIO_CMD_OPEN); * if (n >= 0) * { * while (n > 0) - * n = sio->out (awk, HAWK_SIO_CMD_WRITE, text, text_size); - * sio->out (awk, HAWK_SIO_CMD_CLOSE); + * n = sio->out (hawk, HAWK_SIO_CMD_WRITE, text, text_size); + * sio->out (hawk, HAWK_SIO_CMD_CLOSE); * } * \endcode * @@ -1870,7 +1870,7 @@ HAWK_EXPORT void hawk_clrfnc ( * \return 0 on success, -1 on failure. */ HAWK_EXPORT int hawk_parse ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ hawk_sio_cbs_t* sio /**< source script I/O handler */ ); @@ -2063,7 +2063,7 @@ HAWK_EXPORT hawk_ooi_t hawk_logbfmt ( /** - * The hawk_rtx_open() creates a runtime context associated with \a awk. + * The hawk_rtx_open() creates a runtime context associated with \a hawk. * It also allocates an extra memory block as large as the \a xtn bytes. * You can get the pointer to the beginning of the block with * hawk_rtx_getxtn(). The block is destroyed when the runtime context is @@ -2072,7 +2072,7 @@ HAWK_EXPORT hawk_ooi_t hawk_logbfmt ( * \return new runtime context on success, #HAWK_NULL on failure */ HAWK_EXPORT hawk_rtx_t* hawk_rtx_open ( - hawk_t* awk, /**< awk */ + hawk_t* hawk, /**< hawk */ hawk_oow_t xtn, /**< size of extension in bytes */ hawk_rio_cbs_t* rio /**< runtime IO handlers */ ); @@ -2109,7 +2109,7 @@ static HAWK_INLINE void hawk_rtx_setcmgr (hawk_rtx_t* rtx, hawk_cmgr_t* cmgr) { * * The example shows typical usage of the function. * \code - * rtx = hawk_rtx_open(awk, 0, rio); + * rtx = hawk_rtx_open(hawk, 0, rio); * if (rtx) * { * retv = hawk_rtx_loop (rtx); @@ -2170,7 +2170,7 @@ HAWK_EXPORT hawk_val_t* hawk_rtx_callfun ( * * The example shows typical usage of the function. * \code - * rtx = hawk_rtx_open(awk, 0, rio); + * rtx = hawk_rtx_open(hawk, 0, rio); * if (rtx) * { * v = hawk_rtx_callwithucstr (rtx, HAWK_UT("init"), HAWK_NULL, 0); @@ -2198,7 +2198,7 @@ HAWK_EXPORT hawk_val_t* hawk_rtx_callwithucstr ( * * The example shows typical usage of the function. * \code - * rtx = hawk_rtx_open(awk, 0, rio); + * rtx = hawk_rtx_open(hawk, 0, rio); * if (rtx) * { * v = hawk_rtx_callwithbcstr (rtx, HAWK_BT("init"), HAWK_NULL, 0); @@ -2281,10 +2281,10 @@ HAWK_EXPORT hawk_val_t* hawk_rtx_execwithbcstrarr ( /** * The hawk_haltall() function aborts all active runtime contexts - * associated with \a awk. + * associated with \a hawk. */ HAWK_EXPORT void hawk_haltall ( - hawk_t* awk /**< awk */ + hawk_t* hawk /**< hawk */ ); /** @@ -2474,7 +2474,7 @@ HAWK_EXPORT hawk_htb_t* hawk_rtx_getnvmap ( #if defined(HAWK_HAVE_INLINE) static HAWK_INLINE hawk_errnum_t hawk_rtx_geterrnum (hawk_rtx_t* rtx) { return ((hawk_rtx_alt_t*)rtx)->_gem.errnum; } #else -# define hawk_rtx_geterrnum(awk) (((hawk_rtx_alt_t*)(rtx))->_gem.errnum) +# define hawk_rtx_geterrnum(hawk) (((hawk_rtx_alt_t*)(rtx))->_gem.errnum) #endif /** @@ -3442,10 +3442,10 @@ static HAWK_INLINE void hawk_rtx_freerex (hawk_rtx_t* rtx, hawk_tre_t* code, haw /* ----------------------------------------------------------------------- */ /** - * The hawk_get_awk_nil_val() function returns the pointer to the predefined + * The hawk_get_nil_val() function returns the pointer to the predefined * nil value. you can call this without creating a runtime context. */ -HAWK_EXPORT hawk_val_t* hawk_get_awk_nil_val ( +HAWK_EXPORT hawk_val_t* hawk_get_nil_val ( void ); diff --git a/hawk/lib/htb.c b/hawk/lib/htb.c index 7b406172..ed7344bf 100644 --- a/hawk/lib/htb.c +++ b/hawk/lib/htb.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/idmap-imp.h b/hawk/lib/idmap-imp.h index 5ac8ece0..306c524f 100644 --- a/hawk/lib/idmap-imp.h +++ b/hawk/lib/idmap-imp.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/mb8.c b/hawk/lib/mb8.c index a892d9b5..fdb16501 100644 --- a/hawk/lib/mb8.c +++ b/hawk/lib/mb8.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/misc-prv.h b/hawk/lib/misc-prv.h index 60148835..099965db 100644 --- a/hawk/lib/misc-prv.h +++ b/hawk/lib/misc-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/misc.c b/hawk/lib/misc.c index eec6fc45..6654ab08 100644 --- a/hawk/lib/misc.c +++ b/hawk/lib/misc.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/mod-hawk.c b/hawk/lib/mod-hawk.c index 312f0227..afdc71a1 100644 --- a/hawk/lib/mod-hawk.c +++ b/hawk/lib/mod-hawk.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -241,7 +241,7 @@ static inttab_t inttab[] = { HAWK_T("GC_NUM_GENS"), { HAWK_GC_NUM_GENS } } }; -static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) +static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { int left, right, mid, n; @@ -278,7 +278,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo } } - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } @@ -294,12 +294,12 @@ static void fini (hawk_mod_t* mod, hawk_rtx_t* rtx) /* TODO: anything */ } -static void unload (hawk_mod_t* mod, hawk_t* awk) +static void unload (hawk_mod_t* mod, hawk_t* hawk) { /* TODO: anything */ } -int hawk_mod_hawk (hawk_mod_t* mod, hawk_t* awk) +int hawk_mod_hawk (hawk_mod_t* mod, hawk_t* hawk) { mod->query = query; mod->unload = unload; diff --git a/hawk/lib/mod-hawk.h b/hawk/lib/mod-hawk.h index d8d77296..e4e8f414 100644 --- a/hawk/lib/mod-hawk.h +++ b/hawk/lib/mod-hawk.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -33,7 +33,7 @@ extern "C" { #endif -HAWK_EXPORT int hawk_mod_hawk (hawk_mod_t* mod, hawk_t* awk); +HAWK_EXPORT int hawk_mod_hawk (hawk_mod_t* mod, hawk_t* hawk); #if defined(__cplusplus) } diff --git a/hawk/lib/mod-math.c b/hawk/lib/mod-math.c index f5c74afd..b0b576bc 100644 --- a/hawk/lib/mod-math.c +++ b/hawk/lib/mod-math.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -120,7 +120,7 @@ static int fnc_math_2 (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, hawk_math2_t } -static hawk_flt_t math_ceil (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_ceil (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_CEILQ) return ceilq (x); @@ -135,7 +135,7 @@ static hawk_flt_t math_ceil (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_floor (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_floor (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_FLOORQ) return floorq (x); @@ -150,7 +150,7 @@ static hawk_flt_t math_floor (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_round (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_round (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_ROUNDQ) return roundq (x); @@ -164,7 +164,7 @@ static hawk_flt_t math_round (hawk_t* awk, hawk_flt_t x) hawk_flt_t f, d; - f = math_floor (awk, x); + f = math_floor (hawk, x); d = x - f; /* get fraction */ if (d > (hawk_flt_t)0.5) @@ -186,7 +186,7 @@ static hawk_flt_t math_round (hawk_t* awk, hawk_flt_t x) } #else /* round half to even - C99's rint() does this, i guess. */ - d = f - (hawk_flt_t)2.0 * math_floor(awk, f * (hawk_flt_t)0.5); + d = f - (hawk_flt_t)2.0 * math_floor(hawk, f * (hawk_flt_t)0.5); if (d == (hawk_flt_t)1.0) f = f + (hawk_flt_t)1.0; #endif } @@ -203,7 +203,7 @@ static hawk_flt_t math_round (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_sinh (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_sinh (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_SINHQ) return sinhq (x); @@ -218,7 +218,7 @@ static hawk_flt_t math_sinh (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_cosh (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_cosh (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_COSHQ) return coshq (x); @@ -233,7 +233,7 @@ static hawk_flt_t math_cosh (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_tanh (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_tanh (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_TANHQ) return tanhq (x); @@ -248,7 +248,7 @@ static hawk_flt_t math_tanh (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_asin (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_asin (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_ASINQ) return asinq (x); @@ -263,7 +263,7 @@ static hawk_flt_t math_asin (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_acos (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_acos (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_ACOSQ) return acosq (x); @@ -281,7 +281,7 @@ static hawk_flt_t math_acos (hawk_t* awk, hawk_flt_t x) /* ----------------------------------------------------------------------- */ -static hawk_flt_t math_sin (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_sin (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_SINQ) return sinq (x); @@ -296,7 +296,7 @@ static hawk_flt_t math_sin (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_cos (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_cos (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_COSQ) return cosq (x); @@ -311,7 +311,7 @@ static hawk_flt_t math_cos (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_tan (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_tan (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_TANQ) return tanq (x); @@ -326,7 +326,7 @@ static hawk_flt_t math_tan (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_atan (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_atan (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_ATANQ) return atanq (x); @@ -341,7 +341,7 @@ static hawk_flt_t math_atan (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_atan2 (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) +static hawk_flt_t math_atan2 (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_ATAN2Q) return atan2q (x, y); @@ -356,7 +356,7 @@ static hawk_flt_t math_atan2 (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) #endif } -static HAWK_INLINE hawk_flt_t math_log (hawk_t* awk, hawk_flt_t x) +static HAWK_INLINE hawk_flt_t math_log (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_LOGQ) return logq (x); @@ -371,7 +371,7 @@ static HAWK_INLINE hawk_flt_t math_log (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_log2 (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_log2 (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_LOG2Q) return log2q (x); @@ -382,11 +382,11 @@ static hawk_flt_t math_log2 (hawk_t* awk, hawk_flt_t x) #elif defined(HAVE_LOG2F) return log2f (x); #else - return math_log(awk, x) / math_log(awk, 2.0); + return math_log(hawk, x) / math_log(hawk, 2.0); #endif } -static hawk_flt_t math_log10 (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_log10 (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_LOG10Q) return log10q (x); @@ -401,7 +401,7 @@ static hawk_flt_t math_log10 (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_exp (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_exp (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_EXPQ) return expq (x); @@ -416,7 +416,7 @@ static hawk_flt_t math_exp (hawk_t* awk, hawk_flt_t x) #endif } -static hawk_flt_t math_sqrt (hawk_t* awk, hawk_flt_t x) +static hawk_flt_t math_sqrt (hawk_t* hawk, hawk_flt_t x) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_SQRTQ) return sqrtq (x); @@ -637,7 +637,7 @@ static fnctab_t fnctab[] = { HAWK_T("tanh"), { { 1, 1, HAWK_NULL }, fnc_tanh, 0 } } }; -static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) +static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { int left, right, mid, n; @@ -676,7 +676,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo } #endif - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } @@ -692,20 +692,20 @@ static void fini (hawk_mod_t* mod, hawk_rtx_t* rtx) /* TODO: anything */ } -static void unload (hawk_mod_t* mod, hawk_t* awk) +static void unload (hawk_mod_t* mod, hawk_t* hawk) { modctx_t* modctx; modctx = (modctx_t*)mod->ctx; - hawk_freemem (awk, modctx); + hawk_freemem (hawk, modctx); } -int hawk_mod_math (hawk_mod_t* mod, hawk_t* awk) +int hawk_mod_math (hawk_mod_t* mod, hawk_t* hawk) { modctx_t* modctx; hawk_ntime_t tv; - modctx = hawk_allocmem(awk, HAWK_SIZEOF(*modctx)); + modctx = hawk_allocmem(hawk, HAWK_SIZEOF(*modctx)); if (modctx == HAWK_NULL) return -1; HAWK_MEMSET (modctx, 0, HAWK_SIZEOF(*modctx)); diff --git a/hawk/lib/mod-math.h b/hawk/lib/mod-math.h index cf938c48..6b63a506 100644 --- a/hawk/lib/mod-math.h +++ b/hawk/lib/mod-math.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -33,7 +33,7 @@ extern "C" { #endif -HAWK_EXPORT int hawk_mod_math (hawk_mod_t* mod, hawk_t* awk); +HAWK_EXPORT int hawk_mod_math (hawk_mod_t* mod, hawk_t* hawk); #if defined(__cplusplus) } diff --git a/hawk/lib/mod-str.c b/hawk/lib/mod-str.c index 83f6d37f..f4866f9e 100644 --- a/hawk/lib/mod-str.c +++ b/hawk/lib/mod-str.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -590,7 +590,7 @@ static inttab_t inttab[] = { HAWK_T("TRIM_PAC_SPACES"), { TRIM_FLAG_PAC_SPACES } } }; -static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) +static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { int left, right, mid, n; @@ -627,7 +627,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo } } - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } @@ -643,12 +643,12 @@ static void fini (hawk_mod_t* mod, hawk_rtx_t* rtx) /* TODO: anything */ } -static void unload (hawk_mod_t* mod, hawk_t* awk) +static void unload (hawk_mod_t* mod, hawk_t* hawk) { /* TODO: anything */ } -int hawk_mod_str (hawk_mod_t* mod, hawk_t* awk) +int hawk_mod_str (hawk_mod_t* mod, hawk_t* hawk) { mod->query = query; mod->unload = unload; diff --git a/hawk/lib/mod-str.h b/hawk/lib/mod-str.h index 09538ccc..85fe15a1 100644 --- a/hawk/lib/mod-str.h +++ b/hawk/lib/mod-str.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -33,7 +33,7 @@ extern "C" { #endif -HAWK_EXPORT int hawk_mod_str (hawk_mod_t* mod, hawk_t* awk); +HAWK_EXPORT int hawk_mod_str (hawk_mod_t* mod, hawk_t* hawk); #if defined(__cplusplus) } diff --git a/hawk/lib/mod-sys.c b/hawk/lib/mod-sys.c index 6eb76e6f..d087d653 100644 --- a/hawk/lib/mod-sys.c +++ b/hawk/lib/mod-sys.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -4728,7 +4728,7 @@ static inttab_t inttab[] = { HAWK_T("WNOHANG"), { WNOHANG } } }; -static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) +static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym) { int left, right, mid, n; @@ -4765,7 +4765,7 @@ static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mo } } - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name); return -1; } @@ -4859,17 +4859,17 @@ static void fini (hawk_mod_t* mod, hawk_rtx_t* rtx) } } -static void unload (hawk_mod_t* mod, hawk_t* awk) +static void unload (hawk_mod_t* mod, hawk_t* hawk) { mod_ctx_t* mctx = (mod_ctx_t*)mod->ctx; HAWK_ASSERT (HAWK_RBT_SIZE(mctx->rtxtab) == 0); hawk_rbt_close (mctx->rtxtab); - hawk_freemem (awk, mctx); + hawk_freemem (hawk, mctx); } -int hawk_mod_sys (hawk_mod_t* mod, hawk_t* awk) +int hawk_mod_sys (hawk_mod_t* mod, hawk_t* hawk) { hawk_rbt_t* rbt; @@ -4879,13 +4879,13 @@ int hawk_mod_sys (hawk_mod_t* mod, hawk_t* awk) mod->init = init; mod->fini = fini; - mod->ctx = hawk_callocmem(awk, HAWK_SIZEOF(mod_ctx_t)); + mod->ctx = hawk_callocmem(hawk, HAWK_SIZEOF(mod_ctx_t)); if (!mod->ctx) return -1; - rbt = hawk_rbt_open(hawk_getgem(awk), 0, 1, 1); + rbt = hawk_rbt_open(hawk_getgem(hawk), 0, 1, 1); if (rbt == HAWK_NULL) { - hawk_freemem (awk, mod->ctx); + hawk_freemem (hawk, mod->ctx); return -1; } hawk_rbt_setstyle (rbt, hawk_get_rbt_style(HAWK_RBT_STYLE_INLINE_COPIERS)); diff --git a/hawk/lib/mod-sys.h b/hawk/lib/mod-sys.h index 46ebbe4c..cc5a2111 100644 --- a/hawk/lib/mod-sys.h +++ b/hawk/lib/mod-sys.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -33,7 +33,7 @@ extern "C" { #endif -HAWK_EXPORT int hawk_mod_sys (hawk_mod_t* mod, hawk_t* awk); +HAWK_EXPORT int hawk_mod_sys (hawk_mod_t* mod, hawk_t* hawk); #if defined(__cplusplus) } diff --git a/hawk/lib/mtx.c b/hawk/lib/mtx.c index 48e2788b..c133aea8 100644 --- a/hawk/lib/mtx.c +++ b/hawk/lib/mtx.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/parse-prv.h b/hawk/lib/parse-prv.h index f65e8514..0f1cb55a 100644 --- a/hawk/lib/parse-prv.h +++ b/hawk/lib/parse-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index 7ded0b7a..02f84f1e 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -211,65 +211,65 @@ struct binmap_t int binop; }; -static int parse_progunit (hawk_t* awk); -static hawk_t* collect_globals (hawk_t* awk); -static void adjust_static_globals (hawk_t* awk); -static hawk_oow_t find_global (hawk_t* awk, const hawk_oocs_t* name); -static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop); +static int parse_progunit (hawk_t* hawk); +static hawk_t* collect_globals (hawk_t* hawk); +static void adjust_static_globals (hawk_t* hawk); +static hawk_oow_t find_global (hawk_t* hawk, const hawk_oocs_t* name); +static hawk_t* collect_locals (hawk_t* hawk, hawk_oow_t nlcls, int istop); -static hawk_nde_t* parse_function (hawk_t* awk); -static hawk_nde_t* parse_begin (hawk_t* awk); -static hawk_nde_t* parse_end (hawk_t* awk); -static hawk_chain_t* parse_action_block (hawk_t* awk, hawk_nde_t* ptn, int blockless); +static hawk_nde_t* parse_function (hawk_t* hawk); +static hawk_nde_t* parse_begin (hawk_t* hawk); +static hawk_nde_t* parse_end (hawk_t* hawk); +static hawk_chain_t* parse_action_block (hawk_t* hawk, hawk_nde_t* ptn, int blockless); -static hawk_nde_t* parse_block_dc (hawk_t* awk, const hawk_loc_t* xloc, int istop); +static hawk_nde_t* parse_block_dc (hawk_t* hawk, const hawk_loc_t* xloc, int istop); -static hawk_nde_t* parse_statement (hawk_t* awk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_statement (hawk_t* hawk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_expr_withdc (hawk_t* awk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_expr_withdc (hawk_t* hawk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_logical_or (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_logical_and (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_in (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_regex_match (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_bitwise_or (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_bitwise_xor (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_bitwise_and (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_equality (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_relational (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_shift (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_additive (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_multiplicative (hawk_t* awk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_logical_or (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_logical_and (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_in (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_regex_match (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_bitwise_or (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_bitwise_xor (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_bitwise_and (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_equality (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_relational (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_shift (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_concat (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_additive (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_multiplicative (hawk_t* hawk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_exponent (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_unary_exp (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_primary (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_primary_ident (hawk_t* awk, const hawk_loc_t* xloc); -static hawk_nde_t* parse_hashidx (hawk_t* awk, const hawk_oocs_t* name, const hawk_loc_t* xloc); +static hawk_nde_t* parse_unary (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_exponent (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_unary_exp (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_increment (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_primary (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_primary_ident (hawk_t* hawk, const hawk_loc_t* xloc); +static hawk_nde_t* parse_hashidx (hawk_t* hawk, const hawk_oocs_t* name, const hawk_loc_t* xloc); #define FNCALL_FLAG_NOARG (1 << 0) /* no argument */ #define FNCALL_FLAG_VAR (1 << 1) -static hawk_nde_t* parse_fncall (hawk_t* awk, const hawk_oocs_t* name, hawk_fnc_t* fnc, const hawk_loc_t* xloc, int flags); +static hawk_nde_t* parse_fncall (hawk_t* hawk, const hawk_oocs_t* name, hawk_fnc_t* fnc, const hawk_loc_t* xloc, int flags); -static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc, const hawk_oocs_t* full, const hawk_oocs_t segs[], int nsegs); +static hawk_nde_t* parse_primary_ident_segs (hawk_t* hawk, const hawk_loc_t* xloc, const hawk_oocs_t* full, const hawk_oocs_t segs[], int nsegs); -static int get_token (hawk_t* awk); -static int preget_token (hawk_t* awk); -static int get_rexstr (hawk_t* awk, hawk_tok_t* tok); +static int get_token (hawk_t* hawk); +static int preget_token (hawk_t* hawk); +static int get_rexstr (hawk_t* hawk, hawk_tok_t* tok); -static int skip_spaces (hawk_t* awk); -static int skip_comment (hawk_t* awk); -static int classify_ident (hawk_t* awk, const hawk_oocs_t* name); +static int skip_spaces (hawk_t* hawk); +static int skip_comment (hawk_t* hawk); +static int classify_ident (hawk_t* hawk, const hawk_oocs_t* name); -static int deparse (hawk_t* awk); +static int deparse (hawk_t* hawk); static hawk_htb_walk_t deparse_func (hawk_htb_t* map, hawk_htb_pair_t* pair, void* arg); -static int put_char (hawk_t* awk, hawk_ooch_t c); -static int flush_out (hawk_t* awk); +static int put_char (hawk_t* hawk, hawk_ooch_t c); +static int flush_out (hawk_t* hawk); -static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nsegs, hawk_mod_sym_t* sym); +static hawk_mod_t* query_module (hawk_t* hawk, const hawk_oocs_t segs[], int nsegs, hawk_mod_sym_t* sym); typedef struct kwent_t kwent_t; @@ -376,7 +376,7 @@ static global_t gtab[] = * if set to a non-zero value, remove leading spaces and trailing spaces off a record * before field splitting. * if set to zero, leading spaces and trailing spaces result in 1 empty field respectively. - * if not set, the behavior is dependent on the awk->opt.trait & HAWK_STRIPRECSPC */ + * if not set, the behavior is dependent on the hawk->opt.trait & HAWK_STRIPRECSPC */ { HAWK_T("STRIPRECSPC"), 11, 0 }, { HAWK_T("STRIPSTRSPC"), 11, 0 }, @@ -384,64 +384,64 @@ static global_t gtab[] = { HAWK_T("SUBSEP"), 6, 0 } }; -#define GET_CHAR(awk) \ - do { if (get_char(awk) <= -1) return -1; } while(0) +#define GET_CHAR(hawk) \ + do { if (get_char(hawk) <= -1) return -1; } while(0) -#define GET_CHAR_TO(awk,c) \ +#define GET_CHAR_TO(hawk,c) \ do { \ - if (get_char(awk) <= -1) return -1; \ - c = (awk)->sio.last.c; \ + if (get_char(hawk) <= -1) return -1; \ + c = (hawk)->sio.last.c; \ } while(0) -#define SET_TOKEN_TYPE(awk,tok,code) \ +#define SET_TOKEN_TYPE(hawk,tok,code) \ do { (tok)->type = (code); } while (0) -#define ADD_TOKEN_CHAR(awk,tok,c) \ +#define ADD_TOKEN_CHAR(hawk,tok,c) \ do { \ if (hawk_ooecs_ccat((tok)->name,(c)) == (hawk_oow_t)-1) \ { \ - ADJERR_LOC (awk, &(tok)->loc); \ + ADJERR_LOC (hawk, &(tok)->loc); \ return -1; \ } \ } while (0) -#define ADD_TOKEN_STR(awk,tok,s,l) \ +#define ADD_TOKEN_STR(hawk,tok,s,l) \ do { \ if (hawk_ooecs_ncat((tok)->name,(s),(l)) == (hawk_oow_t)-1) \ { \ - ADJERR_LOC (awk, &(tok)->loc); \ + ADJERR_LOC (hawk, &(tok)->loc); \ return -1; \ } \ } while (0) #if defined(HAWK_OOCH_IS_BCH) -# define ADD_TOKEN_UINT32(awk,tok,c) \ +# define ADD_TOKEN_UINT32(hawk,tok,c) \ do { \ - if (c <= 0xFF) ADD_TOKEN_CHAR(awk, tok, c); \ + if (c <= 0xFF) ADD_TOKEN_CHAR(hawk, tok, c); \ else \ { \ hawk_bch_t __xbuf[HAWK_MBLEN_MAX + 1]; \ hawk_oow_t __len, __i; \ __len = uc_to_utf8(c, __xbuf, HAWK_COUNTOF(__xbuf)); /* use utf8 all the time */ \ - for (__i = 0; __i < __len; __i++) ADD_TOKEN_CHAR(awk, tok, __xbuf[__i]); \ + for (__i = 0; __i < __len; __i++) ADD_TOKEN_CHAR(hawk, tok, __xbuf[__i]); \ } \ } while (0) #else -# define ADD_TOKEN_UINT32(awk,tok,c) ADD_TOKEN_CHAR(awk,tok,c); +# define ADD_TOKEN_UINT32(hawk,tok,c) ADD_TOKEN_CHAR(hawk,tok,c); #endif -#define MATCH(awk,tok_type) ((awk)->tok.type == (tok_type)) -#define MATCH_RANGE(awk,tok_type_start,tok_type_end) ((awk)->tok.type >= (tok_type_start) && (awk)->tok.type <= (tok_type_end)) +#define MATCH(hawk,tok_type) ((hawk)->tok.type == (tok_type)) +#define MATCH_RANGE(hawk,tok_type_start,tok_type_end) ((hawk)->tok.type >= (tok_type_start) && (hawk)->tok.type <= (tok_type_end)) -#define MATCH_TERMINATOR_NORMAL(awk) \ - (MATCH((awk),TOK_SEMICOLON) || MATCH((awk),TOK_NEWLINE)) +#define MATCH_TERMINATOR_NORMAL(hawk) \ + (MATCH((hawk),TOK_SEMICOLON) || MATCH((hawk),TOK_NEWLINE)) -#define MATCH_TERMINATOR_RBRACE(awk) \ - ((awk->opt.trait & HAWK_NEWLINE) && MATCH((awk),TOK_RBRACE)) +#define MATCH_TERMINATOR_RBRACE(hawk) \ + ((hawk->opt.trait & HAWK_NEWLINE) && MATCH((hawk),TOK_RBRACE)) -#define MATCH_TERMINATOR(awk) \ - (MATCH_TERMINATOR_NORMAL(awk) || MATCH_TERMINATOR_RBRACE(awk)) +#define MATCH_TERMINATOR(hawk) \ + (MATCH_TERMINATOR_NORMAL(hawk) || MATCH_TERMINATOR_RBRACE(hawk)) #define ADJERR_LOC(hawk,l) do { (hawk)->_gem.errloc = *(l); } while (0) @@ -474,86 +474,86 @@ static HAWK_INLINE int is_var (hawk_nde_t* nde) nde->type == HAWK_NDE_NAMEDIDX; } -static int get_char (hawk_t* awk) +static int get_char (hawk_t* hawk) { hawk_ooi_t n; - if (awk->sio.nungots > 0) + if (hawk->sio.nungots > 0) { /* there are something in the unget buffer */ - awk->sio.last = awk->sio.ungot[--awk->sio.nungots]; + hawk->sio.last = hawk->sio.ungot[--hawk->sio.nungots]; return 0; } - if (awk->sio.inp->b.pos >= awk->sio.inp->b.len) + if (hawk->sio.inp->b.pos >= hawk->sio.inp->b.len) { - n = awk->sio.inf( - awk, HAWK_SIO_CMD_READ, awk->sio.inp, - awk->sio.inp->b.buf, HAWK_COUNTOF(awk->sio.inp->b.buf) + n = hawk->sio.inf( + hawk, HAWK_SIO_CMD_READ, hawk->sio.inp, + hawk->sio.inp->b.buf, HAWK_COUNTOF(hawk->sio.inp->b.buf) ); if (n <= -1) return -1; if (n == 0) { - awk->sio.inp->last.c = HAWK_OOCI_EOF; - awk->sio.inp->last.line = awk->sio.inp->line; - awk->sio.inp->last.colm = awk->sio.inp->colm; - awk->sio.inp->last.file = awk->sio.inp->path; - awk->sio.last = awk->sio.inp->last; + hawk->sio.inp->last.c = HAWK_OOCI_EOF; + hawk->sio.inp->last.line = hawk->sio.inp->line; + hawk->sio.inp->last.colm = hawk->sio.inp->colm; + hawk->sio.inp->last.file = hawk->sio.inp->path; + hawk->sio.last = hawk->sio.inp->last; return 0; } - awk->sio.inp->b.pos = 0; - awk->sio.inp->b.len = n; + hawk->sio.inp->b.pos = 0; + hawk->sio.inp->b.len = n; } - if (awk->sio.inp->last.c == HAWK_T('\n')) + if (hawk->sio.inp->last.c == HAWK_T('\n')) { /* if the previous charater was a newline, * increment the line counter and reset column to 1. * incrementing it line number here instead of * updating inp->last causes the line number for * TOK_EOF to be the same line as the last newline. */ - awk->sio.inp->line++; - awk->sio.inp->colm = 1; + hawk->sio.inp->line++; + hawk->sio.inp->colm = 1; } - awk->sio.inp->last.c = awk->sio.inp->b.buf[awk->sio.inp->b.pos++]; - awk->sio.inp->last.line = awk->sio.inp->line; - awk->sio.inp->last.colm = awk->sio.inp->colm++; - awk->sio.inp->last.file = awk->sio.inp->path; - awk->sio.last = awk->sio.inp->last; + hawk->sio.inp->last.c = hawk->sio.inp->b.buf[hawk->sio.inp->b.pos++]; + hawk->sio.inp->last.line = hawk->sio.inp->line; + hawk->sio.inp->last.colm = hawk->sio.inp->colm++; + hawk->sio.inp->last.file = hawk->sio.inp->path; + hawk->sio.last = hawk->sio.inp->last; return 0; } -static void unget_char (hawk_t* awk, const hawk_sio_lxc_t* c) +static void unget_char (hawk_t* hawk, const hawk_sio_lxc_t* c) { /* Make sure that the unget buffer is large enough */ - HAWK_ASSERT (awk->sio.nungots < HAWK_COUNTOF(awk->sio.ungot)); - awk->sio.ungot[awk->sio.nungots++] = *c; + HAWK_ASSERT (hawk->sio.nungots < HAWK_COUNTOF(hawk->sio.ungot)); + hawk->sio.ungot[hawk->sio.nungots++] = *c; } -const hawk_ooch_t* hawk_getgblname (hawk_t* awk, hawk_oow_t idx, hawk_oow_t* len) +const hawk_ooch_t* hawk_getgblname (hawk_t* hawk, hawk_oow_t idx, hawk_oow_t* len) { - HAWK_ASSERT (idx < HAWK_ARR_SIZE(awk->parse.gbls)); + HAWK_ASSERT (idx < HAWK_ARR_SIZE(hawk->parse.gbls)); - *len = HAWK_ARR_DLEN(awk->parse.gbls,idx); - return HAWK_ARR_DPTR(awk->parse.gbls,idx); + *len = HAWK_ARR_DLEN(hawk->parse.gbls,idx); + return HAWK_ARR_DPTR(hawk->parse.gbls,idx); } -void hawk_getkwname (hawk_t* awk, hawk_kwid_t id, hawk_oocs_t* s) +void hawk_getkwname (hawk_t* hawk, hawk_kwid_t id, hawk_oocs_t* s) { *s = kwtab[id].name; } -static int parse (hawk_t* awk) +static int parse (hawk_t* hawk) { int ret = -1; hawk_ooi_t op; - HAWK_ASSERT (awk->sio.inf != HAWK_NULL); + HAWK_ASSERT (hawk->sio.inf != HAWK_NULL); - op = awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, awk->sio.inp, HAWK_NULL, 0); + op = hawk->sio.inf(hawk, HAWK_SIO_CMD_OPEN, hawk->sio.inp, HAWK_NULL, 0); if (op <= -1) { /* cannot open the source file. @@ -561,23 +561,23 @@ static int parse (hawk_t* awk) return -1; } - adjust_static_globals (awk); + adjust_static_globals (hawk); /* get the first character and the first token */ - if (get_char (awk) <= -1 || get_token (awk)) goto oops; + if (get_char (hawk) <= -1 || get_token (hawk)) goto oops; while (1) { - while (MATCH(awk,TOK_NEWLINE)) + while (MATCH(hawk,TOK_NEWLINE)) { - if (get_token (awk) <= -1) goto oops; + if (get_token (hawk) <= -1) goto oops; } - if (MATCH(awk,TOK_EOF)) break; + if (MATCH(hawk,TOK_EOF)) break; - if (parse_progunit (awk) <= -1) goto oops; + if (parse_progunit (hawk) <= -1) goto oops; } - if (!(awk->opt.trait & HAWK_IMPLICIT)) + if (!(hawk->opt.trait & HAWK_IMPLICIT)) { /* ensure that all functions called are defined in the EXPLICIT-only mode. * o therwise, the error detection will get delay until run-time. */ @@ -585,26 +585,26 @@ static int parse (hawk_t* awk) hawk_htb_pair_t* p; hawk_htb_itr_t itr; - p = hawk_htb_getfirstpair(awk->parse.funs, &itr); + p = hawk_htb_getfirstpair(hawk->parse.funs, &itr); while (p) { - if (hawk_htb_search(awk->tree.funs, HAWK_HTB_KPTR(p), HAWK_HTB_KLEN(p)) == HAWK_NULL) + if (hawk_htb_search(hawk->tree.funs, HAWK_HTB_KPTR(p), HAWK_HTB_KLEN(p)) == HAWK_NULL) { hawk_nde_t* nde; /* see parse_fncall() for what is - * stored into awk->tree.funs */ + * stored into hawk->tree.funs */ nde = (hawk_nde_t*)HAWK_HTB_VPTR(p); - hawk_seterrfmt (awk, &nde->loc, HAWK_EFUNNF, FMT_EFUNNF, HAWK_HTB_KLEN(p), HAWK_HTB_KPTR(p)); + hawk_seterrfmt (hawk, &nde->loc, HAWK_EFUNNF, FMT_EFUNNF, HAWK_HTB_KLEN(p), HAWK_HTB_KPTR(p)); goto oops; } - p = hawk_htb_getnextpair(awk->parse.funs, &itr); + p = hawk_htb_getnextpair(hawk->parse.funs, &itr); } } - HAWK_ASSERT (awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls)); - HAWK_ASSERT (awk->sio.inp == &awk->sio.arg); + HAWK_ASSERT (hawk->tree.ngbls == HAWK_ARR_SIZE(hawk->parse.gbls)); + HAWK_ASSERT (hawk->sio.inp == &hawk->sio.arg); ret = 0; oops: @@ -613,26 +613,26 @@ oops: /* an error occurred and control has reached here * probably, some included files might not have been * closed. close them */ - while (awk->sio.inp != &awk->sio.arg) + while (hawk->sio.inp != &hawk->sio.arg) { hawk_sio_arg_t* prev; /* nothing much to do about a close error */ - awk->sio.inf (awk, HAWK_SIO_CMD_CLOSE, awk->sio.inp, HAWK_NULL, 0); + hawk->sio.inf (hawk, HAWK_SIO_CMD_CLOSE, hawk->sio.inp, HAWK_NULL, 0); - prev = awk->sio.inp->prev; + prev = hawk->sio.inp->prev; - HAWK_ASSERT (awk->sio.inp->name != HAWK_NULL); - hawk_freemem (awk, awk->sio.inp); + HAWK_ASSERT (hawk->sio.inp->name != HAWK_NULL); + hawk_freemem (hawk, hawk->sio.inp); - awk->sio.inp = prev; + hawk->sio.inp = prev; } } - if (awk->sio.inf(awk, HAWK_SIO_CMD_CLOSE, awk->sio.inp, HAWK_NULL, 0) != 0 && ret == 0) ret = -1; + if (hawk->sio.inf(hawk, HAWK_SIO_CMD_CLOSE, hawk->sio.inp, HAWK_NULL, 0) != 0 && ret == 0) ret = -1; /* clear the parse tree partially constructed on error */ - if (ret <= -1) hawk_clear (awk); + if (ret <= -1) hawk_clear (hawk); return ret; } @@ -713,7 +713,7 @@ void hawk_clearsionames (hawk_t* hawk) } } -int hawk_parse (hawk_t* awk, hawk_sio_cbs_t* sio) +int hawk_parse (hawk_t* hawk, hawk_sio_cbs_t* sio) { int n; @@ -725,63 +725,63 @@ int hawk_parse (hawk_t* awk, hawk_sio_cbs_t* sio) if (!sio || !sio->in) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); return -1; } - HAWK_ASSERT (awk->parse.depth.loop == 0); - HAWK_ASSERT (awk->parse.depth.expr == 0); + HAWK_ASSERT (hawk->parse.depth.loop == 0); + HAWK_ASSERT (hawk->parse.depth.expr == 0); - hawk_clear (awk); - hawk_clearsionames (awk); + hawk_clear (hawk); + hawk_clearsionames (hawk); - HAWK_MEMSET (&awk->sio, 0, HAWK_SIZEOF(awk->sio)); - awk->sio.inf = sio->in; - awk->sio.outf = sio->out; - awk->sio.last.c = HAWK_OOCI_EOF; - /*awk->sio.arg.name = HAWK_NULL; - awk->sio.arg.handle = HAWK_NULL; - awk->sio.arg.path = HAWK_NULL;*/ - awk->sio.arg.line = 1; - awk->sio.arg.colm = 1; - awk->sio.arg.pragma_trait = 0; - awk->sio.inp = &awk->sio.arg; + HAWK_MEMSET (&hawk->sio, 0, HAWK_SIZEOF(hawk->sio)); + hawk->sio.inf = sio->in; + hawk->sio.outf = sio->out; + hawk->sio.last.c = HAWK_OOCI_EOF; + /*hawk->sio.arg.name = HAWK_NULL; + hawk->sio.arg.handle = HAWK_NULL; + hawk->sio.arg.path = HAWK_NULL;*/ + hawk->sio.arg.line = 1; + hawk->sio.arg.colm = 1; + hawk->sio.arg.pragma_trait = 0; + hawk->sio.inp = &hawk->sio.arg; - n = parse(awk); - if (n == 0 && awk->sio.outf != HAWK_NULL) n = deparse (awk); + n = parse(hawk); + if (n == 0 && hawk->sio.outf != HAWK_NULL) n = deparse (hawk); - HAWK_ASSERT (awk->parse.depth.loop == 0); - HAWK_ASSERT (awk->parse.depth.expr == 0); + HAWK_ASSERT (hawk->parse.depth.loop == 0); + HAWK_ASSERT (hawk->parse.depth.expr == 0); return n; } -static int end_include (hawk_t* awk) +static int end_include (hawk_t* hawk) { int x; hawk_sio_arg_t* cur; - if (awk->sio.inp == &awk->sio.arg) return 0; /* no include */ + if (hawk->sio.inp == &hawk->sio.arg) return 0; /* no include */ /* if it is an included file, close it and * retry to read a character from an outer file */ - x = awk->sio.inf(awk, HAWK_SIO_CMD_CLOSE, awk->sio.inp, HAWK_NULL, 0); + x = hawk->sio.inf(hawk, HAWK_SIO_CMD_CLOSE, hawk->sio.inp, HAWK_NULL, 0); /* if closing has failed, still destroy the * sio structure first as normal and return * the failure below. this way, the caller * does not call HAWK_SIO_CMD_CLOSE on - * awk->sio.inp again. */ + * hawk->sio.inp again. */ - cur = awk->sio.inp; - awk->sio.inp = awk->sio.inp->prev; + cur = hawk->sio.inp; + hawk->sio.inp = hawk->sio.inp->prev; HAWK_ASSERT (cur->name != HAWK_NULL); /* restore the pragma values */ - awk->parse.pragma.trait = cur->pragma_trait; - hawk_freemem (awk, cur); - awk->parse.depth.incl--; + hawk->parse.pragma.trait = cur->pragma_trait; + hawk_freemem (hawk, cur); + hawk->parse.depth.incl--; if (x != 0) { @@ -789,54 +789,54 @@ static int end_include (hawk_t* awk) return -1; } - awk->sio.last = awk->sio.inp->last; + hawk->sio.last = hawk->sio.inp->last; return 1; /* ended the included file successfully */ } -static int ever_included (hawk_t* awk, hawk_sio_arg_t* arg) +static int ever_included (hawk_t* hawk, hawk_sio_arg_t* arg) { hawk_oow_t i; - for (i = 0; i < awk->parse.incl_hist.count; i++) + for (i = 0; i < hawk->parse.incl_hist.count; i++) { - if (HAWK_MEMCMP(&awk->parse.incl_hist.ptr[i * HAWK_SIZEOF(arg->unique_id)], arg->unique_id, HAWK_SIZEOF(arg->unique_id)) == 0) return 1; + if (HAWK_MEMCMP(&hawk->parse.incl_hist.ptr[i * HAWK_SIZEOF(arg->unique_id)], arg->unique_id, HAWK_SIZEOF(arg->unique_id)) == 0) return 1; } return 0; } -static int record_ever_included (hawk_t* awk, hawk_sio_arg_t* arg) +static int record_ever_included (hawk_t* hawk, hawk_sio_arg_t* arg) { - if (awk->parse.incl_hist.count >= awk->parse.incl_hist.capa) + if (hawk->parse.incl_hist.count >= hawk->parse.incl_hist.capa) { hawk_uint8_t* tmp; hawk_oow_t newcapa; - newcapa = awk->parse.incl_hist.capa + 128; - tmp = (hawk_uint8_t*)hawk_reallocmem(awk, awk->parse.incl_hist.ptr, newcapa * HAWK_SIZEOF(arg->unique_id)); + newcapa = hawk->parse.incl_hist.capa + 128; + tmp = (hawk_uint8_t*)hawk_reallocmem(hawk, hawk->parse.incl_hist.ptr, newcapa * HAWK_SIZEOF(arg->unique_id)); if (!tmp) return -1; - awk->parse.incl_hist.ptr = tmp; - awk->parse.incl_hist.capa = newcapa; + hawk->parse.incl_hist.ptr = tmp; + hawk->parse.incl_hist.capa = newcapa; } - HAWK_MEMCPY (&awk->parse.incl_hist.ptr[awk->parse.incl_hist.count * HAWK_SIZEOF(arg->unique_id)], arg->unique_id, HAWK_SIZEOF(arg->unique_id)); - awk->parse.incl_hist.count++; + HAWK_MEMCPY (&hawk->parse.incl_hist.ptr[hawk->parse.incl_hist.count * HAWK_SIZEOF(arg->unique_id)], arg->unique_id, HAWK_SIZEOF(arg->unique_id)); + hawk->parse.incl_hist.count++; return 0; } -static int begin_include (hawk_t* awk, int once) +static int begin_include (hawk_t* hawk, int once) { hawk_sio_arg_t* arg = HAWK_NULL; hawk_ooch_t* sio_name; - if (hawk_count_oocstr(HAWK_OOECS_PTR(awk->tok.name)) != HAWK_OOECS_LEN(awk->tok.name)) + if (hawk_count_oocstr(HAWK_OOECS_PTR(hawk->tok.name)) != HAWK_OOECS_LEN(hawk->tok.name)) { /* a '\0' character included in the include file name. * we don't support such a file name */ - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EIONMNL, FMT_EIONMNL, HAWK_OOECS_LEN(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EIONMNL, FMT_EIONMNL, HAWK_OOECS_LEN(hawk->tok.name)); return -1; } - if (awk->opt.includedirs.ptr) + if (hawk->opt.includedirs.ptr) { /* include directory is set... */ /* TODO: search target files in these directories */ @@ -845,17 +845,17 @@ static int begin_include (hawk_t* awk, int once) /* store the include-file name into a list * and this list is not deleted after hawk_parse. * the errinfo.loc.file can point to the file name here. */ - sio_name = hawk_addsionamewithoochars(awk, HAWK_OOECS_PTR(awk->tok.name), HAWK_OOECS_LEN(awk->tok.name)); + sio_name = hawk_addsionamewithoochars(hawk, HAWK_OOECS_PTR(hawk->tok.name), HAWK_OOECS_LEN(hawk->tok.name)); if (!sio_name) { - ADJERR_LOC (awk, &awk->ptok.loc); + ADJERR_LOC (hawk, &hawk->ptok.loc); goto oops; } - arg = (hawk_sio_arg_t*)hawk_callocmem(awk, HAWK_SIZEOF(*arg)); + arg = (hawk_sio_arg_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*arg)); if (!arg) { - ADJERR_LOC (awk, &awk->ptok.loc); + ADJERR_LOC (hawk, &hawk->ptok.loc); goto oops; } @@ -864,33 +864,33 @@ static int begin_include (hawk_t* awk, int once) arg->colm = 1; /* let the argument's prev field point to the current */ - arg->prev = awk->sio.inp; + arg->prev = hawk->sio.inp; - if (awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, arg, HAWK_NULL, 0) <= -1) + if (hawk->sio.inf(hawk, HAWK_SIO_CMD_OPEN, arg, HAWK_NULL, 0) <= -1) { - ADJERR_LOC (awk, &awk->tok.loc); + ADJERR_LOC (hawk, &hawk->tok.loc); goto oops; } /* store the pragma value */ - arg->pragma_trait = awk->parse.pragma.trait; - /* but don't change awk->parse.pragma.trait. it means the included file inherits + arg->pragma_trait = hawk->parse.pragma.trait; + /* but don't change hawk->parse.pragma.trait. it means the included file inherits * the existing progma values. - awk->parse.pragma.trait = (awk->opt.trait & (HAWK_IMPLICIT | HAWK_MULTILINESTR | HAWK_STRIPRECSPC | HAWK_STRIPSTRSPC)); + hawk->parse.pragma.trait = (hawk->opt.trait & (HAWK_IMPLICIT | HAWK_MULTILINESTR | HAWK_STRIPRECSPC | HAWK_STRIPSTRSPC)); */ /* i update the current pointer after opening is successful */ - awk->sio.inp = arg; - awk->parse.depth.incl++; + hawk->sio.inp = arg; + hawk->parse.depth.incl++; - if (once && ever_included(awk, arg)) + if (once && ever_included(hawk, arg)) { - end_include (awk); + end_include (hawk); /* it has been included previously. don't include this file again. */ - if (get_token(awk) <= -1) return -1; /* skip the include file name */ - if (MATCH(awk, TOK_SEMICOLON) || MATCH(awk, TOK_NEWLINE)) + if (get_token(hawk) <= -1) return -1; /* skip the include file name */ + if (MATCH(hawk, TOK_SEMICOLON) || MATCH(hawk, TOK_NEWLINE)) { - if (get_token(awk) <= -1) return -1; /* skip the semicolon */ + if (get_token(hawk) <= -1) return -1; /* skip the semicolon */ } } else @@ -898,11 +898,11 @@ static int begin_include (hawk_t* awk, int once) /* read in the first character in the included file. * so the next call to get_token() sees the character read * from this file. */ - if (record_ever_included(awk, arg) <= -1 || get_char(awk) <= -1 || get_token(awk) <= -1) + if (record_ever_included(hawk, arg) <= -1 || get_char(hawk) <= -1 || get_token(hawk) <= -1) { - end_include (awk); + end_include (hawk); /* i don't jump to oops since i've called - * end_include() where awk->sio.inp/arg is freed. */ + * end_include() where hawk->sio.inp/arg is freed. */ return -1; } } @@ -910,13 +910,13 @@ static int begin_include (hawk_t* awk, int once) return 0; oops: - /* i don't need to free 'link' here since it's linked to awk->sio_names + /* i don't need to free 'link' here since it's linked to hawk->sio_names * that's freed at the beginning of hawk_parse() or by hawk_close(). */ - if (arg) hawk_freemem (awk, arg); + if (arg) hawk_freemem (hawk, arg); return -1; } -static int parse_progunit (hawk_t* awk) +static int parse_progunit (hawk_t* hawk) { /* @pragma .... @@ -928,114 +928,114 @@ static int parse_progunit (hawk_t* awk) function name (parameter-list) { statement } */ - HAWK_ASSERT (awk->parse.depth.loop == 0); + HAWK_ASSERT (hawk->parse.depth.loop == 0); - if (MATCH(awk, TOK_XGLOBAL)) + if (MATCH(hawk, TOK_XGLOBAL)) { hawk_oow_t ngbls; - awk->parse.id.block = PARSE_GBL; + hawk->parse.id.block = PARSE_GBL; - if (get_token(awk) <= -1) return -1; + if (get_token(hawk) <= -1) return -1; - HAWK_ASSERT (awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls)); - ngbls = awk->tree.ngbls; - if (collect_globals(awk) == HAWK_NULL) + HAWK_ASSERT (hawk->tree.ngbls == HAWK_ARR_SIZE(hawk->parse.gbls)); + ngbls = hawk->tree.ngbls; + if (collect_globals(hawk) == HAWK_NULL) { - hawk_arr_delete (awk->parse.gbls, ngbls, HAWK_ARR_SIZE(awk->parse.gbls) - ngbls); - awk->tree.ngbls = ngbls; + hawk_arr_delete (hawk->parse.gbls, ngbls, HAWK_ARR_SIZE(hawk->parse.gbls) - ngbls); + hawk->tree.ngbls = ngbls; return -1; } } - else if (MATCH(awk, TOK_XINCLUDE) || MATCH(awk, TOK_XINCLUDE_ONCE)) + else if (MATCH(hawk, TOK_XINCLUDE) || MATCH(hawk, TOK_XINCLUDE_ONCE)) { int once; - if (awk->opt.depth.s.incl > 0 && - awk->parse.depth.incl >= awk->opt.depth.s.incl) + if (hawk->opt.depth.s.incl > 0 && + hawk->parse.depth.incl >= hawk->opt.depth.s.incl) { - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EINCLTD); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EINCLTD); return -1; } - once = MATCH(awk, TOK_XINCLUDE_ONCE); - if (get_token(awk) <= -1) return -1; + once = MATCH(hawk, TOK_XINCLUDE_ONCE); + if (get_token(hawk) <= -1) return -1; - if (!MATCH(awk, TOK_STR)) + if (!MATCH(hawk, TOK_STR)) { - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EINCLSTR); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EINCLSTR); return -1; } - if (begin_include(awk, once) <= -1) return -1; + if (begin_include(hawk, once) <= -1) return -1; /* i just return without doing anything special * after having setting up the environment for file * inclusion. the loop in parse() proceeds to call * parse_progunit() */ } - else if (MATCH(awk, TOK_XPRAGMA)) + else if (MATCH(hawk, TOK_XPRAGMA)) { hawk_oocs_t name; - if (get_token(awk) <= -1) return -1; - if (!MATCH(awk, TOK_IDENT)) + if (get_token(hawk) <= -1) return -1; + if (!MATCH(hawk, TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier expected for '@pragma'")); + hawk_seterrfmt (hawk, &hawk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier expected for '@pragma'")); return -1; } - name.len = HAWK_OOECS_LEN(awk->tok.name); - name.ptr = HAWK_OOECS_PTR(awk->tok.name); + name.len = HAWK_OOECS_LEN(hawk->tok.name); + name.ptr = HAWK_OOECS_PTR(hawk->tok.name); if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("entry")) == 0) { - if (get_token(awk) <= -1) return -1; - if (!MATCH(awk, TOK_IDENT)) + if (get_token(hawk) <= -1) return -1; + if (!MATCH(hawk, TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->ptok.loc, HAWK_EIDENT, HAWK_T("function name expected for 'entry'")); + hawk_seterrfmt (hawk, &hawk->ptok.loc, HAWK_EIDENT, HAWK_T("function name expected for 'entry'")); return -1; } - if (HAWK_OOECS_LEN(awk->tok.name) >= HAWK_COUNTOF(awk->parse.pragma.entry)) + if (HAWK_OOECS_LEN(hawk->tok.name) >= HAWK_COUNTOF(hawk->parse.pragma.entry)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EFUNNAM, HAWK_T("entry function name too long")); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EFUNNAM, HAWK_T("entry function name too long")); return -1; } - if (awk->sio.inp == &awk->sio.arg) + if (hawk->sio.inp == &hawk->sio.arg) { /* only the top level source */ - if (awk->parse.pragma.entry[0] != '\0') + if (hawk->parse.pragma.entry[0] != '\0') { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EEXIST, HAWK_T("@pragma entry already set")); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EEXIST, HAWK_T("@pragma entry already set")); return -1; } - hawk_copy_oochars_to_oocstr (awk->parse.pragma.entry, HAWK_COUNTOF(awk->parse.pragma.entry), HAWK_OOECS_PTR(awk->tok.name), HAWK_OOECS_LEN(awk->tok.name)); + hawk_copy_oochars_to_oocstr (hawk->parse.pragma.entry, HAWK_COUNTOF(hawk->parse.pragma.entry), HAWK_OOECS_PTR(hawk->tok.name), HAWK_OOECS_LEN(hawk->tok.name)); } } else if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("implicit")) == 0) { /* @pragma implicit on * @pragma implicit off */ - if (get_token(awk) <= -1) return -1; - if (!MATCH(awk, TOK_IDENT)) + if (get_token(hawk) <= -1) return -1; + if (!MATCH(hawk, TOK_IDENT)) { error_ident_on_off_expected_for_implicit: - hawk_seterrfmt (awk, &awk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'implicit'")); + hawk_seterrfmt (hawk, &hawk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'implicit'")); return -1; } - name.len = HAWK_OOECS_LEN(awk->tok.name); - name.ptr = HAWK_OOECS_PTR(awk->tok.name); + name.len = HAWK_OOECS_LEN(hawk->tok.name); + name.ptr = HAWK_OOECS_PTR(hawk->tok.name); if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("on")) == 0) { - awk->parse.pragma.trait |= HAWK_IMPLICIT; + hawk->parse.pragma.trait |= HAWK_IMPLICIT; } else if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("off")) == 0) { - awk->parse.pragma.trait &= ~HAWK_IMPLICIT; + hawk->parse.pragma.trait &= ~HAWK_IMPLICIT; } else { @@ -1044,23 +1044,23 @@ static int parse_progunit (hawk_t* awk) } else if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("multilinestr")) == 0) { - if (get_token(awk) <= -1) return -1; - if (!MATCH(awk, TOK_IDENT)) + if (get_token(hawk) <= -1) return -1; + if (!MATCH(hawk, TOK_IDENT)) { error_ident_on_off_expected_for_multilinestr: - hawk_seterrfmt (awk, &awk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'multilinestr'")); + hawk_seterrfmt (hawk, &hawk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'multilinestr'")); return -1; } - name.len = HAWK_OOECS_LEN(awk->tok.name); - name.ptr = HAWK_OOECS_PTR(awk->tok.name); + name.len = HAWK_OOECS_LEN(hawk->tok.name); + name.ptr = HAWK_OOECS_PTR(hawk->tok.name); if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("on")) == 0) { - awk->parse.pragma.trait |= HAWK_MULTILINESTR; + hawk->parse.pragma.trait |= HAWK_MULTILINESTR; } else if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("off")) == 0) { - awk->parse.pragma.trait &= ~HAWK_MULTILINESTR; + hawk->parse.pragma.trait &= ~HAWK_MULTILINESTR; } else { @@ -1076,18 +1076,18 @@ static int parse_progunit (hawk_t* awk) hawk_int_t sl; /* @pragma stack_limit 99999 */ - if (get_token(awk) <= -1) return -1; - if (!MATCH(awk, TOK_INT)) + if (get_token(hawk) <= -1) return -1; + if (!MATCH(hawk, TOK_INT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EINTLIT, FMT_EINTLIT, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EINTLIT, FMT_EINTLIT, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - sl = hawk_oochars_to_int(HAWK_OOECS_PTR(awk->tok.name), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOCHARS_TO_INT_MAKE_OPTION(0, 0, 0), HAWK_NULL, HAWK_NULL); + sl = hawk_oochars_to_int(HAWK_OOECS_PTR(hawk->tok.name), HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOCHARS_TO_INT_MAKE_OPTION(0, 0, 0), HAWK_NULL, HAWK_NULL); if (sl < HAWK_MIN_RTX_STACK_LIMIT) sl = HAWK_MIN_RTX_STACK_LIMIT; else if (sl > HAWK_MAX_RTX_STACK_LIMIT) sl = HAWK_MAX_RTX_STACK_LIMIT; /* take the specified value if it's greater than the existing value */ - if (sl > awk->parse.pragma.rtx_stack_limit) awk->parse.pragma.rtx_stack_limit = sl; + if (sl > hawk->parse.pragma.rtx_stack_limit) hawk->parse.pragma.rtx_stack_limit = sl; } else if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("striprecspc")) == 0) { @@ -1099,16 +1099,16 @@ static int parse_progunit (hawk_t* awk) */ int is_on; - if (get_token(awk) <= -1) return -1; - if (!MATCH(awk, TOK_IDENT)) + if (get_token(hawk) <= -1) return -1; + if (!MATCH(hawk, TOK_IDENT)) { error_ident_on_off_expected_for_striprecspc: - hawk_seterrfmt (awk, &awk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'striprecspc'")); + hawk_seterrfmt (hawk, &hawk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'striprecspc'")); return -1; } - name.len = HAWK_OOECS_LEN(awk->tok.name); - name.ptr = HAWK_OOECS_PTR(awk->tok.name); + name.len = HAWK_OOECS_LEN(hawk->tok.name); + name.ptr = HAWK_OOECS_PTR(hawk->tok.name); if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("on")) == 0) { is_on = 1; @@ -1122,13 +1122,13 @@ static int parse_progunit (hawk_t* awk) goto error_ident_on_off_expected_for_striprecspc; } - if (awk->sio.inp == &awk->sio.arg) + if (hawk->sio.inp == &hawk->sio.arg) { /* only the top level source. ignore striprecspc pragma in other levels */ if (is_on) - awk->parse.pragma.trait |= HAWK_STRIPRECSPC; + hawk->parse.pragma.trait |= HAWK_STRIPRECSPC; else - awk->parse.pragma.trait &= ~HAWK_STRIPRECSPC; + hawk->parse.pragma.trait &= ~HAWK_STRIPRECSPC; } } else if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("stripstrspc")) == 0) @@ -1138,16 +1138,16 @@ static int parse_progunit (hawk_t* awk) */ int is_on; - if (get_token(awk) <= -1) return -1; - if (!MATCH(awk, TOK_IDENT)) + if (get_token(hawk) <= -1) return -1; + if (!MATCH(hawk, TOK_IDENT)) { error_ident_on_off_expected_for_stripstrspc: - hawk_seterrfmt (awk, &awk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'stripstrspc'")); + hawk_seterrfmt (hawk, &hawk->ptok.loc, HAWK_EIDENT, HAWK_T("identifier 'on' or 'off' expected for 'stripstrspc'")); return -1; } - name.len = HAWK_OOECS_LEN(awk->tok.name); - name.ptr = HAWK_OOECS_PTR(awk->tok.name); + name.len = HAWK_OOECS_LEN(hawk->tok.name); + name.ptr = HAWK_OOECS_PTR(hawk->tok.name); if (hawk_comp_oochars_oocstr(name.ptr, name.len, HAWK_T("on")) == 0) { is_on = 1; @@ -1161,105 +1161,105 @@ static int parse_progunit (hawk_t* awk) goto error_ident_on_off_expected_for_stripstrspc; } - if (awk->sio.inp == &awk->sio.arg) + if (hawk->sio.inp == &hawk->sio.arg) { /* only the top level source. ignore stripstrspc pragma in other levels */ if (is_on) - awk->parse.pragma.trait |= HAWK_STRIPSTRSPC; + hawk->parse.pragma.trait |= HAWK_STRIPSTRSPC; else - awk->parse.pragma.trait &= ~HAWK_STRIPSTRSPC; + hawk->parse.pragma.trait &= ~HAWK_STRIPSTRSPC; } } else { - hawk_seterrfmt (awk, &awk->ptok.loc, HAWK_EIDENT, HAWK_T("unknown @pragma identifier - %.*js"), name.len, name.ptr); + hawk_seterrfmt (hawk, &hawk->ptok.loc, HAWK_EIDENT, HAWK_T("unknown @pragma identifier - %.*js"), name.len, name.ptr); return -1; } - if (get_token(awk) <= -1) return -1; - if (MATCH(awk,TOK_SEMICOLON) && get_token(awk) <= -1) return -1; + if (get_token(hawk) <= -1) return -1; + if (MATCH(hawk,TOK_SEMICOLON) && get_token(hawk) <= -1) return -1; } - else if (MATCH(awk, TOK_FUNCTION)) + else if (MATCH(hawk, TOK_FUNCTION)) { - awk->parse.id.block = PARSE_FUNCTION; - if (parse_function(awk) == HAWK_NULL) return -1; + hawk->parse.id.block = PARSE_FUNCTION; + if (parse_function(hawk) == HAWK_NULL) return -1; } - else if (MATCH(awk, TOK_BEGIN)) + else if (MATCH(hawk, TOK_BEGIN)) { - if (!(awk->opt.trait & HAWK_PABLOCK)) /* pattern action block not allowed */ + if (!(hawk->opt.trait & HAWK_PABLOCK)) /* pattern action block not allowed */ { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - awk->parse.id.block = PARSE_BEGIN; - if (get_token(awk) <= -1) return -1; + hawk->parse.id.block = PARSE_BEGIN; + if (get_token(hawk) <= -1) return -1; - if (MATCH(awk, TOK_NEWLINE) || MATCH(awk, TOK_EOF)) + if (MATCH(hawk, TOK_NEWLINE) || MATCH(hawk, TOK_EOF)) { /* when HAWK_NEWLINE is set, * BEGIN and { should be located on the same line */ - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EBLKBEG); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EBLKBEG); return -1; } - if (!MATCH(awk, TOK_LBRACE)) + if (!MATCH(hawk, TOK_LBRACE)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - awk->parse.id.block = PARSE_BEGIN_BLOCK; - if (parse_begin(awk) == HAWK_NULL) return -1; + hawk->parse.id.block = PARSE_BEGIN_BLOCK; + if (parse_begin(hawk) == HAWK_NULL) return -1; /* skip a semicolon after an action block if any */ - if (MATCH(awk, TOK_SEMICOLON) && get_token(awk) <= -1) return -1; + if (MATCH(hawk, TOK_SEMICOLON) && get_token(hawk) <= -1) return -1; } - else if (MATCH(awk, TOK_END)) + else if (MATCH(hawk, TOK_END)) { - if (!(awk->opt.trait & HAWK_PABLOCK)) + if (!(hawk->opt.trait & HAWK_PABLOCK)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - awk->parse.id.block = PARSE_END; - if (get_token(awk) <= -1) return -1; + hawk->parse.id.block = PARSE_END; + if (get_token(hawk) <= -1) return -1; - if (MATCH(awk, TOK_NEWLINE) || MATCH(awk, TOK_EOF)) + if (MATCH(hawk, TOK_NEWLINE) || MATCH(hawk, TOK_EOF)) { /* when HAWK_NEWLINE is set, * END and { should be located on the same line */ - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EBLKEND); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EBLKEND); return -1; } - if (!MATCH(awk, TOK_LBRACE)) + if (!MATCH(hawk, TOK_LBRACE)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - awk->parse.id.block = PARSE_END_BLOCK; - if (parse_end(awk) == HAWK_NULL) return -1; + hawk->parse.id.block = PARSE_END_BLOCK; + if (parse_end(hawk) == HAWK_NULL) return -1; /* skip a semicolon after an action block if any */ - if (MATCH(awk,TOK_SEMICOLON) && get_token (awk) <= -1) return -1; + if (MATCH(hawk,TOK_SEMICOLON) && get_token (hawk) <= -1) return -1; } - else if (MATCH(awk, TOK_LBRACE)) + else if (MATCH(hawk, TOK_LBRACE)) { /* patternless block */ - if (!(awk->opt.trait & HAWK_PABLOCK)) + if (!(hawk->opt.trait & HAWK_PABLOCK)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - awk->parse.id.block = PARSE_ACTION_BLOCK; - if (parse_action_block(awk, HAWK_NULL, 0) == HAWK_NULL) return -1; + hawk->parse.id.block = PARSE_ACTION_BLOCK; + if (parse_action_block(hawk, HAWK_NULL, 0) == HAWK_NULL) return -1; /* skip a semicolon after an action block if any */ - if (MATCH(awk, TOK_SEMICOLON) && get_token(awk) <= -1) return -1; + if (MATCH(hawk, TOK_SEMICOLON) && get_token(hawk) <= -1) return -1; } else { @@ -1275,102 +1275,102 @@ static int parse_progunit (hawk_t* awk) hawk_nde_t* ptn; hawk_loc_t eloc; - if (!(awk->opt.trait & HAWK_PABLOCK)) + if (!(hawk->opt.trait & HAWK_PABLOCK)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EKWFNC, FMT_EKWFNC, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - awk->parse.id.block = PARSE_PATTERN; + hawk->parse.id.block = PARSE_PATTERN; - eloc = awk->tok.loc; - ptn = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + ptn = parse_expr_withdc (hawk, &eloc); if (ptn == HAWK_NULL) return -1; HAWK_ASSERT (ptn->next == HAWK_NULL); - if (MATCH(awk,TOK_COMMA)) + if (MATCH(hawk,TOK_COMMA)) { - if (get_token (awk) <= -1) + if (get_token (hawk) <= -1) { - hawk_clrpt (awk, ptn); + hawk_clrpt (hawk, ptn); return -1; } - eloc = awk->tok.loc; - ptn->next = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + ptn->next = parse_expr_withdc (hawk, &eloc); if (ptn->next == HAWK_NULL) { - hawk_clrpt (awk, ptn); + hawk_clrpt (hawk, ptn); return -1; } } - if (MATCH(awk,TOK_NEWLINE) || MATCH(awk,TOK_SEMICOLON) || MATCH(awk,TOK_EOF)) + if (MATCH(hawk,TOK_NEWLINE) || MATCH(hawk,TOK_SEMICOLON) || MATCH(hawk,TOK_EOF)) { /* blockless pattern */ int eof; hawk_loc_t ploc; - eof = MATCH(awk,TOK_EOF); - ploc = awk->ptok.loc; + eof = MATCH(hawk,TOK_EOF); + ploc = hawk->ptok.loc; - awk->parse.id.block = PARSE_ACTION_BLOCK; - if (parse_action_block(awk, ptn, 1) == HAWK_NULL) + hawk->parse.id.block = PARSE_ACTION_BLOCK; + if (parse_action_block(hawk, ptn, 1) == HAWK_NULL) { - hawk_clrpt (awk, ptn); + hawk_clrpt (hawk, ptn); return -1; } if (!eof) { - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { /* 'ptn' has been added to the chain. * it doesn't have to be cleared here * as hawk_clear does it */ - /*hawk_clrpt (awk, ptn);*/ + /*hawk_clrpt (hawk, ptn);*/ return -1; } } - if ((awk->opt.trait & HAWK_RIO) != HAWK_RIO) + if ((hawk->opt.trait & HAWK_RIO) != HAWK_RIO) { /* blockless pattern requires HAWK_RIO * to be ON because the implicit block is * "print $0" */ - hawk_seterrnum (awk, &ploc, HAWK_ENOSUP); + hawk_seterrnum (hawk, &ploc, HAWK_ENOSUP); return -1; } } else { /* parse the action block */ - if (!MATCH(awk,TOK_LBRACE)) + if (!MATCH(hawk,TOK_LBRACE)) { - hawk_clrpt (awk, ptn); - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_clrpt (hawk, ptn); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - awk->parse.id.block = PARSE_ACTION_BLOCK; - if (parse_action_block(awk, ptn, 0) == HAWK_NULL) + hawk->parse.id.block = PARSE_ACTION_BLOCK; + if (parse_action_block(hawk, ptn, 0) == HAWK_NULL) { - hawk_clrpt (awk, ptn); + hawk_clrpt (hawk, ptn); return -1; } /* skip a semicolon after an action block if any */ - if (MATCH(awk,TOK_SEMICOLON) && get_token(awk) <= -1) return -1; + if (MATCH(hawk,TOK_SEMICOLON) && get_token(hawk) <= -1) return -1; } } return 0; } -static hawk_nde_t* parse_function (hawk_t* awk) +static hawk_nde_t* parse_function (hawk_t* hawk) { hawk_oocs_t name; hawk_nde_t* body = HAWK_NULL; @@ -1384,65 +1384,65 @@ static hawk_nde_t* parse_function (hawk_t* awk) const hawk_ooch_t* redobj; /* eat up the keyword 'function' and get the next token */ - HAWK_ASSERT (MATCH(awk,TOK_FUNCTION)); - if (get_token(awk) <= -1) return HAWK_NULL; + HAWK_ASSERT (MATCH(hawk,TOK_FUNCTION)); + if (get_token(hawk) <= -1) return HAWK_NULL; /* check if an identifier is in place */ - if (!MATCH(awk,TOK_IDENT)) + if (!MATCH(hawk,TOK_IDENT)) { /* cannot find a valid identifier for a function name */ - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EFUNNAM, HAWK_T("'%.*js' not a valid function name"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EFUNNAM, HAWK_T("'%.*js' not a valid function name"), HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } - name.len = HAWK_OOECS_LEN(awk->tok.name); - name.ptr = HAWK_OOECS_PTR(awk->tok.name); + name.len = HAWK_OOECS_LEN(hawk->tok.name); + name.ptr = HAWK_OOECS_PTR(hawk->tok.name); /* note that i'm assigning to rederr in the 'if' conditions below. * i'm not checking equality */ /* check if it is a builtin function */ - if ((hawk_findfncwithoocs(awk, &name) != HAWK_NULL && (rederr = HAWK_EFNCRED, redobj = HAWK_T("intrinsic function"))) || + if ((hawk_findfncwithoocs(hawk, &name) != HAWK_NULL && (rederr = HAWK_EFNCRED, redobj = HAWK_T("intrinsic function"))) || /* check if it has already been defined as a function */ - (hawk_htb_search(awk->tree.funs, name.ptr, name.len) != HAWK_NULL && (rederr = HAWK_EFUNRED, redobj = HAWK_T("function"))) || + (hawk_htb_search(hawk->tree.funs, name.ptr, name.len) != HAWK_NULL && (rederr = HAWK_EFUNRED, redobj = HAWK_T("function"))) || /* check if it conflicts with a named variable */ - (hawk_htb_search(awk->parse.named, name.ptr, name.len) != HAWK_NULL && (rederr = HAWK_EVARRED, redobj = HAWK_T("variable"))) || + (hawk_htb_search(hawk->parse.named, name.ptr, name.len) != HAWK_NULL && (rederr = HAWK_EVARRED, redobj = HAWK_T("variable"))) || /* check if it coincides to be a global variable name */ - (((g = find_global (awk, &name)) != HAWK_ARR_NIL) && (rederr = HAWK_EGBLRED, redobj = HAWK_T("global variable")))) + (((g = find_global (hawk, &name)) != HAWK_ARR_NIL) && (rederr = HAWK_EGBLRED, redobj = HAWK_T("global variable")))) { - hawk_seterrfmt (awk, &awk->tok.loc, rederr, HAWK_T("%js '%.*js' redefined"), redobj, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, rederr, HAWK_T("%js '%.*js' redefined"), redobj, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } /* duplicate the name before it's overridden by get_token() */ - name.ptr = hawk_dupoochars(awk, name.ptr, name.len); + name.ptr = hawk_dupoochars(hawk, name.ptr, name.len); if (!name.ptr) { - ADJERR_LOC (awk, &awk->tok.loc); + ADJERR_LOC (hawk, &hawk->tok.loc); return HAWK_NULL; } /* get the next token */ - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* match a left parenthesis */ - if (!MATCH(awk,TOK_LPAREN)) + if (!MATCH(hawk,TOK_LPAREN)) { /* a function name is not followed by a left parenthesis */ - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } /* get the next token */ - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* make sure that parameter table is empty */ - HAWK_ASSERT (HAWK_ARR_SIZE(awk->parse.params) == 0); + HAWK_ASSERT (HAWK_ARR_SIZE(hawk->parse.params) == 0); /* read parameter list */ - if (MATCH(awk,TOK_RPAREN)) + if (MATCH(hawk,TOK_RPAREN)) { /* no function parameter found. get the next token */ - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } else { @@ -1451,30 +1451,30 @@ static hawk_nde_t* parse_function (hawk_t* awk) hawk_ooch_t* pa; hawk_oow_t pal; - if (MATCH(awk, TOK_BAND)) + if (MATCH(hawk, TOK_BAND)) { /* pass-by-reference argument */ - nargs = HAWK_ARR_SIZE(awk->parse.params); + nargs = HAWK_ARR_SIZE(hawk->parse.params); if (nargs >= argspeccapa) { hawk_oow_t i, newcapa = HAWK_ALIGN_POW2(nargs + 2, 64); - argspec = hawk_reallocmem(awk, argspec, newcapa * HAWK_SIZEOF(*argspec)); + argspec = hawk_reallocmem(hawk, argspec, newcapa * HAWK_SIZEOF(*argspec)); if (!argspec) goto oops; for (i = argspeccapa; i < newcapa; i++) argspec[i] = HAWK_T(' '); argspeccapa = newcapa; } argspec[nargs] = 'r'; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - if (!MATCH(awk,TOK_IDENT)) + if (!MATCH(hawk,TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EBADPAR, HAWK_T("'%.*js' not a valid parameter name"), HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EBADPAR, HAWK_T("'%.*js' not a valid parameter name"), HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - pa = HAWK_OOECS_PTR(awk->tok.name); - pal = HAWK_OOECS_LEN(awk->tok.name); + pa = HAWK_OOECS_PTR(hawk->tok.name); + pal = HAWK_OOECS_LEN(hawk->tok.name); /* NOTE: the following is not a conflict. * so the parameter is not checked against @@ -1486,90 +1486,90 @@ static hawk_nde_t* parse_function (hawk_t* awk) /* check if a parameter conflicts with the function * name or other parameters */ - if (((awk->opt.trait & HAWK_STRICTNAMING) && + if (((hawk->opt.trait & HAWK_STRICTNAMING) && hawk_comp_oochars(pa, pal, name.ptr, name.len, 0) == 0) || - hawk_arr_search(awk->parse.params, 0, pa, pal) != HAWK_ARR_NIL) + hawk_arr_search(hawk->parse.params, 0, pa, pal) != HAWK_ARR_NIL) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPPAR, HAWK_T("duplicate parameter name '%.*js'"), pal, pa); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EDUPPAR, HAWK_T("duplicate parameter name '%.*js'"), pal, pa); goto oops; } /* push the parameter to the parameter list */ - if (HAWK_ARR_SIZE(awk->parse.params) >= HAWK_MAX_PARAMS) + if (HAWK_ARR_SIZE(hawk->parse.params) >= HAWK_MAX_PARAMS) { - hawk_seterrnum (awk, &awk->tok.loc, HAWK_EPARTM); + hawk_seterrnum (hawk, &hawk->tok.loc, HAWK_EPARTM); goto oops; } - if (hawk_arr_insert(awk->parse.params, HAWK_ARR_SIZE(awk->parse.params), pa, pal) == HAWK_ARR_NIL) + if (hawk_arr_insert(hawk->parse.params, HAWK_ARR_SIZE(hawk->parse.params), pa, pal) == HAWK_ARR_NIL) { - ADJERR_LOC (awk, &awk->tok.loc); + ADJERR_LOC (hawk, &hawk->tok.loc); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - if (MATCH(awk,TOK_RPAREN)) break; + if (MATCH(hawk,TOK_RPAREN)) break; - if (!MATCH(awk,TOK_COMMA)) + if (!MATCH(hawk,TOK_COMMA)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } do { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); } if (argspec) argspec[nargs + 1] = '\0'; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } /* function body can be placed on a different line * from a function name and the parameters even if * HAWK_NEWLINE is set. note TOK_NEWLINE is * available only when the option is set. */ - while (MATCH(awk,TOK_NEWLINE)) + while (MATCH(hawk,TOK_NEWLINE)) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } /* check if the function body starts with a left brace */ - if (!MATCH(awk,TOK_LBRACE)) + if (!MATCH(hawk,TOK_LBRACE)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELBRACE, FMT_ELBRACE, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* remember the current function name so that the body parser * can know the name of the current function being parsed */ - awk->tree.cur_fun.ptr = name.ptr; - awk->tree.cur_fun.len = name.len; + hawk->tree.cur_fun.ptr = name.ptr; + hawk->tree.cur_fun.len = name.len; /* actual function body */ - xloc = awk->ptok.loc; - body = parse_block_dc(awk, &xloc, 1); + xloc = hawk->ptok.loc; + body = parse_block_dc(hawk, &xloc, 1); /* clear the current function name remembered */ - awk->tree.cur_fun.ptr = HAWK_NULL; - awk->tree.cur_fun.len = 0; + hawk->tree.cur_fun.ptr = HAWK_NULL; + hawk->tree.cur_fun.len = 0; if (!body) goto oops; /* TODO: study furthur if the parameter names should be saved * for some reasons - might be needed for better deparsing output */ - nargs = HAWK_ARR_SIZE(awk->parse.params); + nargs = HAWK_ARR_SIZE(hawk->parse.params); /* parameter names are not required anymore. clear them */ - hawk_arr_clear (awk->parse.params); + hawk_arr_clear (hawk->parse.params); - fun = (hawk_fun_t*)hawk_callocmem(awk, HAWK_SIZEOF(*fun)); + fun = (hawk_fun_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*fun)); if (fun == HAWK_NULL) { - ADJERR_LOC (awk, &awk->tok.loc); + ADJERR_LOC (hawk, &hawk->tok.loc); goto oops; } @@ -1579,13 +1579,13 @@ static hawk_nde_t* parse_function (hawk_t* awk) fun->argspec = argspec; fun->body = body; - pair = hawk_htb_insert(awk->tree.funs, name.ptr, name.len, fun, 0); + pair = hawk_htb_insert(hawk->tree.funs, name.ptr, name.len, fun, 0); if (pair == HAWK_NULL) { /* if hawk_htb_insert() fails for other reasons than memory * shortage, there should be implementaion errors as duplicate * functions are detected earlier in this function */ - ADJERR_LOC (awk, &awk->tok.loc); + ADJERR_LOC (hawk, &hawk->tok.loc); goto oops; } @@ -1593,94 +1593,94 @@ static hawk_nde_t* parse_function (hawk_t* awk) * of the pair */ fun->name.ptr = HAWK_HTB_KPTR(pair); fun->name.len = HAWK_HTB_KLEN(pair); - hawk_freemem (awk, name.ptr); + hawk_freemem (hawk, name.ptr); /* remove an undefined function call entry from the parse.fun table */ - hawk_htb_delete (awk->parse.funs, fun->name.ptr, name.len); + hawk_htb_delete (hawk->parse.funs, fun->name.ptr, name.len); return body; oops: - if (body) hawk_clrpt (awk, body); - if (argspec) hawk_freemem (awk, argspec); - if (fun) hawk_freemem (awk, fun); - hawk_freemem (awk, name.ptr); - hawk_arr_clear (awk->parse.params); + if (body) hawk_clrpt (hawk, body); + if (argspec) hawk_freemem (hawk, argspec); + if (fun) hawk_freemem (hawk, fun); + hawk_freemem (hawk, name.ptr); + hawk_arr_clear (hawk->parse.params); return HAWK_NULL; } -static hawk_nde_t* parse_begin (hawk_t* awk) +static hawk_nde_t* parse_begin (hawk_t* hawk) { hawk_nde_t* nde; hawk_loc_t xloc; - xloc = awk->tok.loc; - HAWK_ASSERT (MATCH(awk,TOK_LBRACE)); + xloc = hawk->tok.loc; + HAWK_ASSERT (MATCH(hawk,TOK_LBRACE)); - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_block_dc (awk, &xloc, 1); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_block_dc (hawk, &xloc, 1); if (nde == HAWK_NULL) return HAWK_NULL; - if (awk->tree.begin == HAWK_NULL) + if (hawk->tree.begin == HAWK_NULL) { - awk->tree.begin = nde; - awk->tree.begin_tail = nde; + hawk->tree.begin = nde; + hawk->tree.begin_tail = nde; } else { - awk->tree.begin_tail->next = nde; - awk->tree.begin_tail = nde; + hawk->tree.begin_tail->next = nde; + hawk->tree.begin_tail = nde; } return nde; } -static hawk_nde_t* parse_end (hawk_t* awk) +static hawk_nde_t* parse_end (hawk_t* hawk) { hawk_nde_t* nde; hawk_loc_t xloc; - xloc = awk->tok.loc; - HAWK_ASSERT (MATCH(awk,TOK_LBRACE)); + xloc = hawk->tok.loc; + HAWK_ASSERT (MATCH(hawk,TOK_LBRACE)); - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_block_dc (awk, &xloc, 1); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_block_dc (hawk, &xloc, 1); if (nde == HAWK_NULL) return HAWK_NULL; - if (awk->tree.end == HAWK_NULL) + if (hawk->tree.end == HAWK_NULL) { - awk->tree.end = nde; - awk->tree.end_tail = nde; + hawk->tree.end = nde; + hawk->tree.end_tail = nde; } else { - awk->tree.end_tail->next = nde; - awk->tree.end_tail = nde; + hawk->tree.end_tail->next = nde; + hawk->tree.end_tail = nde; } return nde; } static hawk_chain_t* parse_action_block ( - hawk_t* awk, hawk_nde_t* ptn, int blockless) + hawk_t* hawk, hawk_nde_t* ptn, int blockless) { hawk_nde_t* nde; hawk_chain_t* chain; hawk_loc_t xloc; - xloc = awk->tok.loc; + xloc = hawk->tok.loc; if (blockless) nde = HAWK_NULL; else { - HAWK_ASSERT (MATCH(awk,TOK_LBRACE)); - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_block_dc(awk, &xloc, 1); + HAWK_ASSERT (MATCH(hawk,TOK_LBRACE)); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_block_dc(hawk, &xloc, 1); if (nde == HAWK_NULL) return HAWK_NULL; } - chain = (hawk_chain_t*)hawk_callocmem(awk, HAWK_SIZEOF(*chain)); + chain = (hawk_chain_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*chain)); if (chain == HAWK_NULL) { - hawk_clrpt (awk, nde); - ADJERR_LOC (awk, &xloc); + hawk_clrpt (hawk, nde); + ADJERR_LOC (hawk, &xloc); return HAWK_NULL; } @@ -1688,75 +1688,75 @@ static hawk_chain_t* parse_action_block ( chain->action = nde; chain->next = HAWK_NULL; - if (awk->tree.chain == HAWK_NULL) + if (hawk->tree.chain == HAWK_NULL) { - awk->tree.chain = chain; - awk->tree.chain_tail = chain; - awk->tree.chain_size++; + hawk->tree.chain = chain; + hawk->tree.chain_tail = chain; + hawk->tree.chain_size++; } else { - awk->tree.chain_tail->next = chain; - awk->tree.chain_tail = chain; - awk->tree.chain_size++; + hawk->tree.chain_tail->next = chain; + hawk->tree.chain_tail = chain; + hawk->tree.chain_size++; } return chain; } -static hawk_nde_t* parse_block (hawk_t* awk, const hawk_loc_t* xloc, int istop) +static hawk_nde_t* parse_block (hawk_t* hawk, const hawk_loc_t* xloc, int istop) { hawk_nde_t* head, * curr, * nde; hawk_nde_blk_t* block; hawk_oow_t nlcls, nlcls_max, tmp; - nlcls = HAWK_ARR_SIZE(awk->parse.lcls); - nlcls_max = awk->parse.nlcls_max; + nlcls = HAWK_ARR_SIZE(hawk->parse.lcls); + nlcls_max = hawk->parse.nlcls_max; /* local variable declarations */ while (1) { /* skip new lines before local declaration in a block*/ - while (MATCH(awk,TOK_NEWLINE)) + while (MATCH(hawk,TOK_NEWLINE)) { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; } - if (MATCH(awk,TOK_XINCLUDE) || MATCH(awk, TOK_XINCLUDE_ONCE)) + if (MATCH(hawk,TOK_XINCLUDE) || MATCH(hawk, TOK_XINCLUDE_ONCE)) { /* @include ... */ int once; - if (awk->opt.depth.s.incl > 0 && - awk->parse.depth.incl >= awk->opt.depth.s.incl) + if (hawk->opt.depth.s.incl > 0 && + hawk->parse.depth.incl >= hawk->opt.depth.s.incl) { - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EINCLTD); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EINCLTD); return HAWK_NULL; } - once = MATCH(awk, TOK_XINCLUDE_ONCE); - if (get_token(awk) <= -1) return HAWK_NULL; + once = MATCH(hawk, TOK_XINCLUDE_ONCE); + if (get_token(hawk) <= -1) return HAWK_NULL; - if (!MATCH(awk,TOK_STR)) + if (!MATCH(hawk,TOK_STR)) { - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EINCLSTR); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EINCLSTR); return HAWK_NULL; } - if (begin_include(awk, once) <= -1) return HAWK_NULL; + if (begin_include(hawk, once) <= -1) return HAWK_NULL; } - else if (MATCH(awk,TOK_XLOCAL)) + else if (MATCH(hawk,TOK_XLOCAL)) { /* @local ... */ - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_arr_delete (awk->parse.lcls, nlcls, HAWK_ARR_SIZE(awk->parse.lcls)-nlcls); + hawk_arr_delete (hawk->parse.lcls, nlcls, HAWK_ARR_SIZE(hawk->parse.lcls)-nlcls); return HAWK_NULL; } - if (collect_locals (awk, nlcls, istop) == HAWK_NULL) + if (collect_locals (hawk, nlcls, istop) == HAWK_NULL) { - hawk_arr_delete (awk->parse.lcls, nlcls, HAWK_ARR_SIZE(awk->parse.lcls)-nlcls); + hawk_arr_delete (hawk->parse.lcls, nlcls, HAWK_ARR_SIZE(hawk->parse.lcls)-nlcls); return HAWK_NULL; } } @@ -1769,74 +1769,74 @@ static hawk_nde_t* parse_block (hawk_t* awk, const hawk_loc_t* xloc, int istop) while (1) { /* skip new lines within a block */ - while (MATCH(awk,TOK_NEWLINE)) + while (MATCH(hawk,TOK_NEWLINE)) { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; } /* if EOF is met before the right brace, this is an error */ - if (MATCH(awk,TOK_EOF)) + if (MATCH(hawk,TOK_EOF)) { hawk_arr_delete ( - awk->parse.lcls, nlcls, - HAWK_ARR_SIZE(awk->parse.lcls) - nlcls); - if (head != HAWK_NULL) hawk_clrpt (awk, head); - hawk_seterrnum (awk, &awk->tok.loc, HAWK_EEOF); + hawk->parse.lcls, nlcls, + HAWK_ARR_SIZE(hawk->parse.lcls) - nlcls); + if (head != HAWK_NULL) hawk_clrpt (hawk, head); + hawk_seterrnum (hawk, &hawk->tok.loc, HAWK_EEOF); return HAWK_NULL; } /* end the block when the right brace is met */ - if (MATCH(awk,TOK_RBRACE)) + if (MATCH(hawk,TOK_RBRACE)) { - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { hawk_arr_delete ( - awk->parse.lcls, nlcls, - HAWK_ARR_SIZE(awk->parse.lcls)-nlcls); - if (head != HAWK_NULL) hawk_clrpt (awk, head); + hawk->parse.lcls, nlcls, + HAWK_ARR_SIZE(hawk->parse.lcls)-nlcls); + if (head != HAWK_NULL) hawk_clrpt (hawk, head); return HAWK_NULL; } break; } - else if (MATCH(awk, TOK_XINCLUDE) || MATCH(awk, TOK_XINCLUDE_ONCE)) + else if (MATCH(hawk, TOK_XINCLUDE) || MATCH(hawk, TOK_XINCLUDE_ONCE)) { int once; - if (awk->opt.depth.s.incl > 0 && - awk->parse.depth.incl >= awk->opt.depth.s.incl) + if (hawk->opt.depth.s.incl > 0 && + hawk->parse.depth.incl >= hawk->opt.depth.s.incl) { - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EINCLTD); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EINCLTD); return HAWK_NULL; } - once = MATCH(awk, TOK_XINCLUDE_ONCE); - if (get_token(awk) <= -1) return HAWK_NULL; + once = MATCH(hawk, TOK_XINCLUDE_ONCE); + if (get_token(hawk) <= -1) return HAWK_NULL; - if (!MATCH(awk,TOK_STR)) + if (!MATCH(hawk,TOK_STR)) { - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_EINCLSTR); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_EINCLSTR); return HAWK_NULL; } - if (begin_include(awk, once) <= -1) return HAWK_NULL; + if (begin_include(hawk, once) <= -1) return HAWK_NULL; } else { /* parse an actual statement in a block */ { hawk_loc_t sloc; - sloc = awk->tok.loc; - nde = parse_statement (awk, &sloc); + sloc = hawk->tok.loc; + nde = parse_statement (hawk, &sloc); } if (HAWK_UNLIKELY(!nde)) { hawk_arr_delete ( - awk->parse.lcls, nlcls, - HAWK_ARR_SIZE(awk->parse.lcls)-nlcls); - if (head) hawk_clrpt (awk, head); + hawk->parse.lcls, nlcls, + HAWK_ARR_SIZE(hawk->parse.lcls)-nlcls); + if (head) hawk_clrpt (hawk, head); return HAWK_NULL; } @@ -1844,13 +1844,13 @@ static hawk_nde_t* parse_block (hawk_t* awk, const hawk_loc_t* xloc, int istop) * null statements */ if (nde->type == HAWK_NDE_NULL) { - hawk_clrpt (awk, nde); + hawk_clrpt (hawk, nde); continue; } if (nde->type == HAWK_NDE_BLK && ((hawk_nde_blk_t*)nde)->body == HAWK_NULL) { - hawk_clrpt (awk, nde); + hawk_clrpt (hawk, nde); continue; } @@ -1860,20 +1860,20 @@ static hawk_nde_t* parse_block (hawk_t* awk, const hawk_loc_t* xloc, int istop) } } - block = (hawk_nde_blk_t*)hawk_callocmem(awk, HAWK_SIZEOF(*block)); + block = (hawk_nde_blk_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*block)); if (HAWK_UNLIKELY(!block)) { - hawk_arr_delete (awk->parse.lcls, nlcls, HAWK_ARR_SIZE(awk->parse.lcls) - nlcls); - hawk_clrpt (awk, head); - ADJERR_LOC (awk, xloc); + hawk_arr_delete (hawk->parse.lcls, nlcls, HAWK_ARR_SIZE(hawk->parse.lcls) - nlcls); + hawk_clrpt (hawk, head); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } - tmp = HAWK_ARR_SIZE(awk->parse.lcls); - if (tmp > awk->parse.nlcls_max) awk->parse.nlcls_max = tmp; + tmp = HAWK_ARR_SIZE(hawk->parse.lcls); + if (tmp > hawk->parse.nlcls_max) hawk->parse.nlcls_max = tmp; /* remove all lcls to move it up to the top level */ - hawk_arr_delete (awk->parse.lcls, nlcls, tmp - nlcls); + hawk_arr_delete (hawk->parse.lcls, nlcls, tmp - nlcls); /* adjust the number of lcls for a block without any statements */ /* if (head == HAWK_NULL) tmp = 0; */ @@ -1889,8 +1889,8 @@ static hawk_nde_t* parse_block (hawk_t* awk, const hawk_loc_t* xloc, int istop) /* migrate all block-local variables to a top-level block */ if (istop) { - block->nlcls = awk->parse.nlcls_max - nlcls; - awk->parse.nlcls_max = nlcls_max; + block->nlcls = hawk->parse.nlcls_max - nlcls; + hawk->parse.nlcls_max = nlcls_max; } else { @@ -1901,75 +1901,75 @@ static hawk_nde_t* parse_block (hawk_t* awk, const hawk_loc_t* xloc, int istop) return (hawk_nde_t*)block; } -static hawk_nde_t* parse_block_dc (hawk_t* awk, const hawk_loc_t* xloc, int istop) +static hawk_nde_t* parse_block_dc (hawk_t* hawk, const hawk_loc_t* xloc, int istop) { hawk_nde_t* nde; - if (awk->opt.depth.s.block_parse > 0 && - awk->parse.depth.block >= awk->opt.depth.s.block_parse) + if (hawk->opt.depth.s.block_parse > 0 && + hawk->parse.depth.block >= hawk->opt.depth.s.block_parse) { - hawk_seterrnum (awk, xloc, HAWK_EBLKNST); + hawk_seterrnum (hawk, xloc, HAWK_EBLKNST); return HAWK_NULL; } - awk->parse.depth.block++; - nde = parse_block(awk, xloc, istop); - awk->parse.depth.block--; + hawk->parse.depth.block++; + nde = parse_block(hawk, xloc, istop); + hawk->parse.depth.block--; return nde; } -int hawk_initgbls (hawk_t* awk) +int hawk_initgbls (hawk_t* hawk) { int id; /* hawk_initgbls is not generic-purpose. call this from * hawk_open only. */ - HAWK_ASSERT (awk->tree.ngbls_base == 0 && awk->tree.ngbls == 0); + HAWK_ASSERT (hawk->tree.ngbls_base == 0 && hawk->tree.ngbls == 0); - awk->tree.ngbls_base = 0; - awk->tree.ngbls = 0; + hawk->tree.ngbls_base = 0; + hawk->tree.ngbls = 0; for (id = HAWK_MIN_GBL_ID; id <= HAWK_MAX_GBL_ID; id++) { hawk_oow_t g; - g = hawk_arr_insert(awk->parse.gbls, HAWK_ARR_SIZE(awk->parse.gbls), (hawk_ooch_t*)gtab[id].name, gtab[id].namelen); + g = hawk_arr_insert(hawk->parse.gbls, HAWK_ARR_SIZE(hawk->parse.gbls), (hawk_ooch_t*)gtab[id].name, gtab[id].namelen); if (g == HAWK_ARR_NIL) return -1; HAWK_ASSERT ((int)g == id); - awk->tree.ngbls_base++; - awk->tree.ngbls++; + hawk->tree.ngbls_base++; + hawk->tree.ngbls++; } - HAWK_ASSERT (awk->tree.ngbls_base == HAWK_MAX_GBL_ID-HAWK_MIN_GBL_ID+1); + HAWK_ASSERT (hawk->tree.ngbls_base == HAWK_MAX_GBL_ID-HAWK_MIN_GBL_ID+1); return 0; } -static void adjust_static_globals (hawk_t* awk) +static void adjust_static_globals (hawk_t* hawk) { int id; - HAWK_ASSERT (awk->tree.ngbls_base >= HAWK_MAX_GBL_ID - HAWK_MAX_GBL_ID + 1); + HAWK_ASSERT (hawk->tree.ngbls_base >= HAWK_MAX_GBL_ID - HAWK_MAX_GBL_ID + 1); for (id = HAWK_MIN_GBL_ID; id <= HAWK_MAX_GBL_ID; id++) { - if ((awk->opt.trait & gtab[id].trait) != gtab[id].trait) + if ((hawk->opt.trait & gtab[id].trait) != gtab[id].trait) { - HAWK_ARR_DLEN(awk->parse.gbls,id) = 0; + HAWK_ARR_DLEN(hawk->parse.gbls,id) = 0; } else { - HAWK_ARR_DLEN(awk->parse.gbls,id) = gtab[id].namelen; + HAWK_ARR_DLEN(hawk->parse.gbls,id) = gtab[id].namelen; } } } -static hawk_oow_t get_global (hawk_t* awk, const hawk_oocs_t* name) +static hawk_oow_t get_global (hawk_t* hawk, const hawk_oocs_t* name) { hawk_oow_t i; - hawk_arr_t* gbls = awk->parse.gbls; + hawk_arr_t* gbls = hawk->parse.gbls; for (i = HAWK_ARR_SIZE(gbls); i > 0; ) { @@ -1980,10 +1980,10 @@ static hawk_oow_t get_global (hawk_t* awk, const hawk_oocs_t* name) return HAWK_ARR_NIL; } -static hawk_oow_t find_global (hawk_t* awk, const hawk_oocs_t* name) +static hawk_oow_t find_global (hawk_t* hawk, const hawk_oocs_t* name) { hawk_oow_t i; - hawk_arr_t* gbls = awk->parse.gbls; + hawk_arr_t* gbls = hawk->parse.gbls; for (i = 0; i < HAWK_ARR_SIZE(gbls); i++) { @@ -1993,37 +1993,37 @@ static hawk_oow_t find_global (hawk_t* awk, const hawk_oocs_t* name) return HAWK_ARR_NIL; } -static int add_global (hawk_t* awk, const hawk_oocs_t* name, hawk_loc_t* xloc, int disabled) +static int add_global (hawk_t* hawk, const hawk_oocs_t* name, hawk_loc_t* xloc, int disabled) { hawk_oow_t ngbls; /* check if it is a keyword */ - if (classify_ident(awk, name) != TOK_IDENT) + if (classify_ident(hawk, name) != TOK_IDENT) { - hawk_seterrfmt (awk, xloc, HAWK_EKWRED, HAWK_T("keyword '%.*js' redefined"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EKWRED, HAWK_T("keyword '%.*js' redefined"), name->len, name->ptr); return -1; } /* check if it conflicts with a builtin function name */ - if (hawk_findfncwithoocs(awk, name) != HAWK_NULL) + if (hawk_findfncwithoocs(hawk, name) != HAWK_NULL) { - hawk_seterrfmt (awk, xloc, HAWK_EFNCRED, HAWK_T("intrinsic function '%.*js' redefined"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EFNCRED, HAWK_T("intrinsic function '%.*js' redefined"), name->len, name->ptr); return -1; } /* check if it conflicts with a function name */ - if (hawk_htb_search(awk->tree.funs, name->ptr, name->len) != HAWK_NULL || + if (hawk_htb_search(hawk->tree.funs, name->ptr, name->len) != HAWK_NULL || /* check if it conflicts with a function name caught in the function call table */ - hawk_htb_search(awk->parse.funs, name->ptr, name->len) != HAWK_NULL) + hawk_htb_search(hawk->parse.funs, name->ptr, name->len) != HAWK_NULL) { - hawk_seterrfmt (awk, xloc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), name->len, name->ptr); return -1; } /* check if it conflicts with other global variable names */ - if (find_global(awk, name) != HAWK_ARR_NIL) + if (find_global(hawk, name) != HAWK_ARR_NIL) { - hawk_seterrfmt (awk, xloc, HAWK_EDUPGBL, HAWK_T("duplicate global variable name '%.*js'"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EDUPGBL, HAWK_T("duplicate global variable name '%.*js'"), name->len, name->ptr); return -1; } @@ -2034,48 +2034,48 @@ static int add_global (hawk_t* awk, const hawk_oocs_t* name, hawk_loc_t* xloc, i * @global X; * function x() { print X++; } */ - if (hawk_htb_search(awk->parse.named, name, len) != HAWK_NULL) + if (hawk_htb_search(hawk->parse.named, name, len) != HAWK_NULL) { - hawk_seterrfmt (awk, xloc, HAWK_EVARRED, HAWK_T("variable '%.*js' redefined"), len, name); + hawk_seterrfmt (hawk, xloc, HAWK_EVARRED, HAWK_T("variable '%.*js' redefined"), len, name); return -1; } #endif - ngbls = HAWK_ARR_SIZE(awk->parse.gbls); + ngbls = HAWK_ARR_SIZE(hawk->parse.gbls); if (ngbls >= HAWK_MAX_GBLS) { - hawk_seterrnum (awk, xloc, HAWK_EGBLTM); + hawk_seterrnum (hawk, xloc, HAWK_EGBLTM); return -1; } - if (hawk_arr_insert(awk->parse.gbls, HAWK_ARR_SIZE(awk->parse.gbls), (hawk_ooch_t*)name->ptr, name->len) == HAWK_ARR_NIL) + if (hawk_arr_insert(hawk->parse.gbls, HAWK_ARR_SIZE(hawk->parse.gbls), (hawk_ooch_t*)name->ptr, name->len) == HAWK_ARR_NIL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return -1; } - HAWK_ASSERT (ngbls == HAWK_ARR_SIZE(awk->parse.gbls) - 1); + HAWK_ASSERT (ngbls == HAWK_ARR_SIZE(hawk->parse.gbls) - 1); /* the disabled item is inserted normally but * the name length is reset to zero. */ - if (disabled) HAWK_ARR_DLEN(awk->parse.gbls,ngbls) = 0; + if (disabled) HAWK_ARR_DLEN(hawk->parse.gbls,ngbls) = 0; - awk->tree.ngbls = HAWK_ARR_SIZE (awk->parse.gbls); - HAWK_ASSERT (ngbls == awk->tree.ngbls-1); + hawk->tree.ngbls = HAWK_ARR_SIZE (hawk->parse.gbls); + HAWK_ASSERT (ngbls == hawk->tree.ngbls-1); /* return the id which is the index to the gbl table. */ return (int)ngbls; } -int hawk_addgblwithbcstr (hawk_t* awk, const hawk_bch_t* name) +int hawk_addgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name) { int n; hawk_bcs_t ncs; - if (awk->tree.ngbls > awk->tree.ngbls_base) + if (hawk->tree.ngbls > hawk->tree.ngbls_base) { /* this function is not allowed after hawk_parse is called */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_EPERM); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EPERM); return -1; } @@ -2083,38 +2083,38 @@ int hawk_addgblwithbcstr (hawk_t* awk, const hawk_bch_t* name) ncs.len = hawk_count_bcstr(name);; if (ncs.len <= 0) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); return -1; } #if defined(HAWK_OOCH_IS_BCH) - n = add_global(awk, &ncs, HAWK_NULL, 0); + n = add_global(hawk, &ncs, HAWK_NULL, 0); #else { hawk_ucs_t wcs; - wcs.ptr = hawk_dupbtoucstr(awk, ncs.ptr, &wcs.len, 0); + wcs.ptr = hawk_dupbtoucstr(hawk, ncs.ptr, &wcs.len, 0); if (!wcs.ptr) return -1; - n = add_global(awk, &wcs, HAWK_NULL, 0); - hawk_freemem (awk, wcs.ptr); + n = add_global(hawk, &wcs, HAWK_NULL, 0); + hawk_freemem (hawk, wcs.ptr); } #endif /* update the count of the static globals. * the total global count has been updated inside add_global. */ - if (n >= 0) awk->tree.ngbls_base++; + if (n >= 0) hawk->tree.ngbls_base++; return n; } -int hawk_addgblwithucstr (hawk_t* awk, const hawk_uch_t* name) +int hawk_addgblwithucstr (hawk_t* hawk, const hawk_uch_t* name) { int n; hawk_ucs_t ncs; - if (awk->tree.ngbls > awk->tree.ngbls_base) + if (hawk->tree.ngbls > hawk->tree.ngbls_base) { /* this function is not allowed after hawk_parse is called */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_EPERM); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EPERM); return -1; } @@ -2122,25 +2122,25 @@ int hawk_addgblwithucstr (hawk_t* awk, const hawk_uch_t* name) ncs.len = hawk_count_ucstr(name);; if (ncs.len <= 0) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); return -1; } #if defined(HAWK_OOCH_IS_BCH) { hawk_bcs_t mbs; - mbs.ptr = hawk_duputobcstr(awk, ncs.ptr, &mbs.len); + mbs.ptr = hawk_duputobcstr(hawk, ncs.ptr, &mbs.len); if (!mbs.ptr) return -1; - n = add_global(awk, &mbs, HAWK_NULL, 0); - hawk_freemem (awk, mbs.ptr); + n = add_global(hawk, &mbs, HAWK_NULL, 0); + hawk_freemem (hawk, mbs.ptr); } #else - n = add_global(awk, &ncs, HAWK_NULL, 0); + n = add_global(hawk, &ncs, HAWK_NULL, 0); #endif /* update the count of the static globals. * the total global count has been updated inside add_global. */ - if (n >= 0) awk->tree.ngbls_base++; + if (n >= 0) hawk->tree.ngbls_base++; return n; } @@ -2315,32 +2315,32 @@ int hawk_findgblwithucstr (hawk_t* hawk, const hawk_uch_t* name, int inc_builtin } -static hawk_t* collect_globals (hawk_t* awk) +static hawk_t* collect_globals (hawk_t* hawk) { - if (MATCH(awk,TOK_NEWLINE)) + if (MATCH(hawk,TOK_NEWLINE)) { /* special check if the first name is on the * same line when HAWK_NEWLINE is on */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_EVARMS); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EVARMS); return HAWK_NULL; } while (1) { - if (!MATCH(awk,TOK_IDENT)) + if (!MATCH(hawk,TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EBADVAR, FMT_EBADVAR, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EBADVAR, FMT_EBADVAR, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } - if (add_global(awk, HAWK_OOECS_OOCS(awk->tok.name), &awk->tok.loc, 0) <= -1) return HAWK_NULL; + if (add_global(hawk, HAWK_OOECS_OOCS(hawk->tok.name), &hawk->tok.loc, 0) <= -1) return HAWK_NULL; - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - if (MATCH_TERMINATOR_NORMAL(awk)) + if (MATCH_TERMINATOR_NORMAL(hawk)) { /* skip a terminator (;, ) */ - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; break; } @@ -2348,32 +2348,32 @@ static hawk_t* collect_globals (hawk_t* awk) * unlike collect_locals(), the right brace cannot * terminate a global declaration as it can never be * placed within a block. - * so do not perform MATCH_TERMINATOR_RBRACE(awk)) + * so do not perform MATCH_TERMINATOR_RBRACE(hawk)) */ - if (!MATCH(awk,TOK_COMMA)) + if (!MATCH(hawk,TOK_COMMA)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } do { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); } - return awk; + return hawk; } -static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop) +static hawk_t* collect_locals (hawk_t* hawk, hawk_oow_t nlcls, int istop) { - if (MATCH(awk,TOK_NEWLINE)) + if (MATCH(hawk,TOK_NEWLINE)) { /* special check if the first name is on the * same line when HAWK_NEWLINE is on */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_EVARMS); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EVARMS); return HAWK_NULL; } @@ -2382,19 +2382,19 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop) hawk_oocs_t lcl; hawk_oow_t n; - if (!MATCH(awk,TOK_IDENT)) + if (!MATCH(hawk,TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EBADVAR, FMT_EBADVAR, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EBADVAR, FMT_EBADVAR, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } - lcl = *HAWK_OOECS_OOCS(awk->tok.name); + lcl = *HAWK_OOECS_OOCS(hawk->tok.name); /* check if it conflicts with a builtin function name * function f() { local length; } */ - if (hawk_findfncwithoocs(awk, &lcl) != HAWK_NULL) + if (hawk_findfncwithoocs(hawk, &lcl) != HAWK_NULL) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EFNCRED, HAWK_T("intrinsic function '%.*js' redefined"), lcl.len, lcl.ptr); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EFNCRED, HAWK_T("intrinsic function '%.*js' redefined"), lcl.len, lcl.ptr); return HAWK_NULL; } @@ -2403,91 +2403,91 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop) /* check if it conflicts with a parameter name. * the first level declaration is treated as the same * scope as the parameter list */ - n = hawk_arr_search(awk->parse.params, 0, lcl.ptr, lcl.len); + n = hawk_arr_search(hawk->parse.params, 0, lcl.ptr, lcl.len); if (n != HAWK_ARR_NIL) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EPARRED, HAWK_T("parameter '%.*js' redefined"), lcl.len, lcl.ptr); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EPARRED, HAWK_T("parameter '%.*js' redefined"), lcl.len, lcl.ptr); return HAWK_NULL; } } - if (awk->opt.trait & HAWK_STRICTNAMING) + if (hawk->opt.trait & HAWK_STRICTNAMING) { /* check if it conflicts with the owning function */ - if (awk->tree.cur_fun.ptr != HAWK_NULL) + if (hawk->tree.cur_fun.ptr != HAWK_NULL) { - if (hawk_comp_oochars(lcl.ptr, lcl.len, awk->tree.cur_fun.ptr, awk->tree.cur_fun.len, 0) == 0) + if (hawk_comp_oochars(lcl.ptr, lcl.len, hawk->tree.cur_fun.ptr, hawk->tree.cur_fun.len, 0) == 0) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), lcl.len, lcl.ptr); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), lcl.len, lcl.ptr); return HAWK_NULL; } } } /* check if it conflicts with other local variable names */ - n = hawk_arr_search(awk->parse.lcls, nlcls, lcl.ptr, lcl.len); + n = hawk_arr_search(hawk->parse.lcls, nlcls, lcl.ptr, lcl.len); if (n != HAWK_ARR_NIL) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, FMT_EDUPLCL, lcl.len, lcl.ptr); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EDUPLCL, FMT_EDUPLCL, lcl.len, lcl.ptr); return HAWK_NULL; } /* check if it conflicts with global variable names */ - n = find_global(awk, &lcl); + n = find_global(hawk, &lcl); if (n != HAWK_ARR_NIL) { - if (n < awk->tree.ngbls_base) + if (n < hawk->tree.ngbls_base) { /* it is a conflict only if it is one of a static global variable */ - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, FMT_EDUPLCL, lcl.len, lcl.ptr); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EDUPLCL, FMT_EDUPLCL, lcl.len, lcl.ptr); return HAWK_NULL; } } - if (HAWK_ARR_SIZE(awk->parse.lcls) >= HAWK_MAX_LCLS) + if (HAWK_ARR_SIZE(hawk->parse.lcls) >= HAWK_MAX_LCLS) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELCLTM, HAWK_T("too many local variables defined - %.*js"), lcl.len, lcl.ptr); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELCLTM, HAWK_T("too many local variables defined - %.*js"), lcl.len, lcl.ptr); return HAWK_NULL; } - if (hawk_arr_insert(awk->parse.lcls, HAWK_ARR_SIZE(awk->parse.lcls), lcl.ptr, lcl.len) == HAWK_ARR_NIL) + if (hawk_arr_insert(hawk->parse.lcls, HAWK_ARR_SIZE(hawk->parse.lcls), lcl.ptr, lcl.len) == HAWK_ARR_NIL) { - ADJERR_LOC (awk, &awk->tok.loc); + ADJERR_LOC (hawk, &hawk->tok.loc); return HAWK_NULL; } - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - if (MATCH_TERMINATOR_NORMAL(awk)) + if (MATCH_TERMINATOR_NORMAL(hawk)) { /* skip the terminator (;, ) */ - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; break; } - if (MATCH_TERMINATOR_RBRACE(awk)) + if (MATCH_TERMINATOR_RBRACE(hawk)) { /* should not skip } */ break; } - if (!MATCH(awk,TOK_COMMA)) + if (!MATCH(hawk,TOK_COMMA)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } do { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); } - return awk; + return hawk; } -static hawk_nde_t* parse_if (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_if (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* test = HAWK_NULL; hawk_nde_t* then_part = HAWK_NULL; @@ -2495,20 +2495,20 @@ static hawk_nde_t* parse_if (hawk_t* awk, const hawk_loc_t* xloc) hawk_nde_if_t* nde; hawk_loc_t eloc, tloc; - if (!MATCH(awk,TOK_LPAREN)) + if (!MATCH(hawk,TOK_LPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - eloc = awk->tok.loc; - test = parse_expr_withdc(awk, &eloc); + eloc = hawk->tok.loc; + test = parse_expr_withdc(hawk, &eloc); if (test == HAWK_NULL) goto oops; - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } @@ -2516,34 +2516,34 @@ static hawk_nde_t* parse_if (hawk_t* awk, const hawk_loc_t* xloc) * you can drop the 'if' statement and take either the 'then_part' * or 'else_part'. */ - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - tloc = awk->tok.loc; - then_part = parse_statement(awk, &tloc); + tloc = hawk->tok.loc; + then_part = parse_statement(hawk, &tloc); if (then_part == HAWK_NULL) goto oops; /* skip any new lines before the else block */ - while (MATCH(awk,TOK_NEWLINE)) + while (MATCH(hawk,TOK_NEWLINE)) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - if (MATCH(awk,TOK_ELSE)) + if (MATCH(hawk,TOK_ELSE)) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; { hawk_loc_t eloc; - eloc = awk->tok.loc; - else_part = parse_statement(awk, &eloc); + eloc = hawk->tok.loc; + else_part = parse_statement(hawk, &eloc); if (else_part == HAWK_NULL) goto oops; } } - nde = (hawk_nde_if_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_if_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -2556,46 +2556,46 @@ static hawk_nde_t* parse_if (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; oops: - if (else_part) hawk_clrpt (awk, else_part); - if (then_part) hawk_clrpt (awk, then_part); - if (test) hawk_clrpt (awk, test); + if (else_part) hawk_clrpt (hawk, else_part); + if (then_part) hawk_clrpt (hawk, then_part); + if (test) hawk_clrpt (hawk, test); return HAWK_NULL; } -static hawk_nde_t* parse_while (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_while (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* test = HAWK_NULL; hawk_nde_t* body = HAWK_NULL; hawk_nde_while_t* nde; hawk_loc_t ploc; - if (!MATCH(awk,TOK_LPAREN)) + if (!MATCH(hawk,TOK_LPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - ploc = awk->tok.loc; - test = parse_expr_withdc (awk, &ploc); + ploc = hawk->tok.loc; + test = parse_expr_withdc (hawk, &ploc); if (test == HAWK_NULL) goto oops; - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - ploc = awk->tok.loc; - body = parse_statement (awk, &ploc); + ploc = hawk->tok.loc; + body = parse_statement (hawk, &ploc); if (body == HAWK_NULL) goto oops; - nde = (hawk_nde_while_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_while_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -2607,12 +2607,12 @@ static hawk_nde_t* parse_while (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; oops: - if (body) hawk_clrpt (awk, body); - if (test) hawk_clrpt (awk, test); + if (body) hawk_clrpt (hawk, body); + if (test) hawk_clrpt (hawk, test); return HAWK_NULL; } -static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_for (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* init = HAWK_NULL, * test = HAWK_NULL; hawk_nde_t* incr = HAWK_NULL, * body = HAWK_NULL; @@ -2620,22 +2620,22 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) hawk_nde_forin_t* nde_forin; hawk_loc_t ploc; - if (!MATCH(awk,TOK_LPAREN)) + if (!MATCH(hawk,TOK_LPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - if (!MATCH(awk,TOK_SEMICOLON)) + if (!MATCH(hawk,TOK_SEMICOLON)) { /* this line is very ugly. it checks the entire next * expression or the first element in the expression * is wrapped by a parenthesis */ - int no_forin = MATCH(awk,TOK_LPAREN); + int no_forin = MATCH(hawk,TOK_LPAREN); - ploc = awk->tok.loc; - init = parse_expr_withdc(awk, &ploc); + ploc = hawk->tok.loc; + init = parse_expr_withdc(hawk, &ploc); if (HAWK_UNLIKELY(!init)) goto oops; if (!no_forin && init->type == HAWK_NDE_EXP_BIN && @@ -2648,22 +2648,22 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) { /* switch to forin - for (x in y) */ - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - ploc = awk->tok.loc; - body = parse_statement(awk, &ploc); + ploc = hawk->tok.loc; + body = parse_statement(hawk, &ploc); if (HAWK_UNLIKELY(!body)) goto oops; - nde_forin = (hawk_nde_forin_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde_forin)); + nde_forin = (hawk_nde_forin_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde_forin)); if (HAWK_UNLIKELY(!nde_forin)) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -2675,67 +2675,67 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde_forin; } - if (!MATCH(awk,TOK_SEMICOLON)) + if (!MATCH(hawk,TOK_SEMICOLON)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } } do { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* skip new lines after the first semicolon */ } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); - if (!MATCH(awk,TOK_SEMICOLON)) + if (!MATCH(hawk,TOK_SEMICOLON)) { - ploc = awk->tok.loc; - test = parse_expr_withdc (awk, &ploc); + ploc = hawk->tok.loc; + test = parse_expr_withdc (hawk, &ploc); if (test == HAWK_NULL) goto oops; - if (!MATCH(awk,TOK_SEMICOLON)) + if (!MATCH(hawk,TOK_SEMICOLON)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } } do { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* skip new lines after the second semicolon */ } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { { hawk_loc_t eloc; - eloc = awk->tok.loc; - incr = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + incr = parse_expr_withdc (hawk, &eloc); if (incr == HAWK_NULL) goto oops; } - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - ploc = awk->tok.loc; - body = parse_statement (awk, &ploc); + ploc = hawk->tok.loc; + body = parse_statement (hawk, &ploc); if (body == HAWK_NULL) goto oops; - nde_for = (hawk_nde_for_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde_for)); + nde_for = (hawk_nde_for_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde_for)); if (nde_for == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -2749,63 +2749,63 @@ static hawk_nde_t* parse_for (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde_for; oops: - if (init) hawk_clrpt (awk, init); - if (test) hawk_clrpt (awk, test); - if (incr) hawk_clrpt (awk, incr); - if (body) hawk_clrpt (awk, body); + if (init) hawk_clrpt (hawk, init); + if (test) hawk_clrpt (hawk, test); + if (incr) hawk_clrpt (hawk, incr); + if (body) hawk_clrpt (hawk, body); return HAWK_NULL; } -static hawk_nde_t* parse_dowhile (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_dowhile (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* test = HAWK_NULL; hawk_nde_t* body = HAWK_NULL; hawk_nde_while_t* nde; hawk_loc_t ploc; - HAWK_ASSERT (awk->ptok.type == TOK_DO); + HAWK_ASSERT (hawk->ptok.type == TOK_DO); - ploc = awk->tok.loc; - body = parse_statement (awk, &ploc); + ploc = hawk->tok.loc; + body = parse_statement (hawk, &ploc); if (body == HAWK_NULL) goto oops; - while (MATCH(awk,TOK_NEWLINE)) + while (MATCH(hawk,TOK_NEWLINE)) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - if (!MATCH(awk,TOK_WHILE)) + if (!MATCH(hawk,TOK_WHILE)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWWHL, FMT_EKWWHL, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EKWWHL, FMT_EKWWHL, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - if (!MATCH(awk,TOK_LPAREN)) + if (!MATCH(hawk,TOK_LPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - ploc = awk->tok.loc; - test = parse_expr_withdc (awk, &ploc); + ploc = hawk->tok.loc; + test = parse_expr_withdc (hawk, &ploc); if (test == HAWK_NULL) goto oops; - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - nde = (hawk_nde_while_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_while_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -2817,27 +2817,27 @@ static hawk_nde_t* parse_dowhile (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; oops: - if (body) hawk_clrpt (awk, body); - if (test) hawk_clrpt (awk, test); + if (body) hawk_clrpt (hawk, body); + if (test) hawk_clrpt (hawk, test); HAWK_ASSERT (nde == HAWK_NULL); return HAWK_NULL; } -static hawk_nde_t* parse_break (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_break (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_break_t* nde; - HAWK_ASSERT (awk->ptok.type == TOK_BREAK); - if (awk->parse.depth.loop <= 0) + HAWK_ASSERT (hawk->ptok.type == TOK_BREAK); + if (hawk->parse.depth.loop <= 0) { - hawk_seterrnum (awk, xloc, HAWK_EBREAK); + hawk_seterrnum (hawk, xloc, HAWK_EBREAK); return HAWK_NULL; } - nde = (hawk_nde_break_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_break_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -2847,21 +2847,21 @@ static hawk_nde_t* parse_break (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; } -static hawk_nde_t* parse_continue (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_continue (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_continue_t* nde; - HAWK_ASSERT (awk->ptok.type == TOK_CONTINUE); - if (awk->parse.depth.loop <= 0) + HAWK_ASSERT (hawk->ptok.type == TOK_CONTINUE); + if (hawk->parse.depth.loop <= 0) { - hawk_seterrnum (awk, xloc, HAWK_ECONTINUE); + hawk_seterrnum (hawk, xloc, HAWK_ECONTINUE); return HAWK_NULL; } - nde = (hawk_nde_continue_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_continue_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -2871,24 +2871,24 @@ static hawk_nde_t* parse_continue (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; } -static hawk_nde_t* parse_return (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_return (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_return_t* nde; hawk_nde_t* val; - HAWK_ASSERT (awk->ptok.type == TOK_RETURN); + HAWK_ASSERT (hawk->ptok.type == TOK_RETURN); - nde = (hawk_nde_return_t*) hawk_callocmem ( awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_return_t*) hawk_callocmem ( hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } nde->type = HAWK_NDE_RETURN; nde->loc = *xloc; - if (MATCH_TERMINATOR(awk)) + if (MATCH_TERMINATOR(hawk)) { /* no return value */ val = HAWK_NULL; @@ -2897,11 +2897,11 @@ static hawk_nde_t* parse_return (hawk_t* awk, const hawk_loc_t* xloc) { hawk_loc_t eloc; - eloc = awk->tok.loc; - val = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + val = parse_expr_withdc (hawk, &eloc); if (val == HAWK_NULL) { - hawk_freemem (awk, nde); + hawk_freemem (hawk, nde); return HAWK_NULL; } } @@ -2910,25 +2910,25 @@ static hawk_nde_t* parse_return (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; } -static hawk_nde_t* parse_exit (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_exit (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_exit_t* nde; hawk_nde_t* val; - HAWK_ASSERT (awk->ptok.type == TOK_EXIT || awk->ptok.type == TOK_XABORT); + HAWK_ASSERT (hawk->ptok.type == TOK_EXIT || hawk->ptok.type == TOK_XABORT); - nde = (hawk_nde_exit_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_exit_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } nde->type = HAWK_NDE_EXIT; nde->loc = *xloc; - nde->abort = (awk->ptok.type == TOK_XABORT); + nde->abort = (hawk->ptok.type == TOK_XABORT); - if (MATCH_TERMINATOR(awk)) + if (MATCH_TERMINATOR(hawk)) { /* no exit code */ val = HAWK_NULL; @@ -2937,11 +2937,11 @@ static hawk_nde_t* parse_exit (hawk_t* awk, const hawk_loc_t* xloc) { hawk_loc_t eloc; - eloc = awk->tok.loc; - val = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + val = parse_expr_withdc (hawk, &eloc); if (val == HAWK_NULL) { - hawk_freemem (awk, nde); + hawk_freemem (hawk, nde); return HAWK_NULL; } } @@ -2950,27 +2950,27 @@ static hawk_nde_t* parse_exit (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; } -static hawk_nde_t* parse_next (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_next (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_next_t* nde; - HAWK_ASSERT (awk->ptok.type == TOK_NEXT); + HAWK_ASSERT (hawk->ptok.type == TOK_NEXT); - if (awk->parse.id.block == PARSE_BEGIN_BLOCK) + if (hawk->parse.id.block == PARSE_BEGIN_BLOCK) { - hawk_seterrnum (awk, xloc, HAWK_ENEXTBEG); + hawk_seterrnum (hawk, xloc, HAWK_ENEXTBEG); return HAWK_NULL; } - if (awk->parse.id.block == PARSE_END_BLOCK) + if (hawk->parse.id.block == PARSE_END_BLOCK) { - hawk_seterrnum (awk, xloc, HAWK_ENEXTEND); + hawk_seterrnum (hawk, xloc, HAWK_ENEXTEND); return HAWK_NULL; } - nde = (hawk_nde_next_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_next_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } nde->type = HAWK_NDE_NEXT; @@ -2980,25 +2980,25 @@ static hawk_nde_t* parse_next (hawk_t* awk, const hawk_loc_t* xloc) } static hawk_nde_t* parse_nextfile ( - hawk_t* awk, const hawk_loc_t* xloc, int out) + hawk_t* hawk, const hawk_loc_t* xloc, int out) { hawk_nde_nextfile_t* nde; - if (!out && awk->parse.id.block == PARSE_BEGIN_BLOCK) + if (!out && hawk->parse.id.block == PARSE_BEGIN_BLOCK) { - hawk_seterrnum (awk, xloc, HAWK_ENEXTFBEG); + hawk_seterrnum (hawk, xloc, HAWK_ENEXTFBEG); return HAWK_NULL; } - if (!out && awk->parse.id.block == PARSE_END_BLOCK) + if (!out && hawk->parse.id.block == PARSE_END_BLOCK) { - hawk_seterrnum (awk, xloc, HAWK_ENEXTFEND); + hawk_seterrnum (hawk, xloc, HAWK_ENEXTFEND); return HAWK_NULL; } - nde = (hawk_nde_nextfile_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_nextfile_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -3009,7 +3009,7 @@ static hawk_nde_t* parse_nextfile ( return (hawk_nde_t*)nde; } -static hawk_nde_t* parse_delete (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_delete (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_delete_t* nde; hawk_nde_t* var = HAWK_NULL; @@ -3017,50 +3017,50 @@ static hawk_nde_t* parse_delete (hawk_t* awk, const hawk_loc_t* xloc) hawk_nde_type_t type; int inparen = 0; - HAWK_ASSERT (awk->ptok.type == TOK_DELETE || - awk->ptok.type == TOK_XRESET); + HAWK_ASSERT (hawk->ptok.type == TOK_DELETE || + hawk->ptok.type == TOK_XRESET); - type = (awk->ptok.type == TOK_DELETE)? + type = (hawk->ptok.type == TOK_DELETE)? HAWK_NDE_DELETE: HAWK_NDE_RESET; - if (MATCH(awk,TOK_LPAREN)) + if (MATCH(hawk,TOK_LPAREN)) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; inparen = 1; } - if (!MATCH(awk,TOK_IDENT)) + if (!MATCH(hawk,TOK_IDENT)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EIDENT, FMT_EIDENT, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EIDENT, FMT_EIDENT, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - dloc = awk->tok.loc; - var = parse_primary_ident (awk, &dloc); + dloc = hawk->tok.loc; + var = parse_primary_ident (hawk, &dloc); if (var == HAWK_NULL) goto oops; if ((type == HAWK_NDE_DELETE && !is_var(var)) || (type == HAWK_NDE_RESET && !is_plain_var(var))) { - hawk_seterrnum (awk, &dloc, HAWK_EBADARG); + hawk_seterrnum (hawk, &dloc, HAWK_EBADARG); goto oops; } if (inparen) { - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - nde = (hawk_nde_delete_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_delete_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -3071,11 +3071,11 @@ static hawk_nde_t* parse_delete (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; oops: - if (var) hawk_clrpt (awk, var); + if (var) hawk_clrpt (hawk, var); return HAWK_NULL; } -static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_print (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_print_t* nde; hawk_nde_t* args = HAWK_NULL; @@ -3084,17 +3084,17 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) hawk_nde_type_t type; hawk_loc_t eloc; - HAWK_ASSERT (awk->ptok.type == TOK_PRINT || - awk->ptok.type == TOK_PRINTF); + HAWK_ASSERT (hawk->ptok.type == TOK_PRINT || + hawk->ptok.type == TOK_PRINTF); - type = (awk->ptok.type == TOK_PRINT)? + type = (hawk->ptok.type == TOK_PRINT)? HAWK_NDE_PRINT: HAWK_NDE_PRINTF; - if (!MATCH_TERMINATOR(awk) && - !MATCH(awk,TOK_GT) && - !MATCH(awk,TOK_RS) && - !MATCH(awk,TOK_BOR) && - !MATCH(awk,TOK_LOR)) + if (!MATCH_TERMINATOR(hawk) && + !MATCH(hawk,TOK_GT) && + !MATCH(hawk,TOK_RS) && + !MATCH(hawk,TOK_BOR) && + !MATCH(hawk,TOK_LOR)) { hawk_nde_t* args_tail; hawk_nde_t* tail_prev; @@ -3102,12 +3102,12 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) int in_parens = 0, gm_in_parens = 0; hawk_oow_t opening_lparen_seq; - if (MATCH(awk,TOK_LPAREN)) + if (MATCH(hawk,TOK_LPAREN)) { /* just remember the sequence number of the left * parenthesis before calling parse_expr_withdc() * that eventually calls parse_primary_lparen() */ - opening_lparen_seq = awk->parse.lparen_seq; + opening_lparen_seq = hawk->parse.lparen_seq; in_parens = 1; /* maybe. not confirmed yet */ /* print and printf provide weird syntaxs. @@ -3122,8 +3122,8 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) */ } - eloc = awk->tok.loc; - args = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + args = parse_expr_withdc (hawk, &eloc); if (args == HAWK_NULL) goto oops; args_tail = args; @@ -3135,13 +3135,13 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) * args->type != HAWK_NDE_GRP when print a, b, c */ hawk_oow_t group_opening_lparen_seq; - while (MATCH(awk,TOK_COMMA)) + while (MATCH(hawk,TOK_COMMA)) { do { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); /* if it's grouped, i must check if the last group member * is enclosed in parentheses. @@ -3149,21 +3149,21 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) * i set the condition to false whenever i see * a new group member. */ gm_in_parens = 0; - if (MATCH(awk,TOK_LPAREN)) + if (MATCH(hawk,TOK_LPAREN)) { - group_opening_lparen_seq = awk->parse.lparen_seq; + group_opening_lparen_seq = hawk->parse.lparen_seq; gm_in_parens = 1; /* maybe */ } - eloc = awk->tok.loc; - args_tail->next = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + args_tail->next = parse_expr_withdc (hawk, &eloc); if (args_tail->next == HAWK_NULL) goto oops; tail_prev = args_tail; args_tail = args_tail->next; - if (gm_in_parens == 1 && awk->ptok.type == TOK_RPAREN && - awk->parse.lparen_last_closed == group_opening_lparen_seq) + if (gm_in_parens == 1 && hawk->ptok.type == TOK_RPAREN && + hawk->parse.lparen_last_closed == group_opening_lparen_seq) { /* confirm that the last group seen so far * is parenthesized */ @@ -3190,8 +3190,8 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) * print 1, 2, (3 > 4) > 5; * print 1, 2, (3 > 4) > 5 + 6; */ - if (in_parens == 1 && awk->ptok.type == TOK_RPAREN && - awk->parse.lparen_last_closed == opening_lparen_seq) + if (in_parens == 1 && hawk->ptok.type == TOK_RPAREN && + hawk->parse.lparen_last_closed == opening_lparen_seq) { in_parens = 2; /* confirmed */ } @@ -3235,7 +3235,7 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) { hawk_nde_t* tmp; - if (tab[i].opt && !(awk->opt.trait & tab[i].opt)) break; + if (tab[i].opt && !(hawk->opt.trait & tab[i].opt)) break; tmp = args_tail; @@ -3246,7 +3246,7 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) out = ep->right; out_type = tab[i].out; - hawk_freemem (awk, tmp); + hawk_freemem (hawk, tmp); break; } } @@ -3255,33 +3255,33 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) if (!out) { - out_type = MATCH(awk,TOK_GT)? HAWK_OUT_FILE: - MATCH(awk,TOK_RS)? HAWK_OUT_APFILE: - MATCH(awk,TOK_BOR)? HAWK_OUT_PIPE: - ((awk->opt.trait & HAWK_RWPIPE) && - MATCH(awk,TOK_LOR))? HAWK_OUT_RWPIPE: + out_type = MATCH(hawk,TOK_GT)? HAWK_OUT_FILE: + MATCH(hawk,TOK_RS)? HAWK_OUT_APFILE: + MATCH(hawk,TOK_BOR)? HAWK_OUT_PIPE: + ((hawk->opt.trait & HAWK_RWPIPE) && + MATCH(hawk,TOK_LOR))? HAWK_OUT_RWPIPE: HAWK_OUT_CONSOLE; if (out_type != HAWK_OUT_CONSOLE) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - eloc = awk->tok.loc; - out = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + out = parse_expr_withdc (hawk, &eloc); if (out == HAWK_NULL) goto oops; } } if (type == HAWK_NDE_PRINTF && !args) { - hawk_seterrnum (awk, xloc, HAWK_ENOARG); + hawk_seterrnum (hawk, xloc, HAWK_ENOARG); goto oops; } - nde = (hawk_nde_print_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_print_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -3294,154 +3294,154 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; oops: - if (args) hawk_clrpt (awk, args); - if (out) hawk_clrpt (awk, out); + if (args) hawk_clrpt (hawk, args); + if (out) hawk_clrpt (hawk, out); return HAWK_NULL; } static hawk_nde_t* parse_statement_nb ( - hawk_t* awk, const hawk_loc_t* xloc) + hawk_t* hawk, const hawk_loc_t* xloc) { /* parse a non-block statement */ hawk_nde_t* nde; /* keywords that don't require any terminating semicolon */ - if (MATCH(awk,TOK_IF)) + if (MATCH(hawk,TOK_IF)) { - if (get_token(awk) <= -1) return HAWK_NULL; - return parse_if (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + return parse_if (hawk, xloc); } - else if (MATCH(awk,TOK_WHILE)) + else if (MATCH(hawk,TOK_WHILE)) { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - awk->parse.depth.loop++; - nde = parse_while (awk, xloc); - awk->parse.depth.loop--; + hawk->parse.depth.loop++; + nde = parse_while (hawk, xloc); + hawk->parse.depth.loop--; return nde; } - else if (MATCH(awk,TOK_FOR)) + else if (MATCH(hawk,TOK_FOR)) { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - awk->parse.depth.loop++; - nde = parse_for (awk, xloc); - awk->parse.depth.loop--; + hawk->parse.depth.loop++; + nde = parse_for (hawk, xloc); + hawk->parse.depth.loop--; return nde; } /* keywords that require a terminating semicolon */ - if (MATCH(awk,TOK_DO)) + if (MATCH(hawk,TOK_DO)) { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - awk->parse.depth.loop++; - nde = parse_dowhile (awk, xloc); - awk->parse.depth.loop--; + hawk->parse.depth.loop++; + nde = parse_dowhile (hawk, xloc); + hawk->parse.depth.loop--; return nde; } - else if (MATCH(awk,TOK_BREAK)) + else if (MATCH(hawk,TOK_BREAK)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_break (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_break (hawk, xloc); } - else if (MATCH(awk,TOK_CONTINUE)) + else if (MATCH(hawk,TOK_CONTINUE)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_continue (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_continue (hawk, xloc); } - else if (MATCH(awk,TOK_RETURN)) + else if (MATCH(hawk,TOK_RETURN)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_return (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_return (hawk, xloc); } - else if (MATCH(awk,TOK_EXIT) || MATCH(awk,TOK_XABORT)) + else if (MATCH(hawk,TOK_EXIT) || MATCH(hawk,TOK_XABORT)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_exit (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_exit (hawk, xloc); } - else if (MATCH(awk,TOK_NEXT)) + else if (MATCH(hawk,TOK_NEXT)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_next (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_next (hawk, xloc); } - else if (MATCH(awk,TOK_NEXTFILE)) + else if (MATCH(hawk,TOK_NEXTFILE)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_nextfile (awk, xloc, 0); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_nextfile (hawk, xloc, 0); } - else if (MATCH(awk,TOK_NEXTOFILE)) + else if (MATCH(hawk,TOK_NEXTOFILE)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_nextfile (awk, xloc, 1); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_nextfile (hawk, xloc, 1); } - else if (MATCH(awk,TOK_DELETE) || MATCH(awk,TOK_XRESET)) + else if (MATCH(hawk,TOK_DELETE) || MATCH(hawk,TOK_XRESET)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_delete (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_delete (hawk, xloc); } - else if (!(awk->opt.trait & HAWK_TOLERANT)) + else if (!(hawk->opt.trait & HAWK_TOLERANT)) { /* in the non-tolerant mode, we treat print and printf * as a separate statement */ - if (MATCH(awk,TOK_PRINT) || MATCH(awk,TOK_PRINTF)) + if (MATCH(hawk,TOK_PRINT) || MATCH(hawk,TOK_PRINTF)) { - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_print (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_print (hawk, xloc); } - else nde = parse_expr_withdc (awk, xloc); + else nde = parse_expr_withdc (hawk, xloc); } else { - nde = parse_expr_withdc (awk, xloc); + nde = parse_expr_withdc (hawk, xloc); } if (nde == HAWK_NULL) return HAWK_NULL; - if (MATCH_TERMINATOR_NORMAL(awk)) + if (MATCH_TERMINATOR_NORMAL(hawk)) { /* check if a statement ends with a semicolon or */ - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - if (nde != HAWK_NULL) hawk_clrpt (awk, nde); + if (nde != HAWK_NULL) hawk_clrpt (hawk, nde); return HAWK_NULL; } } - else if (MATCH_TERMINATOR_RBRACE(awk)) + else if (MATCH_TERMINATOR_RBRACE(hawk)) { /* do not skip the right brace as a statement terminator. * is there anything to do here? */ } else { - if (nde != HAWK_NULL) hawk_clrpt (awk, nde); - hawk_seterrnum (awk, &awk->ptok.loc, HAWK_ESTMEND); + if (nde != HAWK_NULL) hawk_clrpt (hawk, nde); + hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_ESTMEND); return HAWK_NULL; } return nde; } -static hawk_nde_t* parse_statement (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_statement (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* nde; /* skip new lines before a statement */ - while (MATCH(awk,TOK_NEWLINE)) + while (MATCH(hawk,TOK_NEWLINE)) { - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; } - if (MATCH(awk,TOK_SEMICOLON)) + if (MATCH(hawk,TOK_SEMICOLON)) { /* null statement */ - nde = (hawk_nde_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (!nde) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -3449,24 +3449,24 @@ static hawk_nde_t* parse_statement (hawk_t* awk, const hawk_loc_t* xloc) nde->loc = *xloc; nde->next = HAWK_NULL; - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_freemem (awk, nde); + hawk_freemem (hawk, nde); return HAWK_NULL; } } - else if (MATCH(awk,TOK_LBRACE)) + else if (MATCH(hawk,TOK_LBRACE)) { /* a block statemnt { ... } */ hawk_loc_t tloc; - tloc = awk->ptok.loc; - if (get_token(awk) <= -1) return HAWK_NULL; - nde = parse_block_dc (awk, &tloc, 0); + tloc = hawk->ptok.loc; + if (get_token(hawk) <= -1) return HAWK_NULL; + nde = parse_block_dc (hawk, &tloc, 0); } else { - /* the statement id held in awk->parse.id.stmt denotes + /* the statement id held in hawk->parse.id.stmt denotes * the token id of the statement currently being parsed. * the current statement id is saved here because the * statement id can be changed in parse_statement_nb. @@ -3475,23 +3475,23 @@ static hawk_nde_t* parse_statement (hawk_t* awk, const hawk_loc_t* xloc) int old_id; hawk_loc_t tloc; - old_id = awk->parse.id.stmt; - tloc = awk->tok.loc; + old_id = hawk->parse.id.stmt; + tloc = hawk->tok.loc; /* set the current statement id */ - awk->parse.id.stmt = awk->tok.type; + hawk->parse.id.stmt = hawk->tok.type; /* proceed parsing the statement */ - nde = parse_statement_nb (awk, &tloc); + nde = parse_statement_nb (hawk, &tloc); /* restore the statement id saved previously */ - awk->parse.id.stmt = old_id; + hawk->parse.id.stmt = old_id; } return nde; } -static int assign_to_opcode (hawk_t* awk) +static int assign_to_opcode (hawk_t* hawk) { /* synchronize it with hawk_assop_type_t in run.h */ static int assop[] = @@ -3512,72 +3512,72 @@ static int assign_to_opcode (hawk_t* awk) HAWK_ASSOP_BOR }; - if (awk->tok.type >= TOK_ASSN && - awk->tok.type <= TOK_BOR_ASSN) + if (hawk->tok.type >= TOK_ASSN && + hawk->tok.type <= TOK_BOR_ASSN) { - return assop[awk->tok.type - TOK_ASSN]; + return assop[hawk->tok.type - TOK_ASSN]; } return -1; } -static hawk_nde_t* parse_expr_basic (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_expr_basic (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* nde, * n1, * n2; - nde = parse_logical_or (awk, xloc); + nde = parse_logical_or (hawk, xloc); if (nde == HAWK_NULL) return HAWK_NULL; - if (MATCH(awk,TOK_QUEST)) - if (MATCH(awk,TOK_QUEST)) + if (MATCH(hawk,TOK_QUEST)) + if (MATCH(hawk,TOK_QUEST)) { hawk_loc_t eloc; hawk_nde_cnd_t* cnd; - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_clrpt (awk, nde); + hawk_clrpt (hawk, nde); return HAWK_NULL; } - eloc = awk->tok.loc; - n1 = parse_expr_withdc(awk, &eloc); + eloc = hawk->tok.loc; + n1 = parse_expr_withdc(hawk, &eloc); if (n1 == HAWK_NULL) { - hawk_clrpt (awk, nde); + hawk_clrpt (hawk, nde); return HAWK_NULL; } - if (!MATCH(awk,TOK_COLON)) + if (!MATCH(hawk,TOK_COLON)) { - hawk_clrpt (awk, nde); - hawk_clrpt (awk, n1); - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOLON, FMT_ECOLON, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_clrpt (hawk, nde); + hawk_clrpt (hawk, n1); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ECOLON, FMT_ECOLON, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_clrpt (awk, nde); - hawk_clrpt (awk, n1); + hawk_clrpt (hawk, nde); + hawk_clrpt (hawk, n1); return HAWK_NULL; } - eloc = awk->tok.loc; - n2 = parse_expr_withdc(awk, &eloc); + eloc = hawk->tok.loc; + n2 = parse_expr_withdc(hawk, &eloc); if (n2 == HAWK_NULL) { - hawk_clrpt (awk, nde); - hawk_clrpt (awk, n1); + hawk_clrpt (hawk, nde); + hawk_clrpt (hawk, n1); return HAWK_NULL; } - cnd = (hawk_nde_cnd_t*)hawk_callocmem(awk, HAWK_SIZEOF(*cnd)); + cnd = (hawk_nde_cnd_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*cnd)); if (cnd == HAWK_NULL) { - hawk_clrpt (awk, nde); - hawk_clrpt (awk, n1); - hawk_clrpt (awk, n2); - ADJERR_LOC (awk, xloc); + hawk_clrpt (hawk, nde); + hawk_clrpt (hawk, n1); + hawk_clrpt (hawk, n2); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -3594,16 +3594,16 @@ static hawk_nde_t* parse_expr_basic (hawk_t* awk, const hawk_loc_t* xloc) return nde; } -static hawk_nde_t* parse_expr (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_expr (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* x, * y; hawk_nde_ass_t* nde; int opcode; - x = parse_expr_basic (awk, xloc); + x = parse_expr_basic (hawk, xloc); if (x == HAWK_NULL) return HAWK_NULL; - opcode = assign_to_opcode (awk); + opcode = assign_to_opcode (hawk); if (opcode <= -1) { /* no assignment operator found. */ @@ -3613,34 +3613,34 @@ static hawk_nde_t* parse_expr (hawk_t* awk, const hawk_loc_t* xloc) HAWK_ASSERT (x->next == HAWK_NULL); if (!is_var(x) && x->type != HAWK_NDE_POS) { - hawk_clrpt (awk, x); - hawk_seterrnum (awk, xloc, HAWK_EASSIGN); + hawk_clrpt (hawk, x); + hawk_seterrnum (hawk, xloc, HAWK_EASSIGN); return HAWK_NULL; } - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_clrpt (awk, x); + hawk_clrpt (hawk, x); return HAWK_NULL; } { hawk_loc_t eloc; - eloc = awk->tok.loc; - y = parse_expr_withdc (awk, &eloc); + eloc = hawk->tok.loc; + y = parse_expr_withdc (hawk, &eloc); } if (y == HAWK_NULL) { - hawk_clrpt (awk, x); + hawk_clrpt (hawk, x); return HAWK_NULL; } - nde = (hawk_nde_ass_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_ass_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - hawk_clrpt (awk, x); - hawk_clrpt (awk, y); - ADJERR_LOC (awk, xloc); + hawk_clrpt (hawk, x); + hawk_clrpt (hawk, y); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -3654,22 +3654,22 @@ static hawk_nde_t* parse_expr (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; } -static hawk_nde_t* parse_expr_withdc (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_expr_withdc (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* nde; /* perform depth check before parsing expression */ - if (awk->opt.depth.s.expr_parse > 0 && - awk->parse.depth.expr >= awk->opt.depth.s.expr_parse) + if (hawk->opt.depth.s.expr_parse > 0 && + hawk->parse.depth.expr >= hawk->opt.depth.s.expr_parse) { - hawk_seterrnum (awk, xloc, HAWK_EEXPRNST); + hawk_seterrnum (hawk, xloc, HAWK_EEXPRNST); return HAWK_NULL; } - awk->parse.depth.expr++; - nde = parse_expr(awk, xloc); - awk->parse.depth.expr--; + hawk->parse.depth.expr++; + nde = parse_expr(hawk, xloc); + hawk->parse.depth.expr--; return nde; } @@ -3694,7 +3694,7 @@ union folded_t typedef union folded_t folded_t; static int fold_constants_for_binop ( - hawk_t* awk, hawk_nde_t* left, hawk_nde_t* right, + hawk_t* hawk, hawk_nde_t* left, hawk_nde_t* right, int opcode, folded_t* folded) { int fold = -1; @@ -3722,7 +3722,7 @@ static int fold_constants_for_binop ( case HAWK_BINOP_DIV: if (((hawk_nde_int_t*)right)->val == 0) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EDIVBY0); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EDIVBY0); fold = -2; /* error */ } else if (INT_BINOP_INT(left,%,right)) @@ -3740,7 +3740,7 @@ static int fold_constants_for_binop ( case HAWK_BINOP_IDIV: if (((hawk_nde_int_t*)right)->val == 0) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EDIVBY0); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EDIVBY0); fold = -2; /* error */ } else @@ -3785,8 +3785,8 @@ static int fold_constants_for_binop ( break; case HAWK_BINOP_MOD: - folded->r = awk->prm.math.mod( - awk, + folded->r = hawk->prm.math.mod( + hawk, ((hawk_nde_flt_t*)left)->val, ((hawk_nde_flt_t*)right)->val ); @@ -3826,8 +3826,8 @@ static int fold_constants_for_binop ( break; case HAWK_BINOP_MOD: - folded->r = awk->prm.math.mod( - awk, + folded->r = hawk->prm.math.mod( + hawk, (hawk_flt_t)((hawk_nde_int_t*)left)->val, ((hawk_nde_flt_t*)right)->val ); @@ -3867,8 +3867,8 @@ static int fold_constants_for_binop ( break; case HAWK_BINOP_MOD: - folded->r = awk->prm.math.mod( - awk, + folded->r = hawk->prm.math.mod( + hawk, ((hawk_nde_flt_t*)left)->val, (hawk_flt_t)((hawk_nde_int_t*)right)->val ); @@ -3884,12 +3884,12 @@ static int fold_constants_for_binop ( } static hawk_nde_t* new_exp_bin_node ( - hawk_t* awk, const hawk_loc_t* loc, + hawk_t* hawk, const hawk_loc_t* loc, int opcode, hawk_nde_t* left, hawk_nde_t* right) { hawk_nde_exp_t* tmp; - tmp = (hawk_nde_exp_t*) hawk_callocmem (awk, HAWK_SIZEOF(*tmp)); + tmp = (hawk_nde_exp_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*tmp)); if (tmp) { tmp->type = HAWK_NDE_EXP_BIN; @@ -3898,7 +3898,7 @@ static hawk_nde_t* new_exp_bin_node ( tmp->left = left; tmp->right = right; } - else ADJERR_LOC (awk, loc); + else ADJERR_LOC (hawk, loc); return (hawk_nde_t*)tmp; } @@ -3958,7 +3958,7 @@ static HAWK_INLINE void update_flt_node (hawk_t* hawk, hawk_nde_flt_t* node, haw } static hawk_nde_t* parse_binary ( - hawk_t* awk, const hawk_loc_t* xloc, + hawk_t* hawk, const hawk_loc_t* xloc, int skipnl, const binmap_t* binmap, hawk_nde_t*(*next_level_func)(hawk_t*,const hawk_loc_t*)) { @@ -3966,7 +3966,7 @@ static hawk_nde_t* parse_binary ( hawk_nde_t* right = HAWK_NULL; hawk_loc_t rloc; - left = next_level_func(awk, xloc); + left = next_level_func(hawk, xloc); if (HAWK_UNLIKELY(!left)) goto oops; do @@ -3978,7 +3978,7 @@ static hawk_nde_t* parse_binary ( while (p->token != TOK_EOF) { - if (MATCH(awk,p->token)) + if (MATCH(hawk,p->token)) { opcode = p->binop; matched = 1; @@ -3990,37 +3990,37 @@ static hawk_nde_t* parse_binary ( do { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - while (skipnl && MATCH(awk,TOK_NEWLINE)); + while (skipnl && MATCH(hawk,TOK_NEWLINE)); - rloc = awk->tok.loc; - right = next_level_func (awk, &rloc); + rloc = hawk->tok.loc; + right = next_level_func (hawk, &rloc); if (right == HAWK_NULL) goto oops; - fold = fold_constants_for_binop (awk, left, right, opcode, &folded); + fold = fold_constants_for_binop (hawk, left, right, opcode, &folded); switch (fold) { case HAWK_NDE_INT: if (fold == left->type) { - hawk_clrpt (awk, right); + hawk_clrpt (hawk, right); right = HAWK_NULL; - update_int_node (awk, (hawk_nde_int_t*)left, folded.l); + update_int_node (hawk, (hawk_nde_int_t*)left, folded.l); } else if (fold == right->type) { - hawk_clrpt (awk, left); - update_int_node (awk, (hawk_nde_int_t*)right, folded.l); + hawk_clrpt (hawk, left); + update_int_node (hawk, (hawk_nde_int_t*)right, folded.l); left = right; right = HAWK_NULL; } else { - hawk_clrpt (awk, right); right = HAWK_NULL; - hawk_clrpt (awk, left); left = HAWK_NULL; + hawk_clrpt (hawk, right); right = HAWK_NULL; + hawk_clrpt (hawk, left); left = HAWK_NULL; - left = new_int_node (awk, folded.l, xloc); + left = new_int_node (hawk, folded.l, xloc); if (left == HAWK_NULL) goto oops; } @@ -4029,23 +4029,23 @@ static hawk_nde_t* parse_binary ( case HAWK_NDE_FLT: if (fold == left->type) { - hawk_clrpt (awk, right); + hawk_clrpt (hawk, right); right = HAWK_NULL; - update_flt_node (awk, (hawk_nde_flt_t*)left, folded.r); + update_flt_node (hawk, (hawk_nde_flt_t*)left, folded.r); } else if (fold == right->type) { - hawk_clrpt (awk, left); - update_flt_node (awk, (hawk_nde_flt_t*)right, folded.r); + hawk_clrpt (hawk, left); + update_flt_node (hawk, (hawk_nde_flt_t*)right, folded.r); left = right; right = HAWK_NULL; } else { - hawk_clrpt (awk, right); right = HAWK_NULL; - hawk_clrpt (awk, left); left = HAWK_NULL; + hawk_clrpt (hawk, right); right = HAWK_NULL; + hawk_clrpt (hawk, left); left = HAWK_NULL; - left = new_flt_node (awk, folded.r, xloc); + left = new_flt_node (hawk, folded.r, xloc); if (left == HAWK_NULL) goto oops; } @@ -4058,7 +4058,7 @@ static hawk_nde_t* parse_binary ( { hawk_nde_t* tmp; - tmp = new_exp_bin_node (awk, xloc, opcode, left, right); + tmp = new_exp_bin_node (hawk, xloc, opcode, left, right); if (tmp == HAWK_NULL) goto oops; left = tmp; right = HAWK_NULL; break; @@ -4070,12 +4070,12 @@ static hawk_nde_t* parse_binary ( return left; oops: - if (right) hawk_clrpt (awk, right); - if (left) hawk_clrpt (awk, left); + if (right) hawk_clrpt (hawk, right); + if (left) hawk_clrpt (hawk, left); return HAWK_NULL; } -static hawk_nde_t* parse_logical_or (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_logical_or (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4083,10 +4083,10 @@ static hawk_nde_t* parse_logical_or (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 1, map, parse_logical_and); + return parse_binary (hawk, xloc, 1, map, parse_logical_and); } -static hawk_nde_t* parse_logical_and (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_logical_and (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4094,10 +4094,10 @@ static hawk_nde_t* parse_logical_and (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 1, map, parse_in); + return parse_binary (hawk, xloc, 1, map, parse_in); } -static hawk_nde_t* parse_in (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_in (hawk_t* hawk, const hawk_loc_t* xloc) { /* static binmap_t map[] = @@ -4106,26 +4106,26 @@ static hawk_nde_t* parse_in (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_regex_match); + return parse_binary (hawk, xloc, 0, map, parse_regex_match); */ hawk_nde_t* left = HAWK_NULL; hawk_nde_t* right = HAWK_NULL; hawk_loc_t rloc; - left = parse_regex_match (awk, xloc); + left = parse_regex_match (hawk, xloc); if (left == HAWK_NULL) goto oops; do { hawk_nde_t* tmp; - if (!MATCH(awk,TOK_IN)) break; + if (!MATCH(hawk,TOK_IN)) break; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - rloc = awk->tok.loc; - right = parse_regex_match(awk, &rloc); + rloc = hawk->tok.loc; + right = parse_regex_match(hawk, &rloc); if (HAWK_UNLIKELY(!right)) goto oops; #if defined(HAWK_ENABLE_GC) @@ -4134,11 +4134,11 @@ static hawk_nde_t* parse_in (hawk_t* awk, const hawk_loc_t* xloc) if (!is_plain_var(right)) #endif { - hawk_seterrnum (awk, &rloc, HAWK_ENOTVAR); + hawk_seterrnum (hawk, &rloc, HAWK_ENOTVAR); goto oops; } - tmp = new_exp_bin_node(awk, xloc, HAWK_BINOP_IN, left, right); + tmp = new_exp_bin_node(hawk, xloc, HAWK_BINOP_IN, left, right); if (HAWK_UNLIKELY(!left)) goto oops; left = tmp; @@ -4149,12 +4149,12 @@ static hawk_nde_t* parse_in (hawk_t* awk, const hawk_loc_t* xloc) return left; oops: - if (right) hawk_clrpt (awk, right); - if (left) hawk_clrpt (awk, left); + if (right) hawk_clrpt (hawk, right); + if (left) hawk_clrpt (hawk, left); return HAWK_NULL; } -static hawk_nde_t* parse_regex_match (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_regex_match (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4163,10 +4163,10 @@ static hawk_nde_t* parse_regex_match (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 }, }; - return parse_binary (awk, xloc, 0, map, parse_bitwise_or); + return parse_binary (hawk, xloc, 0, map, parse_bitwise_or); } -static hawk_nde_t* parse_bitwise_or (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_bitwise_or (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4174,10 +4174,10 @@ static hawk_nde_t* parse_bitwise_or (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_bitwise_xor); + return parse_binary (hawk, xloc, 0, map, parse_bitwise_xor); } -static hawk_nde_t* parse_bitwise_xor (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_bitwise_xor (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4185,10 +4185,10 @@ static hawk_nde_t* parse_bitwise_xor (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_bitwise_and); + return parse_binary (hawk, xloc, 0, map, parse_bitwise_and); } -static hawk_nde_t* parse_bitwise_and (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_bitwise_and (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4196,10 +4196,10 @@ static hawk_nde_t* parse_bitwise_and (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_equality); + return parse_binary (hawk, xloc, 0, map, parse_equality); } -static hawk_nde_t* parse_equality (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_equality (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4210,10 +4210,10 @@ static hawk_nde_t* parse_equality (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_relational); + return parse_binary (hawk, xloc, 0, map, parse_relational); } -static hawk_nde_t* parse_relational (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_relational (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4224,10 +4224,10 @@ static hawk_nde_t* parse_relational (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_shift); + return parse_binary (hawk, xloc, 0, map, parse_shift); } -static hawk_nde_t* parse_shift (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_shift (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4236,27 +4236,27 @@ static hawk_nde_t* parse_shift (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_concat); + return parse_binary (hawk, xloc, 0, map, parse_concat); } -static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_concat (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* left = HAWK_NULL; hawk_nde_t* right = HAWK_NULL; hawk_loc_t rloc; - left = parse_additive(awk, xloc); + left = parse_additive(hawk, xloc); if (HAWK_UNLIKELY(!left)) goto oops; do { hawk_nde_t* tmp; - if (MATCH(awk,TOK_CONCAT)) + if (MATCH(hawk,TOK_CONCAT)) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - else if (awk->opt.trait & HAWK_BLANKCONCAT) + else if (hawk->opt.trait & HAWK_BLANKCONCAT) { /* * [NOTE] @@ -4265,15 +4265,15 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc) * the tilde is an unary bitwise negation operator at this phase. * You may use (~10) rather than ~10 after concatenation to avoid confusion. */ - if (MATCH(awk,TOK_LPAREN) || MATCH(awk,TOK_DOLLAR) || + if (MATCH(hawk,TOK_LPAREN) || MATCH(hawk,TOK_DOLLAR) || /* unary operators */ - MATCH(awk,TOK_PLUS) || MATCH(awk,TOK_MINUS) || - MATCH(awk,TOK_LNOT) ||/* MATCH(awk,TOK_TILDE) ||*/ + MATCH(hawk,TOK_PLUS) || MATCH(hawk,TOK_MINUS) || + MATCH(hawk,TOK_LNOT) ||/* MATCH(hawk,TOK_TILDE) ||*/ /* increment operators */ - MATCH(awk,TOK_PLUSPLUS) || MATCH(awk,TOK_MINUSMINUS) || - ((awk->opt.trait & HAWK_TOLERANT) && - (awk->tok.type == TOK_PRINT || awk->tok.type == TOK_PRINTF)) || - awk->tok.type >= TOK_GETLINE) + MATCH(hawk,TOK_PLUSPLUS) || MATCH(hawk,TOK_MINUSMINUS) || + ((hawk->opt.trait & HAWK_TOLERANT) && + (hawk->tok.type == TOK_PRINT || hawk->tok.type == TOK_PRINTF)) || + hawk->tok.type >= TOK_GETLINE) { /* proceed to handle concatenation expression */ /* nothing to to here. just fall through */ @@ -4282,11 +4282,11 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc) } else break; - rloc = awk->tok.loc; - right = parse_additive(awk, &rloc); + rloc = hawk->tok.loc; + right = parse_additive(hawk, &rloc); if (HAWK_UNLIKELY(!right)) goto oops; - tmp = new_exp_bin_node(awk, xloc, HAWK_BINOP_CONCAT, left, right); + tmp = new_exp_bin_node(hawk, xloc, HAWK_BINOP_CONCAT, left, right); if (HAWK_UNLIKELY(!tmp)) goto oops; left = tmp; right = HAWK_NULL; } @@ -4295,12 +4295,12 @@ static hawk_nde_t* parse_concat (hawk_t* awk, const hawk_loc_t* xloc) return left; oops: - if (right) hawk_clrpt (awk, right); - if (left) hawk_clrpt (awk, left); + if (right) hawk_clrpt (hawk, right); + if (left) hawk_clrpt (hawk, left); return HAWK_NULL; } -static hawk_nde_t* parse_additive (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_additive (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4309,10 +4309,10 @@ static hawk_nde_t* parse_additive (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_multiplicative); + return parse_binary (hawk, xloc, 0, map, parse_multiplicative); } -static hawk_nde_t* parse_multiplicative (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_multiplicative (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4324,10 +4324,10 @@ static hawk_nde_t* parse_multiplicative (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_unary); + return parse_binary (hawk, xloc, 0, map, parse_unary); } -static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_unary (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* left; hawk_loc_t uloc; @@ -4335,27 +4335,27 @@ static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc) int fold; folded_t folded; - opcode = (MATCH(awk,TOK_PLUS))? HAWK_UNROP_PLUS: - (MATCH(awk,TOK_MINUS))? HAWK_UNROP_MINUS: - (MATCH(awk,TOK_LNOT))? HAWK_UNROP_LNOT: - (MATCH(awk,TOK_TILDE))? HAWK_UNROP_BNOT: -1; + opcode = (MATCH(hawk,TOK_PLUS))? HAWK_UNROP_PLUS: + (MATCH(hawk,TOK_MINUS))? HAWK_UNROP_MINUS: + (MATCH(hawk,TOK_LNOT))? HAWK_UNROP_LNOT: + (MATCH(hawk,TOK_TILDE))? HAWK_UNROP_BNOT: -1; - /*if (opcode <= -1) return parse_increment(awk);*/ - if (opcode <= -1) return parse_exponent(awk, xloc); + /*if (opcode <= -1) return parse_increment(hawk);*/ + if (opcode <= -1) return parse_exponent(hawk, xloc); - if (awk->opt.depth.s.expr_parse > 0 && - awk->parse.depth.expr >= awk->opt.depth.s.expr_parse) + if (hawk->opt.depth.s.expr_parse > 0 && + hawk->parse.depth.expr >= hawk->opt.depth.s.expr_parse) { - hawk_seterrnum (awk, xloc, HAWK_EEXPRNST); + hawk_seterrnum (hawk, xloc, HAWK_EEXPRNST); return HAWK_NULL; } - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - awk->parse.depth.expr++; - uloc = awk->tok.loc; - left = parse_unary (awk, &uloc); - awk->parse.depth.expr--; + hawk->parse.depth.expr++; + uloc = hawk->tok.loc; + left = parse_unary (hawk, &uloc); + hawk->parse.depth.expr--; if (left == HAWK_NULL) return HAWK_NULL; fold = -1; @@ -4418,38 +4418,38 @@ static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc) case HAWK_NDE_INT: if (left->type == fold) { - update_int_node (awk, (hawk_nde_int_t*)left, folded.l); + update_int_node (hawk, (hawk_nde_int_t*)left, folded.l); return left; } else { HAWK_ASSERT (left->type == HAWK_NDE_FLT); - hawk_clrpt (awk, left); - return new_int_node (awk, folded.l, xloc); + hawk_clrpt (hawk, left); + return new_int_node (hawk, folded.l, xloc); } case HAWK_NDE_FLT: if (left->type == fold) { - update_flt_node (awk, (hawk_nde_flt_t*)left, folded.r); + update_flt_node (hawk, (hawk_nde_flt_t*)left, folded.r); return left; } else { HAWK_ASSERT (left->type == HAWK_NDE_INT); - hawk_clrpt (awk, left); - return new_flt_node (awk, folded.r, xloc); + hawk_clrpt (hawk, left); + return new_flt_node (hawk, folded.r, xloc); } default: { hawk_nde_exp_t* nde; - nde = (hawk_nde_exp_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_exp_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - hawk_clrpt (awk, left); - ADJERR_LOC (awk, xloc); + hawk_clrpt (hawk, left); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -4464,7 +4464,7 @@ static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc) } } -static hawk_nde_t* parse_exponent (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_exponent (hawk_t* hawk, const hawk_loc_t* xloc) { static binmap_t map[] = { @@ -4472,43 +4472,43 @@ static hawk_nde_t* parse_exponent (hawk_t* awk, const hawk_loc_t* xloc) { TOK_EOF, 0 } }; - return parse_binary (awk, xloc, 0, map, parse_unary_exp); + return parse_binary (hawk, xloc, 0, map, parse_unary_exp); } -static hawk_nde_t* parse_unary_exp (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_unary_exp (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_exp_t* nde; hawk_nde_t* left; hawk_loc_t uloc; int opcode; - opcode = (MATCH(awk,TOK_PLUS))? HAWK_UNROP_PLUS: - (MATCH(awk,TOK_MINUS))? HAWK_UNROP_MINUS: - (MATCH(awk,TOK_LNOT))? HAWK_UNROP_LNOT: - (MATCH(awk,TOK_TILDE))? HAWK_UNROP_BNOT: -1; /* ~ in the unary context is a bitwise-not operator */ + opcode = (MATCH(hawk,TOK_PLUS))? HAWK_UNROP_PLUS: + (MATCH(hawk,TOK_MINUS))? HAWK_UNROP_MINUS: + (MATCH(hawk,TOK_LNOT))? HAWK_UNROP_LNOT: + (MATCH(hawk,TOK_TILDE))? HAWK_UNROP_BNOT: -1; /* ~ in the unary context is a bitwise-not operator */ - if (opcode <= -1) return parse_increment (awk, xloc); + if (opcode <= -1) return parse_increment (hawk, xloc); - if (awk->opt.depth.s.expr_parse > 0 && - awk->parse.depth.expr >= awk->opt.depth.s.expr_parse) + if (hawk->opt.depth.s.expr_parse > 0 && + hawk->parse.depth.expr >= hawk->opt.depth.s.expr_parse) { - hawk_seterrnum (awk, xloc, HAWK_EEXPRNST); + hawk_seterrnum (hawk, xloc, HAWK_EEXPRNST); return HAWK_NULL; } - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - awk->parse.depth.expr++; - uloc = awk->tok.loc; - left = parse_unary (awk, &uloc); - awk->parse.depth.expr--; + hawk->parse.depth.expr++; + uloc = hawk->tok.loc; + left = parse_unary (hawk, &uloc); + hawk->parse.depth.expr--; if (left == HAWK_NULL) return HAWK_NULL; - nde = (hawk_nde_exp_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_exp_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - hawk_clrpt (awk, left); - ADJERR_LOC (awk, xloc); + hawk_clrpt (hawk, left); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -4521,7 +4521,7 @@ static hawk_nde_t* parse_unary_exp (hawk_t* awk, const hawk_loc_t* xloc) return (hawk_nde_t*)nde; } -static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_increment (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_exp_t* nde; hawk_nde_t* left; @@ -4529,31 +4529,31 @@ static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc) hawk_loc_t ploc; /* check for prefix increment operator */ - opcode1 = MATCH(awk,TOK_PLUSPLUS)? HAWK_INCOP_PLUS: - MATCH(awk,TOK_MINUSMINUS)? HAWK_INCOP_MINUS: -1; + opcode1 = MATCH(hawk,TOK_PLUSPLUS)? HAWK_INCOP_PLUS: + MATCH(hawk,TOK_MINUSMINUS)? HAWK_INCOP_MINUS: -1; if (opcode1 != -1) { /* there is a prefix increment operator */ - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; } - ploc = awk->tok.loc; - left = parse_primary (awk, &ploc); + ploc = hawk->tok.loc; + left = parse_primary (hawk, &ploc); if (left == HAWK_NULL) return HAWK_NULL; /* check for postfix increment operator */ - opcode2 = MATCH(awk,TOK_PLUSPLUS)? HAWK_INCOP_PLUS: - MATCH(awk,TOK_MINUSMINUS)? HAWK_INCOP_MINUS: -1; + opcode2 = MATCH(hawk,TOK_PLUSPLUS)? HAWK_INCOP_PLUS: + MATCH(hawk,TOK_MINUSMINUS)? HAWK_INCOP_MINUS: -1; - if (!(awk->opt.trait & HAWK_BLANKCONCAT)) + if (!(hawk->opt.trait & HAWK_BLANKCONCAT)) { if (opcode1 != -1 && opcode2 != -1) { /* both prefix and postfix increment operator. * not allowed */ - hawk_clrpt (awk, left); - hawk_seterrnum (awk, xloc, HAWK_EPREPST); + hawk_clrpt (hawk, left); + hawk_seterrnum (hawk, xloc, HAWK_EPREPST); return HAWK_NULL; } } @@ -4580,9 +4580,9 @@ static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc) opcode = opcode2; /* let's do it later - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_clrpt (awk, left); + hawk_clrpt (hawk, left); return HAWK_NULL; } */ @@ -4598,8 +4598,8 @@ static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc) } else { - hawk_clrpt (awk, left); - hawk_seterrnum (awk, xloc, HAWK_EINCDECOPR); + hawk_clrpt (hawk, left); + hawk_seterrnum (hawk, xloc, HAWK_EINCDECOPR); return HAWK_NULL; } } @@ -4607,18 +4607,18 @@ static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc) if (type == HAWK_NDE_EXP_INCPST) { /* consume the postfix operator */ - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_clrpt (awk, left); + hawk_clrpt (hawk, left); return HAWK_NULL; } } - nde = (hawk_nde_exp_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_exp_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - hawk_clrpt (awk, left); - ADJERR_LOC (awk, xloc); + hawk_clrpt (hawk, left); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -4635,14 +4635,14 @@ static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc) #define FNTYPE_FNC 1 #define FNTYPE_FUN 2 -static HAWK_INLINE int isfunname (hawk_t* awk, const hawk_oocs_t* name, hawk_fun_t** fun) +static HAWK_INLINE int isfunname (hawk_t* hawk, const hawk_oocs_t* name, hawk_fun_t** fun) { hawk_htb_pair_t* pair; - /* check if it is an awk function being processed currently */ - if (awk->tree.cur_fun.ptr) + /* check if it is an hawk function being processed currently */ + if (hawk->tree.cur_fun.ptr) { - if (hawk_comp_oochars(awk->tree.cur_fun.ptr, awk->tree.cur_fun.len, name->ptr, name->len, 0) == 0) + if (hawk_comp_oochars(hawk->tree.cur_fun.ptr, hawk->tree.cur_fun.len, name->ptr, name->len, 0) == 0) { /* the current function begin parsed */ return FNTYPE_FUN; @@ -4650,7 +4650,7 @@ static HAWK_INLINE int isfunname (hawk_t* awk, const hawk_oocs_t* name, hawk_fun } /* check the funtion name in the function table */ - pair = hawk_htb_search(awk->tree.funs, name->ptr, name->len); + pair = hawk_htb_search(hawk->tree.funs, name->ptr, name->len); if (pair) { /* one of the functions defined previously */ @@ -4663,7 +4663,7 @@ static HAWK_INLINE int isfunname (hawk_t* awk, const hawk_oocs_t* name, hawk_fun } /* check if it is a function not resolved so far */ - if (hawk_htb_search(awk->parse.funs, name->ptr, name->len)) + if (hawk_htb_search(hawk->parse.funs, name->ptr, name->len)) { /* one of the function calls not resolved so far. */ return FNTYPE_FUN; @@ -4672,15 +4672,15 @@ static HAWK_INLINE int isfunname (hawk_t* awk, const hawk_oocs_t* name, hawk_fun return FNTYPE_UNKNOWN; } -static HAWK_INLINE int isfnname (hawk_t* awk, const hawk_oocs_t* name) +static HAWK_INLINE int isfnname (hawk_t* hawk, const hawk_oocs_t* name) { - if (hawk_findfncwithoocs(awk, name) != HAWK_NULL) + if (hawk_findfncwithoocs(hawk, name) != HAWK_NULL) { /* implicit function */ return FNTYPE_FNC; } - return isfunname(awk, name, HAWK_NULL); + return isfunname(hawk, name, HAWK_NULL); } static hawk_nde_t* parse_primary_int (hawk_t* hawk, const hawk_loc_t* xloc) @@ -4741,40 +4741,40 @@ oops: return HAWK_NULL; } -static hawk_nde_t* parse_primary_str (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary_str (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_str_t* nde; - nde = (hawk_nde_str_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_str_t*) hawk_callocmem (hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } nde->type = HAWK_NDE_STR; nde->loc = *xloc; - nde->len = HAWK_OOECS_LEN(awk->tok.name); - nde->ptr = hawk_dupoocs(awk, HAWK_OOECS_OOCS(awk->tok.name)); - if (nde->ptr == HAWK_NULL || get_token(awk) <= -1) goto oops; + nde->len = HAWK_OOECS_LEN(hawk->tok.name); + nde->ptr = hawk_dupoocs(hawk, HAWK_OOECS_OOCS(hawk->tok.name)); + if (nde->ptr == HAWK_NULL || get_token(hawk) <= -1) goto oops; return (hawk_nde_t*)nde; oops: HAWK_ASSERT (nde != HAWK_NULL); - if (nde->ptr) hawk_freemem (awk, nde->ptr); - hawk_freemem (awk, nde); + if (nde->ptr) hawk_freemem (hawk, nde->ptr); + hawk_freemem (hawk, nde); return HAWK_NULL; } -static hawk_nde_t* parse_primary_mbs (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary_mbs (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_mbs_t* nde; - nde = (hawk_nde_mbs_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_mbs_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -4782,42 +4782,42 @@ static hawk_nde_t* parse_primary_mbs (hawk_t* awk, const hawk_loc_t* xloc) nde->loc = *xloc; #if defined(HAWK_OOCH_IS_BCH) - nde->len = HAWK_OOECS_LEN(awk->tok.name); - nde->ptr = hawk_dupoocs(awk, HAWK_OOECS_OOCS(awk->tok.name)); + nde->len = HAWK_OOECS_LEN(hawk->tok.name); + nde->ptr = hawk_dupoocs(hawk, HAWK_OOECS_OOCS(hawk->tok.name)); if (!nde->ptr) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } #else { - /* the MBS token doesn't include a character greater than 0xFF in awk->tok.name + /* the MBS token doesn't include a character greater than 0xFF in hawk->tok.name * even though it is a unicode string. simply copy over without conversion */ - nde->len = HAWK_OOECS_LEN(awk->tok.name); - nde->ptr = hawk_allocmem(awk, (nde->len + 1) * HAWK_SIZEOF(*nde->ptr)); + nde->len = HAWK_OOECS_LEN(hawk->tok.name); + nde->ptr = hawk_allocmem(hawk, (nde->len + 1) * HAWK_SIZEOF(*nde->ptr)); if (!nde->ptr) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } - hawk_copy_uchars_to_bchars (nde->ptr, HAWK_OOECS_PTR(awk->tok.name), nde->len); + hawk_copy_uchars_to_bchars (nde->ptr, HAWK_OOECS_PTR(hawk->tok.name), nde->len); nde->ptr[nde->len] = '\0'; } #endif - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; return (hawk_nde_t*)nde; oops: HAWK_ASSERT (nde != HAWK_NULL); - if (nde->ptr) hawk_freemem (awk, nde->ptr); - hawk_freemem (awk, nde); + if (nde->ptr) hawk_freemem (hawk, nde->ptr); + hawk_freemem (hawk, nde); return HAWK_NULL; } -static hawk_nde_t* parse_primary_rex (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary_rex (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_rex_t* nde; @@ -4825,69 +4825,69 @@ static hawk_nde_t* parse_primary_rex (hawk_t* awk, const hawk_loc_t* xloc) * of the context-sensitivity of the slash symbol. * if TOK_DIV is seen as a primary, it tries to compile * it as a regular expression */ - hawk_ooecs_clear (awk->tok.name); + hawk_ooecs_clear (hawk->tok.name); - if (MATCH(awk,TOK_DIV_ASSN) && hawk_ooecs_ccat(awk->tok.name, HAWK_T('=')) == (hawk_oow_t)-1) + if (MATCH(hawk,TOK_DIV_ASSN) && hawk_ooecs_ccat(hawk->tok.name, HAWK_T('=')) == (hawk_oow_t)-1) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } - SET_TOKEN_TYPE (awk, &awk->tok, TOK_REX); - if (get_rexstr (awk, &awk->tok) <= -1) return HAWK_NULL; + SET_TOKEN_TYPE (hawk, &hawk->tok, TOK_REX); + if (get_rexstr (hawk, &hawk->tok) <= -1) return HAWK_NULL; - HAWK_ASSERT (MATCH(awk,TOK_REX)); + HAWK_ASSERT (MATCH(hawk,TOK_REX)); - nde = (hawk_nde_rex_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_rex_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } nde->type = HAWK_NDE_REX; nde->loc = *xloc; - nde->str.len = HAWK_OOECS_LEN(awk->tok.name); - nde->str.ptr = hawk_dupoocs(awk, HAWK_OOECS_OOCS(awk->tok.name)); + nde->str.len = HAWK_OOECS_LEN(hawk->tok.name); + nde->str.ptr = hawk_dupoocs(hawk, HAWK_OOECS_OOCS(hawk->tok.name)); if (nde->str.ptr == HAWK_NULL) goto oops; - if (hawk_buildrex(awk, HAWK_OOECS_PTR(awk->tok.name), HAWK_OOECS_LEN(awk->tok.name), &nde->code[0], &nde->code[1]) <= -1) + if (hawk_buildrex(hawk, HAWK_OOECS_PTR(hawk->tok.name), HAWK_OOECS_LEN(hawk->tok.name), &nde->code[0], &nde->code[1]) <= -1) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; return (hawk_nde_t*)nde; oops: HAWK_ASSERT (nde != HAWK_NULL); - if (nde->code[0]) hawk_freerex (awk, nde->code[0], nde->code[1]); - if (nde->str.ptr) hawk_freemem (awk, nde->str.ptr); - hawk_freemem (awk, nde); + if (nde->code[0]) hawk_freerex (hawk, nde->code[0], nde->code[1]); + if (nde->str.ptr) hawk_freemem (hawk, nde->str.ptr); + hawk_freemem (hawk, nde); return HAWK_NULL; } -static hawk_nde_t* parse_primary_positional (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary_positional (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_pos_t* nde; hawk_loc_t ploc; - nde = (hawk_nde_pos_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_pos_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (HAWK_UNLIKELY(!nde)) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } nde->type = HAWK_NDE_POS; nde->loc = *xloc; - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; - ploc = awk->tok.loc; - nde->val = parse_primary(awk, &ploc); + ploc = hawk->tok.loc; + nde->val = parse_primary(hawk, &ploc); if (HAWK_UNLIKELY(!nde->val)) goto oops; return (hawk_nde_t*)nde; @@ -4895,45 +4895,45 @@ static hawk_nde_t* parse_primary_positional (hawk_t* awk, const hawk_loc_t* xloc oops: if (nde) { - if (nde->val) hawk_clrpt (awk, nde->val); - hawk_freemem (awk, nde); + if (nde->val) hawk_clrpt (hawk, nde->val); + hawk_freemem (hawk, nde); } return HAWK_NULL; } -static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary_lparen (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* nde; hawk_nde_t* last; hawk_loc_t eloc; hawk_oow_t opening_lparen_seq; - opening_lparen_seq = awk->parse.lparen_seq++; + opening_lparen_seq = hawk->parse.lparen_seq++; /* eat up the left parenthesis */ - if (get_token(awk) <= -1) return HAWK_NULL; + if (get_token(hawk) <= -1) return HAWK_NULL; /* parse the sub-expression inside the parentheses */ - eloc = awk->tok.loc; - nde = parse_expr_withdc(awk, &eloc); + eloc = hawk->tok.loc; + nde = parse_expr_withdc(hawk, &eloc); if (HAWK_UNLIKELY(!nde)) return HAWK_NULL; /* parse subsequent expressions separated by a comma, if any */ last = nde; HAWK_ASSERT (last->next == HAWK_NULL); - while (MATCH(awk,TOK_COMMA)) + while (MATCH(hawk,TOK_COMMA)) { hawk_nde_t* tmp; do { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); - eloc = awk->tok.loc; - tmp = parse_expr_withdc(awk, &eloc); + eloc = hawk->tok.loc; + tmp = parse_expr_withdc(hawk, &eloc); if (HAWK_UNLIKELY(!tmp)) goto oops; HAWK_ASSERT (tmp->next == HAWK_NULL); @@ -4943,17 +4943,17 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc) /* ----------------- */ /* check for the closing parenthesis */ - if (!MATCH(awk,TOK_RPAREN)) + if (!MATCH(hawk,TOK_RPAREN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERPAREN, FMT_ERPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } /* remember the sequence number of the left parenthesis * that' been just closed by the matching right parenthesis */ - awk->parse.lparen_last_closed = opening_lparen_seq; + hawk->parse.lparen_last_closed = opening_lparen_seq; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* check if it is a chained node */ if (nde->next) @@ -4963,19 +4963,19 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc) hawk_nde_grp_t* tmp; - if ((awk->parse.id.stmt != TOK_PRINT && awk->parse.id.stmt != TOK_PRINTF) || awk->parse.depth.expr != 1) + if ((hawk->parse.id.stmt != TOK_PRINT && hawk->parse.id.stmt != TOK_PRINTF) || hawk->parse.depth.expr != 1) { - if (!(awk->opt.trait & HAWK_TOLERANT) && !MATCH(awk,TOK_IN)) + if (!(hawk->opt.trait & HAWK_TOLERANT) && !MATCH(hawk,TOK_IN)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EKWIN, FMT_EKWIN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EKWIN, FMT_EKWIN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } } - tmp = (hawk_nde_grp_t*)hawk_callocmem(awk, HAWK_SIZEOF(hawk_nde_grp_t)); + tmp = (hawk_nde_grp_t*)hawk_callocmem(hawk, HAWK_SIZEOF(hawk_nde_grp_t)); if (HAWK_UNLIKELY(!tmp)) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -4990,11 +4990,11 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc) return nde; oops: - if (nde) hawk_clrpt (awk, nde); + if (nde) hawk_clrpt (hawk, nde); return HAWK_NULL; } -static hawk_nde_t* parse_primary_getline (hawk_t* awk, const hawk_loc_t* xloc, int mbs) +static hawk_nde_t* parse_primary_getline (hawk_t* hawk, const hawk_loc_t* xloc, int mbs) { /* parse the statement-level getline. * getline after the pipe symbols(|,||) is parsed @@ -5004,7 +5004,7 @@ static hawk_nde_t* parse_primary_getline (hawk_t* awk, const hawk_loc_t* xloc, i hawk_nde_getline_t* nde; hawk_loc_t ploc; - nde = (hawk_nde_getline_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_getline_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (HAWK_UNLIKELY(!nde)) goto oops; nde->type = HAWK_NDE_GETLINE; @@ -5012,24 +5012,24 @@ static hawk_nde_t* parse_primary_getline (hawk_t* awk, const hawk_loc_t* xloc, i nde->loc = *xloc; nde->in_type = HAWK_IN_CONSOLE; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - if (MATCH(awk,TOK_IDENT) || MATCH(awk,TOK_DOLLAR)) + if (MATCH(hawk,TOK_IDENT) || MATCH(hawk,TOK_DOLLAR)) { /* getline var * getline $XXX */ - if ((awk->opt.trait & HAWK_BLANKCONCAT) && MATCH(awk,TOK_IDENT)) + if ((hawk->opt.trait & HAWK_BLANKCONCAT) && MATCH(hawk,TOK_IDENT)) { /* i need to perform some precheck on if the identifier is * really a variable */ - if (preget_token(awk) <= -1) goto oops; + if (preget_token(hawk) <= -1) goto oops; - if (awk->ntok.type == TOK_DBLCOLON) goto novar; - if (awk->ntok.type == TOK_LPAREN) + if (hawk->ntok.type == TOK_DBLCOLON) goto novar; + if (hawk->ntok.type == TOK_LPAREN) { - if (awk->ntok.loc.line == awk->tok.loc.line && - awk->ntok.loc.colm == awk->tok.loc.colm + HAWK_OOECS_LEN(awk->tok.name)) + if (hawk->ntok.loc.line == hawk->tok.loc.line && + hawk->ntok.loc.colm == hawk->tok.loc.colm + HAWK_OOECS_LEN(hawk->tok.name)) { /* it's in the form of a function call since * there is no spaces between the identifier @@ -5038,11 +5038,11 @@ static hawk_nde_t* parse_primary_getline (hawk_t* awk, const hawk_loc_t* xloc, i } } - if (isfnname(awk, HAWK_OOECS_OOCS(awk->tok.name)) != FNTYPE_UNKNOWN) goto novar; + if (isfnname(hawk, HAWK_OOECS_OOCS(hawk->tok.name)) != FNTYPE_UNKNOWN) goto novar; } - ploc = awk->tok.loc; - nde->var = parse_primary(awk, &ploc); + ploc = hawk->tok.loc; + nde->var = parse_primary(hawk, &ploc); if (HAWK_UNLIKELY(!nde->var)) goto oops; if (!is_var(nde->var) && nde->var->type != HAWK_NDE_POS) @@ -5051,21 +5051,21 @@ static hawk_nde_t* parse_primary_getline (hawk_t* awk, const hawk_loc_t* xloc, i * getline a() * getline sys::WNOHANG */ - hawk_seterrnum (awk, &ploc, HAWK_EBADARG); + hawk_seterrnum (hawk, &ploc, HAWK_EBADARG); goto oops; } } novar: - if (MATCH(awk, TOK_LT)) + if (MATCH(hawk, TOK_LT)) { /* getline [var] < file */ - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - ploc = awk->tok.loc; + ploc = hawk->tok.loc; /* TODO: is this correct? */ - /*nde->in = parse_expr_withdc (awk, &ploc);*/ - nde->in = parse_primary(awk, &ploc); + /*nde->in = parse_expr_withdc (hawk, &ploc);*/ + nde->in = parse_primary(hawk, &ploc); if (HAWK_UNLIKELY(!nde->in)) goto oops; nde->in_type = HAWK_IN_FILE; @@ -5076,47 +5076,47 @@ novar: oops: if (nde) { - if (nde->in) hawk_clrpt (awk, nde->in); - if (nde->var) hawk_clrpt (awk, nde->var); - hawk_freemem (awk, nde); + if (nde->in) hawk_clrpt (hawk, nde->in); + if (nde->var) hawk_clrpt (hawk, nde->var); + hawk_freemem (hawk, nde); } return HAWK_NULL; } -static hawk_nde_t* parse_primary_nopipe (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary_nopipe (hawk_t* hawk, const hawk_loc_t* xloc) { - switch (awk->tok.type) + switch (hawk->tok.type) { case TOK_IDENT: - return parse_primary_ident(awk, xloc); + return parse_primary_ident(hawk, xloc); case TOK_INT: - return parse_primary_int(awk, xloc); + return parse_primary_int(hawk, xloc); case TOK_FLT: - return parse_primary_flt(awk, xloc); + return parse_primary_flt(hawk, xloc); case TOK_STR: - return parse_primary_str(awk, xloc); + return parse_primary_str(hawk, xloc); case TOK_MBS: - return parse_primary_mbs(awk, xloc); + return parse_primary_mbs(hawk, xloc); case TOK_DIV: case TOK_DIV_ASSN: - return parse_primary_rex(awk, xloc); + return parse_primary_rex(hawk, xloc); case TOK_DOLLAR: - return parse_primary_positional(awk, xloc); + return parse_primary_positional(hawk, xloc); case TOK_LPAREN: - return parse_primary_lparen(awk, xloc); + return parse_primary_lparen(hawk, xloc); case TOK_GETBLINE: - return parse_primary_getline(awk, xloc, 1); + return parse_primary_getline(hawk, xloc, 1); case TOK_GETLINE: - return parse_primary_getline(awk, xloc, 0); + return parse_primary_getline(hawk, xloc, 0); default: { @@ -5124,29 +5124,29 @@ static hawk_nde_t* parse_primary_nopipe (hawk_t* awk, const hawk_loc_t* xloc) /* in the tolerant mode, we treat print and printf * as a function like getline */ - if ((awk->opt.trait & HAWK_TOLERANT) && - (MATCH(awk,TOK_PRINT) || MATCH(awk,TOK_PRINTF))) + if ((hawk->opt.trait & HAWK_TOLERANT) && + (MATCH(hawk,TOK_PRINT) || MATCH(hawk,TOK_PRINTF))) { - if (get_token(awk) <= -1) return HAWK_NULL; - return parse_print (awk, xloc); + if (get_token(hawk) <= -1) return HAWK_NULL; + return parse_print (hawk, xloc); } /* valid expression introducer is expected */ - xtok = MATCH(awk,TOK_NEWLINE)? &awk->ptok: &awk->tok; - hawk_seterrfmt (awk, &xtok->loc, HAWK_EEXPRNR, HAWK_T("expression not recognized around '%.*js'"), HAWK_OOECS_LEN(xtok->name), HAWK_OOECS_PTR(xtok->name)); + xtok = MATCH(hawk,TOK_NEWLINE)? &hawk->ptok: &hawk->tok; + hawk_seterrfmt (hawk, &xtok->loc, HAWK_EEXPRNR, HAWK_T("expression not recognized around '%.*js'"), HAWK_OOECS_LEN(xtok->name), HAWK_OOECS_PTR(xtok->name)); return HAWK_NULL; } } } -static hawk_nde_t* parse_primary (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* left; hawk_nde_getline_t* nde; hawk_nde_t* var = HAWK_NULL; hawk_loc_t ploc; - left = parse_primary_nopipe(awk, xloc); + left = parse_primary_nopipe(hawk, xloc); if (left == HAWK_NULL) goto oops; /* handle the piping part */ @@ -5155,13 +5155,13 @@ static hawk_nde_t* parse_primary (hawk_t* awk, const hawk_loc_t* xloc) int intype = -1; int mbs; - if (awk->opt.trait & HAWK_RIO) + if (hawk->opt.trait & HAWK_RIO) { - if (MATCH(awk,TOK_BOR)) + if (MATCH(hawk,TOK_BOR)) { intype = HAWK_IN_PIPE; } - else if (MATCH(awk,TOK_LOR) && (awk->opt.trait & HAWK_RWPIPE)) + else if (MATCH(hawk,TOK_LOR) && (hawk->opt.trait & HAWK_RWPIPE)) { intype = HAWK_IN_RWPIPE; } @@ -5169,34 +5169,34 @@ static hawk_nde_t* parse_primary (hawk_t* awk, const hawk_loc_t* xloc) if (intype == -1) break; - if (preget_token(awk) <= -1) goto oops; - if (awk->ntok.type == TOK_GETBLINE) mbs = 1; - else if (awk->ntok.type == TOK_GETLINE) mbs = 0; + if (preget_token(hawk) <= -1) goto oops; + if (hawk->ntok.type == TOK_GETBLINE) mbs = 1; + else if (hawk->ntok.type == TOK_GETLINE) mbs = 0; else break; /* consume ntok('getline') */ - get_token(awk); /* no error check needed as it's guaranteeded to succeed for preget_token() above */ + get_token(hawk); /* no error check needed as it's guaranteeded to succeed for preget_token() above */ /* get the next token */ - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* TODO: is this correct? */ - if (MATCH(awk,TOK_IDENT) || MATCH(awk,TOK_DOLLAR)) + if (MATCH(hawk,TOK_IDENT) || MATCH(hawk,TOK_DOLLAR)) { /* command | getline var * command || getline var */ - if ((awk->opt.trait & HAWK_BLANKCONCAT) && MATCH(awk,TOK_IDENT)) + if ((hawk->opt.trait & HAWK_BLANKCONCAT) && MATCH(hawk,TOK_IDENT)) { /* i need to perform some precheck on if the identifier is * really a variable */ - if (preget_token(awk) <= -1) goto oops; + if (preget_token(hawk) <= -1) goto oops; - if (awk->ntok.type == TOK_DBLCOLON) goto novar; - if (awk->ntok.type == TOK_LPAREN) + if (hawk->ntok.type == TOK_DBLCOLON) goto novar; + if (hawk->ntok.type == TOK_LPAREN) { - if (awk->ntok.loc.line == awk->tok.loc.line && - awk->ntok.loc.colm == awk->tok.loc.colm + HAWK_OOECS_LEN(awk->tok.name)) + if (hawk->ntok.loc.line == hawk->tok.loc.line && + hawk->ntok.loc.colm == hawk->tok.loc.colm + HAWK_OOECS_LEN(hawk->tok.name)) { /* it's in the form of a function call since * there is no spaces between the identifier @@ -5205,27 +5205,27 @@ static hawk_nde_t* parse_primary (hawk_t* awk, const hawk_loc_t* xloc) } } - if (isfnname(awk, HAWK_OOECS_OOCS(awk->tok.name)) != FNTYPE_UNKNOWN) goto novar; + if (isfnname(hawk, HAWK_OOECS_OOCS(hawk->tok.name)) != FNTYPE_UNKNOWN) goto novar; } - ploc = awk->tok.loc; - var = parse_primary(awk, &ploc); + ploc = hawk->tok.loc; + var = parse_primary(hawk, &ploc); if (var == HAWK_NULL) goto oops; if (!is_var(var) && var->type != HAWK_NDE_POS) { /* fucntion a() {} * print ("ls -laF" | getline a()) */ - hawk_seterrnum (awk, &ploc, HAWK_EBADARG); + hawk_seterrnum (hawk, &ploc, HAWK_EBADARG); goto oops; } } novar: - nde = (hawk_nde_getline_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_getline_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -5244,32 +5244,32 @@ static hawk_nde_t* parse_primary (hawk_t* awk, const hawk_loc_t* xloc) return left; oops: - if (var) hawk_clrpt (awk, var); - hawk_clrpt (awk, left); + if (var) hawk_clrpt (hawk, var); + hawk_clrpt (hawk, left); return HAWK_NULL; } -static hawk_nde_t* parse_variable (hawk_t* awk, const hawk_loc_t* xloc, hawk_nde_type_t type, const hawk_oocs_t* name, hawk_oow_t idxa) +static hawk_nde_t* parse_variable (hawk_t* hawk, const hawk_loc_t* xloc, hawk_nde_type_t type, const hawk_oocs_t* name, hawk_oow_t idxa) { hawk_nde_var_t* nde; int is_fcv = 0; - if (MATCH(awk,TOK_LPAREN)) + if (MATCH(hawk,TOK_LPAREN)) { #if defined(HAWK_ENABLE_FUN_AS_VALUE) /* - if (MATCH(awk,TOK_LPAREN) && - (!(awk->opt.trait & HAWK_BLANKCONCAT) || - (awk->tok.loc.line == xloc->line && - awk->tok.loc.colm == xloc->colm + name->len))) + if (MATCH(hawk,TOK_LPAREN) && + (!(hawk->opt.trait & HAWK_BLANKCONCAT) || + (hawk->tok.loc.line == xloc->line && + hawk->tok.loc.colm == xloc->colm + name->len))) */ - if (awk->tok.loc.line == xloc->line && awk->tok.loc.colm == xloc->colm + name->len) + if (hawk->tok.loc.line == xloc->line && hawk->tok.loc.colm == xloc->colm + name->len) { is_fcv = 1; } else #endif - if (!(awk->opt.trait & HAWK_BLANKCONCAT)) + if (!(hawk->opt.trait & HAWK_BLANKCONCAT)) { /* if concatenation by blanks is not allowed, the explicit * concatenation operator(%%) must be used. so it is obvious @@ -5278,15 +5278,15 @@ static hawk_nde_t* parse_variable (hawk_t* awk, const hawk_loc_t* xloc, hawk_nde * the value of var_xxx and 1. */ /* a variable is not a function */ - hawk_seterrfmt (awk, xloc, HAWK_EFUNNAM, HAWK_T("'%.*js' not a valid function name"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EFUNNAM, HAWK_T("'%.*js' not a valid function name"), name->len, name->ptr); return HAWK_NULL; } } - nde = (hawk_nde_var_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_var_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -5300,53 +5300,53 @@ static hawk_nde_t* parse_variable (hawk_t* awk, const hawk_loc_t* xloc, hawk_nde #if defined(HAWK_ENABLE_FUN_AS_VALUE) if (!is_fcv) return (hawk_nde_t*)nde; - return parse_fncall(awk, (const hawk_oocs_t*)nde, HAWK_NULL, xloc, FNCALL_FLAG_VAR); + return parse_fncall(hawk, (const hawk_oocs_t*)nde, HAWK_NULL, xloc, FNCALL_FLAG_VAR); #else return (hawk_nde_t*)nde; #endif } -static int dup_ident_and_get_next (hawk_t* awk, const hawk_loc_t* xloc, hawk_oocs_t* name, int max) +static int dup_ident_and_get_next (hawk_t* hawk, const hawk_loc_t* xloc, hawk_oocs_t* name, int max) { int nsegs = 0; - HAWK_ASSERT (MATCH(awk,TOK_IDENT)); + HAWK_ASSERT (MATCH(hawk,TOK_IDENT)); do { - name[nsegs].ptr = HAWK_OOECS_PTR(awk->tok.name); - name[nsegs].len = HAWK_OOECS_LEN(awk->tok.name); + name[nsegs].ptr = HAWK_OOECS_PTR(hawk->tok.name); + name[nsegs].len = HAWK_OOECS_LEN(hawk->tok.name); /* duplicate the identifier */ - name[nsegs].ptr = hawk_dupoochars(awk, name[nsegs].ptr, name[nsegs].len); + name[nsegs].ptr = hawk_dupoochars(hawk, name[nsegs].ptr, name[nsegs].len); if (!name[nsegs].ptr) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } nsegs++; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - if (!MATCH(awk,TOK_DBLCOLON)) break; + if (!MATCH(hawk,TOK_DBLCOLON)) break; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; /* the identifier after :: * allow reserved words as well since i view the whole name(mod::ident) * as one segment. however, i don't want the identifier part to begin * with @. some extended keywords begin with @ like @include. * TOK_XGLOBAL to TOK_XRESET are excuded from the check for that reason. */ - if (!MATCH(awk, TOK_IDENT) && !(MATCH_RANGE(awk, TOK_BEGIN, TOK_GETLINE))) + if (!MATCH(hawk, TOK_IDENT) && !(MATCH_RANGE(hawk, TOK_BEGIN, TOK_GETLINE))) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EIDENT, FMT_EIDENT, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EIDENT, FMT_EIDENT, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } if (nsegs >= max) { - hawk_seterrnum (awk, xloc, HAWK_ESEGTM); + hawk_seterrnum (hawk, xloc, HAWK_ESEGTM); goto oops; } } @@ -5355,20 +5355,20 @@ static int dup_ident_and_get_next (hawk_t* awk, const hawk_loc_t* xloc, hawk_ooc return nsegs; oops: - while (nsegs > 0) hawk_freemem (awk, name[--nsegs].ptr); + while (nsegs > 0) hawk_freemem (hawk, name[--nsegs].ptr); return -1; } #if defined(HAWK_ENABLE_FUN_AS_VALUE) -static hawk_nde_t* parse_fun_as_value (hawk_t* awk, const hawk_oocs_t* name, const hawk_loc_t* xloc, hawk_fun_t* funptr) +static hawk_nde_t* parse_fun_as_value (hawk_t* hawk, const hawk_oocs_t* name, const hawk_loc_t* xloc, hawk_fun_t* funptr) { hawk_nde_fun_t* nde; /* create the node for the literal */ - nde = (hawk_nde_fun_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_fun_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (nde == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } @@ -5382,17 +5382,17 @@ static hawk_nde_t* parse_fun_as_value (hawk_t* awk, const hawk_oocs_t* name, co } #endif -static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xloc, const hawk_oocs_t* name) +static hawk_nde_t* parse_primary_ident_noseg (hawk_t* hawk, const hawk_loc_t* xloc, const hawk_oocs_t* name) { hawk_fnc_t* fnc; hawk_oow_t idxa; hawk_nde_t* nde = HAWK_NULL; /* check if name is an intrinsic function name */ - fnc = hawk_findfncwithoocs(awk, name); + fnc = hawk_findfncwithoocs(hawk, name); if (fnc) { - if (MATCH(awk,TOK_LPAREN) || fnc->dfl0) + if (MATCH(hawk,TOK_LPAREN) || fnc->dfl0) { if (fnc->spec.arg.min > fnc->spec.arg.max) { @@ -5410,68 +5410,68 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo segs[0].len = hawk_count_oocstr(fnc->spec.arg.spec); segs[1] = *name; - return parse_primary_ident_segs (awk, xloc, name, segs, 2); + return parse_primary_ident_segs (hawk, xloc, name, segs, 2); } /* fnc->dfl0 means that the function can be called without (). * i.e. length */ - nde = parse_fncall(awk, name, fnc, xloc, ((!MATCH(awk,TOK_LPAREN) && fnc->dfl0)? FNCALL_FLAG_NOARG: 0)); + nde = parse_fncall(hawk, name, fnc, xloc, ((!MATCH(hawk,TOK_LPAREN) && fnc->dfl0)? FNCALL_FLAG_NOARG: 0)); } else { /* an intrinsic function should be in the form of the function call */ - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); } } /* now we know that name is a normal identifier. */ - else if (MATCH(awk,TOK_LBRACK)) + else if (MATCH(hawk,TOK_LBRACK)) { - nde = parse_hashidx(awk, name, xloc); + nde = parse_hashidx(hawk, name, xloc); } - else if ((idxa = hawk_arr_rsearch(awk->parse.lcls, HAWK_ARR_SIZE(awk->parse.lcls), name->ptr, name->len)) != HAWK_ARR_NIL) + else if ((idxa = hawk_arr_rsearch(hawk->parse.lcls, HAWK_ARR_SIZE(hawk->parse.lcls), name->ptr, name->len)) != HAWK_ARR_NIL) { /* local variable */ - nde = parse_variable(awk, xloc, HAWK_NDE_LCL, name, idxa); + nde = parse_variable(hawk, xloc, HAWK_NDE_LCL, name, idxa); } - else if ((idxa = hawk_arr_search(awk->parse.params, 0, name->ptr, name->len)) != HAWK_ARR_NIL) + else if ((idxa = hawk_arr_search(hawk->parse.params, 0, name->ptr, name->len)) != HAWK_ARR_NIL) { /* parameter */ - nde = parse_variable(awk, xloc, HAWK_NDE_ARG, name, idxa); + nde = parse_variable(hawk, xloc, HAWK_NDE_ARG, name, idxa); } - else if ((idxa = get_global(awk, name)) != HAWK_ARR_NIL) + else if ((idxa = get_global(hawk, name)) != HAWK_ARR_NIL) { /* global variable */ - nde = parse_variable(awk, xloc, HAWK_NDE_GBL, name, idxa); + nde = parse_variable(hawk, xloc, HAWK_NDE_GBL, name, idxa); } else { int fntype; hawk_fun_t* funptr = HAWK_NULL; - fntype = isfunname(awk, name, &funptr); + fntype = isfunname(hawk, name, &funptr); if (fntype) { HAWK_ASSERT (fntype == FNTYPE_FUN); - if (MATCH(awk,TOK_LPAREN)) + if (MATCH(hawk,TOK_LPAREN)) { /* must be a function name */ - HAWK_ASSERT (hawk_htb_search(awk->parse.named, name->ptr, name->len) == HAWK_NULL); - nde = parse_fncall(awk, name, HAWK_NULL, xloc, 0); + HAWK_ASSERT (hawk_htb_search(hawk->parse.named, name->ptr, name->len) == HAWK_NULL); + nde = parse_fncall(hawk, name, HAWK_NULL, xloc, 0); } else { /* function name appeared without (). used as a value without invocation */ #if defined(HAWK_ENABLE_FUN_AS_VALUE) - nde = parse_fun_as_value(awk, name, xloc, funptr); + nde = parse_fun_as_value(hawk, name, xloc, funptr); #else - hawk_seterrfmt (awk, xloc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), name->len, name->ptr); #endif } } - /*else if (awk->opt.trait & HAWK_IMPLICIT) */ - else if (awk->parse.pragma.trait & HAWK_IMPLICIT) + /*else if (hawk->opt.trait & HAWK_IMPLICIT) */ + else if (hawk->parse.pragma.trait & HAWK_IMPLICIT) { /* if the name is followed by ( without spaces, * it's considered a function call though the name @@ -5483,25 +5483,25 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo */ int is_fncall_var = 0; - if (MATCH(awk,TOK_LPAREN) && - (!(awk->opt.trait & HAWK_BLANKCONCAT) || - (awk->tok.loc.line == xloc->line && - awk->tok.loc.colm == xloc->colm + name->len))) + if (MATCH(hawk,TOK_LPAREN) && + (!(hawk->opt.trait & HAWK_BLANKCONCAT) || + (hawk->tok.loc.line == xloc->line && + hawk->tok.loc.colm == xloc->colm + name->len))) { /* it is a function call to an undefined function yet */ - if (hawk_htb_search(awk->parse.named, name->ptr, name->len) != HAWK_NULL) + if (hawk_htb_search(hawk->parse.named, name->ptr, name->len) != HAWK_NULL) { /* the function call conflicts with a named variable */ #if defined(HAWK_ENABLE_FUN_AS_VALUE) is_fncall_var = 1; goto named_var; #else - hawk_seterrfmt (awk, xloc, HAWK_EVARRED, HAWK_T("variable '%.*js' redefined"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EVARRED, HAWK_T("variable '%.*js' redefined"), name->len, name->ptr); #endif } else { - nde = parse_fncall(awk, name, HAWK_NULL, xloc, 0); + nde = parse_fncall(hawk, name, HAWK_NULL, xloc, 0); } } else @@ -5516,16 +5516,16 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo * while the name is not resolved to anything, we treat the space * as concatention by blanks. so we handle the name as a named * variable. */ - tmp = (hawk_nde_var_t*)hawk_callocmem(awk, HAWK_SIZEOF(*tmp)); - if (tmp == HAWK_NULL) ADJERR_LOC (awk, xloc); + tmp = (hawk_nde_var_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*tmp)); + if (tmp == HAWK_NULL) ADJERR_LOC (hawk, xloc); else { /* collect unique instances of a named variable * for reference */ - if (hawk_htb_upsert(awk->parse.named, name->ptr, name->len, HAWK_NULL, 0) == HAWK_NULL) + if (hawk_htb_upsert(hawk->parse.named, name->ptr, name->len, HAWK_NULL, 0) == HAWK_NULL) { - ADJERR_LOC (awk, xloc); - hawk_freemem (awk, tmp); + ADJERR_LOC (hawk, xloc); + hawk_freemem (hawk, tmp); } else { @@ -5539,7 +5539,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo #if defined(HAWK_ENABLE_FUN_AS_VALUE) if (is_fncall_var) - nde = parse_fncall(awk, (const hawk_oocs_t*)nde, HAWK_NULL, xloc, FNCALL_FLAG_VAR); + nde = parse_fncall(hawk, (const hawk_oocs_t*)nde, HAWK_NULL, xloc, FNCALL_FLAG_VAR); #endif } } @@ -5547,16 +5547,16 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo } else { - if (MATCH(awk,TOK_LPAREN)) + if (MATCH(hawk,TOK_LPAREN)) { /* it is a function call as the name is followed * by ( with/without spaces and implicit variables are disabled. */ - nde = parse_fncall(awk, name, HAWK_NULL, xloc, 0); + nde = parse_fncall(hawk, name, HAWK_NULL, xloc, 0); } else { /* undefined variable */ - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, name->len, name->ptr); } } } @@ -5564,7 +5564,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo return nde; } -static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc, const hawk_oocs_t* full, const hawk_oocs_t segs[], int nsegs) +static hawk_nde_t* parse_primary_ident_segs (hawk_t* hawk, const hawk_loc_t* xloc, const hawk_oocs_t* full, const hawk_oocs_t segs[], int nsegs) { /* parse xxx::yyy */ @@ -5573,50 +5573,50 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc hawk_mod_sym_t sym; hawk_fnc_t fnc; - mod = query_module(awk, segs, nsegs, &sym); + mod = query_module(hawk, segs, nsegs, &sym); if (mod == HAWK_NULL) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); } else { switch (sym.type) { case HAWK_MOD_FNC: - if ((awk->opt.trait & sym.u.fnc.trait) != sym.u.fnc.trait) + if ((hawk->opt.trait & sym.u.fnc.trait) != sym.u.fnc.trait) { - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr); break; } - if (MATCH(awk,TOK_LPAREN)) + if (MATCH(hawk,TOK_LPAREN)) { HAWK_MEMSET (&fnc, 0, HAWK_SIZEOF(fnc)); fnc.name.ptr = full->ptr; fnc.name.len = full->len; fnc.spec = sym.u.fnc; fnc.mod = mod; - nde = parse_fncall (awk, full, &fnc, xloc, 0); + nde = parse_fncall (hawk, full, &fnc, xloc, 0); } else { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELPAREN, FMT_ELPAREN, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); } break; case HAWK_MOD_INT: - nde = new_int_node(awk, sym.u.in.val, xloc); + nde = new_int_node(hawk, sym.u.in.val, xloc); /* i don't remember the symbol in the original form */ break; case HAWK_MOD_FLT: - nde = new_flt_node(awk, sym.u.flt.val, xloc); + nde = new_flt_node(hawk, sym.u.flt.val, xloc); /* i don't remember the symbol in the original form */ break; default: /* TODO: support MOD_VAR */ - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr); break; } } @@ -5624,21 +5624,21 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* awk, const hawk_loc_t* xloc return nde; } -static hawk_nde_t* parse_primary_ident (hawk_t* awk, const hawk_loc_t* xloc) +static hawk_nde_t* parse_primary_ident (hawk_t* hawk, const hawk_loc_t* xloc) { hawk_nde_t* nde = HAWK_NULL; hawk_oocs_t name[2]; /* TODO: support more than 2 segments??? */ int nsegs; - HAWK_ASSERT (MATCH(awk,TOK_IDENT)); + HAWK_ASSERT (MATCH(hawk,TOK_IDENT)); - nsegs = dup_ident_and_get_next(awk, xloc, name, HAWK_COUNTOF(name)); + nsegs = dup_ident_and_get_next(hawk, xloc, name, HAWK_COUNTOF(name)); if (nsegs <= -1) return HAWK_NULL; if (nsegs <= 1) { - nde = parse_primary_ident_noseg(awk, xloc, &name[0]); - if (!nde) hawk_freemem (awk, name[0].ptr); + nde = parse_primary_ident_noseg(hawk, xloc, &name[0]); + if (!nde) hawk_freemem (hawk, name[0].ptr); } else { @@ -5647,7 +5647,7 @@ static hawk_nde_t* parse_primary_ident (hawk_t* awk, const hawk_loc_t* xloc) int i; for (capa = 0, i = 0; i < nsegs; i++) capa += name[i].len + 2; /* +2 for :: */ - full.ptr = hawk_allocmem(awk, HAWK_SIZEOF(*full.ptr) * (capa + 1)); + full.ptr = hawk_allocmem(hawk, HAWK_SIZEOF(*full.ptr) * (capa + 1)); if (full.ptr) { capa = hawk_copy_oochars_to_oocstr_unlimited(&full.ptr[0], name[0].ptr, name[0].len); @@ -5659,28 +5659,28 @@ static hawk_nde_t* parse_primary_ident (hawk_t* awk, const hawk_loc_t* xloc) full.ptr[capa] = HAWK_T('\0'); full.len = capa; - nde = parse_primary_ident_segs(awk, xloc, &full, name, nsegs); + nde = parse_primary_ident_segs(hawk, xloc, &full, name, nsegs); if (!nde || nde->type != HAWK_NDE_FNCALL_FNC) { /* the FNC node takes the full name but other * nodes don't. so i need to free it. i know it's ugly. */ - hawk_freemem (awk, full.ptr); + hawk_freemem (hawk, full.ptr); } } else { /* error number is set in hawk_allocmem */ - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); } /* i don't need the name segments */ - while (nsegs > 0) hawk_freemem (awk, name[--nsegs].ptr); + while (nsegs > 0) hawk_freemem (hawk, name[--nsegs].ptr); } return nde; } -static hawk_nde_t* parse_hashidx (hawk_t* awk, const hawk_oocs_t* name, const hawk_loc_t* xloc) +static hawk_nde_t* parse_hashidx (hawk_t* hawk, const hawk_oocs_t* name, const hawk_loc_t* xloc) { hawk_nde_t* idx, * tmp, * last; hawk_nde_var_t* nde; @@ -5694,20 +5694,20 @@ more_idx: #endif do { - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - if (idx) hawk_clrpt (awk, idx); + if (idx) hawk_clrpt (hawk, idx); return HAWK_NULL; } { hawk_loc_t eloc; - eloc = awk->tok.loc; - tmp = parse_expr_withdc(awk, &eloc); + eloc = hawk->tok.loc; + tmp = parse_expr_withdc(hawk, &eloc); } if (HAWK_UNLIKELY(!tmp)) { - if (idx) hawk_clrpt (awk, idx); + if (idx) hawk_clrpt (hawk, idx); return HAWK_NULL; } @@ -5725,33 +5725,33 @@ more_idx: last = tmp; } } - while (MATCH(awk,TOK_COMMA)); + while (MATCH(hawk,TOK_COMMA)); HAWK_ASSERT (idx != HAWK_NULL); - if (!MATCH(awk,TOK_RBRACK)) + if (!MATCH(hawk,TOK_RBRACK)) { - hawk_clrpt (awk, idx); - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ERBRACK, FMT_ERBRACK, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_clrpt (hawk, idx); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ERBRACK, FMT_ERBRACK, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return HAWK_NULL; } - if (get_token(awk) <= -1) + if (get_token(hawk) <= -1) { - hawk_clrpt (awk, idx); + hawk_clrpt (hawk, idx); return HAWK_NULL; } #if defined(HAWK_ENABLE_GC) - if (MATCH(awk,TOK_LBRACK)) + if (MATCH(hawk,TOK_LBRACK)) { /* additional index - a[10][20] ... * use the NULL node as a splitter */ - tmp = (hawk_nde_t*)hawk_callocmem(awk, HAWK_SIZEOF(*tmp)); + tmp = (hawk_nde_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*tmp)); if (HAWK_UNLIKELY(!tmp)) { - hawk_clrpt (awk, idx); - ADJERR_LOC (awk, xloc); + hawk_clrpt (hawk, idx); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } tmp->type = HAWK_NDE_NULL; @@ -5765,16 +5765,16 @@ more_idx: } #endif - nde = (hawk_nde_var_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde)); + nde = (hawk_nde_var_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); if (HAWK_UNLIKELY(!nde)) { - hawk_clrpt (awk, idx); - ADJERR_LOC (awk, xloc); + hawk_clrpt (hawk, idx); + ADJERR_LOC (hawk, xloc); return HAWK_NULL; } /* search the local variable list */ - idxa = hawk_arr_rsearch(awk->parse.lcls, HAWK_ARR_SIZE(awk->parse.lcls), name->ptr, name->len); + idxa = hawk_arr_rsearch(hawk->parse.lcls, HAWK_ARR_SIZE(hawk->parse.lcls), name->ptr, name->len); if (idxa != HAWK_ARR_NIL) { nde->type = HAWK_NDE_LCLIDX; @@ -5789,7 +5789,7 @@ more_idx: } /* search the parameter name list */ - idxa = hawk_arr_search(awk->parse.params, 0, name->ptr, name->len); + idxa = hawk_arr_search(hawk->parse.params, 0, name->ptr, name->len); if (idxa != HAWK_ARR_NIL) { nde->type = HAWK_NDE_ARGIDX; @@ -5804,7 +5804,7 @@ more_idx: } /* gets the global variable index */ - idxa = get_global(awk, name); + idxa = get_global(hawk, name); if (idxa != HAWK_ARR_NIL) { nde->type = HAWK_NDE_GBLIDX; @@ -5818,18 +5818,18 @@ more_idx: return (hawk_nde_t*)nde; } - /*if (awk->opt.trait & HAWK_IMPLICIT) */ - if (awk->parse.pragma.trait & HAWK_IMPLICIT) + /*if (hawk->opt.trait & HAWK_IMPLICIT) */ + if (hawk->parse.pragma.trait & HAWK_IMPLICIT) { - int fnname = isfnname(awk, name); + int fnname = isfnname(hawk, name); switch (fnname) { case FNTYPE_FNC: - hawk_seterrfmt (awk, xloc, HAWK_EFNCRED, HAWK_T("intrinsic function '%.*js' redefined"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EFNCRED, HAWK_T("intrinsic function '%.*js' redefined"), name->len, name->ptr); goto exit_func; case FNTYPE_FUN: - hawk_seterrfmt (awk, xloc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EFUNRED, HAWK_T("function '%.*js' redefined"), name->len, name->ptr); goto exit_func; } @@ -5846,16 +5846,16 @@ more_idx: } /* undefined variable */ - hawk_seterrfmt (awk, xloc, HAWK_EUNDEF, FMT_EUNDEF, name->len, name->ptr); + hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, name->len, name->ptr); exit_func: - hawk_clrpt (awk, idx); - hawk_freemem (awk, nde); + hawk_clrpt (hawk, idx); + hawk_freemem (hawk, nde); return HAWK_NULL; } -static hawk_nde_t* parse_fncall (hawk_t* awk, const hawk_oocs_t* name, hawk_fnc_t* fnc, const hawk_loc_t* xloc, int flags) +static hawk_nde_t* parse_fncall (hawk_t* hawk, const hawk_oocs_t* name, hawk_fnc_t* fnc, const hawk_loc_t* xloc, int flags) { hawk_nde_t* head, * curr, * nde; hawk_nde_fncall_t* call; @@ -5867,20 +5867,20 @@ static hawk_nde_t* parse_fncall (hawk_t* awk, const hawk_oocs_t* name, hawk_fnc_ nargs = 0; if (flags & FNCALL_FLAG_NOARG) goto make_node; - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; - if (MATCH(awk,TOK_RPAREN)) + if (MATCH(hawk,TOK_RPAREN)) { /* no parameters to the function call */ - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } else { /* parse function parameters */ while (1) { - eloc = awk->tok.loc; - nde = parse_expr_withdc(awk, &eloc); + eloc = hawk->tok.loc; + nde = parse_expr_withdc(hawk, &eloc); if (!nde) goto oops; if (!head) head = nde; @@ -5889,32 +5889,32 @@ static hawk_nde_t* parse_fncall (hawk_t* awk, const hawk_oocs_t* name, hawk_fnc_ nargs++; - if (MATCH(awk,TOK_RPAREN)) + if (MATCH(hawk,TOK_RPAREN)) { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; break; } - if (!MATCH(awk,TOK_COMMA)) + if (!MATCH(hawk,TOK_COMMA)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ECOMMA, FMT_ECOMMA, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); goto oops; } do { - if (get_token(awk) <= -1) goto oops; + if (get_token(hawk) <= -1) goto oops; } - while (MATCH(awk,TOK_NEWLINE)); + while (MATCH(hawk,TOK_NEWLINE)); } } make_node: - call = (hawk_nde_fncall_t*)hawk_callocmem(awk, HAWK_SIZEOF(*call)); + call = (hawk_nde_fncall_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*call)); if (!call) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } @@ -5941,12 +5941,12 @@ make_node: if (nargs > call->u.fnc.spec.arg.max) { - hawk_seterrnum (awk, xloc, HAWK_EARGTM); + hawk_seterrnum (hawk, xloc, HAWK_EARGTM); goto oops; } else if (nargs < call->u.fnc.spec.arg.min) { - hawk_seterrnum (awk, xloc, HAWK_EARGTF); + hawk_seterrnum (hawk, xloc, HAWK_EARGTF); goto oops; } } @@ -5959,10 +5959,10 @@ make_node: call->args = head; call->nargs = nargs; - /* store a non-builtin function call into the awk->parse.funs table */ - if (!hawk_htb_upsert(awk->parse.funs, name->ptr, name->len, call, 0)) + /* store a non-builtin function call into the hawk->parse.funs table */ + if (!hawk_htb_upsert(hawk->parse.funs, name->ptr, name->len, call, 0)) { - ADJERR_LOC (awk, xloc); + ADJERR_LOC (hawk, xloc); goto oops; } } @@ -5970,32 +5970,32 @@ make_node: return (hawk_nde_t*)call; oops: - if (call) hawk_freemem (awk, call); - if (head) hawk_clrpt (awk, head); + if (call) hawk_freemem (hawk, call); + if (head) hawk_clrpt (hawk, head); return HAWK_NULL; } -static int get_number (hawk_t* awk, hawk_tok_t* tok) +static int get_number (hawk_t* hawk, hawk_tok_t* tok) { hawk_ooci_t c; HAWK_ASSERT (HAWK_OOECS_LEN(tok->name) == 0); - SET_TOKEN_TYPE (awk, tok, TOK_INT); + SET_TOKEN_TYPE (hawk, tok, TOK_INT); - c = awk->sio.last.c; + c = hawk->sio.last.c; if (c == HAWK_T('0')) { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_T('x') || c == HAWK_T('X')) { /* hexadecimal number */ do { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } while (hawk_is_ooch_xdigit(c)); @@ -6006,8 +6006,8 @@ static int get_number (hawk_t* awk, hawk_tok_t* tok) /* binary number */ do { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } while (c == HAWK_T('0') || c == HAWK_T('1')); @@ -6018,13 +6018,13 @@ static int get_number (hawk_t* awk, hawk_tok_t* tok) /* octal number */ while (c >= HAWK_T('0') && c <= HAWK_T('7')) { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } if (c == HAWK_T('8') || c == HAWK_T('9')) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_ELXCHR, HAWK_T("invalid digit '%jc'"), (hawk_ooch_t)c); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_ELXCHR, HAWK_T("invalid digit '%jc'"), (hawk_ooch_t)c); return -1; } @@ -6034,42 +6034,42 @@ static int get_number (hawk_t* awk, hawk_tok_t* tok) while (hawk_is_ooch_digit(c)) { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } if (c == HAWK_T('.')) { /* floating-point number */ - SET_TOKEN_TYPE (awk, tok, TOK_FLT); + SET_TOKEN_TYPE (hawk, tok, TOK_FLT); - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); while (hawk_is_ooch_digit(c)) { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } } if (c == HAWK_T('E') || c == HAWK_T('e')) { - SET_TOKEN_TYPE (awk, tok, TOK_FLT); + SET_TOKEN_TYPE (hawk, tok, TOK_FLT); - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_T('+') || c == HAWK_T('-')) { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } while (hawk_is_ooch_digit(c)) { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } } @@ -6077,13 +6077,13 @@ static int get_number (hawk_t* awk, hawk_tok_t* tok) } /* i think allowing only up to 2 hexadigits is more useful though it - * may break compatibilty with other awk implementations. If you want + * may break compatibilty with other hawk implementations. If you want * more than 2, define HEX_DIGIT_LIMIT_FOR_X to HAWK_TYPE_MAX(hawk_oow_t). */ /*#define HEX_DIGIT_LIMIT_FOR_X (HAWK_TYPE_MAX(hawk_oow_t))*/ #define HEX_DIGIT_LIMIT_FOR_X (2) static int get_string ( - hawk_t* awk, hawk_ooch_t end_char, + hawk_t* hawk, hawk_ooch_t end_char, hawk_ooch_t esc_char, int keep_esc_char, int byte_only, hawk_oow_t preescaped, hawk_tok_t* tok) { @@ -6094,11 +6094,11 @@ static int get_string ( while (1) { - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_OOCI_EOF) { - hawk_seterrnum (awk, &awk->tok.loc, HAWK_ESTRNC); + hawk_seterrnum (hawk, &hawk->tok.loc, HAWK_ESTRNC); return -1; } @@ -6107,7 +6107,7 @@ static int get_string ( #else if (byte_only && c != HAWK_T('\\') && !HAWK_BYTE_PRINTABLE(c)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EMBSCHR, HAWK_T("invalid mbs character '%jc'"), (hawk_ooch_t)c); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EMBSCHR, HAWK_T("invalid mbs character '%jc'"), (hawk_ooch_t)c); return -1; } #endif @@ -6122,14 +6122,14 @@ static int get_string ( { /* should i limit the max to 0xFF/0377? if (c_acc > 0377) c_acc = 0377; */ - ADD_TOKEN_UINT32 (awk, tok, c_acc); + ADD_TOKEN_UINT32 (hawk, tok, c_acc); escaped = 0; } continue; } else { - ADD_TOKEN_UINT32 (awk, tok, c_acc); + ADD_TOKEN_UINT32 (hawk, tok, c_acc); escaped = 0; } } @@ -6141,7 +6141,7 @@ static int get_string ( digit_count++; if (digit_count >= escaped) { - ADD_TOKEN_UINT32 (awk, tok, c_acc); + ADD_TOKEN_UINT32 (hawk, tok, c_acc); escaped = 0; } continue; @@ -6152,7 +6152,7 @@ static int get_string ( digit_count++; if (digit_count >= escaped) { - ADD_TOKEN_UINT32 (awk, tok, c_acc); + ADD_TOKEN_UINT32 (hawk, tok, c_acc); escaped = 0; } continue; @@ -6163,7 +6163,7 @@ static int get_string ( digit_count++; if (digit_count >= escaped) { - ADD_TOKEN_UINT32 (awk, tok, c_acc); + ADD_TOKEN_UINT32 (hawk, tok, c_acc); escaped = 0; } continue; @@ -6184,9 +6184,9 @@ static int get_string ( * 'c' is at the first G. this part is to restore the * \x part. since \x is not followed by any hexadecimal * digits, it's literally 'x' */ - ADD_TOKEN_CHAR (awk, tok, ec); + ADD_TOKEN_CHAR (hawk, tok, ec); } - else ADD_TOKEN_UINT32 (awk, tok, c_acc); + else ADD_TOKEN_UINT32 (hawk, tok, c_acc); escaped = 0; /* carray on to handle the current character */ @@ -6205,8 +6205,8 @@ static int get_string ( if (c == end_char) { /* terminating quote */ - /*GET_CHAR_TO (awk, c);*/ - GET_CHAR (awk); + /*GET_CHAR_TO (hawk, c);*/ + GET_CHAR (hawk); break; } else if (c == esc_char) @@ -6214,9 +6214,9 @@ static int get_string ( escaped = 1; continue; } - else if (!(awk->parse.pragma.trait & HAWK_MULTILINESTR) && (c == '\n' || c == '\r')) + else if (!(hawk->parse.pragma.trait & HAWK_MULTILINESTR) && (c == '\n' || c == '\r')) { - hawk_seterrnum (awk, &awk->tok.loc, HAWK_ESTRNC); + hawk_seterrnum (hawk, &hawk->tok.loc, HAWK_ESTRNC); return -1; } } @@ -6282,21 +6282,21 @@ static int get_string ( * an unhandled escape sequence can be handled * outside this function since the escape character * is preserved.*/ - ADD_TOKEN_CHAR (awk, tok, esc_char); + ADD_TOKEN_CHAR (hawk, tok, esc_char); } escaped = 0; } - ADD_TOKEN_CHAR (awk, tok, c); + ADD_TOKEN_CHAR (hawk, tok, c); } return 0; } -static int get_rexstr (hawk_t* awk, hawk_tok_t* tok) +static int get_rexstr (hawk_t* hawk, hawk_tok_t* tok) { - if (awk->sio.last.c == HAWK_T('/')) + if (hawk->sio.last.c == HAWK_T('/')) { /* handle an empty regular expression. * @@ -6307,13 +6307,13 @@ static int get_rexstr (hawk_t* awk, hawk_tok_t* tok) * the token type is set to TOK_REX, this function can * just return after reading the next character. * see parse_primary_rex(). */ - GET_CHAR (awk); + GET_CHAR (hawk); return 0; } else { hawk_oow_t preescaped = 0; - if (awk->sio.last.c == HAWK_T('\\')) + if (hawk->sio.last.c == HAWK_T('\\')) { /* for input like /\//, this condition is met. * the initial escape character is added when the @@ -6324,24 +6324,24 @@ static int get_rexstr (hawk_t* awk, hawk_tok_t* tok) { /* add other initial characters here as get_string() * begins with reading the next character */ - ADD_TOKEN_CHAR (awk, tok, awk->sio.last.c); + ADD_TOKEN_CHAR (hawk, tok, hawk->sio.last.c); } - return get_string(awk, HAWK_T('/'), HAWK_T('\\'), 1, 0, preescaped, tok); + return get_string(hawk, HAWK_T('/'), HAWK_T('\\'), 1, 0, preescaped, tok); } } -static int get_single_quoted_string (hawk_t* awk, int byte_only, hawk_tok_t* tok) +static int get_single_quoted_string (hawk_t* hawk, int byte_only, hawk_tok_t* tok) { hawk_ooci_t c; while (1) { - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_OOCI_EOF) { - hawk_seterrnum (awk, &awk->tok.loc, HAWK_ESTRNC); + hawk_seterrnum (hawk, &hawk->tok.loc, HAWK_ESTRNC); return -1; } @@ -6350,7 +6350,7 @@ static int get_single_quoted_string (hawk_t* awk, int byte_only, hawk_tok_t* tok #else if (byte_only && c != HAWK_T('\\') && !HAWK_BYTE_PRINTABLE(c)) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EMBSCHR, HAWK_T("invalid mbs character '%jc'"), (hawk_ooch_t)c); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EMBSCHR, HAWK_T("invalid mbs character '%jc'"), (hawk_ooch_t)c); return -1; } #endif @@ -6358,26 +6358,26 @@ static int get_single_quoted_string (hawk_t* awk, int byte_only, hawk_tok_t* tok if (c == HAWK_T('\'')) { /* terminating quote */ - GET_CHAR (awk); + GET_CHAR (hawk); break; } - ADD_TOKEN_CHAR (awk, tok, c); + ADD_TOKEN_CHAR (hawk, tok, c); } return 0; } -static int skip_spaces (hawk_t* awk) +static int skip_spaces (hawk_t* hawk) { - hawk_ooci_t c = awk->sio.last.c; + hawk_ooci_t c = hawk->sio.last.c; - if (awk->opt.trait & HAWK_NEWLINE) + if (hawk->opt.trait & HAWK_NEWLINE) { do { while (c != HAWK_T('\n') && hawk_is_ooch_space(c)) - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_T('\\')) { @@ -6385,28 +6385,28 @@ static int skip_spaces (hawk_t* awk) hawk_sio_lxc_t cr; int hascr = 0; - bs = awk->sio.last; - GET_CHAR_TO (awk, c); + bs = hawk->sio.last; + GET_CHAR_TO (hawk, c); if (c == HAWK_T('\r')) { hascr = 1; - cr = awk->sio.last; - GET_CHAR_TO (awk, c); + cr = hawk->sio.last; + GET_CHAR_TO (hawk, c); } if (c == HAWK_T('\n')) { - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); continue; } else { /* push back the last character */ - unget_char (awk, &awk->sio.last); + unget_char (hawk, &hawk->sio.last); /* push CR if any */ - if (hascr) unget_char (awk, &cr); + if (hascr) unget_char (hawk, &cr); /* restore the orginal backslash */ - awk->sio.last = bs; + hawk->sio.last = bs; } } @@ -6416,24 +6416,24 @@ static int skip_spaces (hawk_t* awk) } else { - while (hawk_is_ooch_space(c)) GET_CHAR_TO (awk, c); + while (hawk_is_ooch_space(c)) GET_CHAR_TO (hawk, c); } return 0; } -static int skip_comment (hawk_t* awk) +static int skip_comment (hawk_t* hawk) { - hawk_ooci_t c = awk->sio.last.c; + hawk_ooci_t c = hawk->sio.last.c; hawk_sio_lxc_t lc; if (c == HAWK_T('#')) { /* skip up to \n */ - do { GET_CHAR_TO (awk, c); } + do { GET_CHAR_TO (hawk, c); } while (c != HAWK_T('\n') && c != HAWK_OOCI_EOF); - if (!(awk->opt.trait & HAWK_NEWLINE)) GET_CHAR (awk); + if (!(hawk->opt.trait & HAWK_NEWLINE)) GET_CHAR (hawk); return 1; /* comment by # */ } @@ -6441,42 +6441,42 @@ static int skip_comment (hawk_t* awk) if (c != HAWK_T('/')) return 0; /* not a comment */ /* save the last character */ - lc = awk->sio.last; + lc = hawk->sio.last; /* read a new character */ - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_T('*')) { do { - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_OOCI_EOF) { hawk_loc_t loc; - loc.line = awk->sio.inp->line; - loc.colm = awk->sio.inp->colm; - loc.file = awk->sio.inp->path; - hawk_seterrnum (awk, &loc, HAWK_ECMTNC); + loc.line = hawk->sio.inp->line; + loc.colm = hawk->sio.inp->colm; + loc.file = hawk->sio.inp->path; + hawk_seterrnum (hawk, &loc, HAWK_ECMTNC); return -1; } if (c == HAWK_T('*')) { - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_OOCI_EOF) { hawk_loc_t loc; - loc.line = awk->sio.inp->line; - loc.colm = awk->sio.inp->colm; - loc.file = awk->sio.inp->path; - hawk_seterrnum (awk, &loc, HAWK_ECMTNC); + loc.line = hawk->sio.inp->line; + loc.colm = hawk->sio.inp->colm; + loc.file = hawk->sio.inp->path; + hawk_seterrnum (hawk, &loc, HAWK_ECMTNC); return -1; } if (c == HAWK_T('/')) { - /*GET_CHAR_TO (awk, c);*/ - GET_CHAR (awk); + /*GET_CHAR_TO (hawk, c);*/ + GET_CHAR (hawk); break; } } @@ -6487,14 +6487,14 @@ static int skip_comment (hawk_t* awk) } /* unget '*' */ - unget_char (awk, &awk->sio.last); + unget_char (hawk, &hawk->sio.last); /* restore the previous state */ - awk->sio.last = lc; + hawk->sio.last = lc; return 0; } -static int get_symbols (hawk_t* awk, hawk_ooci_t c, hawk_tok_t* tok) +static int get_symbols (hawk_t* hawk, hawk_ooci_t c, hawk_tok_t* tok) { struct ops_t { @@ -6574,19 +6574,19 @@ static int get_symbols (hawk_t* awk, hawk_ooci_t c, hawk_tok_t* tok) for (p = ops; p->str != HAWK_NULL; ) { - if (p->trait == 0 || (awk->opt.trait & p->trait)) + if (p->trait == 0 || (hawk->opt.trait & p->trait)) { if (p->str[idx] == HAWK_T('\0')) { - ADD_TOKEN_STR (awk, tok, p->str, p->len); - SET_TOKEN_TYPE (awk, tok, p->tid); + ADD_TOKEN_STR (hawk, tok, p->str, p->len); + SET_TOKEN_TYPE (hawk, tok, p->tid); return 1; } if (c == p->str[idx]) { idx++; - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); continue; } } @@ -6597,7 +6597,7 @@ static int get_symbols (hawk_t* awk, hawk_ooci_t c, hawk_tok_t* tok) return 0; } -static int get_token_into (hawk_t* awk, hawk_tok_t* tok) +static int get_token_into (hawk_t* hawk, hawk_tok_t* tok) { hawk_ooci_t c; int n; @@ -6606,58 +6606,58 @@ static int get_token_into (hawk_t* awk, hawk_tok_t* tok) retry: do { - if (skip_spaces(awk) <= -1) return -1; - if ((n = skip_comment(awk)) <= -1) return -1; + if (skip_spaces(hawk) <= -1) return -1; + if ((n = skip_comment(hawk)) <= -1) return -1; } while (n >= 1); hawk_ooecs_clear (tok->name); - tok->loc.file = awk->sio.last.file; - tok->loc.line = awk->sio.last.line; - tok->loc.colm = awk->sio.last.colm; + tok->loc.file = hawk->sio.last.file; + tok->loc.line = hawk->sio.last.line; + tok->loc.colm = hawk->sio.last.colm; - c = awk->sio.last.c; + c = hawk->sio.last.c; if (c == HAWK_OOCI_EOF) { - n = end_include(awk); + n = end_include(hawk); if (n <= -1) return -1; if (n >= 1) { - /*awk->sio.last = awk->sio.inp->last;*/ + /*hawk->sio.last = hawk->sio.inp->last;*/ /* mark that i'm retrying after end of an included file */ skip_semicolon_after_include = 1; goto retry; } - ADD_TOKEN_STR (awk, tok, HAWK_T(""), 5); - SET_TOKEN_TYPE (awk, tok, TOK_EOF); + ADD_TOKEN_STR (hawk, tok, HAWK_T(""), 5); + SET_TOKEN_TYPE (hawk, tok, TOK_EOF); } else if (c == HAWK_T('\n')) { - /*ADD_TOKEN_CHAR (awk, tok, HAWK_T('\n'));*/ - ADD_TOKEN_STR (awk, tok, HAWK_T(""), 4); - SET_TOKEN_TYPE (awk, tok, TOK_NEWLINE); - GET_CHAR (awk); + /*ADD_TOKEN_CHAR (hawk, tok, HAWK_T('\n'));*/ + ADD_TOKEN_STR (hawk, tok, HAWK_T(""), 4); + SET_TOKEN_TYPE (hawk, tok, TOK_NEWLINE); + GET_CHAR (hawk); } else if (hawk_is_ooch_digit(c)/*|| c == HAWK_T('.')*/) { - if (get_number (awk, tok) <= -1) return -1; + if (get_number (hawk, tok) <= -1) return -1; } else if (c == HAWK_T('.')) { hawk_sio_lxc_t lc; - lc = awk->sio.last; - GET_CHAR_TO (awk, c); + lc = hawk->sio.last; + GET_CHAR_TO (hawk, c); - unget_char (awk, &awk->sio.last); - awk->sio.last = lc; + unget_char (hawk, &hawk->sio.last); + hawk->sio.last = lc; if (hawk_is_ooch_digit(c)) { /* for a token such as .123 */ - if (get_number(awk, tok) <= -1) return -1; + if (get_number(hawk, tok) <= -1) return -1; } else { @@ -6669,14 +6669,14 @@ retry: { int type; - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); /* if (c == HAWK_T('@')) { - SET_TOKEN_TYPE (awk, tok, TOK_DBLAT); - GET_CHAR (awk); + SET_TOKEN_TYPE (hawk, tok, TOK_DBLAT); + GET_CHAR (hawk); }*/ /* other special extended operators here else if (c == HAWK_T('*')) @@ -6686,7 +6686,7 @@ retry: { /* this extended keyword is empty, * not followed by a valid word */ - hawk_seterrnum (awk, &(awk)->tok.loc, HAWK_EXKWEM); + hawk_seterrnum (hawk, &(hawk)->tok.loc, HAWK_EXKWEM); return -1; } else @@ -6694,37 +6694,37 @@ retry: /* expect normal identifier starting with an alphabet */ do { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } while (c == HAWK_T('_') || hawk_is_ooch_alpha(c) || hawk_is_ooch_digit(c)); - type = classify_ident(awk, HAWK_OOECS_OOCS(tok->name)); + type = classify_ident(hawk, HAWK_OOECS_OOCS(tok->name)); if (type == TOK_IDENT) { - hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EXKWNR, FMT_EXKWNR, HAWK_OOECS_LEN(awk->tok.name), HAWK_OOECS_PTR(awk->tok.name)); + hawk_seterrfmt (hawk, &hawk->tok.loc, HAWK_EXKWNR, FMT_EXKWNR, HAWK_OOECS_LEN(hawk->tok.name), HAWK_OOECS_PTR(hawk->tok.name)); return -1; } - SET_TOKEN_TYPE (awk, tok, type); + SET_TOKEN_TYPE (hawk, tok, type); } } else if (c == HAWK_T('B')) { - GET_CHAR_TO (awk, c); + GET_CHAR_TO (hawk, c); if (c == HAWK_T('\"')) { /* multi-byte string/byte array */ - SET_TOKEN_TYPE (awk, tok, TOK_MBS); - if (get_string(awk, c, HAWK_T('\\'), 0, 1, 0, tok) <= -1) return -1; + SET_TOKEN_TYPE (hawk, tok, TOK_MBS); + if (get_string(hawk, c, HAWK_T('\\'), 0, 1, 0, tok) <= -1) return -1; } else if (c == HAWK_T('\'')) { - SET_TOKEN_TYPE (awk, tok, TOK_MBS); - if (get_single_quoted_string(awk, 1, tok) <= -1) return -1; + SET_TOKEN_TYPE (hawk, tok, TOK_MBS); + if (get_single_quoted_string(hawk, 1, tok) <= -1) return -1; } else { - ADD_TOKEN_CHAR (awk, tok, HAWK_T('B')); + ADD_TOKEN_CHAR (hawk, tok, HAWK_T('B')); goto process_identifier; } } @@ -6736,41 +6736,41 @@ retry: /* identifier */ do { - ADD_TOKEN_CHAR (awk, tok, c); - GET_CHAR_TO (awk, c); + ADD_TOKEN_CHAR (hawk, tok, c); + GET_CHAR_TO (hawk, c); } while (c == HAWK_T('_') || hawk_is_ooch_alpha(c) || hawk_is_ooch_digit(c)); - type = classify_ident(awk, HAWK_OOECS_OOCS(tok->name)); - SET_TOKEN_TYPE (awk, tok, type); + type = classify_ident(hawk, HAWK_OOECS_OOCS(tok->name)); + SET_TOKEN_TYPE (hawk, tok, type); } else if (c == HAWK_T('\"')) { /* double-quoted string */ - SET_TOKEN_TYPE (awk, tok, TOK_STR); - if (get_string(awk, c, HAWK_T('\\'), 0, 0, 0, tok) <= -1) return -1; + SET_TOKEN_TYPE (hawk, tok, TOK_STR); + if (get_string(hawk, c, HAWK_T('\\'), 0, 0, 0, tok) <= -1) return -1; } else if (c == HAWK_T('\'')) { /* single-quoted string - no escaping */ - SET_TOKEN_TYPE (awk, tok, TOK_STR); - if (get_single_quoted_string(awk, 0, tok) <= -1) return -1; + SET_TOKEN_TYPE (hawk, tok, TOK_STR); + if (get_single_quoted_string(hawk, 0, tok) <= -1) return -1; } else { try_get_symbols: - n = get_symbols(awk, c, tok); + n = get_symbols(hawk, c, tok); if (n <= -1) return -1; if (n == 0) { /* not handled yet */ if (c == HAWK_T('\0')) { - hawk_seterrfmt (awk, &tok->loc, HAWK_ELXCHR, HAWK_T("invalid character '\\0'")); + hawk_seterrfmt (hawk, &tok->loc, HAWK_ELXCHR, HAWK_T("invalid character '\\0'")); } else { - hawk_seterrfmt (awk, &tok->loc, HAWK_ELXCHR, HAWK_T("invalid character '%jc'"), (hawk_ooch_t)c); + hawk_seterrfmt (hawk, &tok->loc, HAWK_ELXCHR, HAWK_T("invalid character '%jc'"), (hawk_ooch_t)c); } return -1; } @@ -6784,46 +6784,46 @@ retry: } } - if (skip_semicolon_after_include && !(awk->opt.trait & HAWK_NEWLINE)) + if (skip_semicolon_after_include && !(hawk->opt.trait & HAWK_NEWLINE)) { /* semiclon has not been skipped yet and the newline option is not set. */ - hawk_seterrfmt (awk, &tok->loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(tok->name), HAWK_OOECS_PTR(tok->name)); + hawk_seterrfmt (hawk, &tok->loc, HAWK_ESCOLON, FMT_ESCOLON, HAWK_OOECS_LEN(tok->name), HAWK_OOECS_PTR(tok->name)); return -1; } return 0; } -static int get_token (hawk_t* awk) +static int get_token (hawk_t* hawk) { - awk->ptok.type = awk->tok.type; - awk->ptok.loc.file = awk->tok.loc.file; - awk->ptok.loc.line = awk->tok.loc.line; - awk->ptok.loc.colm = awk->tok.loc.colm; - hawk_ooecs_swap (awk->ptok.name, awk->tok.name); + hawk->ptok.type = hawk->tok.type; + hawk->ptok.loc.file = hawk->tok.loc.file; + hawk->ptok.loc.line = hawk->tok.loc.line; + hawk->ptok.loc.colm = hawk->tok.loc.colm; + hawk_ooecs_swap (hawk->ptok.name, hawk->tok.name); - if (HAWK_OOECS_LEN(awk->ntok.name) > 0) + if (HAWK_OOECS_LEN(hawk->ntok.name) > 0) { - awk->tok.type = awk->ntok.type; - awk->tok.loc.file = awk->ntok.loc.file; - awk->tok.loc.line = awk->ntok.loc.line; - awk->tok.loc.colm = awk->ntok.loc.colm; + hawk->tok.type = hawk->ntok.type; + hawk->tok.loc.file = hawk->ntok.loc.file; + hawk->tok.loc.line = hawk->ntok.loc.line; + hawk->tok.loc.colm = hawk->ntok.loc.colm; - hawk_ooecs_swap (awk->tok.name, awk->ntok.name); - hawk_ooecs_clear (awk->ntok.name); + hawk_ooecs_swap (hawk->tok.name, hawk->ntok.name); + hawk_ooecs_clear (hawk->ntok.name); return 0; } - return get_token_into (awk, &awk->tok); + return get_token_into (hawk, &hawk->tok); } -static int preget_token (hawk_t* awk) +static int preget_token (hawk_t* hawk) { /* LIMITATION: no more than one token can be pre-read in a row without consumption. */ - if (HAWK_OOECS_LEN(awk->ntok.name) > 0) + if (HAWK_OOECS_LEN(hawk->ntok.name) > 0) { /* you can't read more than 1 token in advance. * @@ -6857,12 +6857,12 @@ static int preget_token (hawk_t* awk) else { /* if there is no token pre-read, we get a new - * token and place it to awk->ntok. */ - return get_token_into (awk, &awk->ntok); + * token and place it to hawk->ntok. */ + return get_token_into (hawk, &hawk->ntok); } } -static int classify_ident (hawk_t* awk, const hawk_oocs_t* name) +static int classify_ident (hawk_t* hawk, const hawk_oocs_t* name) { /* perform binary search */ @@ -6891,7 +6891,7 @@ static int classify_ident (hawk_t* awk, const hawk_oocs_t* name) else if (n < 0) left = mid + 1; else { - if ((awk->opt.trait & kwp->trait) != kwp->trait) break; + if ((hawk->opt.trait & kwp->trait) != kwp->trait) break; return kwp->type; } } @@ -6924,13 +6924,13 @@ int hawk_isvalidident (hawk_t* hawk, const hawk_ooch_t* name) struct deparse_func_t { - hawk_t* awk; + hawk_t* hawk; hawk_ooch_t* tmp; hawk_oow_t tmp_len; int ret; }; -static int deparse (hawk_t* awk) +static int deparse (hawk_t* hawk) { hawk_nde_t* nde; hawk_chain_t* chain; @@ -6940,160 +6940,160 @@ static int deparse (hawk_t* awk) hawk_ooi_t op; hawk_oocs_t kw; - HAWK_ASSERT (awk->sio.outf != HAWK_NULL); + HAWK_ASSERT (hawk->sio.outf != HAWK_NULL); - HAWK_MEMSET (&awk->sio.arg, 0, HAWK_SIZEOF(awk->sio.arg)); + HAWK_MEMSET (&hawk->sio.arg, 0, HAWK_SIZEOF(hawk->sio.arg)); - op = awk->sio.outf(awk, HAWK_SIO_CMD_OPEN, &awk->sio.arg, HAWK_NULL, 0); + op = hawk->sio.outf(hawk, HAWK_SIO_CMD_OPEN, &hawk->sio.arg, HAWK_NULL, 0); if (op <= -1) return -1; #define EXIT_DEPARSE() do { n = -1; goto exit_deparse; } while(0) - if (awk->parse.pragma.rtx_stack_limit > 0 && awk->parse.pragma.rtx_stack_limit != awk->opt.rtx_stack_limit) + if (hawk->parse.pragma.rtx_stack_limit > 0 && hawk->parse.pragma.rtx_stack_limit != hawk->opt.rtx_stack_limit) { hawk_oow_t len; - len = hawk_int_to_oocstr((hawk_int_t)awk->parse.pragma.rtx_stack_limit, 10, HAWK_NULL, tmp, HAWK_COUNTOF(tmp)); - if (hawk_putsrcoocstr(awk, HAWK_T("@pragma stack_limit ")) <= -1 || - hawk_putsrcoochars (awk, tmp, len) <= -1 || - hawk_putsrcoocstr(awk, HAWK_T(";\n")) <= -1) EXIT_DEPARSE (); + len = hawk_int_to_oocstr((hawk_int_t)hawk->parse.pragma.rtx_stack_limit, 10, HAWK_NULL, tmp, HAWK_COUNTOF(tmp)); + if (hawk_putsrcoocstr(hawk, HAWK_T("@pragma stack_limit ")) <= -1 || + hawk_putsrcoochars (hawk, tmp, len) <= -1 || + hawk_putsrcoocstr(hawk, HAWK_T(";\n")) <= -1) EXIT_DEPARSE (); } - if (awk->tree.ngbls > awk->tree.ngbls_base) + if (hawk->tree.ngbls > hawk->tree.ngbls_base) { hawk_oow_t i, len; - HAWK_ASSERT (awk->tree.ngbls > 0); + HAWK_ASSERT (hawk->tree.ngbls > 0); - hawk_getkwname (awk, HAWK_KWID_XGLOBAL, &kw); - if (hawk_putsrcoochars(awk, kw.ptr, kw.len) <= -1 || hawk_putsrcoocstr (awk, HAWK_T(" ")) <= -1) EXIT_DEPARSE (); + hawk_getkwname (hawk, HAWK_KWID_XGLOBAL, &kw); + if (hawk_putsrcoochars(hawk, kw.ptr, kw.len) <= -1 || hawk_putsrcoocstr (hawk, HAWK_T(" ")) <= -1) EXIT_DEPARSE (); - for (i = awk->tree.ngbls_base; i < awk->tree.ngbls - 1; i++) + for (i = hawk->tree.ngbls_base; i < hawk->tree.ngbls - 1; i++) { - if (!(awk->opt.trait & HAWK_IMPLICIT)) + if (!(hawk->opt.trait & HAWK_IMPLICIT)) { /* use the actual name if no named variable is allowed */ - if (hawk_putsrcoochars (awk, HAWK_ARR_DPTR(awk->parse.gbls, i), HAWK_ARR_DLEN(awk->parse.gbls, i)) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoochars (hawk, HAWK_ARR_DPTR(hawk->parse.gbls, i), HAWK_ARR_DLEN(hawk->parse.gbls, i)) <= -1) EXIT_DEPARSE (); } else { len = hawk_int_to_oocstr((hawk_int_t)i, 10, HAWK_T("__g"), tmp, HAWK_COUNTOF(tmp)); HAWK_ASSERT (len != (hawk_oow_t)-1); - if (hawk_putsrcoochars (awk, tmp, len) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoochars (hawk, tmp, len) <= -1) EXIT_DEPARSE (); } - if (hawk_putsrcoocstr (awk, HAWK_T(", ")) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoocstr (hawk, HAWK_T(", ")) <= -1) EXIT_DEPARSE (); } - if (!(awk->opt.trait & HAWK_IMPLICIT)) + if (!(hawk->opt.trait & HAWK_IMPLICIT)) { /* use the actual name if no named variable is allowed */ - if (hawk_putsrcoochars(awk, HAWK_ARR_DPTR(awk->parse.gbls,i), HAWK_ARR_DLEN(awk->parse.gbls,i)) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoochars(hawk, HAWK_ARR_DPTR(hawk->parse.gbls,i), HAWK_ARR_DLEN(hawk->parse.gbls,i)) <= -1) EXIT_DEPARSE (); } else { len = hawk_int_to_oocstr((hawk_int_t)i, 10, HAWK_T("__g"), tmp, HAWK_COUNTOF(tmp)); HAWK_ASSERT (len != (hawk_oow_t)-1); - if (hawk_putsrcoochars (awk, tmp, len) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoochars (hawk, tmp, len) <= -1) EXIT_DEPARSE (); } - if (awk->opt.trait & HAWK_CRLF) + if (hawk->opt.trait & HAWK_CRLF) { - if (hawk_putsrcoocstr(awk, HAWK_T(";\r\n\r\n")) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoocstr(hawk, HAWK_T(";\r\n\r\n")) <= -1) EXIT_DEPARSE (); } else { - if (hawk_putsrcoocstr(awk, HAWK_T(";\n\n")) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoocstr(hawk, HAWK_T(";\n\n")) <= -1) EXIT_DEPARSE (); } } - df.awk = awk; + df.hawk = hawk; df.tmp = tmp; df.tmp_len = HAWK_COUNTOF(tmp); df.ret = 0; - hawk_htb_walk (awk->tree.funs, deparse_func, &df); + hawk_htb_walk (hawk->tree.funs, deparse_func, &df); if (df.ret <= -1) EXIT_DEPARSE (); - for (nde = awk->tree.begin; nde != HAWK_NULL; nde = nde->next) + for (nde = hawk->tree.begin; nde != HAWK_NULL; nde = nde->next) { hawk_oocs_t kw; - hawk_getkwname (awk, HAWK_KWID_BEGIN, &kw); + hawk_getkwname (hawk, HAWK_KWID_BEGIN, &kw); - if (hawk_putsrcoochars (awk, kw.ptr, kw.len) <= -1) EXIT_DEPARSE (); - if (hawk_putsrcoocstr (awk, HAWK_T(" ")) <= -1) EXIT_DEPARSE (); - if (hawk_prnnde (awk, nde) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoochars (hawk, kw.ptr, kw.len) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoocstr (hawk, HAWK_T(" ")) <= -1) EXIT_DEPARSE (); + if (hawk_prnnde (hawk, nde) <= -1) EXIT_DEPARSE (); - if (awk->opt.trait & HAWK_CRLF) + if (hawk->opt.trait & HAWK_CRLF) { - if (put_char(awk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); + if (put_char(hawk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); } - if (put_char(awk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); + if (put_char(hawk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); } - chain = awk->tree.chain; + chain = hawk->tree.chain; while (chain != HAWK_NULL) { if (chain->pattern != HAWK_NULL) { - if (hawk_prnptnpt(awk, chain->pattern) <= -1) EXIT_DEPARSE (); + if (hawk_prnptnpt(hawk, chain->pattern) <= -1) EXIT_DEPARSE (); } if (chain->action == HAWK_NULL) { /* blockless pattern */ - if (awk->opt.trait & HAWK_CRLF) + if (hawk->opt.trait & HAWK_CRLF) { - if (put_char(awk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); + if (put_char(hawk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); } - if (put_char(awk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); + if (put_char(hawk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); } else { if (chain->pattern != HAWK_NULL) { - if (put_char(awk, HAWK_T(' ')) <= -1) EXIT_DEPARSE (); + if (put_char(hawk, HAWK_T(' ')) <= -1) EXIT_DEPARSE (); } - if (hawk_prnpt(awk, chain->action) <= -1) EXIT_DEPARSE (); + if (hawk_prnpt(hawk, chain->action) <= -1) EXIT_DEPARSE (); } - if (awk->opt.trait & HAWK_CRLF) + if (hawk->opt.trait & HAWK_CRLF) { - if (put_char(awk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); + if (put_char(hawk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); } - if (put_char(awk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); + if (put_char(hawk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); chain = chain->next; } - for (nde = awk->tree.end; nde != HAWK_NULL; nde = nde->next) + for (nde = hawk->tree.end; nde != HAWK_NULL; nde = nde->next) { hawk_oocs_t kw; - hawk_getkwname (awk, HAWK_KWID_END, &kw); + hawk_getkwname (hawk, HAWK_KWID_END, &kw); - if (hawk_putsrcoochars(awk, kw.ptr, kw.len) <= -1) EXIT_DEPARSE (); - if (hawk_putsrcoocstr(awk, HAWK_T(" ")) <= -1) EXIT_DEPARSE (); - if (hawk_prnnde(awk, nde) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoochars(hawk, kw.ptr, kw.len) <= -1) EXIT_DEPARSE (); + if (hawk_putsrcoocstr(hawk, HAWK_T(" ")) <= -1) EXIT_DEPARSE (); + if (hawk_prnnde(hawk, nde) <= -1) EXIT_DEPARSE (); /* - if (awk->opt.trait & HAWK_CRLF) + if (hawk->opt.trait & HAWK_CRLF) { - if (put_char (awk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); + if (put_char (hawk, HAWK_T('\r')) <= -1) EXIT_DEPARSE (); } - if (put_char (awk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); + if (put_char (hawk, HAWK_T('\n')) <= -1) EXIT_DEPARSE (); */ } - if (flush_out (awk) <= -1) EXIT_DEPARSE (); + if (flush_out (hawk) <= -1) EXIT_DEPARSE (); exit_deparse: - if (awk->sio.outf(awk, HAWK_SIO_CMD_CLOSE, &awk->sio.arg, HAWK_NULL, 0) != 0 && n == 0) n = -1; + if (hawk->sio.outf(hawk, HAWK_SIO_CMD_CLOSE, &hawk->sio.arg, HAWK_NULL, 0) != 0 && n == 0) n = -1; return n; } @@ -7107,21 +7107,21 @@ static hawk_htb_walk_t deparse_func (hawk_htb_t* map, hawk_htb_pair_t* pair, voi HAWK_ASSERT (hawk_comp_oochars(HAWK_HTB_KPTR(pair), HAWK_HTB_KLEN(pair), fun->name.ptr, fun->name.len, 0) == 0); #define PUT_C(x,c) \ - if (put_char(x->awk,c)==-1) { \ + if (put_char(x->hawk,c)==-1) { \ x->ret = -1; return HAWK_HTB_WALK_STOP; \ } #define PUT_S(x,str) \ - if (hawk_putsrcoocstr(x->awk,str) <= -1) { \ + if (hawk_putsrcoocstr(x->hawk,str) <= -1) { \ x->ret = -1; return HAWK_HTB_WALK_STOP; \ } #define PUT_SX(x,str,len) \ - if (hawk_putsrcoochars (x->awk, str, len) <= -1) { \ + if (hawk_putsrcoochars (x->hawk, str, len) <= -1) { \ x->ret = -1; return HAWK_HTB_WALK_STOP; \ } - hawk_getkwname (df->awk, HAWK_KWID_FUNCTION, &kw); + hawk_getkwname (df->hawk, HAWK_KWID_FUNCTION, &kw); PUT_SX (df, kw.ptr, kw.len); PUT_C (df, HAWK_T(' ')); @@ -7140,12 +7140,12 @@ static hawk_htb_walk_t deparse_func (hawk_htb_t* map, hawk_htb_pair_t* pair, voi } PUT_S (df, HAWK_T(")")); - if (df->awk->opt.trait & HAWK_CRLF) PUT_C (df, HAWK_T('\r')); + if (df->hawk->opt.trait & HAWK_CRLF) PUT_C (df, HAWK_T('\r')); PUT_C (df, HAWK_T('\n')); - if (hawk_prnpt(df->awk, fun->body) <= -1) return -1; - if (df->awk->opt.trait & HAWK_CRLF) + if (hawk_prnpt(df->hawk, fun->body) <= -1) return -1; + if (df->hawk->opt.trait & HAWK_CRLF) { PUT_C (df, HAWK_T('\r')); } @@ -7158,33 +7158,33 @@ static hawk_htb_walk_t deparse_func (hawk_htb_t* map, hawk_htb_pair_t* pair, voi #undef PUT_SX } -static int put_char (hawk_t* awk, hawk_ooch_t c) +static int put_char (hawk_t* hawk, hawk_ooch_t c) { - awk->sio.arg.b.buf[awk->sio.arg.b.len++] = c; - if (awk->sio.arg.b.len >= HAWK_COUNTOF(awk->sio.arg.b.buf)) + hawk->sio.arg.b.buf[hawk->sio.arg.b.len++] = c; + if (hawk->sio.arg.b.len >= HAWK_COUNTOF(hawk->sio.arg.b.buf)) { - if (flush_out (awk) <= -1) return -1; + if (flush_out (hawk) <= -1) return -1; } return 0; } -static int flush_out (hawk_t* awk) +static int flush_out (hawk_t* hawk) { hawk_ooi_t n; - while (awk->sio.arg.b.pos < awk->sio.arg.b.len) + while (hawk->sio.arg.b.pos < hawk->sio.arg.b.len) { - n = awk->sio.outf ( - awk, HAWK_SIO_CMD_WRITE, &awk->sio.arg, - &awk->sio.arg.b.buf[awk->sio.arg.b.pos], - awk->sio.arg.b.len - awk->sio.arg.b.pos + n = hawk->sio.outf ( + hawk, HAWK_SIO_CMD_WRITE, &hawk->sio.arg, + &hawk->sio.arg.b.buf[hawk->sio.arg.b.pos], + hawk->sio.arg.b.len - hawk->sio.arg.b.pos ); if (n <= 0) return -1; - awk->sio.arg.b.pos += n; + hawk->sio.arg.b.pos += n; } - awk->sio.arg.b.pos = 0; - awk->sio.arg.b.len = 0; + hawk->sio.arg.b.pos = 0; + hawk->sio.arg.b.len = 0; return 0; } @@ -7229,7 +7229,7 @@ int hawk_putsrcoochars (hawk_t* hawk, const hawk_ooch_t* str, hawk_oow_t len) #endif /* - * if modules are linked statically into the main awk module, + * if modules are linked statically into the main hawk module, * this table is used to find the entry point of the modules. * you must update this table if you add more modules */ @@ -7237,7 +7237,7 @@ int hawk_putsrcoochars (hawk_t* hawk, const hawk_ooch_t* str, hawk_oow_t len) static struct { hawk_ooch_t* modname; - int (*modload) (hawk_mod_t* mod, hawk_t* awk); + int (*modload) (hawk_mod_t* mod, hawk_t* hawk); } static_modtab[] = { { HAWK_T("hawk"), hawk_mod_hawk }, @@ -7253,7 +7253,7 @@ static struct }; #endif -static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nsegs, hawk_mod_sym_t* sym) +static hawk_mod_t* query_module (hawk_t* hawk, const hawk_oocs_t segs[], int nsegs, hawk_mod_sym_t* sym) { hawk_rbt_pair_t* pair; hawk_mod_data_t* mdp; @@ -7261,7 +7261,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg HAWK_ASSERT (nsegs == 2); - pair = hawk_rbt_search (awk->modtab, segs[0].ptr, segs[0].len); + pair = hawk_rbt_search (hawk->modtab, segs[0].ptr, segs[0].len); if (pair) { mdp = (hawk_mod_data_t*)HAWK_RBT_VPTR(pair); @@ -7286,7 +7286,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg if (segs[0].len > HAWK_COUNTOF(buf) - 15) { /* module name too long */ - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ESEGTL, FMT_ESEGTL, segs[0].len, segs[0].ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ESEGTL, FMT_ESEGTL, segs[0].len, segs[0].ptr); return HAWK_NULL; } @@ -7305,7 +7305,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg /*if (n >= HAWK_COUNTOF(static_modtab)) { - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%.*js' not found"), segs[0].len, segs[0].ptr); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%.*js' not found"), segs[0].len, segs[0].ptr); return HAWK_NULL; }*/ @@ -7318,13 +7318,13 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg /* i copy-insert 'md' into the table before calling 'load'. * to pass the same address to load(), query(), etc */ - pair = hawk_rbt_insert(awk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md)); + pair = hawk_rbt_insert(hawk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md)); if (pair == HAWK_NULL) return HAWK_NULL; mdp = (hawk_mod_data_t*)HAWK_RBT_VPTR(pair); - if (load(&mdp->mod, awk) <= -1) + if (load(&mdp->mod, hawk) <= -1) { - hawk_rbt_delete (awk->modtab, segs[0].ptr, segs[0].len); + hawk_rbt_delete (hawk->modtab, segs[0].ptr, segs[0].len); return HAWK_NULL; } @@ -7333,16 +7333,16 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg #endif /* attempt to find an external module */ HAWK_MEMSET (&spec, 0, HAWK_SIZEOF(spec)); - spec.prefix = (awk->opt.mod[1].len > 0)? awk->opt.mod[1].ptr: HAWK_T(HAWK_DEFAULT_MODPREFIX); - spec.postfix = (awk->opt.mod[2].len > 0)? awk->opt.mod[2].ptr: HAWK_T(HAWK_DEFAULT_MODPOSTFIX); + spec.prefix = (hawk->opt.mod[1].len > 0)? hawk->opt.mod[1].ptr: HAWK_T(HAWK_DEFAULT_MODPREFIX); + spec.postfix = (hawk->opt.mod[2].len > 0)? hawk->opt.mod[2].ptr: HAWK_T(HAWK_DEFAULT_MODPOSTFIX); spec.name = segs[0].ptr; - if (!awk->prm.modopen || !awk->prm.modgetsym || !awk->prm.modclose) + if (!hawk->prm.modopen || !hawk->prm.modgetsym || !hawk->prm.modclose) { - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EINVAL, HAWK_T("module callbacks not set properly")); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EINVAL, HAWK_T("module callbacks not set properly")); goto open_fail; } - spec.libdir = (awk->opt.mod[0].len > 0)? awk->opt.mod[0].ptr: HAWK_T(HAWK_DEFAULT_MODLIBDIRS); + spec.libdir = (hawk->opt.mod[0].len > 0)? hawk->opt.mod[0].ptr: HAWK_T(HAWK_DEFAULT_MODLIBDIRS); do { #if defined(_WIN32) || defined(__OS2__) || defined(__DOS__) @@ -7355,7 +7355,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg if (colon) *colon = '\0'; HAWK_MEMSET (&md, 0, HAWK_SIZEOF(md)); - md.handle = awk->prm.modopen(awk, &spec); + md.handle = hawk->prm.modopen(hawk, &spec); if (!colon) break; *colon = LIBDIR_SEPARATOR; @@ -7368,33 +7368,33 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg { const hawk_ooch_t* bem; open_fail: - bem = hawk_backuperrmsg(awk); - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js%js%js' for module '%js' not found - %js"), + bem = hawk_backuperrmsg(hawk); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js%js%js' for module '%js' not found - %js"), (spec.prefix? spec.prefix: HAWK_T("")), spec.name, (spec.postfix? spec.postfix: HAWK_T("")), spec.name, bem); return HAWK_NULL; } buflen = hawk_copy_oocstr_unlimited(&buf[10], segs[0].ptr); /* attempt hawk_mod_xxx */ - load = awk->prm.modgetsym(awk, md.handle, &buf[1]); + load = hawk->prm.modgetsym(hawk, md.handle, &buf[1]); if (!load) { /* attempt _hawk_mod_xxx */ - load = awk->prm.modgetsym(awk, md.handle, &buf[0]); + load = hawk->prm.modgetsym(hawk, md.handle, &buf[0]); if (!load) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_ENOERR); /* attempt hawk_mod_xxx_ */ buf[10 + buflen] = HAWK_T('_'); buf[10 + buflen + 1] = HAWK_T('\0'); - load = awk->prm.modgetsym(awk, md.handle, &buf[1]); + load = hawk->prm.modgetsym(hawk, md.handle, &buf[1]); if (!load) { - const hawk_ooch_t* bem = hawk_backuperrmsg(awk); - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("module symbol '%.*js' not found - %js"), (10 + buflen), &buf[1], bem); + const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("module symbol '%.*js' not found - %js"), (10 + buflen), &buf[1], bem); - awk->prm.modclose (awk, md.handle); + hawk->prm.modclose (hawk, md.handle); return HAWK_NULL; } } @@ -7402,29 +7402,29 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg /* i copy-insert 'md' into the table before calling 'load'. * to pass the same address to load(), query(), etc */ - pair = hawk_rbt_insert(awk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md)); + pair = hawk_rbt_insert(hawk->modtab, segs[0].ptr, segs[0].len, &md, HAWK_SIZEOF(md)); if (pair == HAWK_NULL) { - awk->prm.modclose (awk, md.handle); + hawk->prm.modclose (hawk, md.handle); return HAWK_NULL; } mdp = (hawk_mod_data_t*)HAWK_RBT_VPTR(pair); - if (load(&mdp->mod, awk) <= -1) + if (load(&mdp->mod, hawk) <= -1) { - hawk_rbt_delete (awk->modtab, segs[0].ptr, segs[0].len); - awk->prm.modclose (awk, mdp->handle); + hawk_rbt_delete (hawk->modtab, segs[0].ptr, segs[0].len); + hawk->prm.modclose (hawk, mdp->handle); return HAWK_NULL; } } done: - hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR); - n = mdp->mod.query(&mdp->mod, awk, segs[1].ptr, sym); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_ENOERR); + n = mdp->mod.query(&mdp->mod, hawk, segs[1].ptr, sym); if (n <= -1) { - const hawk_ooch_t* olderrmsg = hawk_backuperrmsg(awk); - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("unable to find '%.*js' in module '%.*js' - %js"), segs[1].len, segs[1].ptr, segs[0].len, segs[0].ptr, olderrmsg); + const hawk_ooch_t* olderrmsg = hawk_backuperrmsg(hawk); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("unable to find '%.*js' in module '%.*js' - %js"), segs[1].len, segs[1].ptr, segs[0].len, segs[0].ptr, olderrmsg); return HAWK_NULL; } return &mdp->mod; diff --git a/hawk/lib/pio.c b/hawk/lib/pio.c index daa7cdd4..072fc3af 100644 --- a/hawk/lib/pio.c +++ b/hawk/lib/pio.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/rbt.c b/hawk/lib/rbt.c index d5e10f83..e4a67816 100644 --- a/hawk/lib/rbt.c +++ b/hawk/lib/rbt.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/rec.c b/hawk/lib/rec.c index c64f9930..785f84d8 100644 --- a/hawk/lib/rec.c +++ b/hawk/lib/rec.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/rio-prv.h b/hawk/lib/rio-prv.h index c3ee06cf..f8ed8f9a 100644 --- a/hawk/lib/rio-prv.h +++ b/hawk/lib/rio-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/rio.c b/hawk/lib/rio.c index 109eec8c..c405fce9 100644 --- a/hawk/lib/rio.c +++ b/hawk/lib/rio.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/run-prv.h b/hawk/lib/run-prv.h index bbc564e4..06833495 100644 --- a/hawk/lib/run-prv.h +++ b/hawk/lib/run-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/run.c b/hawk/lib/run.c index 2a4413e8..b431beda 100644 --- a/hawk/lib/run.c +++ b/hawk/lib/run.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -90,7 +90,7 @@ struct pafv_t 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); -static int init_rtx (hawk_rtx_t* rtx, hawk_t* awk, hawk_rio_cbs_t* rio); +static int init_rtx (hawk_rtx_t* rtx, hawk_t* hawk, hawk_rio_cbs_t* rio); static void fini_rtx (hawk_rtx_t* rtx, int fini_globals); static int init_globals (hawk_rtx_t* rtx); @@ -850,47 +850,47 @@ static hawk_rbt_walk_t fini_module (hawk_rbt_t* rbt, hawk_rbt_pair_t* pair, void return HAWK_RBT_WALK_FORWARD; } -hawk_rtx_t* hawk_rtx_open (hawk_t* awk, hawk_oow_t xtnsize, hawk_rio_cbs_t* rio) +hawk_rtx_t* hawk_rtx_open (hawk_t* hawk, hawk_oow_t xtnsize, hawk_rio_cbs_t* rio) { hawk_rtx_t* rtx; struct module_init_ctx_t mic; - /* clear the awk error code */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR); + /* clear the hawk error code */ + hawk_seterrnum (hawk, HAWK_NULL, HAWK_ENOERR); /* check if the code has ever been parsed */ - if (awk->tree.ngbls == 0 && - awk->tree.begin == HAWK_NULL && - awk->tree.end == HAWK_NULL && - awk->tree.chain_size == 0 && - hawk_htb_getsize(awk->tree.funs) == 0) + if (hawk->tree.ngbls == 0 && + hawk->tree.begin == HAWK_NULL && + hawk->tree.end == HAWK_NULL && + hawk->tree.chain_size == 0 && + hawk_htb_getsize(hawk->tree.funs) == 0) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EPERM); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EPERM); return HAWK_NULL; } /* allocate the storage for the rtx object */ - rtx = (hawk_rtx_t*)hawk_allocmem(awk, HAWK_SIZEOF(hawk_rtx_t) + xtnsize); + rtx = (hawk_rtx_t*)hawk_allocmem(hawk, HAWK_SIZEOF(hawk_rtx_t) + xtnsize); if (HAWK_UNLIKELY(!rtx)) { - /* if it fails, the failure is reported thru the awk object */ + /* if it fails, the failure is reported thru the hawk object */ return HAWK_NULL; } /* initialize the rtx object */ HAWK_MEMSET (rtx, 0, HAWK_SIZEOF(hawk_rtx_t) + xtnsize); rtx->_instsize = HAWK_SIZEOF(hawk_rtx_t); - if (HAWK_UNLIKELY(init_rtx(rtx, awk, rio) <= -1)) + if (HAWK_UNLIKELY(init_rtx(rtx, hawk, rio) <= -1)) { - hawk_freemem (awk, rtx); + hawk_freemem (hawk, rtx); return HAWK_NULL; } if (HAWK_UNLIKELY(init_globals(rtx) <= -1)) { - hawk_rtx_errortohawk (rtx, awk); + hawk_rtx_errortohawk (rtx, hawk); fini_rtx (rtx, 0); - hawk_freemem (awk, rtx); + hawk_freemem (hawk, rtx); return HAWK_NULL; } @@ -908,7 +908,7 @@ hawk_rtx_t* hawk_rtx_open (hawk_t* awk, hawk_oow_t xtnsize, hawk_rio_cbs_t* rio) } fini_rtx (rtx, 1); - hawk_freemem (awk, rtx); + hawk_freemem (hawk, rtx); return HAWK_NULL; } @@ -988,7 +988,7 @@ static void same_namedval (hawk_htb_t* map, void* dptr, hawk_oow_t dlen) hawk_rtx_refdownval_nofree (*(hawk_rtx_t**)hawk_htb_getxtn(map), dptr); } -static int init_rtx (hawk_rtx_t* rtx, hawk_t* awk, hawk_rio_cbs_t* rio) +static int init_rtx (hawk_rtx_t* rtx, hawk_t* hawk, hawk_rio_cbs_t* rio) { static hawk_htb_style_t style_for_named = { @@ -1007,12 +1007,12 @@ static int init_rtx (hawk_rtx_t* rtx, hawk_t* awk, hawk_rio_cbs_t* rio) }; hawk_oow_t stack_limit, i; - rtx->_gem = awk->_gem; - rtx->hawk = awk; + rtx->_gem = hawk->_gem; + rtx->hawk = hawk; CLRERR (rtx); - stack_limit = awk->parse.pragma.rtx_stack_limit > 0? awk->parse.pragma.rtx_stack_limit: awk->opt.rtx_stack_limit; + stack_limit = hawk->parse.pragma.rtx_stack_limit > 0? hawk->parse.pragma.rtx_stack_limit: hawk->opt.rtx_stack_limit; if (stack_limit < HAWK_MIN_RTX_STACK_LIMIT) stack_limit = HAWK_MIN_RTX_STACK_LIMIT; rtx->stack = hawk_rtx_allocmem(rtx, stack_limit * HAWK_SIZEOF(void*)); if (HAWK_UNLIKELY(!rtx->stack)) goto oops_0; @@ -1068,7 +1068,7 @@ static int init_rtx (hawk_rtx_t* rtx, hawk_t* awk, hawk_rio_cbs_t* rio) hawk_htb_setstyle (rtx->named, &style_for_named); rtx->format.tmp.ptr = (hawk_ooch_t*)hawk_rtx_allocmem(rtx, 4096 * HAWK_SIZEOF(hawk_ooch_t)); - if (HAWK_UNLIKELY(!rtx->format.tmp.ptr)) goto oops_12; /* the error is set on the awk object after this jump is made */ + if (HAWK_UNLIKELY(!rtx->format.tmp.ptr)) goto oops_12; /* the error is set on the hawk object after this jump is made */ rtx->format.tmp.len = 4096; rtx->format.tmp.inc = 4096 * 2; @@ -4892,7 +4892,7 @@ static HAWK_INLINE int __cmp_val (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t* static cmp_val_t func[] = { /* this table must be synchronized with - * the HAWK_VAL_XXX values in awk.h */ + * the HAWK_VAL_XXX values in hawk.h */ __cmp_nil_nil, __cmp_nil_int, __cmp_nil_flt, __cmp_nil_str, __cmp_nil_mbs, __cmp_nil_fun, __cmp_nil_map, __cmp_int_nil, __cmp_int_int, __cmp_int_flt, __cmp_int_str, __cmp_int_mbs, __cmp_int_fun, __cmp_int_map, __cmp_flt_nil, __cmp_flt_int, __cmp_flt_flt, __cmp_flt_str, __cmp_flt_mbs, __cmp_flt_fun, __cmp_flt_map, @@ -5273,7 +5273,7 @@ static hawk_val_t* eval_binop_mod (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t hawk_flt_t r1, r2; hawk_val_t* res; - /* the mod function must be provided when the awk object is created to be able to calculate floating-pointer remainder */ + /* the mod function must be provided when the hawk object is created to be able to calculate floating-pointer remainder */ HAWK_ASSERT (rtx->hawk->prm.math.mod != HAWK_NULL); n1 = hawk_rtx_valtonum(rtx, left, &l1, &r1); @@ -5902,7 +5902,7 @@ static HAWK_INLINE hawk_val_t* eval_fncall_fun (hawk_rtx_t* rtx, hawk_nde_t* nde if (!call->u.fun.fun) { - /* there can be multiple runtime instances for a single awk object. + /* there can be multiple runtime instances for a single hawk object. * changing the parse tree from one runtime instance can affect * other instances. however i do change the parse tree without protection * hoping that the pointer assignment is atomic. (call->u.fun.fun = fun). @@ -6072,7 +6072,7 @@ hawk_val_t* hawk_rtx_evalcall ( if (fun) { - /* extra step for normal awk functions */ + /* extra step for normal hawk functions */ while (nargs < fun->nargs) { /* push as many nils as the number of missing actual arguments */ @@ -6091,7 +6091,7 @@ hawk_val_t* hawk_rtx_evalcall ( if (fun) { - /* normal awk function */ + /* normal hawk function */ HAWK_ASSERT (fun->body->type == HAWK_NDE_BLK); n = run_block(rtx, (hawk_nde_blk_t*)fun->body); } diff --git a/hawk/lib/sio.c b/hawk/lib/sio.c index 96e160e4..1e92e775 100644 --- a/hawk/lib/sio.c +++ b/hawk/lib/sio.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/std-prv.h b/hawk/lib/std-prv.h index e2de5a31..bda54653 100644 --- a/hawk/lib/std-prv.h +++ b/hawk/lib/std-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -33,15 +33,15 @@ extern "C" { #endif -HAWK_EXPORT hawk_flt_t hawk_stdmathpow (hawk_t* awk, hawk_flt_t x, hawk_flt_t y); -HAWK_EXPORT hawk_flt_t hawk_stdmathmod (hawk_t* awk, hawk_flt_t x, hawk_flt_t y); +HAWK_EXPORT hawk_flt_t hawk_stdmathpow (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y); +HAWK_EXPORT hawk_flt_t hawk_stdmathmod (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y); -HAWK_EXPORT int hawk_stdmodstartup (hawk_t* awk); -HAWK_EXPORT void hawk_stdmodshutdown (hawk_t* awk); +HAWK_EXPORT int hawk_stdmodstartup (hawk_t* hawk); +HAWK_EXPORT void hawk_stdmodshutdown (hawk_t* hawk); -HAWK_EXPORT void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec); -HAWK_EXPORT void hawk_stdmodclose (hawk_t* awk, void* handle); -HAWK_EXPORT void* hawk_stdmodgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name); +HAWK_EXPORT void* hawk_stdmodopen (hawk_t* hawk, const hawk_mod_spec_t* spec); +HAWK_EXPORT void hawk_stdmodclose (hawk_t* hawk, void* handle); +HAWK_EXPORT void* hawk_stdmodgetsym (hawk_t* hawk, void* handle, const hawk_ooch_t* name); #if defined(__cplusplus) } diff --git a/hawk/lib/std.c b/hawk/lib/std.c index e928bcde..b3f623fd 100644 --- a/hawk/lib/std.c +++ b/hawk/lib/std.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -226,7 +226,7 @@ static hawk_mmgr_t sys_mmgr = /* ----------------------------------------------------------------------- */ -hawk_flt_t hawk_stdmathpow (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) +hawk_flt_t hawk_stdmathpow (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_POWQ) return powq(x, y); @@ -241,7 +241,7 @@ hawk_flt_t hawk_stdmathpow (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) #endif } -hawk_flt_t hawk_stdmathmod (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) +hawk_flt_t hawk_stdmathmod (hawk_t* hawk, hawk_flt_t x, hawk_flt_t y) { #if defined(HAWK_USE_AWK_FLTMAX) && defined(HAVE_FMODQ) return fmodq(x, y); @@ -258,10 +258,10 @@ hawk_flt_t hawk_stdmathmod (hawk_t* awk, hawk_flt_t x, hawk_flt_t y) /* [IMPORTANT] * hawk_stdmodXXXX() functions must not access the extension - * area of 'awk'. they are used in StdAwk.cpp which instantiates - * an awk object with hawk_open() instead of hawk_openstd(). */ + * area of 'hawk'. they are used in StdAwk.cpp which instantiates + * an hawk object with hawk_open() instead of hawk_openstd(). */ -int hawk_stdmodstartup (hawk_t* awk) +int hawk_stdmodstartup (hawk_t* hawk) { #if defined(USE_LTDL) @@ -277,7 +277,7 @@ int hawk_stdmodstartup (hawk_t* awk) } -void hawk_stdmodshutdown (hawk_t* awk) +void hawk_stdmodshutdown (hawk_t* hawk) { #if defined(USE_LTDL) lt_dlexit (); @@ -286,22 +286,22 @@ void hawk_stdmodshutdown (hawk_t* awk) #endif } -static void* std_mod_open_checked (hawk_t* awk, const hawk_mod_spec_t* spec) +static void* std_mod_open_checked (hawk_t* hawk, const hawk_mod_spec_t* spec) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); if (!xtn->stdmod_up) { /* hawk_stdmodstartup() must have failed upon start-up. * return failure immediately */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOIMPL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_ENOIMPL); return HAWK_NULL; } - return hawk_stdmodopen(awk, spec); + return hawk_stdmodopen(hawk, spec); } -void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) +void* hawk_stdmodopen (hawk_t* hawk, const hawk_mod_spec_t* spec) { #if defined(USE_LTDL) void* h; @@ -326,15 +326,15 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) tmp[count] = HAWK_NULL; #if defined(HAWK_OOCH_IS_BCH) - modpath = hawk_dupbcstrarr(awk, tmp, HAWK_NULL); + modpath = hawk_dupbcstrarr(hawk, tmp, HAWK_NULL); #else - modpath = hawk_dupucstrarrtobcstr(awk, tmp, HAWK_NULL) + modpath = hawk_dupucstrarrtobcstr(hawk, tmp, HAWK_NULL) #endif if (!modpath) return HAWK_NULL; if (lt_dladvise_init(&adv) != 0) { - hawk_seterrfmt (awk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), lt_dlerror()); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), lt_dlerror()); return HAWK_NULL; } @@ -345,7 +345,7 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) lt_dladvise_destroy (&adv); - HAWK_MMGR_FREE (hawk_getmmgr(awk), modpath); + HAWK_MMGR_FREE (hawk_getmmgr(hawk), modpath); return h; @@ -374,13 +374,13 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) if (spec->postfix) tmp[count++] = spec->postfix; tmp[count] = HAWK_NULL; - modpath = hawk_dupoocstrarr(awk, tmp, HAWK_NULL); + modpath = hawk_dupoocstrarr(hawk, tmp, HAWK_NULL); if (!modpath) return HAWK_NULL; h = LoadLibrary (modpath); - if (!h) hawk_seterrnum (awk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()); + if (!h) hawk_seterrnum (hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()); - hawk_freemem (awk, modpath); + hawk_freemem (hawk, modpath); HAWK_ASSERT (HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*)); return h; @@ -410,9 +410,9 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) tmp[count] = HAWK_NULL; #if defined(HAWK_OOCH_IS_BCH) - modpath = hawk_dupbcstrarr(awk, tmp, HAWK_NULL); + modpath = hawk_dupbcstrarr(hawk, tmp, HAWK_NULL); #else - modpath = hawk_dupucstrarrtobcstr(awk, tmp, HAWK_NULL); + modpath = hawk_dupucstrarrtobcstr(hawk, tmp, HAWK_NULL); #endif if (!modpath) return HAWK_NULL; @@ -422,10 +422,10 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) if (rc != NO_ERROR) { h = HAWK_NULL; - hawk_seterrnum (awk, HAWK_NULL, hawk_syserr_to_errnum(rc)); + hawk_seterrnum (hawk, HAWK_NULL, hawk_syserr_to_errnum(rc)); } - hawk_freemem (awk, modpath); + hawk_freemem (hawk, modpath); HAWK_ASSERT (HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*)); return h; @@ -456,16 +456,16 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) tmp[count] = HAWK_NULL; #if defined(HAWK_OOCH_IS_BCH) - modpath = hawk_dupbcstrarr(awk, tmp, HAWK_NULL); + modpath = hawk_dupbcstrarr(hawk, tmp, HAWK_NULL); #else - modpath = hawk_dupucstrarrtobcstr(awk, tmp, HAWK_NULL); + modpath = hawk_dupucstrarrtobcstr(hawk, tmp, HAWK_NULL); #endif if (!modpath) return HAWK_NULL; h = LoadModule(modpath); - if (!h) hawk_seterrnum (awk, HAWK_NULL, HAWK_ESYSERR); + if (!h) hawk_seterrnum (hawk, HAWK_NULL, HAWK_ESYSERR); - hawk_freemem (awk, modpath); + hawk_freemem (hawk, modpath); HAWK_ASSERT (HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*)); return h; @@ -492,26 +492,26 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec) tmp[count] = HAWK_NULL; #if defined(HAWK_OOCH_IS_BCH) - modpath = hawk_dupbcstrarr(awk, tmp, HAWK_NULL); + modpath = hawk_dupbcstrarr(hawk, tmp, HAWK_NULL); #else - modpath = hawk_dupucstrarrtobcstr(awk, tmp, HAWK_NULL); + modpath = hawk_dupucstrarrtobcstr(hawk, tmp, HAWK_NULL); #endif if (!modpath) return HAWK_NULL; h = dlopen(modpath, RTLD_NOW); - if (!h) hawk_seterrfmt (awk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), dlerror()); + if (!h) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), dlerror()); - hawk_freemem (awk, modpath); + hawk_freemem (hawk, modpath); return h; #else - hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOIMPL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_ENOIMPL); return HAWK_NULL; #endif } -void hawk_stdmodclose (hawk_t* awk, void* handle) +void hawk_stdmodclose (hawk_t* hawk, void* handle) { #if defined(USE_LTDL) lt_dlclose (handle); @@ -528,7 +528,7 @@ void hawk_stdmodclose (hawk_t* awk, void* handle) #endif } -void* hawk_stdmodgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name) +void* hawk_stdmodgetsym (hawk_t* hawk, void* handle, const hawk_ooch_t* name) { void* s; hawk_bch_t* mname; @@ -536,17 +536,17 @@ void* hawk_stdmodgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name) #if defined(HAWK_OOCH_IS_BCH) mname = (hawk_bch_t*)name; #else - mname = hawk_duputobcstr(awk, name, HAWK_NULL); + mname = hawk_duputobcstr(hawk, name, HAWK_NULL); if (!mname) return HAWK_NULL; #endif #if defined(USE_LTDL) s = lt_dlsym(handle, mname); - if (!s) hawk_seterrfmt (awk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), lt_dlerror()); + if (!s) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), lt_dlerror()); #elif defined(_WIN32) s = GetProcAddress((HMODULE)handle, mname); - if (!s) hawk_seterrnum (awk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()); + if (!s) hawk_seterrnum (hawk, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()); #elif defined(__OS2__) { @@ -555,17 +555,17 @@ void* hawk_stdmodgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name) if (rc != NO_ERROR) { s = HAWK_NULL; - hawk_seterrnum (awk, HAWK_NULL, hawk_syserr_to_errnum(rc)); + hawk_seterrnum (hawk, HAWK_NULL, hawk_syserr_to_errnum(rc)); } } #elif defined(__DOS__) && defined(HAWK_ENABLE_DOS_DYNAMIC_MODULE) s = GetProcAddress(handle, mname); - if (!s) hawk_seterrnum (awk, HAWK_NULL, HAWK_ESYSERR); + if (!s) hawk_seterrnum (hawk, HAWK_NULL, HAWK_ESYSERR); #elif defined(USE_DLFCN) s = dlsym(handle, mname); - if (!s) hawk_seterrfmt (awk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), dlerror()); + if (!s) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ESYSERR, HAWK_T("%hs"), dlerror()); #else s = HAWK_NULL; @@ -574,7 +574,7 @@ void* hawk_stdmodgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name) #if defined(HAWK_OOCH_IS_BCH) /* nothing to do */ #else - hawk_freemem (awk, mname); + hawk_freemem (hawk, mname); #endif return s; @@ -866,20 +866,20 @@ static void log_write (hawk_t* hawk, hawk_bitmask_t mask, const hawk_ooch_t* msg } /* ----------------------------------------------------------------------- */ -static int add_globals (hawk_t* awk); -static int add_functions (hawk_t* awk); +static int add_globals (hawk_t* hawk); +static int add_functions (hawk_t* hawk); hawk_t* hawk_openstd (hawk_oow_t xtnsize, hawk_errnum_t* errnum) { return hawk_openstdwithmmgr(&sys_mmgr, xtnsize, hawk_get_cmgr_by_id(HAWK_CMGR_UTF8), errnum); } -static void fini_xtn (hawk_t* awk) +static void fini_xtn (hawk_t* hawk) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); if (xtn->stdmod_up) { - hawk_stdmodshutdown (awk); + hawk_stdmodshutdown (hawk); xtn->stdmod_up = 0; } @@ -887,14 +887,14 @@ static void fini_xtn (hawk_t* awk) reset_log_to_default (xtn); } -static void clear_xtn (hawk_t* awk) +static void clear_xtn (hawk_t* hawk) { /* nothing to do */ } hawk_t* hawk_openstdwithmmgr (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t* cmgr, hawk_errnum_t* errnum) { - hawk_t* awk; + hawk_t* hawk; hawk_prm_t prm; xtn_t* xtn; @@ -908,35 +908,35 @@ hawk_t* hawk_openstdwithmmgr (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t prm.logwrite = log_write; /* create an object */ - awk = hawk_open(mmgr, HAWK_SIZEOF(xtn_t) + xtnsize, cmgr, &prm, errnum); - if (!awk) return HAWK_NULL; + hawk = hawk_open(mmgr, HAWK_SIZEOF(xtn_t) + xtnsize, cmgr, &prm, errnum); + if (!hawk) return HAWK_NULL; /* adjust the object size by the sizeof xtn_t so that hawk_getxtn() returns the right pointer. */ - awk->_instsize += HAWK_SIZEOF(xtn_t); + hawk->_instsize += HAWK_SIZEOF(xtn_t); /* #if defined(USE_DLFCN) - if (hawk_setopt(awk, HAWK_OPT_MODPOSTFIX, HAWK_T(".so")) <= -1) + if (hawk_setopt(hawk, HAWK_OPT_MODPOSTFIX, HAWK_T(".so")) <= -1) { - if (errnum) *errnum = hawk_geterrnum(awk); + if (errnum) *errnum = hawk_geterrnum(hawk); goto oops; } #endif */ /* initialize extension */ - xtn = GET_XTN(awk); + xtn = GET_XTN(hawk); reset_log_to_default (xtn); /* add intrinsic global variables and functions */ - if (add_globals(awk) <= -1 || add_functions(awk) <= -1) + if (add_globals(hawk) <= -1 || add_functions(hawk) <= -1) { - if (errnum) *errnum = hawk_geterrnum(awk); + if (errnum) *errnum = hawk_geterrnum(hawk); goto oops; } - if (hawk_stdmodstartup(awk) <= -1) + if (hawk_stdmodstartup(hawk) <= -1) { xtn->stdmod_up = 0; /* carry on regardless of failure */ @@ -948,12 +948,12 @@ hawk_t* hawk_openstdwithmmgr (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t xtn->ecb.close = fini_xtn; xtn->ecb.clear = clear_xtn; - hawk_pushecb (awk, &xtn->ecb); + hawk_pushecb (hawk, &xtn->ecb); - return awk; + return hawk; oops: - if (awk) hawk_close (awk); + if (hawk) hawk_close (hawk); return HAWK_NULL; } @@ -988,14 +988,14 @@ static hawk_oocs_t sio_std_names[] = { HAWK_T("stderr"), 6 } }; -static hawk_sio_t* open_sio_std (hawk_t* awk, hawk_sio_std_t std, int flags) +static hawk_sio_t* open_sio_std (hawk_t* hawk, hawk_sio_std_t std, int flags) { hawk_sio_t* sio; - sio = hawk_sio_openstd(hawk_getgem(awk), 0, std, flags); + sio = hawk_sio_openstd(hawk_getgem(hawk), 0, std, flags); if (sio == HAWK_NULL) { - const hawk_ooch_t* bem = hawk_backuperrmsg(awk); - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), &sio_std_names[std], bem); + const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), &sio_std_names[std], bem); } return sio; } @@ -1022,7 +1022,7 @@ static int is_psin_file (hawk_parsestd_t* psin) psin->type == HAWK_PARSESTD_FILEU; } -static int open_parsestd (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow_t index) +static int open_parsestd (hawk_t* hawk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow_t index) { hawk_parsestd_t* psin = &xtn->s.in.x[index]; @@ -1043,13 +1043,13 @@ static int open_parsestd (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow { /* no path name or - -> stdin */ path = HAWK_NULL; - tmp = open_sio_std(awk, HAWK_SIO_STDIN, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR); + tmp = open_sio_std(hawk, HAWK_SIO_STDIN, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR); } else { - path = hawk_addsionamewithbchars(awk, psin->u.fileb.path, hawk_count_bcstr(psin->u.fileb.path)); + path = hawk_addsionamewithbchars(hawk, psin->u.fileb.path, hawk_count_bcstr(psin->u.fileb.path)); if (!path) return -1; - tmp = open_sio(awk, path, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH); + tmp = open_sio(hawk, path, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH); } if (tmp == HAWK_NULL) return -1; @@ -1075,13 +1075,13 @@ static int open_parsestd (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow { /* no path name or - -> stdin */ path = HAWK_NULL; - tmp = open_sio_std(awk, HAWK_SIO_STDIN, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR); + tmp = open_sio_std(hawk, HAWK_SIO_STDIN, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR); } else { - path = hawk_addsionamewithuchars(awk, psin->u.fileu.path, hawk_count_ucstr(psin->u.fileu.path)); + path = hawk_addsionamewithuchars(hawk, psin->u.fileu.path, hawk_count_ucstr(psin->u.fileu.path)); if (!path) return -1; - tmp = open_sio(awk, path, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH); + tmp = open_sio(hawk, path, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH); } if (tmp == HAWK_NULL) return -1; @@ -1112,7 +1112,7 @@ static int open_parsestd (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow return 0; default: - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINTERN); return -1; } } @@ -1159,16 +1159,16 @@ static int fill_sio_arg_unique_id (hawk_t* hawk, hawk_sio_arg_t* arg, const hawk #endif } -static hawk_ooi_t sf_in_open (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn) +static hawk_ooi_t sf_in_open (hawk_t* hawk, hawk_sio_arg_t* arg, xtn_t* xtn) { if (arg->prev == HAWK_NULL) { /* handle top-level source input stream specified to hawk_parsestd() */ hawk_ooi_t x; - HAWK_ASSERT (arg == &awk->sio.arg); + HAWK_ASSERT (arg == &hawk->sio.arg); - x = open_parsestd(awk, arg, xtn, 0); + x = open_parsestd(hawk, arg, xtn, 0); if (x >= 0) xtn->s.in.xindex = 0; /* update the current stream index */ return x; @@ -1203,7 +1203,7 @@ static hawk_ooi_t sf_in_open (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn) totlen = hawk_count_oocstr(arg->name) + dirlen; if (totlen >= HAWK_COUNTOF(fbuf)) { - dbuf = hawk_allocmem(awk, HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1)); + dbuf = hawk_allocmem(hawk, HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1)); if (!dbuf) return -1; path = dbuf; } @@ -1214,35 +1214,35 @@ static hawk_ooi_t sf_in_open (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn) } } - xpath = hawk_addsionamewithoochars(awk, path, hawk_count_oocstr(path)); - if (dbuf) hawk_freemem (awk, dbuf); + xpath = hawk_addsionamewithoochars(hawk, path, hawk_count_oocstr(path)); + if (dbuf) hawk_freemem (hawk, dbuf); } else { - xpath = hawk_addsionamewithoochars(awk, arg->name, hawk_count_oocstr(arg->name)); + xpath = hawk_addsionamewithoochars(hawk, arg->name, hawk_count_oocstr(arg->name)); } if (!xpath) goto fail; - arg->handle = hawk_sio_open(hawk_getgem(awk), 0, xpath, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH); + arg->handle = hawk_sio_open(hawk_getgem(hawk), 0, xpath, HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH); if (!arg->handle) { const hawk_ooch_t* bem; fail: - bem = hawk_backuperrmsg(awk); - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), arg->name, bem); + bem = hawk_backuperrmsg(hawk); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EOPEN, HAWK_T("unable to open %js - %js"), arg->name, bem); return -1; } arg->path = xpath; /* TODO: use the system handle(file descriptor) instead of the path? */ /*syshnd = hawk_sio_gethnd(arg->handle);*/ - fill_sio_arg_unique_id(awk, arg, xpath); /* ignore failure */ + fill_sio_arg_unique_id(hawk, arg, xpath); /* ignore failure */ return 0; } } -static hawk_ooi_t sf_in_close (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn) +static hawk_ooi_t sf_in_close (hawk_t* hawk, hawk_sio_arg_t* arg, xtn_t* xtn) { if (arg->prev == HAWK_NULL) { @@ -1276,13 +1276,13 @@ static hawk_ooi_t sf_in_close (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn) return 0; } -static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t size, xtn_t* xtn) +static hawk_ooi_t sf_in_read (hawk_t* hawk, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t size, xtn_t* xtn) { if (arg->prev == HAWK_NULL) { hawk_ooi_t n; - HAWK_ASSERT (arg == &awk->sio.arg); + HAWK_ASSERT (arg == &hawk->sio.arg); again: switch (xtn->s.in.x[xtn->s.in.xindex].type) @@ -1295,13 +1295,13 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat n = hawk_sio_getoochars(arg->handle, data, size); if (n <= -1) { - const hawk_ooch_t* bem = hawk_backuperrmsg(awk); + const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); const hawk_uch_t* path; path = xtn->s.in.x[xtn->s.in.xindex].u.fileu.path; if (path) - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %ls - %js"), path, bem); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %ls - %js"), path, bem); else - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), sio_std_names[HAWK_SIO_STDIN].ptr, bem); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), sio_std_names[HAWK_SIO_STDIN].ptr, bem); } break; @@ -1313,13 +1313,13 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat n = hawk_sio_getoochars(arg->handle, data, size); if (n <= -1) { - const hawk_ooch_t* bem = hawk_backuperrmsg(awk); + const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); const hawk_bch_t* path; path = xtn->s.in.x[xtn->s.in.xindex].u.fileb.path; if (path) - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %hs - %js"), path, bem); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %hs - %js"), path, bem); else - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), sio_std_names[HAWK_SIO_STDIN].ptr, bem); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), sio_std_names[HAWK_SIO_STDIN].ptr, bem); } break; @@ -1343,9 +1343,9 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat mbslen = xtn->s.in.u.bcs.end - xtn->s.in.u.bcs.ptr; wcslen = size; - if ((m = hawk_conv_bchars_to_uchars_with_cmgr(xtn->s.in.u.bcs.ptr, &mbslen, data, &wcslen, hawk_getcmgr(awk), 0)) <= -1 && m != -2) + if ((m = hawk_conv_bchars_to_uchars_with_cmgr(xtn->s.in.u.bcs.ptr, &mbslen, data, &wcslen, hawk_getcmgr(hawk), 0)) <= -1 && m != -2) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); n = -1; } else @@ -1365,9 +1365,9 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat wcslen = xtn->s.in.u.ucs.end - xtn->s.in.u.ucs.ptr; mbslen = size; - if ((m = hawk_conv_uchars_to_bchars_with_cmgr(xtn->s.in.u.ucs.ptr, &wcslen, data, &mbslen, hawk_getcmgr(awk))) <= -1 && m != -2) + if ((m = hawk_conv_uchars_to_bchars_with_cmgr(xtn->s.in.u.ucs.ptr, &wcslen, data, &mbslen, hawk_getcmgr(hawk))) <= -1 && m != -2) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); n = -1; } else @@ -1383,7 +1383,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat default: /* this should never happen */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINTERN); n = -1; break; } @@ -1395,7 +1395,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat if (xtn->s.in.x[next].type != HAWK_PARSESTD_NULL) { /* open the next stream if available. */ - if (open_parsestd(awk, arg, xtn, next) <= -1) n = -1; + if (open_parsestd(hawk, arg, xtn, next) <= -1) n = -1; else { xtn->s.in.xindex = next; /* update the next to the current */ @@ -1420,37 +1420,37 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat if (n <= -1) { - const hawk_ooch_t* bem = hawk_backuperrmsg(awk); - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), arg->name, bem); + const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EREAD, HAWK_T("unable to read %js - %js"), arg->name, bem); } return n; } } -static hawk_ooi_t sf_in (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t size) +static hawk_ooi_t sf_in (hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t size) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); switch (cmd) { case HAWK_SIO_CMD_OPEN: - return sf_in_open(awk, arg, xtn); + return sf_in_open(hawk, arg, xtn); case HAWK_SIO_CMD_CLOSE: - return sf_in_close(awk, arg, xtn); + return sf_in_close(hawk, arg, xtn); case HAWK_SIO_CMD_READ: - return sf_in_read(awk, arg, data, size, xtn); + return sf_in_read(hawk, arg, data, size, xtn); default: - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINTERN); return -1; } } -static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t size) +static hawk_ooi_t sf_out (hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t size) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); switch (cmd) { @@ -1467,19 +1467,19 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, if (xtn->s.out.x->u.fileb.path == HAWK_NULL || (xtn->s.out.x->u.fileb.path[0] == '-' && xtn->s.out.x->u.fileb.path[1] == '\0')) { /* no path name or - -> stdout */ - xtn->s.out.u.file.sio = open_sio_std(awk, HAWK_SIO_STDOUT, HAWK_SIO_WRITE | HAWK_SIO_IGNOREECERR | HAWK_SIO_LINEBREAK); + xtn->s.out.u.file.sio = open_sio_std(hawk, HAWK_SIO_STDOUT, HAWK_SIO_WRITE | HAWK_SIO_IGNOREECERR | HAWK_SIO_LINEBREAK); if (xtn->s.out.u.file.sio == HAWK_NULL) return -1; } else { #if defined(HAWK_OOCH_IS_UCH) hawk_uch_t* upath; - upath = hawk_dupbtoucstr(awk, xtn->s.out.x->u.fileb.path, HAWK_NULL, 1); + upath = hawk_dupbtoucstr(hawk, xtn->s.out.x->u.fileb.path, HAWK_NULL, 1); if (!upath) return -1; - xtn->s.out.u.file.sio = open_sio(awk, upath, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); - hawk_freemem (awk, upath); + xtn->s.out.u.file.sio = open_sio(hawk, upath, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); + hawk_freemem (hawk, upath); #else - xtn->s.out.u.file.sio = open_sio(awk, xtn->s.out.x->u.fileb.path, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); + xtn->s.out.u.file.sio = open_sio(hawk, xtn->s.out.x->u.fileb.path, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); #endif if (xtn->s.out.u.file.sio == HAWK_NULL) return -1; } @@ -1496,19 +1496,19 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, if (xtn->s.out.x->u.fileu.path == HAWK_NULL || (xtn->s.out.x->u.fileu.path[0] == '-' && xtn->s.out.x->u.fileu.path[1] == '\0')) { /* no path name or - -> stdout */ - xtn->s.out.u.file.sio = open_sio_std(awk, HAWK_SIO_STDOUT, HAWK_SIO_WRITE | HAWK_SIO_IGNOREECERR | HAWK_SIO_LINEBREAK); + xtn->s.out.u.file.sio = open_sio_std(hawk, HAWK_SIO_STDOUT, HAWK_SIO_WRITE | HAWK_SIO_IGNOREECERR | HAWK_SIO_LINEBREAK); if (xtn->s.out.u.file.sio == HAWK_NULL) return -1; } else { #if defined(HAWK_OOCH_IS_UCH) - xtn->s.out.u.file.sio = open_sio(awk, xtn->s.out.x->u.fileu.path, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); + xtn->s.out.u.file.sio = open_sio(hawk, xtn->s.out.x->u.fileu.path, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); #else hawk_bch_t* bpath; - bpath = hawk_duputobcstr(awk, xtn->s.out.x->u.fileu.path, HAWK_NULL); + bpath = hawk_duputobcstr(hawk, xtn->s.out.x->u.fileu.path, HAWK_NULL); if (!bpath) return -1; - xtn->s.out.u.file.sio = open_sio(awk, bpath, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); - hawk_freemem (awk, bpath); + xtn->s.out.u.file.sio = open_sio(hawk, bpath, HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR); + hawk_freemem (hawk, bpath); #endif if (xtn->s.out.u.file.sio == HAWK_NULL) return -1; } @@ -1517,17 +1517,17 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, return 1; case HAWK_PARSESTD_OOCS: - xtn->s.out.u.oocs.buf = hawk_ooecs_open(hawk_getgem(awk), 0, 512); + xtn->s.out.u.oocs.buf = hawk_ooecs_open(hawk_getgem(hawk), 0, 512); if (xtn->s.out.u.oocs.buf == HAWK_NULL) return -1; return 1; case HAWK_PARSESTD_BCS: - xtn->s.out.u.bcs.buf = hawk_becs_open(hawk_getgem(awk), 0, 512); + xtn->s.out.u.bcs.buf = hawk_becs_open(hawk_getgem(hawk), 0, 512); if (xtn->s.out.u.bcs.buf == HAWK_NULL) return -1; return 1; case HAWK_PARSESTD_UCS: - xtn->s.out.u.ucs.buf = hawk_uecs_open(hawk_getgem(awk), 0, 512); + xtn->s.out.u.ucs.buf = hawk_uecs_open(hawk_getgem(hawk), 0, 512); if (xtn->s.out.u.ucs.buf == HAWK_NULL) return -1; return 1; } @@ -1571,10 +1571,10 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, if (n <= -1) { const hawk_ooch_t* ioname; - const hawk_ooch_t* bem = hawk_backuperrmsg(awk); + const hawk_ooch_t* bem = hawk_backuperrmsg(hawk); ioname = xtn->s.out.x->u.file.path; if (!ioname) ioname = sio_std_names[HAWK_SIO_STDOUT].ptr; - hawk_seterrfmt (awk, HAWK_NULL, HAWK_EWRITE, HAWK_T("unable to write to %js - %js"), ioname, bem); + hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EWRITE, HAWK_T("unable to write to %js - %js"), ioname, bem); } return n; } @@ -1594,14 +1594,14 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_oow_t orglen; wcslen = size; - if (hawk_convutobchars(awk, data, &wcslen, HAWK_NULL, &mbslen) <= -1) return -1; + if (hawk_convutobchars(hawk, data, &wcslen, HAWK_NULL, &mbslen) <= -1) return -1; if (mbslen > HAWK_TYPE_MAX(hawk_ooi_t)) mbslen = HAWK_TYPE_MAX(hawk_ooi_t); orglen = hawk_becs_getlen(xtn->s.out.u.bcs.buf); if (hawk_becs_setlen(xtn->s.out.u.bcs.buf, orglen + mbslen) == (hawk_oow_t)-1) return -1; wcslen = size; - hawk_convutobchars (awk, data, &wcslen, HAWK_BECS_CPTR(xtn->s.out.u.bcs.buf, orglen), &mbslen); + hawk_convutobchars (hawk, data, &wcslen, HAWK_BECS_CPTR(xtn->s.out.u.bcs.buf, orglen), &mbslen); size = wcslen; return size; @@ -1615,14 +1615,14 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_oow_t orglen; mbslen = size; - if (hawk_convbtouchars(awk, data, &mbslen, HAWK_NULL, &wcslen, 0) <= -1) return -1; + if (hawk_convbtouchars(hawk, data, &mbslen, HAWK_NULL, &wcslen, 0) <= -1) return -1; if (wcslen > HAWK_TYPE_MAX(hawk_ooi_t)) wcslen = HAWK_TYPE_MAX(hawk_ooi_t); orglen = hawk_becs_getlen(xtn->s.out.u.ucs.buf); if (hawk_uecs_setlen(xtn->s.out.u.ucs.buf, orglen + wcslen) == (hawk_oow_t)-1) return -1; mbslen = size; - hawk_convbtouchars (awk, data, &mbslen, HAWK_UECS_CPTR(xtn->s.out.u.ucs.buf, orglen), &wcslen, 0); + hawk_convbtouchars (hawk, data, &mbslen, HAWK_UECS_CPTR(xtn->s.out.u.ucs.buf, orglen), &wcslen, 0); size = mbslen; return size; @@ -1640,14 +1640,14 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, break; } - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINTERN); return -1; } -int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out) +int hawk_parsestd (hawk_t* hawk, hawk_parsestd_t in[], hawk_parsestd_t* out) { hawk_sio_cbs_t sio; - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); int n; if (in == HAWK_NULL || (in[0].type != HAWK_PARSESTD_FILE && @@ -1659,7 +1659,7 @@ int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out) { /* the input is a must. at least 1 file or 1 string * must be specified */ - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); return -1; } @@ -1676,14 +1676,14 @@ int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out) out->type != HAWK_PARSESTD_BCS && out->type != HAWK_PARSESTD_UCS) { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINVAL); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINVAL); return -1; } sio.out = sf_out; xtn->s.out.x = out; } - n = hawk_parse(awk, &sio); + n = hawk_parse(hawk, &sio); if (out) { @@ -1951,7 +1951,7 @@ static hawk_ooi_t pio_handler_rest (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_ri return -1; } -static hawk_ooi_t awk_rio_pipe (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t size) +static hawk_ooi_t hawk_rio_pipe (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t size) { if (cmd == HAWK_RIO_CMD_OPEN) { @@ -1997,7 +1997,7 @@ static hawk_ooi_t awk_rio_pipe (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_ar return pio_handler_rest(rtx, cmd, riod, data, size); } -static hawk_ooi_t awk_rio_file (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t size) +static hawk_ooi_t hawk_rio_file (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t size) { switch (cmd) { @@ -2199,7 +2199,7 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod) * if an argument has a special form of var=val, it is treated specially * * on the command-line - * hawk -f a.awk a=20 /etc/passwd + * hawk -f a.hawk a=20 /etc/passwd * or via ARGV * hawk 'BEGIN { ARGV[1] = "a=20"; } * { print a $1; }' dummy /etc/hosts @@ -2369,7 +2369,7 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod) return -1; } -static hawk_ooi_t awk_rio_console (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t size) +static hawk_ooi_t hawk_rio_console (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t size) { switch (cmd) { @@ -2748,7 +2748,7 @@ static int make_additional_globals (hawk_rtx_t* rtx, xtn_t* xtn, const hawk_ooch } static hawk_rtx_t* open_rtx_std ( - hawk_t* awk, + hawk_t* hawk, hawk_oow_t xtnsize, const hawk_ooch_t* id, hawk_ooch_t* icf[], @@ -2760,13 +2760,13 @@ static hawk_rtx_t* open_rtx_std ( rxtn_t* rxtn; xtn_t* xtn; - xtn = GET_XTN(awk); + xtn = GET_XTN(hawk); - rio.pipe = awk_rio_pipe; - rio.file = awk_rio_file; - rio.console = awk_rio_console; + rio.pipe = hawk_rio_pipe; + rio.file = hawk_rio_file; + rio.console = hawk_rio_console; - rtx = hawk_rtx_open(awk, HAWK_SIZEOF(rxtn_t) + xtnsize, &rio); + rtx = hawk_rtx_open(hawk, HAWK_SIZEOF(rxtn_t) + xtnsize, &rio); if (!rtx) return HAWK_NULL; rtx->_instsize += HAWK_SIZEOF(rxtn_t); @@ -2775,7 +2775,7 @@ static hawk_rtx_t* open_rtx_std ( if (rtx->hawk->opt.trait & HAWK_RIO) { - if (hawk_htb_init(&rxtn->cmgrtab, hawk_getgem(awk), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1) <= -1) + if (hawk_htb_init(&rxtn->cmgrtab, hawk_getgem(hawk), 256, 70, HAWK_SIZEOF(hawk_ooch_t), 1) <= -1) { hawk_rtx_close (rtx); return HAWK_NULL; @@ -2811,7 +2811,7 @@ static hawk_rtx_t* open_rtx_std ( { if (hawk_rtx_setofilenamewithoochars(rtx, ocf[0], hawk_count_oocstr(ocf[0])) <= -1) { - hawk_rtx_errortohawk (rtx, awk); + hawk_rtx_errortohawk (rtx, hawk); hawk_rtx_close (rtx); return HAWK_NULL; } @@ -2819,7 +2819,7 @@ static hawk_rtx_t* open_rtx_std ( if (make_additional_globals(rtx, xtn, id, icf) <= -1) { - hawk_rtx_errortohawk (rtx, awk); + hawk_rtx_errortohawk (rtx, hawk); hawk_rtx_close (rtx); return HAWK_NULL; } @@ -2828,7 +2828,7 @@ static hawk_rtx_t* open_rtx_std ( } hawk_rtx_t* hawk_rtx_openstdwithbcstr ( - hawk_t* awk, + hawk_t* hawk, hawk_oow_t xtnsize, const hawk_bch_t* id, hawk_bch_t* icf[], @@ -2840,7 +2840,7 @@ hawk_rtx_t* hawk_rtx_openstdwithbcstr ( hawk_ooch_t* xid, ** xicf = HAWK_NULL, ** xocf = HAWK_NULL; #if defined(HAWK_OOCH_IS_UCH) - xid = hawk_dupbtoucstr(awk, id, &wcslen, 0); + xid = hawk_dupbtoucstr(hawk, id, &wcslen, 0); if (!xid) return HAWK_NULL; #else xid = (hawk_ooch_t*)id; @@ -2850,15 +2850,15 @@ hawk_rtx_t* hawk_rtx_openstdwithbcstr ( { for (i = 0; icf[i]; i++) ; - xicf = (hawk_ooch_t**)hawk_callocmem(awk, HAWK_SIZEOF(*xicf) * (i + 1)); + xicf = (hawk_ooch_t**)hawk_callocmem(hawk, HAWK_SIZEOF(*xicf) * (i + 1)); if (!xicf) goto done; for (i = 0; icf[i]; i++) { #if defined(HAWK_OOCH_IS_UCH) - xicf[i] = hawk_dupbtoucstr(awk, icf[i], &wcslen, 0); + xicf[i] = hawk_dupbtoucstr(hawk, icf[i], &wcslen, 0); #else - xicf[i] = hawk_dupbcstr(awk, icf[i], HAWK_NULL); + xicf[i] = hawk_dupbcstr(hawk, icf[i], HAWK_NULL); #endif if (!xicf[i]) goto done; } @@ -2869,47 +2869,47 @@ hawk_rtx_t* hawk_rtx_openstdwithbcstr ( { for (i = 0; ocf[i]; i++) ; - xocf = (hawk_ooch_t**)hawk_callocmem(awk, HAWK_SIZEOF(*xocf) * (i + 1)); + xocf = (hawk_ooch_t**)hawk_callocmem(hawk, HAWK_SIZEOF(*xocf) * (i + 1)); if (!xocf) goto done; for (i = 0; ocf[i]; i++) { #if defined(HAWK_OOCH_IS_UCH) - xocf[i] = hawk_dupbtoucstr(awk, ocf[i], &wcslen, 0); + xocf[i] = hawk_dupbtoucstr(hawk, ocf[i], &wcslen, 0); #else - xocf[i] = hawk_dupucstr(awk, ocf[i], HAWK_NULL); + xocf[i] = hawk_dupucstr(hawk, ocf[i], HAWK_NULL); #endif if (!xocf[i]) goto done; } xocf[i] = HAWK_NULL; } - rtx = open_rtx_std(awk, xtnsize, xid, xicf, xocf, cmgr); + rtx = open_rtx_std(hawk, xtnsize, xid, xicf, xocf, cmgr); done: if (!rtx) { if (xocf) { - for (i = 0; xocf[i]; i++) hawk_freemem (awk, xocf[i]); - hawk_freemem (awk, xocf); + for (i = 0; xocf[i]; i++) hawk_freemem (hawk, xocf[i]); + hawk_freemem (hawk, xocf); } if (xicf) { - for (i = 0; xicf[i]; i++) hawk_freemem (awk, xicf[i]); - hawk_freemem (awk, xicf); + for (i = 0; xicf[i]; i++) hawk_freemem (hawk, xicf[i]); + hawk_freemem (hawk, xicf); } } #if defined(HAWK_OOCH_IS_UCH) - hawk_freemem (awk, xid); + hawk_freemem (hawk, xid); #endif return rtx; } hawk_rtx_t* hawk_rtx_openstdwithucstr ( - hawk_t* awk, + hawk_t* hawk, hawk_oow_t xtnsize, const hawk_uch_t* id, hawk_uch_t* icf[], @@ -2921,7 +2921,7 @@ hawk_rtx_t* hawk_rtx_openstdwithucstr ( hawk_ooch_t* xid, ** xicf = HAWK_NULL, ** xocf = HAWK_NULL; #if defined(HAWK_OOCH_IS_BCH) - xid = hawk_duputobcstr(awk, id, &mbslen); + xid = hawk_duputobcstr(hawk, id, &mbslen); if (!xid) return HAWK_NULL; #else xid = (hawk_ooch_t*)id; @@ -2931,15 +2931,15 @@ hawk_rtx_t* hawk_rtx_openstdwithucstr ( { for (i = 0; icf[i]; i++) ; - xicf = (hawk_ooch_t**)hawk_callocmem(awk, HAWK_SIZEOF(*xicf) * (i + 1)); + xicf = (hawk_ooch_t**)hawk_callocmem(hawk, HAWK_SIZEOF(*xicf) * (i + 1)); if (!xicf) goto done; for (i = 0; icf[i]; i++) { #if defined(HAWK_OOCH_IS_BCH) - xicf[i] = hawk_duputobcstr(awk, icf[i], &mbslen); + xicf[i] = hawk_duputobcstr(hawk, icf[i], &mbslen); #else - xicf[i] = hawk_dupucstr(awk, icf[i], HAWK_NULL); + xicf[i] = hawk_dupucstr(hawk, icf[i], HAWK_NULL); #endif if (HAWK_UNLIKELY(!xicf[i])) goto done; } @@ -2950,40 +2950,40 @@ hawk_rtx_t* hawk_rtx_openstdwithucstr ( { for (i = 0; ocf[i]; i++) ; - xocf = (hawk_ooch_t**)hawk_callocmem(awk, HAWK_SIZEOF(*xocf) * (i + 1)); + xocf = (hawk_ooch_t**)hawk_callocmem(hawk, HAWK_SIZEOF(*xocf) * (i + 1)); if (!xocf) goto done; for (i = 0; ocf[i]; i++) { #if defined(HAWK_OOCH_IS_BCH) - xocf[i] = hawk_dupbtoucstr(awk, ocf[i], &mbslen, 0); + xocf[i] = hawk_dupbtoucstr(hawk, ocf[i], &mbslen, 0); #else - xocf[i] = hawk_dupucstr(awk, ocf[i], HAWK_NULL); + xocf[i] = hawk_dupucstr(hawk, ocf[i], HAWK_NULL); #endif if (!xocf[i]) goto done; } xocf[i] = HAWK_NULL; } - rtx = open_rtx_std(awk, xtnsize, xid, xicf, xocf, cmgr); + rtx = open_rtx_std(hawk, xtnsize, xid, xicf, xocf, cmgr); done: if (!rtx) { if (xocf) { - for (i = 0; xocf[i]; i++) hawk_freemem (awk, xocf[i]); - hawk_freemem (awk, xocf); + for (i = 0; xocf[i]; i++) hawk_freemem (hawk, xocf[i]); + hawk_freemem (hawk, xocf); } if (xicf) { - for (i = 0; xicf[i]; i++) hawk_freemem (awk, xicf[i]); - hawk_freemem (awk, xicf); + for (i = 0; xicf[i]; i++) hawk_freemem (hawk, xicf[i]); + hawk_freemem (hawk, xicf); } } #if defined(HAWK_OOCH_IS_BCH) - hawk_freemem (awk, xid); + hawk_freemem (hawk, xid); #endif return rtx; @@ -3263,13 +3263,13 @@ hawk_cmgr_t* hawk_rtx_getiocmgrstd (hawk_rtx_t* rtx, const hawk_ooch_t* ioname) return HAWK_NULL; } -static int add_globals (hawk_t* awk) +static int add_globals (hawk_t* hawk) { - xtn_t* xtn = GET_XTN(awk); + xtn_t* xtn = GET_XTN(hawk); - xtn->gbl_argc = hawk_addgblwithoocstr(awk, HAWK_T("ARGC")); - xtn->gbl_argv = hawk_addgblwithoocstr(awk, HAWK_T("ARGV")); - xtn->gbl_environ = hawk_addgblwithoocstr(awk, HAWK_T("ENVIRON")); + xtn->gbl_argc = hawk_addgblwithoocstr(hawk, HAWK_T("ARGC")); + xtn->gbl_argv = hawk_addgblwithoocstr(hawk, HAWK_T("ARGV")); + xtn->gbl_environ = hawk_addgblwithoocstr(hawk, HAWK_T("ENVIRON")); return (HAWK_UNLIKELY(xtn->gbl_argc <= -1 || xtn->gbl_argv <= -1 || xtn->gbl_environ <= -1))? -1: 0; } @@ -3292,13 +3292,13 @@ static struct fnctab_t fnctab[] = { HAWK_T("getioattr"), { {3, 3, HAWK_T("vvr")}, fnc_getioattr, HAWK_RIO } } }; -static int add_functions (hawk_t* awk) +static int add_functions (hawk_t* hawk) { int i; for (i = 0; i < HAWK_COUNTOF(fnctab); i++) { - if (hawk_addfnc (awk, fnctab[i].name, &fnctab[i].spec) == HAWK_NULL) return -1; + if (hawk_addfnc (hawk, fnctab[i].name, &fnctab[i].spec) == HAWK_NULL) return -1; } return 0; diff --git a/hawk/lib/syscall.h b/hawk/lib/syscall.h index 947ba253..cf7ba8e2 100644 --- a/hawk/lib/syscall.h +++ b/hawk/lib/syscall.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tio.c b/hawk/lib/tio.c index 2fb63a11..21470c2c 100644 --- a/hawk/lib/tio.c +++ b/hawk/lib/tio.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-ast.c b/hawk/lib/tre-ast.c index 918d6d34..a95de245 100644 --- a/hawk/lib/tre-ast.c +++ b/hawk/lib/tre-ast.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-ast.h b/hawk/lib/tre-ast.h index c939afa6..4e0f1bb0 100644 --- a/hawk/lib/tre-ast.h +++ b/hawk/lib/tre-ast.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-compile.c b/hawk/lib/tre-compile.c index bb05c21a..53798cd9 100644 --- a/hawk/lib/tre-compile.c +++ b/hawk/lib/tre-compile.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-compile.h b/hawk/lib/tre-compile.h index 10d784e3..56dacaa2 100644 --- a/hawk/lib/tre-compile.h +++ b/hawk/lib/tre-compile.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-match-bt.c b/hawk/lib/tre-match-bt.c index 96d3277e..3a333544 100644 --- a/hawk/lib/tre-match-bt.c +++ b/hawk/lib/tre-match-bt.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-match-pa.c b/hawk/lib/tre-match-pa.c index b0c1ce72..1c3a3d54 100644 --- a/hawk/lib/tre-match-pa.c +++ b/hawk/lib/tre-match-pa.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-match-ut.h b/hawk/lib/tre-match-ut.h index 44e194fa..061a5f5c 100644 --- a/hawk/lib/tre-match-ut.h +++ b/hawk/lib/tre-match-ut.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-mem.c b/hawk/lib/tre-mem.c index 87376c06..f1dc43d8 100644 --- a/hawk/lib/tre-mem.c +++ b/hawk/lib/tre-mem.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-mem.h b/hawk/lib/tre-mem.h index a521bd40..66a86347 100644 --- a/hawk/lib/tre-mem.h +++ b/hawk/lib/tre-mem.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-parse.c b/hawk/lib/tre-parse.c index 84b43940..d39095dd 100644 --- a/hawk/lib/tre-parse.c +++ b/hawk/lib/tre-parse.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-parse.h b/hawk/lib/tre-parse.h index 9583c400..2c0da71d 100644 --- a/hawk/lib/tre-parse.h +++ b/hawk/lib/tre-parse.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-prv.h b/hawk/lib/tre-prv.h index 2186bfe1..6cd31926 100644 --- a/hawk/lib/tre-prv.h +++ b/hawk/lib/tre-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-stack.c b/hawk/lib/tre-stack.c index d1dc1560..1b7ed123 100644 --- a/hawk/lib/tre-stack.c +++ b/hawk/lib/tre-stack.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre-stack.h b/hawk/lib/tre-stack.h index c9fbc8ae..cad621e5 100644 --- a/hawk/lib/tre-stack.h +++ b/hawk/lib/tre-stack.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tre.c b/hawk/lib/tre.c index c97cfd33..8ce3108c 100644 --- a/hawk/lib/tre.c +++ b/hawk/lib/tre.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/tree-prv.h b/hawk/lib/tree-prv.h index 1db91b82..de4cfe83 100644 --- a/hawk/lib/tree-prv.h +++ b/hawk/lib/tree-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -340,13 +340,13 @@ extern "C" { #endif /* print the entire tree */ -int hawk_prnpt (hawk_t* awk, hawk_nde_t* tree); +int hawk_prnpt (hawk_t* hawk, hawk_nde_t* tree); /* print a single top-level node */ -int hawk_prnnde (hawk_t* awk, hawk_nde_t* node); +int hawk_prnnde (hawk_t* hawk, hawk_nde_t* node); /* print the pattern part */ -int hawk_prnptnpt (hawk_t* awk, hawk_nde_t* tree); +int hawk_prnptnpt (hawk_t* hawk, hawk_nde_t* tree); -void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree); +void hawk_clrpt (hawk_t* hawk, hawk_nde_t* tree); #if defined(__cplusplus) } diff --git a/hawk/lib/tree.c b/hawk/lib/tree.c index 74d49935..359614de 100644 --- a/hawk/lib/tree.c +++ b/hawk/lib/tree.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -113,87 +113,87 @@ static const hawk_ooch_t* print_outop_str[] = HAWK_T("") }; -#define PUT_SRCSTR(awk,str) do { if (hawk_putsrcoocstr (awk, str) == -1) return -1; } while(0) +#define PUT_SRCSTR(hawk,str) do { if (hawk_putsrcoocstr (hawk, str) == -1) return -1; } while(0) -#define PUT_NL(awk) do { \ - if (awk->opt.trait & HAWK_CRLF) PUT_SRCSTR (awk, HAWK_T("\r")); \ - PUT_SRCSTR (awk, HAWK_T("\n")); \ +#define PUT_NL(hawk) do { \ + if (hawk->opt.trait & HAWK_CRLF) PUT_SRCSTR (hawk, HAWK_T("\r")); \ + PUT_SRCSTR (hawk, HAWK_T("\n")); \ } while(0) -#define PUT_SRCSTRN(awk,str,len) do { \ - if (hawk_putsrcoochars (awk, str, len) == -1) return -1; \ +#define PUT_SRCSTRN(hawk,str,len) do { \ + if (hawk_putsrcoochars (hawk, str, len) == -1) return -1; \ } while(0) -#define PRINT_TABS(awk,depth) do { \ - if (print_tabs(awk,depth) == -1) return -1; \ +#define PRINT_TABS(hawk,depth) do { \ + if (print_tabs(hawk,depth) == -1) return -1; \ } while(0) -#define PRINT_EXPR(awk,nde) do { \ - if (print_expr(awk,nde) == -1) return -1; \ +#define PRINT_EXPR(hawk,nde) do { \ + if (print_expr(hawk,nde) == -1) return -1; \ } while(0) -#define PRINT_EXPR_LIST(awk,nde) do { \ - if (print_expr_list(awk,nde) == -1) return -1; \ +#define PRINT_EXPR_LIST(hawk,nde) do { \ + if (print_expr_list(hawk,nde) == -1) return -1; \ } while(0) -#define PRINT_EXPR_LIST_FOR_IDX(awk,nde) do { \ - if (print_expr_list_for_idx(awk,nde) == -1) return -1; \ +#define PRINT_EXPR_LIST_FOR_IDX(hawk,nde) do { \ + if (print_expr_list_for_idx(hawk,nde) == -1) return -1; \ } while(0) -#define PRINT_STMTS(awk,nde,depth) do { \ - if (print_stmts(awk,nde,depth) == -1) return -1; \ +#define PRINT_STMTS(hawk,nde,depth) do { \ + if (print_stmts(hawk,nde,depth) == -1) return -1; \ } while(0) -static int print_tabs (hawk_t* awk, int depth); -static int print_expr (hawk_t* awk, hawk_nde_t* nde); -static int print_expr_list (hawk_t* awk, hawk_nde_t* tree); -static int print_expr_list_for_idx (hawk_t* awk, hawk_nde_t* tree); -static int print_stmts (hawk_t* awk, hawk_nde_t* tree, int depth); +static int print_tabs (hawk_t* hawk, int depth); +static int print_expr (hawk_t* hawk, hawk_nde_t* nde); +static int print_expr_list (hawk_t* hawk, hawk_nde_t* tree); +static int print_expr_list_for_idx (hawk_t* hawk, hawk_nde_t* tree); +static int print_stmts (hawk_t* hawk, hawk_nde_t* tree, int depth); -static int print_tabs (hawk_t* awk, int depth) +static int print_tabs (hawk_t* hawk, int depth) { while (depth > 0) { - PUT_SRCSTR (awk, HAWK_T("\t")); + PUT_SRCSTR (hawk, HAWK_T("\t")); depth--; } return 0; } -static int print_printx (hawk_t* awk, hawk_nde_print_t* px) +static int print_printx (hawk_t* hawk, hawk_nde_print_t* px) { hawk_oocs_t kw; if (px->type == HAWK_NDE_PRINT) { - hawk_getkwname (awk, HAWK_KWID_PRINT, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); + hawk_getkwname (hawk, HAWK_KWID_PRINT, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); } else { - hawk_getkwname (awk, HAWK_KWID_PRINTF, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); + hawk_getkwname (hawk, HAWK_KWID_PRINTF, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); } if (px->args != HAWK_NULL) { - PUT_SRCSTR (awk, HAWK_T(" ")); - PRINT_EXPR_LIST (awk, px->args); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PRINT_EXPR_LIST (hawk, px->args); } if (px->out != HAWK_NULL) { - PUT_SRCSTR (awk, HAWK_T(" ")); - PUT_SRCSTR (awk, print_outop_str[px->out_type]); - PUT_SRCSTR (awk, HAWK_T(" ")); - PRINT_EXPR (awk, px->out); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PUT_SRCSTR (hawk, print_outop_str[px->out_type]); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PRINT_EXPR (hawk, px->out); } return 0; } -static int print_expr (hawk_t* awk, hawk_nde_t* nde) +static int print_expr (hawk_t* hawk, hawk_nde_t* nde) { hawk_oocs_t kw; @@ -203,15 +203,15 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { hawk_nde_t* p = ((hawk_nde_grp_t*)nde)->body; - PUT_SRCSTR (awk, HAWK_T("(")); + PUT_SRCSTR (hawk, HAWK_T("(")); while (p != HAWK_NULL) { - PRINT_EXPR (awk, p); + PRINT_EXPR (hawk, p); if (p->next != HAWK_NULL) - PUT_SRCSTR (awk, HAWK_T(",")); + PUT_SRCSTR (hawk, HAWK_T(",")); p = p->next; } - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } @@ -219,11 +219,11 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { hawk_nde_ass_t* px = (hawk_nde_ass_t*)nde; - PRINT_EXPR (awk, px->left); - PUT_SRCSTR (awk, HAWK_T(" ")); - PUT_SRCSTR (awk, assop_str[px->opcode]); - PUT_SRCSTR (awk, HAWK_T(" ")); - PRINT_EXPR (awk, px->right); + PRINT_EXPR (hawk, px->left); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PUT_SRCSTR (hawk, assop_str[px->opcode]); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PRINT_EXPR (hawk, px->right); HAWK_ASSERT (px->right->next == HAWK_NULL); break; @@ -233,21 +233,21 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { hawk_nde_exp_t* px = (hawk_nde_exp_t*)nde; - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR (awk, px->left); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR (hawk, px->left); HAWK_ASSERT (px->left->next == HAWK_NULL); - PUT_SRCSTR (awk, HAWK_T(" ")); - PUT_SRCSTR (awk, binop_str[px->opcode][(awk->opt.trait & HAWK_BLANKCONCAT)? 0: 1]); - PUT_SRCSTR (awk, HAWK_T(" ")); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PUT_SRCSTR (hawk, binop_str[px->opcode][(hawk->opt.trait & HAWK_BLANKCONCAT)? 0: 1]); + PUT_SRCSTR (hawk, HAWK_T(" ")); if (px->right->type == HAWK_NDE_ASS) - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR (awk, px->right); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR (hawk, px->right); if (px->right->type == HAWK_NDE_ASS) - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T(")")); HAWK_ASSERT (px->right->next == HAWK_NULL); - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } @@ -256,12 +256,12 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) hawk_nde_exp_t* px = (hawk_nde_exp_t*)nde; HAWK_ASSERT (px->right == HAWK_NULL); - PUT_SRCSTR (awk, HAWK_T("(")); - PUT_SRCSTR (awk, unrop_str[px->opcode]); - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR (awk, px->left); - PUT_SRCSTR (awk, HAWK_T(")")); - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T("(")); + PUT_SRCSTR (hawk, unrop_str[px->opcode]); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR (hawk, px->left); + PUT_SRCSTR (hawk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } @@ -270,10 +270,10 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) hawk_nde_exp_t* px = (hawk_nde_exp_t*)nde; HAWK_ASSERT (px->right == HAWK_NULL); - PUT_SRCSTR (awk, incop_str[px->opcode]); - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR (awk, px->left); - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, incop_str[px->opcode]); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR (hawk, px->left); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } @@ -282,10 +282,10 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) hawk_nde_exp_t* px = (hawk_nde_exp_t*)nde; HAWK_ASSERT (px->right == HAWK_NULL); - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR (awk, px->left); - PUT_SRCSTR (awk, HAWK_T(")")); - PUT_SRCSTR (awk, incop_str[px->opcode]); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR (hawk, px->left); + PUT_SRCSTR (hawk, HAWK_T(")")); + PUT_SRCSTR (hawk, incop_str[px->opcode]); break; } @@ -293,13 +293,13 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { hawk_nde_cnd_t* px = (hawk_nde_cnd_t*)nde; - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR (awk, px->test); - PUT_SRCSTR (awk, HAWK_T(")?")); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR (hawk, px->test); + PUT_SRCSTR (hawk, HAWK_T(")?")); - PRINT_EXPR (awk, px->left); - PUT_SRCSTR (awk, HAWK_T(":")); - PRINT_EXPR (awk, px->right); + PRINT_EXPR (hawk, px->left); + PUT_SRCSTR (hawk, HAWK_T(":")); + PRINT_EXPR (hawk, px->right); break; } @@ -307,7 +307,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { if (((hawk_nde_int_t*)nde)->str) { - PUT_SRCSTRN (awk, + PUT_SRCSTRN (hawk, ((hawk_nde_int_t*)nde)->str, ((hawk_nde_int_t*)nde)->len); } @@ -333,7 +333,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) HAWK_T('\0'), HAWK_NULL ); - PUT_SRCSTR (awk, buf); + PUT_SRCSTR (hawk, buf); } break; } @@ -342,7 +342,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { if (((hawk_nde_flt_t*)nde)->str) { - PUT_SRCSTRN (awk, + PUT_SRCSTRN (hawk, ((hawk_nde_flt_t*)nde)->str, ((hawk_nde_flt_t*)nde)->len); } @@ -350,7 +350,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { hawk_ooch_t buf[96]; - hawk_fmttooocstr (awk, + hawk_fmttooocstr (hawk, buf, HAWK_COUNTOF(buf), #if defined(HAWK_USE_AWK_FLTMAX) HAWK_T("%jf"), @@ -360,7 +360,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) ((hawk_nde_flt_t*)nde)->val ); - PUT_SRCSTR (awk, buf); + PUT_SRCSTR (hawk, buf); } break; } @@ -370,7 +370,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) hawk_ooch_t* ptr; hawk_oow_t len, i; - PUT_SRCSTR (awk, HAWK_T("\"")); + PUT_SRCSTR (hawk, HAWK_T("\"")); ptr = ((hawk_nde_str_t*)nde)->ptr; len = ((hawk_nde_str_t*)nde)->len; @@ -380,41 +380,41 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) switch (ptr[i]) { case HAWK_T('\n'): - PUT_SRCSTR (awk, HAWK_T("\\n")); + PUT_SRCSTR (hawk, HAWK_T("\\n")); break; case HAWK_T('\r'): - PUT_SRCSTR (awk, HAWK_T("\\r")); + PUT_SRCSTR (hawk, HAWK_T("\\r")); break; case HAWK_T('\t'): - PUT_SRCSTR (awk, HAWK_T("\\t")); + PUT_SRCSTR (hawk, HAWK_T("\\t")); break; case HAWK_T('\f'): - PUT_SRCSTR (awk, HAWK_T("\\f")); + PUT_SRCSTR (hawk, HAWK_T("\\f")); break; case HAWK_T('\b'): - PUT_SRCSTR (awk, HAWK_T("\\b")); + PUT_SRCSTR (hawk, HAWK_T("\\b")); break; case HAWK_T('\v'): - PUT_SRCSTR (awk, HAWK_T("\\v")); + PUT_SRCSTR (hawk, HAWK_T("\\v")); break; case HAWK_T('\a'): - PUT_SRCSTR (awk, HAWK_T("\\a")); + PUT_SRCSTR (hawk, HAWK_T("\\a")); break; case HAWK_T('\0'): - PUT_SRCSTR (awk, HAWK_T("\\0")); + PUT_SRCSTR (hawk, HAWK_T("\\0")); break; case HAWK_T('\"'): - PUT_SRCSTR (awk, HAWK_T("\\\"")); + PUT_SRCSTR (hawk, HAWK_T("\\\"")); break; case HAWK_T('\\'): - PUT_SRCSTR (awk, HAWK_T("\\\\")); + PUT_SRCSTR (hawk, HAWK_T("\\\\")); break; default: - PUT_SRCSTRN (awk, &ptr[i], 1); + PUT_SRCSTRN (hawk, &ptr[i], 1); break; } } - PUT_SRCSTR (awk, HAWK_T("\"")); + PUT_SRCSTR (hawk, HAWK_T("\"")); break; } @@ -423,7 +423,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) hawk_bch_t* ptr; hawk_oow_t len, i; - PUT_SRCSTR (awk, HAWK_T("B\"")); + PUT_SRCSTR (hawk, HAWK_T("B\"")); ptr = ((hawk_nde_mbs_t*)nde)->ptr; len = ((hawk_nde_mbs_t*)nde)->len; for (i = 0; i < len; i++) @@ -432,75 +432,75 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) switch (ptr[i]) { case HAWK_BT('\n'): - PUT_SRCSTR (awk, HAWK_T("\\n")); + PUT_SRCSTR (hawk, HAWK_T("\\n")); break; case HAWK_BT('\r'): - PUT_SRCSTR (awk, HAWK_T("\\r")); + PUT_SRCSTR (hawk, HAWK_T("\\r")); break; case HAWK_BT('\t'): - PUT_SRCSTR (awk, HAWK_T("\\t")); + PUT_SRCSTR (hawk, HAWK_T("\\t")); break; case HAWK_BT('\f'): - PUT_SRCSTR (awk, HAWK_T("\\f")); + PUT_SRCSTR (hawk, HAWK_T("\\f")); break; case HAWK_BT('\b'): - PUT_SRCSTR (awk, HAWK_T("\\b")); + PUT_SRCSTR (hawk, HAWK_T("\\b")); break; case HAWK_BT('\v'): - PUT_SRCSTR (awk, HAWK_T("\\v")); + PUT_SRCSTR (hawk, HAWK_T("\\v")); break; case HAWK_BT('\a'): - PUT_SRCSTR (awk, HAWK_T("\\a")); + PUT_SRCSTR (hawk, HAWK_T("\\a")); break; case HAWK_BT('\0'): - PUT_SRCSTR (awk, HAWK_T("\\0")); + PUT_SRCSTR (hawk, HAWK_T("\\0")); break; case HAWK_BT('\"'): - PUT_SRCSTR (awk, HAWK_T("\\\"")); + PUT_SRCSTR (hawk, HAWK_T("\\\"")); break; case HAWK_BT('\\'): - PUT_SRCSTR (awk, HAWK_T("\\\\")); + PUT_SRCSTR (hawk, HAWK_T("\\\\")); break; default: { #if defined(HAWK_OOCH_IS_BCH) - PUT_SRCSTRN (awk, &ptr[i], 1); + PUT_SRCSTRN (hawk, &ptr[i], 1); #else hawk_ooch_t wc = ptr[i]; if (HAWK_BYTE_PRINTABLE(wc)) { - PUT_SRCSTRN (awk, &wc, 1); + PUT_SRCSTRN (hawk, &wc, 1); } else { hawk_bch_t xbuf[3]; hawk_byte_to_bcstr (wc, xbuf, HAWK_COUNTOF(xbuf), 16, '0'); - PUT_SRCSTR (awk, HAWK_T("\\x")); - wc = xbuf[0]; PUT_SRCSTRN (awk, &wc, 1); - wc = xbuf[1]; PUT_SRCSTRN (awk, &wc, 1); + PUT_SRCSTR (hawk, HAWK_T("\\x")); + wc = xbuf[0]; PUT_SRCSTRN (hawk, &wc, 1); + wc = xbuf[1]; PUT_SRCSTRN (hawk, &wc, 1); } #endif break; } } } - PUT_SRCSTR (awk, HAWK_T("\"")); + PUT_SRCSTR (hawk, HAWK_T("\"")); break; } case HAWK_NDE_REX: { - PUT_SRCSTR (awk, HAWK_T("/")); - PUT_SRCSTRN (awk, + PUT_SRCSTR (hawk, HAWK_T("/")); + PUT_SRCSTRN (hawk, ((hawk_nde_rex_t*)nde)->str.ptr, ((hawk_nde_rex_t*)nde)->str.len); - PUT_SRCSTR (awk, HAWK_T("/")); + PUT_SRCSTR (hawk, HAWK_T("/")); break; } case HAWK_NDE_FUN: { - PUT_SRCSTRN (awk, + PUT_SRCSTRN (hawk, ((hawk_nde_fun_t*)nde)->name.ptr, ((hawk_nde_fun_t*)nde)->name.len); break; @@ -515,8 +515,8 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, tmp, HAWK_COUNTOF(tmp)); - PUT_SRCSTR (awk, HAWK_T("__p")); - PUT_SRCSTRN (awk, tmp, n); + PUT_SRCSTR (hawk, HAWK_T("__p")); + PUT_SRCSTRN (hawk, tmp, n); HAWK_ASSERT (px->idx == HAWK_NULL); break; @@ -529,10 +529,10 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) HAWK_ASSERT (px->id.idxa != (hawk_oow_t)-1); HAWK_ASSERT (px->idx != HAWK_NULL); - PUT_SRCSTR (awk, HAWK_T("__p")); - n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, awk->tmp.fmt, HAWK_COUNTOF(awk->tmp.fmt)); - PUT_SRCSTRN (awk, awk->tmp.fmt, n); - PRINT_EXPR_LIST_FOR_IDX (awk, px->idx); + PUT_SRCSTR (hawk, HAWK_T("__p")); + n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, hawk->tmp.fmt, HAWK_COUNTOF(hawk->tmp.fmt)); + PUT_SRCSTRN (hawk, hawk->tmp.fmt, n); + PRINT_EXPR_LIST_FOR_IDX (hawk, px->idx); break; } @@ -542,7 +542,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) HAWK_ASSERT (px->id.idxa == (hawk_oow_t)-1); HAWK_ASSERT (px->idx == HAWK_NULL); - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); break; } @@ -552,8 +552,8 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) HAWK_ASSERT (px->id.idxa == (hawk_oow_t)-1); HAWK_ASSERT (px->idx != HAWK_NULL); - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); - PRINT_EXPR_LIST_FOR_IDX (awk, px->idx); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); + PRINT_EXPR_LIST_FOR_IDX (hawk, px->idx); break; } @@ -563,32 +563,32 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) if (px->id.idxa != (hawk_oow_t)-1) { - /* deparsing is global. so i can't honor awk->parse.pragma.trait - * which can change in each input file. let me just check awk->opt.trait */ - if (!(awk->opt.trait & HAWK_IMPLICIT)) + /* deparsing is global. so i can't honor hawk->parse.pragma.trait + * which can change in each input file. let me just check hawk->opt.trait */ + if (!(hawk->opt.trait & HAWK_IMPLICIT)) { /* no implicit(named) variable is allowed. * use the actual name */ - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } - else if (px->id.idxa < awk->tree.ngbls_base) + else if (px->id.idxa < hawk->tree.ngbls_base) { /* static global variables */ - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } else { hawk_ooch_t tmp[HAWK_SIZEOF(hawk_int_t)*8+2]; hawk_oow_t n; - PUT_SRCSTR (awk, HAWK_T("__g")); + PUT_SRCSTR (hawk, HAWK_T("__g")); n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, tmp, HAWK_COUNTOF(tmp)); - PUT_SRCSTRN (awk, tmp, n); + PUT_SRCSTRN (hawk, tmp, n); } } else { - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } HAWK_ASSERT (px->idx == HAWK_NULL); break; @@ -600,35 +600,35 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) if (px->id.idxa != (hawk_oow_t)-1) { - /* deparsing is global. so i can't honor awk->parse.pragma.trait - * which can change in each input file. let me just check awk->opt.trait */ - if (!(awk->opt.trait & HAWK_IMPLICIT)) + /* deparsing is global. so i can't honor hawk->parse.pragma.trait + * which can change in each input file. let me just check hawk->opt.trait */ + if (!(hawk->opt.trait & HAWK_IMPLICIT)) { /* no implicit(named) variable is allowed. * use the actual name */ - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } - else if (px->id.idxa < awk->tree.ngbls_base) + else if (px->id.idxa < hawk->tree.ngbls_base) { /* static global variables */ - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } else { hawk_ooch_t tmp[HAWK_SIZEOF(hawk_int_t)*8+2]; hawk_oow_t n; - PUT_SRCSTR (awk, HAWK_T("__g")); + PUT_SRCSTR (hawk, HAWK_T("__g")); n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, tmp, HAWK_COUNTOF(tmp)); - PUT_SRCSTRN (awk, tmp, n); + PUT_SRCSTRN (hawk, tmp, n); } } else { - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } HAWK_ASSERT (px->idx != HAWK_NULL); - PRINT_EXPR_LIST_FOR_IDX (awk, px->idx); + PRINT_EXPR_LIST_FOR_IDX (hawk, px->idx); break; } @@ -639,13 +639,13 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) if (px->id.idxa != (hawk_oow_t)-1) { - PUT_SRCSTR (awk, HAWK_T("__l")); - n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, awk->tmp.fmt, HAWK_COUNTOF(awk->tmp.fmt)); - PUT_SRCSTRN (awk, awk->tmp.fmt, n); + PUT_SRCSTR (hawk, HAWK_T("__l")); + n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, hawk->tmp.fmt, HAWK_COUNTOF(hawk->tmp.fmt)); + PUT_SRCSTRN (hawk, hawk->tmp.fmt, n); } else { - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } HAWK_ASSERT (px->idx == HAWK_NULL); break; @@ -658,54 +658,54 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) if (px->id.idxa != (hawk_oow_t)-1) { - PUT_SRCSTR (awk, HAWK_T("__l")); - n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, awk->tmp.fmt, HAWK_COUNTOF(awk->tmp.fmt)); - PUT_SRCSTRN (awk, awk->tmp.fmt, n); + PUT_SRCSTR (hawk, HAWK_T("__l")); + n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, hawk->tmp.fmt, HAWK_COUNTOF(hawk->tmp.fmt)); + PUT_SRCSTRN (hawk, hawk->tmp.fmt, n); } else { - PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len); + PUT_SRCSTRN (hawk, px->id.name.ptr, px->id.name.len); } HAWK_ASSERT (px->idx != HAWK_NULL); - PRINT_EXPR_LIST_FOR_IDX (awk, px->idx); + PRINT_EXPR_LIST_FOR_IDX (hawk, px->idx); break; } case HAWK_NDE_POS: { - PUT_SRCSTR (awk, HAWK_T("$(")); - PRINT_EXPR (awk, ((hawk_nde_pos_t*)nde)->val); - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T("$(")); + PRINT_EXPR (hawk, ((hawk_nde_pos_t*)nde)->val); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } case HAWK_NDE_FNCALL_FNC: { hawk_nde_fncall_t* px = (hawk_nde_fncall_t*)nde; - PUT_SRCSTRN (awk, px->u.fnc.info.name.ptr, px->u.fnc.info.name.len); - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR_LIST (awk, px->args); - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTRN (hawk, px->u.fnc.info.name.ptr, px->u.fnc.info.name.len); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR_LIST (hawk, px->args); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } case HAWK_NDE_FNCALL_FUN: { hawk_nde_fncall_t* px = (hawk_nde_fncall_t*)nde; - PUT_SRCSTRN (awk, px->u.fun.name.ptr, px->u.fun.name.len); - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR_LIST (awk, px->args); - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTRN (hawk, px->u.fun.name.ptr, px->u.fun.name.len); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR_LIST (hawk, px->args); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } case HAWK_NDE_FNCALL_VAR: { hawk_nde_fncall_t* px = (hawk_nde_fncall_t*)nde; - PRINT_EXPR (awk, (hawk_nde_t*)px->u.var.var); - PUT_SRCSTR (awk, HAWK_T("(")); - PRINT_EXPR_LIST (awk, px->args); - PUT_SRCSTR (awk, HAWK_T(")")); + PRINT_EXPR (hawk, (hawk_nde_t*)px->u.var.var); + PUT_SRCSTR (hawk, HAWK_T("(")); + PRINT_EXPR_LIST (hawk, px->args); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } @@ -713,51 +713,51 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) { hawk_nde_getline_t* px = (hawk_nde_getline_t*)nde; - PUT_SRCSTR (awk, HAWK_T("(")); + PUT_SRCSTR (hawk, HAWK_T("(")); if (px->in != HAWK_NULL && (px->in_type == HAWK_IN_PIPE || px->in_type == HAWK_IN_RWPIPE)) { - PRINT_EXPR (awk, px->in); - PUT_SRCSTR (awk, HAWK_T(" ")); - PUT_SRCSTR (awk, getline_inop_str[px->in_type]); - PUT_SRCSTR (awk, HAWK_T(" ")); + PRINT_EXPR (hawk, px->in); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PUT_SRCSTR (hawk, getline_inop_str[px->in_type]); + PUT_SRCSTR (hawk, HAWK_T(" ")); } - hawk_getkwname (awk, (px->mbs? HAWK_KWID_GETBLINE: HAWK_KWID_GETLINE), &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); + hawk_getkwname (hawk, (px->mbs? HAWK_KWID_GETBLINE: HAWK_KWID_GETLINE), &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); if (px->var != HAWK_NULL) { - PUT_SRCSTR (awk, HAWK_T(" ")); - PRINT_EXPR (awk, px->var); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PRINT_EXPR (hawk, px->var); } if (px->in != HAWK_NULL && px->in_type == HAWK_IN_FILE) { - PUT_SRCSTR (awk, HAWK_T(" ")); - PUT_SRCSTR (awk, getline_inop_str[px->in_type]); - PUT_SRCSTR (awk, HAWK_T(" ")); - PRINT_EXPR (awk, px->in); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PUT_SRCSTR (hawk, getline_inop_str[px->in_type]); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PRINT_EXPR (hawk, px->in); } - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T(")")); break; } case HAWK_NDE_PRINT: case HAWK_NDE_PRINTF: { - PUT_SRCSTR (awk, HAWK_T("(")); - if (print_printx (awk, (hawk_nde_print_t*)nde) <= -1) return -1; - PUT_SRCSTR (awk, HAWK_T(")")); + PUT_SRCSTR (hawk, HAWK_T("(")); + if (print_printx (hawk, (hawk_nde_print_t*)nde) <= -1) return -1; + PUT_SRCSTR (hawk, HAWK_T(")")); break; } default: { - hawk_seterrnum (awk, HAWK_NULL, HAWK_EINTERN); + hawk_seterrnum (hawk, HAWK_NULL, HAWK_EINTERN); return -1; } } @@ -765,28 +765,28 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde) return 0; } -static int print_expr_list (hawk_t* awk, hawk_nde_t* tree) +static int print_expr_list (hawk_t* hawk, hawk_nde_t* tree) { hawk_nde_t* p = tree; while (p) { - PRINT_EXPR (awk, p); + PRINT_EXPR (hawk, p); p = p->next; - if (p) PUT_SRCSTR (awk, HAWK_T(",")); + if (p) PUT_SRCSTR (hawk, HAWK_T(",")); } return 0; } -static int print_expr_list_for_idx (hawk_t* awk, hawk_nde_t* tree) +static int print_expr_list_for_idx (hawk_t* hawk, hawk_nde_t* tree) { hawk_nde_t* p = tree; - PUT_SRCSTR (awk, HAWK_T("[")); + PUT_SRCSTR (hawk, HAWK_T("[")); while (p) { - PRINT_EXPR (awk, p); + PRINT_EXPR (hawk, p); p = p->next; if (p) { @@ -796,18 +796,18 @@ static int print_expr_list_for_idx (hawk_t* awk, hawk_nde_t* tree) * if the true multi-dimensional indices are enabled(i.e. HAWK_ENABLE_GC is defined) * e.g. a[x][y][z] * let me print this regardless of */ - PUT_SRCSTR (awk, HAWK_T("][")); + PUT_SRCSTR (hawk, HAWK_T("][")); p = p->next; } - else PUT_SRCSTR (awk, HAWK_T(",")); + else PUT_SRCSTR (hawk, HAWK_T(",")); } } - PUT_SRCSTR (awk, HAWK_T("]")); + PUT_SRCSTR (hawk, HAWK_T("]")); return 0; } -static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) +static int print_stmt (hawk_t* hawk, hawk_nde_t* p, int depth) { hawk_oow_t i; hawk_oocs_t kw; @@ -816,9 +816,9 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) { case HAWK_NDE_NULL: { - PRINT_TABS (awk, depth); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); break; } @@ -827,37 +827,37 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) hawk_oow_t n; hawk_nde_blk_t* px = (hawk_nde_blk_t*)p; - PRINT_TABS (awk, depth); - PUT_SRCSTR (awk, HAWK_T("{")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + PUT_SRCSTR (hawk, HAWK_T("{")); + PUT_NL (hawk); if (px->nlcls > 0) { - PRINT_TABS (awk, depth + 1); + PRINT_TABS (hawk, depth + 1); - hawk_getkwname (awk, HAWK_KWID_XLOCAL, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" ")); + hawk_getkwname (hawk, HAWK_KWID_XLOCAL, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" ")); for (i = 0; i < px->nlcls - 1; i++) { - PUT_SRCSTR (awk, HAWK_T("__l")); - n = hawk_int_to_oocstr(i, 10, HAWK_NULL, awk->tmp.fmt, HAWK_COUNTOF(awk->tmp.fmt)); - PUT_SRCSTRN (awk, awk->tmp.fmt, n); - PUT_SRCSTR (awk, HAWK_T(", ")); + PUT_SRCSTR (hawk, HAWK_T("__l")); + n = hawk_int_to_oocstr(i, 10, HAWK_NULL, hawk->tmp.fmt, HAWK_COUNTOF(hawk->tmp.fmt)); + PUT_SRCSTRN (hawk, hawk->tmp.fmt, n); + PUT_SRCSTR (hawk, HAWK_T(", ")); } - PUT_SRCSTR (awk, HAWK_T("__l")); - n = hawk_int_to_oocstr(i, 10, HAWK_NULL, awk->tmp.fmt, HAWK_COUNTOF(awk->tmp.fmt)); - PUT_SRCSTRN (awk, awk->tmp.fmt, n); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PUT_SRCSTR (hawk, HAWK_T("__l")); + n = hawk_int_to_oocstr(i, 10, HAWK_NULL, hawk->tmp.fmt, HAWK_COUNTOF(hawk->tmp.fmt)); + PUT_SRCSTRN (hawk, hawk->tmp.fmt, n); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); } - PRINT_STMTS (awk, px->body, depth + 1); - PRINT_TABS (awk, depth); - PUT_SRCSTR (awk, HAWK_T("}")); - PUT_NL (awk); + PRINT_STMTS (hawk, px->body, depth + 1); + PRINT_TABS (hawk, depth); + PUT_SRCSTR (hawk, HAWK_T("}")); + PUT_NL (hawk); break; } @@ -865,30 +865,30 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) { hawk_nde_if_t* px = (hawk_nde_if_t*)p; - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_IF, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" (")); - PRINT_EXPR (awk, px->test); - PUT_SRCSTR (awk, HAWK_T(")")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_IF, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" (")); + PRINT_EXPR (hawk, px->test); + PUT_SRCSTR (hawk, HAWK_T(")")); + PUT_NL (hawk); HAWK_ASSERT (px->then_part != HAWK_NULL); if (px->then_part->type == HAWK_NDE_BLK) - PRINT_STMTS (awk, px->then_part, depth); + PRINT_STMTS (hawk, px->then_part, depth); else - PRINT_STMTS (awk, px->then_part, depth + 1); + PRINT_STMTS (hawk, px->then_part, depth + 1); if (px->else_part != HAWK_NULL) { - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_ELSE, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_ELSE, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_NL (hawk); if (px->else_part->type == HAWK_NDE_BLK) - PRINT_STMTS (awk, px->else_part, depth); + PRINT_STMTS (hawk, px->else_part, depth); else - PRINT_STMTS (awk, px->else_part, depth + 1); + PRINT_STMTS (hawk, px->else_part, depth + 1); } break; } @@ -897,20 +897,20 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) { hawk_nde_while_t* px = (hawk_nde_while_t*)p; - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_WHILE, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" (")); - PRINT_EXPR (awk, px->test); - PUT_SRCSTR (awk, HAWK_T(")")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_WHILE, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" (")); + PRINT_EXPR (hawk, px->test); + PUT_SRCSTR (hawk, HAWK_T(")")); + PUT_NL (hawk); if (px->body->type == HAWK_NDE_BLK) { - PRINT_STMTS (awk, px->body, depth); + PRINT_STMTS (hawk, px->body, depth); } else { - PRINT_STMTS (awk, px->body, depth + 1); + PRINT_STMTS (hawk, px->body, depth + 1); } break; } @@ -919,26 +919,26 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) { hawk_nde_while_t* px = (hawk_nde_while_t*)p; - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_DO, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_DO, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_NL (hawk); if (px->body->type == HAWK_NDE_BLK) { - PRINT_STMTS (awk, px->body, depth); + PRINT_STMTS (hawk, px->body, depth); } else { - PRINT_STMTS (awk, px->body, depth + 1); + PRINT_STMTS (hawk, px->body, depth + 1); } - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_WHILE, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" (")); - PRINT_EXPR (awk, px->test); - PUT_SRCSTR (awk, HAWK_T(");")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_WHILE, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" (")); + PRINT_EXPR (hawk, px->test); + PUT_SRCSTR (hawk, HAWK_T(");")); + PUT_NL (hawk); break; } @@ -946,34 +946,34 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) { hawk_nde_for_t* px = (hawk_nde_for_t*)p; - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_FOR, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" (")); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_FOR, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" (")); if (px->init != HAWK_NULL) { - PRINT_EXPR (awk, px->init); + PRINT_EXPR (hawk, px->init); } - PUT_SRCSTR (awk, HAWK_T("; ")); + PUT_SRCSTR (hawk, HAWK_T("; ")); if (px->test != HAWK_NULL) { - PRINT_EXPR (awk, px->test); + PRINT_EXPR (hawk, px->test); } - PUT_SRCSTR (awk, HAWK_T("; ")); + PUT_SRCSTR (hawk, HAWK_T("; ")); if (px->incr != HAWK_NULL) { - PRINT_EXPR (awk, px->incr); + PRINT_EXPR (hawk, px->incr); } - PUT_SRCSTR (awk, HAWK_T(")")); - PUT_NL (awk); + PUT_SRCSTR (hawk, HAWK_T(")")); + PUT_NL (hawk); if (px->body->type == HAWK_NDE_BLK) { - PRINT_STMTS (awk, px->body, depth); + PRINT_STMTS (hawk, px->body, depth); } else { - PRINT_STMTS (awk, px->body, depth + 1); + PRINT_STMTS (hawk, px->body, depth + 1); } break; } @@ -982,63 +982,63 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) { hawk_nde_forin_t* px = (hawk_nde_forin_t*)p; - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_FOR, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" ")); - PRINT_EXPR (awk, px->test); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_FOR, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" ")); + PRINT_EXPR (hawk, px->test); + PUT_NL (hawk); if (px->body->type == HAWK_NDE_BLK) { - PRINT_STMTS (awk, px->body, depth); + PRINT_STMTS (hawk, px->body, depth); } else { - PRINT_STMTS (awk, px->body, depth + 1); + PRINT_STMTS (hawk, px->body, depth + 1); } break; } case HAWK_NDE_BREAK: { - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_BREAK, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_BREAK, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); break; } case HAWK_NDE_CONTINUE: { - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_CONTINUE, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_CONTINUE, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); break; } case HAWK_NDE_RETURN: { - PRINT_TABS (awk, depth); + PRINT_TABS (hawk, depth); if (((hawk_nde_return_t*)p)->val == HAWK_NULL) { - hawk_getkwname (awk, HAWK_KWID_RETURN, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + hawk_getkwname (hawk, HAWK_KWID_RETURN, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); } else { - hawk_getkwname (awk, HAWK_KWID_RETURN, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" ")); + hawk_getkwname (hawk, HAWK_KWID_RETURN, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" ")); HAWK_ASSERT (((hawk_nde_return_t*)p)->val->next == HAWK_NULL); - PRINT_EXPR (awk, ((hawk_nde_return_t*)p)->val); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_EXPR (hawk, ((hawk_nde_return_t*)p)->val); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); } break; } @@ -1046,92 +1046,92 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) case HAWK_NDE_EXIT: { hawk_nde_exit_t* px = (hawk_nde_exit_t*)p; - PRINT_TABS (awk, depth); + PRINT_TABS (hawk, depth); if (px->val == HAWK_NULL) { - hawk_getkwname (awk, (px->abort? HAWK_KWID_XABORT: HAWK_KWID_EXIT), &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + hawk_getkwname (hawk, (px->abort? HAWK_KWID_XABORT: HAWK_KWID_EXIT), &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); } else { - hawk_getkwname (awk, (px->abort? HAWK_KWID_XABORT: HAWK_KWID_EXIT), &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" ")); + hawk_getkwname (hawk, (px->abort? HAWK_KWID_XABORT: HAWK_KWID_EXIT), &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" ")); HAWK_ASSERT (px->val->next == HAWK_NULL); - PRINT_EXPR (awk, px->val); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_EXPR (hawk, px->val); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); } break; } case HAWK_NDE_NEXT: { - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_NEXT, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_NEXT, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); break; } case HAWK_NDE_NEXTFILE: { - PRINT_TABS (awk, depth); + PRINT_TABS (hawk, depth); if (((hawk_nde_nextfile_t*)p)->out) { - hawk_getkwname (awk, HAWK_KWID_NEXTOFILE, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); + hawk_getkwname (hawk, HAWK_KWID_NEXTOFILE, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); } else { - hawk_getkwname (awk, HAWK_KWID_NEXTFILE, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); + hawk_getkwname (hawk, HAWK_KWID_NEXTFILE, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); } - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); break; } case HAWK_NDE_DELETE: { - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_DELETE, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" ")); - hawk_prnpt (awk, ((hawk_nde_delete_t*)p)->var); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_DELETE, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" ")); + hawk_prnpt (hawk, ((hawk_nde_delete_t*)p)->var); break; } case HAWK_NDE_RESET: { - PRINT_TABS (awk, depth); - hawk_getkwname (awk, HAWK_KWID_XRESET, &kw); - PUT_SRCSTRN (awk, kw.ptr, kw.len); - PUT_SRCSTR (awk, HAWK_T(" ")); - hawk_prnpt (awk, ((hawk_nde_reset_t*)p)->var); + PRINT_TABS (hawk, depth); + hawk_getkwname (hawk, HAWK_KWID_XRESET, &kw); + PUT_SRCSTRN (hawk, kw.ptr, kw.len); + PUT_SRCSTR (hawk, HAWK_T(" ")); + hawk_prnpt (hawk, ((hawk_nde_reset_t*)p)->var); break; } case HAWK_NDE_PRINT: case HAWK_NDE_PRINTF: { - PRINT_TABS (awk, depth); - if (print_printx (awk, (hawk_nde_print_t*)p) <= -1) return -1; - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + if (print_printx (hawk, (hawk_nde_print_t*)p) <= -1) return -1; + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); break; } default: { - PRINT_TABS (awk, depth); - PRINT_EXPR (awk, p); - PUT_SRCSTR (awk, HAWK_T(";")); - PUT_NL (awk); + PRINT_TABS (hawk, depth); + PRINT_EXPR (hawk, p); + PUT_SRCSTR (hawk, HAWK_T(";")); + PUT_NL (hawk); break; } } @@ -1139,46 +1139,46 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth) return 0; } -static int print_stmts (hawk_t* awk, hawk_nde_t* tree, int depth) +static int print_stmts (hawk_t* hawk, hawk_nde_t* tree, int depth) { hawk_nde_t* p = tree; while (p != HAWK_NULL) { - if (print_stmt (awk, p, depth) == -1) return -1; + if (print_stmt (hawk, p, depth) == -1) return -1; p = p->next; } return 0; } -int hawk_prnpt (hawk_t* awk, hawk_nde_t* tree) +int hawk_prnpt (hawk_t* hawk, hawk_nde_t* tree) { - return print_stmts (awk, tree, 0); + return print_stmts (hawk, tree, 0); } -int hawk_prnnde (hawk_t* awk, hawk_nde_t* tree) +int hawk_prnnde (hawk_t* hawk, hawk_nde_t* tree) { - return print_stmt (awk, tree, 0); + return print_stmt (hawk, tree, 0); } -int hawk_prnptnpt (hawk_t* awk, hawk_nde_t* tree) +int hawk_prnptnpt (hawk_t* hawk, hawk_nde_t* tree) { hawk_nde_t* nde = tree; while (nde != HAWK_NULL) { - if (print_expr (awk, nde) == -1) return -1; + if (print_expr (hawk, nde) == -1) return -1; if (nde->next == HAWK_NULL) break; - PUT_SRCSTR (awk, HAWK_T(",")); + PUT_SRCSTR (hawk, HAWK_T(",")); nde = nde->next; } return 0; } -void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree) +void hawk_clrpt (hawk_t* hawk, hawk_nde_t* tree) { hawk_nde_t* p = tree; hawk_nde_t* next; @@ -1191,101 +1191,101 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree) { case HAWK_NDE_NULL: { - hawk_freemem (awk, p); + hawk_freemem (hawk, p); break; } case HAWK_NDE_BLK: { - hawk_clrpt (awk, ((hawk_nde_blk_t*)p)->body); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_blk_t*)p)->body); + hawk_freemem (hawk, p); break; } case HAWK_NDE_IF: { hawk_nde_if_t* px = (hawk_nde_if_t*)p; - hawk_clrpt (awk, px->test); - hawk_clrpt (awk, px->then_part); - if (px->else_part) hawk_clrpt (awk, px->else_part); - hawk_freemem (awk, p); + hawk_clrpt (hawk, px->test); + hawk_clrpt (hawk, px->then_part); + if (px->else_part) hawk_clrpt (hawk, px->else_part); + hawk_freemem (hawk, p); break; } case HAWK_NDE_WHILE: case HAWK_NDE_DOWHILE: { - hawk_clrpt (awk, ((hawk_nde_while_t*)p)->test); - hawk_clrpt (awk, ((hawk_nde_while_t*)p)->body); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_while_t*)p)->test); + hawk_clrpt (hawk, ((hawk_nde_while_t*)p)->body); + hawk_freemem (hawk, p); break; } case HAWK_NDE_FOR: { hawk_nde_for_t* px = (hawk_nde_for_t*)p; - if (px->init) hawk_clrpt (awk, px->init); - if (px->test) hawk_clrpt (awk, px->test); - if (px->incr) hawk_clrpt (awk, px->incr); - hawk_clrpt (awk, px->body); - hawk_freemem (awk, p); + if (px->init) hawk_clrpt (hawk, px->init); + if (px->test) hawk_clrpt (hawk, px->test); + if (px->incr) hawk_clrpt (hawk, px->incr); + hawk_clrpt (hawk, px->body); + hawk_freemem (hawk, p); break; } case HAWK_NDE_FORIN: { - hawk_clrpt (awk, ((hawk_nde_forin_t*)p)->test); - hawk_clrpt (awk, ((hawk_nde_forin_t*)p)->body); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_forin_t*)p)->test); + hawk_clrpt (hawk, ((hawk_nde_forin_t*)p)->body); + hawk_freemem (hawk, p); break; } case HAWK_NDE_BREAK: { - hawk_freemem (awk, p); + hawk_freemem (hawk, p); break; } case HAWK_NDE_CONTINUE: { - hawk_freemem (awk, p); + hawk_freemem (hawk, p); break; } case HAWK_NDE_RETURN: { hawk_nde_return_t* px = (hawk_nde_return_t*)p; - if (px->val) hawk_clrpt (awk, px->val); - hawk_freemem (awk, p); + if (px->val) hawk_clrpt (hawk, px->val); + hawk_freemem (hawk, p); break; } case HAWK_NDE_EXIT: { if (((hawk_nde_exit_t*)p)->val != HAWK_NULL) - hawk_clrpt (awk, ((hawk_nde_exit_t*)p)->val); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_exit_t*)p)->val); + hawk_freemem (hawk, p); break; } case HAWK_NDE_NEXT: case HAWK_NDE_NEXTFILE: { - hawk_freemem (awk, p); + hawk_freemem (hawk, p); break; } case HAWK_NDE_DELETE: { - hawk_clrpt (awk, ((hawk_nde_delete_t*)p)->var); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_delete_t*)p)->var); + hawk_freemem (hawk, p); break; } case HAWK_NDE_RESET: { - hawk_clrpt (awk, ((hawk_nde_reset_t*)p)->var); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_reset_t*)p)->var); + hawk_freemem (hawk, p); break; } @@ -1293,24 +1293,24 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree) case HAWK_NDE_PRINTF: { hawk_nde_print_t* px = (hawk_nde_print_t*)p; - if (px->args) hawk_clrpt (awk, px->args); - if (px->out) hawk_clrpt (awk, px->out); - hawk_freemem (awk, p); + if (px->args) hawk_clrpt (hawk, px->args); + if (px->out) hawk_clrpt (hawk, px->out); + hawk_freemem (hawk, p); break; } case HAWK_NDE_GRP: { - hawk_clrpt (awk, ((hawk_nde_grp_t*)p)->body); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_grp_t*)p)->body); + hawk_freemem (hawk, p); break; } case HAWK_NDE_ASS: { - hawk_clrpt (awk, ((hawk_nde_ass_t*)p)->left); - hawk_clrpt (awk, ((hawk_nde_ass_t*)p)->right); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_ass_t*)p)->left); + hawk_clrpt (hawk, ((hawk_nde_ass_t*)p)->right); + hawk_freemem (hawk, p); break; } @@ -1320,9 +1320,9 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree) HAWK_ASSERT (px->left->next == HAWK_NULL); HAWK_ASSERT (px->right->next == HAWK_NULL); - hawk_clrpt (awk, px->left); - hawk_clrpt (awk, px->right); - hawk_freemem (awk, p); + hawk_clrpt (hawk, px->left); + hawk_clrpt (hawk, px->right); + hawk_freemem (hawk, p); break; } @@ -1332,63 +1332,63 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree) { hawk_nde_exp_t* px = (hawk_nde_exp_t*)p; HAWK_ASSERT (px->right == HAWK_NULL); - hawk_clrpt (awk, px->left); - hawk_freemem (awk, p); + hawk_clrpt (hawk, px->left); + hawk_freemem (hawk, p); break; } case HAWK_NDE_CND: { - hawk_clrpt (awk, ((hawk_nde_cnd_t*)p)->test); - hawk_clrpt (awk, ((hawk_nde_cnd_t*)p)->left); - hawk_clrpt (awk, ((hawk_nde_cnd_t*)p)->right); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_cnd_t*)p)->test); + hawk_clrpt (hawk, ((hawk_nde_cnd_t*)p)->left); + hawk_clrpt (hawk, ((hawk_nde_cnd_t*)p)->right); + hawk_freemem (hawk, p); break; } case HAWK_NDE_INT: { if (((hawk_nde_int_t*)p)->str) - hawk_freemem (awk, ((hawk_nde_int_t*)p)->str); - hawk_freemem (awk, p); + hawk_freemem (hawk, ((hawk_nde_int_t*)p)->str); + hawk_freemem (hawk, p); break; } case HAWK_NDE_FLT: { if (((hawk_nde_flt_t*)p)->str) - hawk_freemem (awk, ((hawk_nde_flt_t*)p)->str); - hawk_freemem (awk, p); + hawk_freemem (hawk, ((hawk_nde_flt_t*)p)->str); + hawk_freemem (hawk, p); break; } case HAWK_NDE_STR: { - hawk_freemem (awk, ((hawk_nde_str_t*)p)->ptr); - hawk_freemem (awk, p); + hawk_freemem (hawk, ((hawk_nde_str_t*)p)->ptr); + hawk_freemem (hawk, p); break; } case HAWK_NDE_MBS: { - hawk_freemem (awk, ((hawk_nde_mbs_t*)p)->ptr); - hawk_freemem (awk, p); + hawk_freemem (hawk, ((hawk_nde_mbs_t*)p)->ptr); + hawk_freemem (hawk, p); break; } case HAWK_NDE_REX: { hawk_nde_rex_t* rex = (hawk_nde_rex_t*)p; - hawk_freerex (awk, rex->code[0], rex->code[1]); - hawk_freemem (awk, ((hawk_nde_rex_t*)p)->str.ptr); - hawk_freemem (awk, p); + hawk_freerex (hawk, rex->code[0], rex->code[1]); + hawk_freemem (hawk, ((hawk_nde_rex_t*)p)->str.ptr); + hawk_freemem (hawk, p); break; } case HAWK_NDE_FUN: { - hawk_freemem (awk, ((hawk_nde_fun_t*)p)->name.ptr); - hawk_freemem (awk, p); + hawk_freemem (hawk, ((hawk_nde_fun_t*)p)->name.ptr); + hawk_freemem (hawk, p); break; } @@ -1399,8 +1399,8 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree) { hawk_nde_var_t* px = (hawk_nde_var_t*)p; HAWK_ASSERT (px->idx == HAWK_NULL); - if (px->id.name.ptr) hawk_freemem (awk, px->id.name.ptr); - hawk_freemem (awk, p); + if (px->id.name.ptr) hawk_freemem (hawk, px->id.name.ptr); + hawk_freemem (hawk, p); break; } @@ -1411,60 +1411,60 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree) { hawk_nde_var_t* px = (hawk_nde_var_t*)p; HAWK_ASSERT (px->idx != HAWK_NULL); - hawk_clrpt (awk, px->idx); - if (px->id.name.ptr) hawk_freemem (awk, px->id.name.ptr); - hawk_freemem (awk, p); + hawk_clrpt (hawk, px->idx); + if (px->id.name.ptr) hawk_freemem (hawk, px->id.name.ptr); + hawk_freemem (hawk, p); break; } case HAWK_NDE_POS: { - hawk_clrpt (awk, ((hawk_nde_pos_t*)p)->val); - hawk_freemem (awk, p); + hawk_clrpt (hawk, ((hawk_nde_pos_t*)p)->val); + hawk_freemem (hawk, p); break; } case HAWK_NDE_FNCALL_FNC: { hawk_nde_fncall_t* px = (hawk_nde_fncall_t*)p; - /* hawk_freemem (awk, px->u.fnc); */ - hawk_freemem (awk, px->u.fnc.info.name.ptr); - hawk_clrpt (awk, px->args); - hawk_freemem (awk, p); + /* hawk_freemem (hawk, px->u.fnc); */ + hawk_freemem (hawk, px->u.fnc.info.name.ptr); + hawk_clrpt (hawk, px->args); + hawk_freemem (hawk, p); break; } case HAWK_NDE_FNCALL_FUN: { hawk_nde_fncall_t* px = (hawk_nde_fncall_t*)p; - hawk_freemem (awk, px->u.fun.name.ptr); - hawk_clrpt (awk, px->args); - hawk_freemem (awk, p); + hawk_freemem (hawk, px->u.fun.name.ptr); + hawk_clrpt (hawk, px->args); + hawk_freemem (hawk, p); break; } case HAWK_NDE_FNCALL_VAR: { hawk_nde_fncall_t* px = (hawk_nde_fncall_t*)p; - hawk_clrpt (awk, (hawk_nde_t*)px->u.var.var); - hawk_clrpt (awk, px->args); - hawk_freemem (awk, p); + hawk_clrpt (hawk, (hawk_nde_t*)px->u.var.var); + hawk_clrpt (hawk, px->args); + hawk_freemem (hawk, p); break; } case HAWK_NDE_GETLINE: { hawk_nde_getline_t* px = (hawk_nde_getline_t*)p; - if (px->var) hawk_clrpt (awk, px->var); - if (px->in) hawk_clrpt (awk, px->in); - hawk_freemem (awk, p); + if (px->var) hawk_clrpt (hawk, px->var); + if (px->in) hawk_clrpt (hawk, px->in); + hawk_freemem (hawk, p); break; } default: { HAWK_ASSERT (!"should never happen - invalid node type"); - hawk_freemem (awk, p); + hawk_freemem (hawk, p); break; } } diff --git a/hawk/lib/utf16.c b/hawk/lib/utf16.c index 9982bc84..8d917ea6 100644 --- a/hawk/lib/utf16.c +++ b/hawk/lib/utf16.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utf8.c b/hawk/lib/utf8.c index e7f200e2..eecc54fa 100644 --- a/hawk/lib/utf8.c +++ b/hawk/lib/utf8.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utl-ass.c b/hawk/lib/utl-ass.c index aaf7090c..0cd124b9 100644 --- a/hawk/lib/utl-ass.c +++ b/hawk/lib/utl-ass.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utl-skad.c b/hawk/lib/utl-skad.c index dfc65f79..255a7cbe 100644 --- a/hawk/lib/utl-skad.c +++ b/hawk/lib/utl-skad.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utl-skad.h b/hawk/lib/utl-skad.h index caadf74d..9bd259d8 100644 --- a/hawk/lib/utl-skad.h +++ b/hawk/lib/utl-skad.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utl-sort.c b/hawk/lib/utl-sort.c index 17952e5c..b639ae1c 100644 --- a/hawk/lib/utl-sort.c +++ b/hawk/lib/utl-sort.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utl-str.c b/hawk/lib/utl-str.c index 0a28531b..c1f7d685 100644 --- a/hawk/lib/utl-str.c +++ b/hawk/lib/utl-str.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utl-sys.c b/hawk/lib/utl-sys.c index 61004cf6..1adb14c6 100644 --- a/hawk/lib/utl-sys.c +++ b/hawk/lib/utl-sys.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/utl.c b/hawk/lib/utl.c index 74a0077f..3182a515 100644 --- a/hawk/lib/utl.c +++ b/hawk/lib/utl.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/lib/val-prv.h b/hawk/lib/val-prv.h index 7f8f7fe4..5f300639 100644 --- a/hawk/lib/val-prv.h +++ b/hawk/lib/val-prv.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -111,7 +111,7 @@ struct hawk_val_rchunk_t /* sizeof(hawk_intptr_t) may not be the same as sizeof(hawk_int_t). * so step-by-step type conversions are needed. - * e.g) pointer to uintptr_t, uintptr_t to intptr_t, intptr_t to awk_int_t */ + * e.g) pointer to uintptr_t, uintptr_t to intptr_t, intptr_t to hawk_int_t */ #define HAWK_VTR_TO_QUICKINT_POSITIVE(p) \ ((hawk_intptr_t)((hawk_uintptr_t)(p) >> HAWK_VTR_NUM_TYPE_BITS)) #define HAWK_VTR_TO_QUICKINT_NEGATIVE(p) \ diff --git a/hawk/lib/val.c b/hawk/lib/val.c index 902caf57..9b2486fa 100644 --- a/hawk/lib/val.c +++ b/hawk/lib/val.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 @@ -28,13 +28,13 @@ #define CHUNKSIZE HAWK_VAL_CHUNK_SIZE -static hawk_val_nil_t awk_nil = { HAWK_VAL_NIL, 0, 1, 0, 0 }; -static hawk_val_str_t awk_zls = { HAWK_VAL_STR, 0, 1, 0, 0, { HAWK_T(""), 0 } }; -static hawk_val_mbs_t awk_zlm = { HAWK_VAL_MBS, 0, 1, 0, 0, { HAWK_BT(""), 0 } }; +static hawk_val_nil_t hawk_nil = { HAWK_VAL_NIL, 0, 1, 0, 0 }; +static hawk_val_str_t hawk_zls = { HAWK_VAL_STR, 0, 1, 0, 0, { HAWK_T(""), 0 } }; +static hawk_val_mbs_t hawk_zlm = { HAWK_VAL_MBS, 0, 1, 0, 0, { HAWK_BT(""), 0 } }; -hawk_val_t* hawk_val_nil = (hawk_val_t*)&awk_nil; -hawk_val_t* hawk_val_zls = (hawk_val_t*)&awk_zls; -hawk_val_t* hawk_val_zlm = (hawk_val_t*)&awk_zlm; +hawk_val_t* hawk_val_nil = (hawk_val_t*)&hawk_nil; +hawk_val_t* hawk_val_zls = (hawk_val_t*)&hawk_zls; +hawk_val_t* hawk_val_zlm = (hawk_val_t*)&hawk_zlm; /* --------------------------------------------------------------------- */ @@ -412,19 +412,19 @@ static HAWK_INLINE hawk_val_t* gc_calloc_val (hawk_rtx_t* rtx, hawk_oow_t size) /* --------------------------------------------------------------------- */ -hawk_val_t* hawk_get_awk_nil_val (void) +hawk_val_t* hawk_get_nil_val (void) { - return (hawk_val_t*)&awk_nil; + return (hawk_val_t*)&hawk_nil; } int hawk_rtx_isnilval (hawk_rtx_t* rtx, hawk_val_t* val) { - return val == (hawk_val_t*)&awk_nil || (HAWK_VTR_IS_POINTER(val) && val->v_type == HAWK_VAL_NIL); + return val == (hawk_val_t*)&hawk_nil || (HAWK_VTR_IS_POINTER(val) && val->v_type == HAWK_VAL_NIL); } hawk_val_t* hawk_rtx_makenilval (hawk_rtx_t* rtx) { - return (hawk_val_t*)&awk_nil; + return (hawk_val_t*)&hawk_nil; } hawk_val_t* hawk_rtx_makeintval (hawk_rtx_t* rtx, hawk_int_t v) @@ -1100,7 +1100,7 @@ hawk_val_t* hawk_rtx_getmapvalfld (hawk_rtx_t* rtx, hawk_val_t* map, const hawk_ { /* the given key is not found in the map. * we return NULL here as this function is called by - * a user unlike the awk statement accessing the map key. + * a user unlike the hawk statement accessing the map key. * so you can easily determine if the key is found by * checking the error number. */ @@ -1174,7 +1174,7 @@ const hawk_ooch_t* hawk_rtx_getvaltypename(hawk_rtx_t* rtx, hawk_val_t* val) { static const hawk_ooch_t* __val_type_name[] = { - /* synchronize this table with enum hawk_val_type_t in awk.h */ + /* synchronize this table with enum hawk_val_type_t in hawk.h */ HAWK_T("nil"), HAWK_T("int"), HAWK_T("flt"), diff --git a/hawk/mod/mod-mysql.c b/hawk/mod/mod-mysql.c index 33d8c9b8..0d2dc85a 100644 --- a/hawk/mod/mod-mysql.c +++ b/hawk/mod/mod-mysql.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/mod/mod-mysql.h b/hawk/mod/mod-mysql.h index 9ab0adec..9121436b 100644 --- a/hawk/mod/mod-mysql.h +++ b/hawk/mod/mod-mysql.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/mod/mod-uci.c b/hawk/mod/mod-uci.c index d93248ea..af3a737a 100644 --- a/hawk/mod/mod-uci.c +++ b/hawk/mod/mod-uci.c @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/mod/mod-uci.h b/hawk/mod/mod-uci.h index c21e2d88..07215949 100644 --- a/hawk/mod/mod-uci.h +++ b/hawk/mod/mod-uci.h @@ -1,7 +1,7 @@ /* * $Id$ * - Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved. + Copyright (c) 2006-2020 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 diff --git a/hawk/pkgs/hawk.spec.in b/hawk/pkgs/hawk.spec.in index a4dee477..314cc52c 100644 --- a/hawk/pkgs/hawk.spec.in +++ b/hawk/pkgs/hawk.spec.in @@ -41,6 +41,9 @@ rm -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig rm -f $RPM_BUILD_ROOT%{_bindir}/uni-case rm -f $RPM_BUILD_ROOT%{_bindir}/uni-prop +%check +make check + %clean rm -rf "$RPM_BUILD_ROOT"