added %check to the rpm spec file.

renamed awk to hawk
updated copyright years
This commit is contained in:
hyung-hwan 2020-04-16 03:42:30 +00:00
parent 5f4635d455
commit c3d137a5c2
105 changed files with 2872 additions and 2869 deletions

View File

@ -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, ...)

View File

@ -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);
}
/////////////////////////////////

View File

@ -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<Cstr,FunctionHandler>
{
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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)
}

View File

@ -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

View File

@ -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

View File

@ -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[],

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;
}
/* ------------------------------------------------------------------------ */

View File

@ -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
);

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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)
}

View File

@ -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));

View File

@ -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)
}

View File

@ -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;

View File

@ -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)
}

View File

@ -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));

View File

@ -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)
}

View File

@ -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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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)
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)
}

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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) \

View File

@ -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"),

Some files were not shown because too many files have changed in this diff Show More