cleaned up code

This commit is contained in:
2009-07-16 04:43:31 +00:00
parent e149b933f7
commit f0f2db5e8a
22 changed files with 781 additions and 796 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp 234 2009-07-14 14:08:48Z hyunghwan.chung $
* $Id: Awk.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -227,7 +227,7 @@ void* Awk::Value::operator new (size_t n, Run* run) throw ()
return (char*)ptr+QSE_SIZEOF(run);
}
void* Awk::Value::operator new[] (size_t n, Run* run) throw ()
void* Awk::Value::operator new[] (size_t n, Run* run) throw ()
{
void* ptr = qse_awk_rtx_alloc (run->rtx, QSE_SIZEOF(run) + n);
if (ptr == QSE_NULL) return QSE_NULL;
@ -237,24 +237,24 @@ void* Awk::Value::operator new[] (size_t n, Run* run) throw ()
}
#if !defined(__BORLANDC__)
void Awk::Value::operator delete (void* ptr, Run* run) throw ()
void Awk::Value::operator delete (void* ptr, Run* run)
{
qse_awk_rtx_free (run->rtx, (char*)ptr-QSE_SIZEOF(run));
}
void Awk::Value::operator delete[] (void* ptr, Run* run) throw ()
void Awk::Value::operator delete[] (void* ptr, Run* run)
{
qse_awk_rtx_free (run->rtx, (char*)ptr-QSE_SIZEOF(run));
}
#endif
void Awk::Value::operator delete (void* ptr) throw ()
void Awk::Value::operator delete (void* ptr)
{
void* p = (char*)ptr-QSE_SIZEOF(Run*);
qse_awk_rtx_free ((*(Run**)p)->rtx, p);
}
void Awk::Value::operator delete[] (void* ptr) throw ()
void Awk::Value::operator delete[] (void* ptr)
{
void* p = (char*)ptr-QSE_SIZEOF(Run*);
qse_awk_rtx_free ((*(Run**)p)->rtx, p);
@ -602,7 +602,7 @@ int Awk::Value::setIndexedVal (Run* r, const Index& idx, val_t* v)
{
qse_awk_rtx_refdownval (r->rtx, v);
qse_awk_rtx_refdownval (r->rtx, map);
r->setError (ERR_NOMEM, 0, QSE_NULL, 0);
r->setError (ERR_NOMEM);
r->awk->retrieveError (r);
return -1;
}
@ -887,61 +887,40 @@ Awk::Run::operator Awk::rtx_t* () const
return this->rtx;
}
void Awk::Run::stop () const
void Awk::Run::stop () const
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_rtx_stop (this->rtx);
}
bool Awk::Run::isStop () const
bool Awk::Run::shouldStop () const
{
QSE_ASSERT (this->rtx != QSE_NULL);
return qse_awk_rtx_shouldstop (this->rtx)? true: false;
}
Awk::ErrorNumber Awk::Run::errorNumber () const throw ()
Awk::ErrorNumber Awk::Run::getErrorNumber () const
{
QSE_ASSERT (this->rtx != QSE_NULL);
return (ErrorNumber)qse_awk_rtx_geterrnum (this->rtx);
}
Awk::size_t Awk::Run::errorLine () const throw ()
Awk::size_t Awk::Run::getErrorLine () const
{
QSE_ASSERT (this->rtx != QSE_NULL);
return qse_awk_rtx_geterrlin (this->rtx);
}
const Awk::char_t* Awk::Run::errorMessage () const throw ()
const Awk::char_t* Awk::Run::getErrorMessage () const
{
QSE_ASSERT (this->rtx != QSE_NULL);
return qse_awk_rtx_geterrmsg (this->rtx);
}
void Awk::Run::setError (ErrorNumber code)
void Awk::Run::setError (ErrorNumber code, size_t line, const cstr_t* args)
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, 0, QSE_NULL);
}
void Awk::Run::setError (ErrorNumber code, size_t line)
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, QSE_NULL);
}
void Awk::Run::setError (ErrorNumber code, size_t line, const char_t* arg)
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_cstr_t x = { arg, qse_strlen(arg) };
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, &x);
}
void Awk::Run::setError (
ErrorNumber code, size_t line, const char_t* arg, size_t len)
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_cstr_t x = { arg, len };
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, &x);
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, args);
}
void Awk::Run::setErrorWithMessage (
@ -949,7 +928,7 @@ void Awk::Run::setErrorWithMessage (
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_errinf_t errinf;
errinf_t errinf;
errinf.num = (errnum_t)code;
errinf.lin = line;
@ -1013,77 +992,62 @@ int Awk::Run::getGlobal (int id, Value& g) const
// Awk
//////////////////////////////////////////////////////////////////
Awk::Awk () throw (): awk (QSE_NULL), functionMap (QSE_NULL),
Awk::Awk () : awk (QSE_NULL), functionMap (QSE_NULL),
sourceIn (this, Source::READ), sourceOut (this, Source::WRITE),
errnum (ERR_NOERR), errlin (0), runCallback (false),
runctx (this)
runCallback (false), runctx (this)
{
this->errmsg[0] = QSE_T('\0');
errinf.num = (errnum_t)ERR_NOERR;
errinf.lin = 0;
errinf.msg[0] = QSE_T('\0');
}
Awk::operator Awk::awk_t* () const
Awk::operator Awk::awk_t* () const
{
return this->awk;
}
const Awk::char_t* Awk::errorString (ErrorNumber num) const throw ()
const Awk::char_t* Awk::getErrorString (ErrorNumber num) const
{
QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (dflerrstr != QSE_NULL);
return dflerrstr (awk, (errnum_t)num);
}
const Awk::char_t* Awk::xerrstr (awk_t* a, errnum_t num) throw ()
const Awk::char_t* Awk::xerrstr (awk_t* a, errnum_t num)
{
Awk* awk = *(Awk**)QSE_XTN(a);
return awk->errorString ((ErrorNumber)num);
return awk->getErrorString ((ErrorNumber)num);
}
Awk::ErrorNumber Awk::errorNumber () const throw ()
Awk::ErrorNumber Awk::getErrorNumber () const
{
return this->errnum;
return (ErrorNumber)this->errinf.num;
}
Awk::size_t Awk::errorLine () const throw ()
Awk::size_t Awk::getErrorLine () const
{
return this->errlin;
return this->errinf.lin;
}
const Awk::char_t* Awk::errorMessage () const throw ()
const Awk::char_t* Awk::getErrorMessage () const
{
return this->errmsg;
return this->errinf.msg;
}
void Awk::setError (ErrorNumber code)
{
setError (code, 0, QSE_NULL, 0);
}
void Awk::setError (ErrorNumber code, size_t line)
{
setError (code, line, QSE_NULL, 0);
}
void Awk::setError (ErrorNumber code, size_t line, const char_t* arg)
{
setError (code, line, arg, qse_strlen(arg));
}
void Awk::setError (ErrorNumber code, size_t line, const char_t* arg, size_t len)
void Awk::setError (ErrorNumber code, size_t line, const cstr_t* args)
{
if (awk != QSE_NULL)
{
qse_cstr_t x = { arg, len };
qse_awk_seterror (awk, (errnum_t)code, line, &x);
qse_awk_seterror (awk, (errnum_t)code, line, args);
retrieveError ();
}
else
{
this->errnum = code;
this->errlin = line;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg),
errinf.num = (errnum_t)code;
errinf.lin = line;
qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg),
QSE_T("not ready to set an error message"));
}
}
@ -1092,28 +1056,24 @@ void Awk::setErrorWithMessage (ErrorNumber code, size_t line, const char_t* msg)
{
if (awk != QSE_NULL)
{
qse_awk_errinf_t errinf;
errinf.num = (errnum_t)code;
errinf.lin = line;
qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg);
qse_awk_seterrinf (awk, &errinf);
retrieveError ();
}
else
{
this->errnum = code;
this->errlin = line;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg);
errinf.num = (errnum_t)code;
errinf.lin = line;
qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg);
}
}
void Awk::clearError ()
{
this->errnum = ERR_NOERR;
this->errlin = 0;
this->errmsg[0] = QSE_T('\0');
errinf.num = (errnum_t)ERR_NOERR;
errinf.lin = 0;
errinf.msg[0] = QSE_T('\0');
}
void Awk::retrieveError ()
@ -1124,29 +1084,25 @@ void Awk::retrieveError ()
}
else
{
errnum_t num;
const char_t* msg;
qse_awk_geterror (this->awk, &num, &this->errlin, &msg);
this->errnum = (ErrorNumber)num;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg);
qse_awk_geterrinf (this->awk, &errinf);
}
}
void Awk::retrieveError (Run* run)
{
errnum_t num;
const char_t* msg;
QSE_ASSERT (run != QSE_NULL);
if (run->rtx == QSE_NULL) return;
qse_awk_rtx_geterror (run->rtx, &num, &this->errlin, &msg);
this->errnum = (ErrorNumber)num;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg);
qse_awk_rtx_geterrinf (run->rtx, &errinf);
}
int Awk::open ()
static void free_function_map_value (
Awk::map_t* map, void* dptr, Awk::size_t dlen)
{
Awk* awk = *(Awk**) QSE_XTN (map);
qse_awk_free ((Awk::awk_t*)*awk, dptr);
}
int Awk::open ()
{
QSE_ASSERT (awk == QSE_NULL && functionMap == QSE_NULL);
@ -1181,14 +1137,14 @@ int Awk::open ()
*(Awk**)QSE_XTN(functionMap) = this;
qse_map_setcopier (functionMap, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setfreeer (functionMap, QSE_MAP_VAL, freeFunctionMapValue);
qse_map_setfreeer (functionMap, QSE_MAP_VAL, free_function_map_value);
qse_map_setscale (functionMap, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
runCallback = false;
return 0;
}
void Awk::close ()
void Awk::close ()
{
fini_runctx ();
clearArguments ();
@ -1209,31 +1165,7 @@ void Awk::close ()
runCallback = false;
}
void Awk::setOption (int opt)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setoption (awk, opt);
}
int Awk::getOption () const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getoption (awk);
}
void Awk::setMaxDepth (int ids, size_t depth)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setmaxdepth (awk, ids, depth);
}
Awk::size_t Awk::getMaxDepth (int id) const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getmaxdepth (awk, id);
}
Awk::Run* Awk::parse (Source& in, Source& out)
Awk::Run* Awk::parse (Source& in, Source& out)
{
QSE_ASSERT (awk != QSE_NULL);
@ -1263,53 +1195,7 @@ Awk::Run* Awk::parse (Source& in, Source& out)
return &runctx;
}
int Awk::init_runctx ()
{
if (runctx.rtx != QSE_NULL) return 0;
qse_awk_rio_t rio;
qse_awk_rcb_t rcb;
rio.pipe = pipeHandler;
rio.file = fileHandler;
rio.console = consoleHandler;
if (runCallback)
{
QSE_MEMSET (&rcb, 0, QSE_SIZEOF(rcb));
rcb.on_loop_enter = onLoopEnter;
rcb.on_loop_exit = onLoopExit;
rcb.on_statement = onStatement;
rcb.udd = &runctx;
}
rtx_t* rtx = qse_awk_rtx_open (
awk, QSE_SIZEOF(rxtn_t), &rio, (qse_cstr_t*)runarg.ptr);
if (rtx == QSE_NULL)
{
retrieveError();
return -1;
}
runctx.rtx = rtx;
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
rxtn->run = &runctx;
if (runCallback) qse_awk_rtx_setrcb (rtx, &rcb);
return 0;
}
void Awk::fini_runctx ()
{
if (runctx.rtx != QSE_NULL)
{
qse_awk_rtx_close (runctx.rtx);
runctx.rtx = QSE_NULL;
}
}
int Awk::loop ()
int Awk::loop ()
{
QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1319,7 +1205,9 @@ int Awk::loop ()
return n;
}
int Awk::call (const char_t* name, Value* ret, const Value* args, size_t nargs)
int Awk::call (
const char_t* name, Value* ret,
const Value* args, size_t nargs)
{
QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1361,20 +1249,90 @@ int Awk::call (const char_t* name, Value* ret, const Value* args, size_t nargs)
return 0;
}
void Awk::stop ()
void Awk::stop ()
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_stopall (awk);
}
int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
int Awk::init_runctx ()
{
if (runctx.rtx != QSE_NULL) return 0;
qse_awk_rio_t rio;
qse_awk_rcb_t rcb;
rio.pipe = pipeHandler;
rio.file = fileHandler;
rio.console = consoleHandler;
if (runCallback)
{
QSE_MEMSET (&rcb, 0, QSE_SIZEOF(rcb));
rcb.on_loop_enter = onLoopEnter;
rcb.on_loop_exit = onLoopExit;
rcb.on_statement = onStatement;
rcb.udd = &runctx;
}
rtx_t* rtx = qse_awk_rtx_open (
awk, QSE_SIZEOF(rxtn_t), &rio, (qse_cstr_t*)runarg.ptr);
if (rtx == QSE_NULL)
{
retrieveError();
return -1;
}
runctx.rtx = rtx;
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
rxtn->run = &runctx;
if (runCallback) qse_awk_rtx_setrcb (rtx, &rcb);
return 0;
}
void Awk::fini_runctx ()
{
if (runctx.rtx != QSE_NULL)
{
qse_awk_rtx_close (runctx.rtx);
runctx.rtx = QSE_NULL;
}
}
int Awk::getOption () const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getoption (awk);
}
void Awk::setOption (int opt)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setoption (awk, opt);
}
void Awk::setMaxDepth (int ids, size_t depth)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setmaxdepth (awk, ids, depth);
}
Awk::size_t Awk::getMaxDepth (int id) const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getmaxdepth (awk, id);
}
int Awk::dispatch_function (Run* run, const cstr_t* name)
{
pair_t* pair;
pair = qse_map_search (functionMap, name, len);
pair = qse_map_search (functionMap, name->ptr, name->len);
if (pair == QSE_NULL)
{
run->setError (ERR_FUNNF, 0, name, len);
run->setError (ERR_FUNNF, 0, name);
return -1;
}
@ -1391,7 +1349,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
args = new(run) Value[nargs];
if (args == QSE_NULL)
{
run->setError (ERR_NOMEM, 0, QSE_NULL, 0);
run->setError (ERR_NOMEM);
return -1;
}
}
@ -1401,7 +1359,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
val_t* v = qse_awk_rtx_getarg (run->rtx, i);
if (args[i].setVal (run, v) == -1)
{
run->setError (ERR_NOMEM, 0, QSE_NULL, 0);
run->setError (ERR_NOMEM);
if (args != buf) delete[] args;
return -1;
}
@ -1409,7 +1367,10 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
Value ret (run);
int n = (this->*handler) (*run, ret, args, nargs, name, len);
int n;
try { n = (this->*handler) (*run, ret, args, nargs, name); }
catch (...) { n = -1; }
if (args != buf) delete[] args;
@ -1424,7 +1385,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
return 0;
}
int Awk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len)
int Awk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len)
{
if (this->len >= this->capa)
{
@ -1451,7 +1412,7 @@ int Awk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len)
return 0;
}
void Awk::xstrs_t::clear (awk_t* awk)
void Awk::xstrs_t::clear (awk_t* awk)
{
if (this->ptr != QSE_NULL)
{
@ -1464,7 +1425,7 @@ void Awk::xstrs_t::clear (awk_t* awk)
}
}
int Awk::addArgument (const char_t* arg, size_t len)
int Awk::addArgument (const char_t* arg, size_t len)
{
QSE_ASSERT (awk != QSE_NULL);
int n = runarg.add (awk, arg, len);
@ -1472,17 +1433,17 @@ int Awk::addArgument (const char_t* arg, size_t len)
return n;
}
int Awk::addArgument (const char_t* arg)
int Awk::addArgument (const char_t* arg)
{
return addArgument (arg, qse_strlen(arg));
}
void Awk::clearArguments ()
void Awk::clearArguments ()
{
runarg.clear (awk);
}
int Awk::addGlobal (const char_t* name)
int Awk::addGlobal (const char_t* name)
{
QSE_ASSERT (awk != QSE_NULL);
@ -1491,7 +1452,7 @@ int Awk::addGlobal (const char_t* name)
return n;
}
int Awk::deleteGlobal (const char_t* name)
int Awk::deleteGlobal (const char_t* name)
{
QSE_ASSERT (awk != QSE_NULL);
int n = qse_awk_delgbl (awk, name, qse_strlen(name));
@ -1499,7 +1460,7 @@ int Awk::deleteGlobal (const char_t* name)
return n;
}
int Awk::setGlobal (int id, const Value& v)
int Awk::setGlobal (int id, const Value& v)
{
QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1515,7 +1476,7 @@ int Awk::setGlobal (int id, const Value& v)
return n;
}
int Awk::getGlobal (int id, Value& v)
int Awk::getGlobal (int id, Value& v)
{
QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1527,7 +1488,7 @@ int Awk::getGlobal (int id, Value& v)
int Awk::addFunction (
const char_t* name, size_t minArgs, size_t maxArgs,
FunctionHandler handler)
FunctionHandler handler)
{
QSE_ASSERT (awk != QSE_NULL);
@ -1568,7 +1529,7 @@ int Awk::addFunction (
return 0;
}
int Awk::deleteFunction (const char_t* name)
int Awk::deleteFunction (const char_t* name)
{
QSE_ASSERT (awk != QSE_NULL);
@ -1581,49 +1542,49 @@ int Awk::deleteFunction (const char_t* name)
return n;
}
void Awk::enableRunCallback ()
void Awk::enableRunCallback ()
{
runCallback = true;
}
void Awk::disableRunCallback ()
void Awk::disableRunCallback ()
{
runCallback = false;
}
int Awk::getWord (
const char_t* ow, qse_size_t owl,
const char_t** nw, qse_size_t* nwl) throw ()
const char_t** nw, qse_size_t* nwl)
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getword (awk, ow, owl, nw, nwl);
}
int Awk::setWord (const char_t* ow, const char_t* nw) throw ()
int Awk::setWord (const char_t* ow, const char_t* nw)
{
return setWord (ow, qse_strlen(ow), nw, qse_strlen(nw));
}
int Awk::setWord (
const char_t* ow, qse_size_t owl,
const char_t* nw, qse_size_t nwl) throw ()
const char_t* nw, qse_size_t nwl)
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_setword (awk, ow, owl, nw, nwl);
}
int Awk::unsetWord (const char_t* ow) throw ()
int Awk::unsetWord (const char_t* ow)
{
return unsetWord (ow, qse_strlen(ow));
}
int Awk::unsetWord (const char_t* ow, qse_size_t owl) throw ()
int Awk::unsetWord (const char_t* ow, qse_size_t owl)
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_setword (awk, ow, owl, QSE_NULL, 0);
}
int Awk::unsetAllWords () throw ()
int Awk::unsetAllWords ()
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_setword (awk, QSE_NULL, 0, QSE_NULL, 0);
@ -1690,26 +1651,31 @@ Awk::ssize_t Awk::pipeHandler (
Pipe pipe (rxtn->run, riod);
switch (cmd)
{
case QSE_AWK_RIO_OPEN:
return awk->openPipe (pipe);
case QSE_AWK_RIO_CLOSE:
return awk->closePipe (pipe);
try
{
switch (cmd)
{
case QSE_AWK_RIO_OPEN:
return awk->openPipe (pipe);
case QSE_AWK_RIO_CLOSE:
return awk->closePipe (pipe);
case QSE_AWK_RIO_READ:
return awk->readPipe (pipe, data, count);
case QSE_AWK_RIO_WRITE:
return awk->writePipe (pipe, data, count);
case QSE_AWK_RIO_READ:
return awk->readPipe (pipe, data, count);
case QSE_AWK_RIO_WRITE:
return awk->writePipe (pipe, data, count);
case QSE_AWK_RIO_FLUSH:
return awk->flushPipe (pipe);
case QSE_AWK_RIO_FLUSH:
return awk->flushPipe (pipe);
case QSE_AWK_RIO_NEXT:
return -1;
default:
return -1;
}
}
catch (...)
{
return -1;
}
return -1;
}
Awk::ssize_t Awk::fileHandler (
@ -1723,26 +1689,31 @@ Awk::ssize_t Awk::fileHandler (
File file (rxtn->run, riod);
switch (cmd)
try
{
case QSE_AWK_RIO_OPEN:
return awk->openFile (file);
case QSE_AWK_RIO_CLOSE:
return awk->closeFile (file);
switch (cmd)
{
case QSE_AWK_RIO_OPEN:
return awk->openFile (file);
case QSE_AWK_RIO_CLOSE:
return awk->closeFile (file);
case QSE_AWK_RIO_READ:
return awk->readFile (file, data, count);
case QSE_AWK_RIO_WRITE:
return awk->writeFile (file, data, count);
case QSE_AWK_RIO_READ:
return awk->readFile (file, data, count);
case QSE_AWK_RIO_WRITE:
return awk->writeFile (file, data, count);
case QSE_AWK_RIO_FLUSH:
return awk->flushFile (file);
case QSE_AWK_RIO_FLUSH:
return awk->flushFile (file);
case QSE_AWK_RIO_NEXT:
return -1;
default:
return -1;
}
}
catch (...)
{
return -1;
}
return -1;
}
Awk::ssize_t Awk::consoleHandler (
@ -1756,39 +1727,41 @@ Awk::ssize_t Awk::consoleHandler (
Console console (rxtn->run, riod);
switch (cmd)
try
{
case QSE_AWK_RIO_OPEN:
return awk->openConsole (console);
case QSE_AWK_RIO_CLOSE:
return awk->closeConsole (console);
switch (cmd)
{
case QSE_AWK_RIO_OPEN:
return awk->openConsole (console);
case QSE_AWK_RIO_CLOSE:
return awk->closeConsole (console);
case QSE_AWK_RIO_READ:
return awk->readConsole (console, data, count);
case QSE_AWK_RIO_WRITE:
return awk->writeConsole (console, data, count);
case QSE_AWK_RIO_READ:
return awk->readConsole (console, data, count);
case QSE_AWK_RIO_WRITE:
return awk->writeConsole (console, data, count);
case QSE_AWK_RIO_FLUSH:
return awk->flushConsole (console);
case QSE_AWK_RIO_NEXT:
return awk->nextConsole (console);
case QSE_AWK_RIO_FLUSH:
return awk->flushConsole (console);
case QSE_AWK_RIO_NEXT:
return awk->nextConsole (console);
default:
return -1;
}
}
catch (...)
{
return -1;
}
return -1;
}
int Awk::functionHandler (rtx_t* rtx, const char_t* name, size_t len)
int Awk::functionHandler (rtx_t* rtx, const cstr_t* name)
{
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
return rxtn->run->awk->dispatchFunction (rxtn->run, name, len);
return rxtn->run->awk->dispatch_function (rxtn->run, name);
}
void Awk::freeFunctionMapValue (map_t* map, void* dptr, size_t dlen)
{
Awk* awk = *(Awk**) QSE_XTN (map);
qse_awk_free (awk->awk, dptr);
}
int Awk::onLoopEnter (rtx_t* rtx, void* data)
{
Run* run = (Run*)data;

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.cpp 234 2009-07-14 14:08:48Z hyunghwan.chung $
* $Id: StdAwk.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -48,7 +48,7 @@ QSE_BEGIN_NAMESPACE(QSE)
} \
} while (0)
int StdAwk::open ()
int StdAwk::open ()
{
int n = Awk::open ();
if (n == -1) return n;
@ -75,7 +75,7 @@ int StdAwk::open ()
return 0;
}
void StdAwk::close ()
void StdAwk::close ()
{
clearConsoleOutputs ();
Awk::close ();
@ -391,7 +391,7 @@ int StdAwk::flushFile (File& io)
return qse_fio_flush ((qse_fio_t*)io.getHandle());
}
int StdAwk::addConsoleOutput (const char_t* arg, size_t len)
int StdAwk::addConsoleOutput (const char_t* arg, size_t len)
{
QSE_ASSERT (awk != QSE_NULL);
int n = ofile.add (awk, arg, len);
@ -399,12 +399,12 @@ int StdAwk::addConsoleOutput (const char_t* arg, size_t len)
return n;
}
int StdAwk::addConsoleOutput (const char_t* arg)
int StdAwk::addConsoleOutput (const char_t* arg)
{
return addConsoleOutput (arg, qse_strlen(arg));
}
void StdAwk::clearConsoleOutputs ()
void StdAwk::clearConsoleOutputs ()
{
ofile.clear (awk);
}
@ -462,7 +462,14 @@ int StdAwk::open_console_in (Console& io)
return 0;
}
// TODO: need to check for '\0' contained???
if (qse_strlen(file) != runarg.ptr[runarg_index].len)
{
cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_IONMNL, 0, &arg);
return -1;
}
/* handle special case when ARGV[x] has been altered.
* so from here down, the file name gotten from
@ -506,7 +513,10 @@ int StdAwk::open_console_in (Console& io)
if (qse_strlen(out.u.cpldup.ptr) < out.u.cpldup.len)
{
/* the name contains one or more '\0' */
((Run*)io)->setError (ERR_IONMNL, 0, out.u.cpldup.ptr);
cstr_t arg;
arg.ptr = out.u.cpldup.ptr;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_IONMNL, 0, &arg);
qse_awk_rtx_free (rtx, out.u.cpldup.ptr);
return -1;
}
@ -524,7 +534,10 @@ int StdAwk::open_console_in (Console& io)
rtx->awk->mmgr, 0, file, QSE_SIO_READ);
if (sio == QSE_NULL)
{
((Run*)io)->setError (ERR_OPEN, 0, file);
cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_OPEN, 0, &arg);
qse_awk_rtx_free (rtx, out.u.cpldup.ptr);
return -1;
}
@ -581,7 +594,14 @@ int StdAwk::open_console_out (Console& io)
return 0;
}
// TODO: need to check for '\0' contained???
if (qse_strlen(file) != ofile.ptr[ofile_index].len)
{
cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_IONMNL, 0, &arg);
return -1;
}
if (file[0] == QSE_T('-') && file[1] == QSE_T('\0'))
{
@ -594,7 +614,10 @@ int StdAwk::open_console_out (Console& io)
rtx->awk->mmgr, 0, file, QSE_SIO_READ);
if (sio == QSE_NULL)
{
((Run*)io)->setError (ERR_OPEN, 0, file);
cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_OPEN, 0, &arg);
return -1;
}
}
@ -725,17 +748,17 @@ int StdAwk::nextConsole (Console& io)
}
// memory allocation primitives
void* StdAwk::allocMem (size_t n) throw ()
void* StdAwk::allocMem (size_t n)
{
return ::malloc (n);
}
void* StdAwk::reallocMem (void* ptr, size_t n) throw ()
void* StdAwk::reallocMem (void* ptr, size_t n)
{
return ::realloc (ptr, n);
}
void StdAwk::freeMem (void* ptr) throw ()
void StdAwk::freeMem (void* ptr)
{
::free (ptr);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c 232 2009-07-14 08:06:14Z hyunghwan.chung $
* $Id: err.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -134,8 +134,7 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum)
QSE_T("'next' called from END block"),
QSE_T("'nextfile' called from BEGIN block"),
QSE_T("'nextfile' called from END block"),
QSE_T("wrong implementation of intrinsic function handler"),
QSE_T("intrinsic function handler returned an error"),
QSE_T("intrinsic function handler for '${0}' failed"),
QSE_T("wrong implementation of user-defined io handler"),
QSE_T("I/O handler returned an error"),
QSE_T("no such I/O name found"),

View File

@ -1,5 +1,5 @@
/*
* $Id: fnc.c 213 2009-06-26 13:05:19Z hyunghwan.chung $
* $Id: fnc.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -18,18 +18,18 @@
#include "awk.h"
static int fnc_close (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_fflush (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_index (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_length (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_substr (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_split (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_tolower (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_toupper (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_gsub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_sub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_match (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_sprintf (qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
static int fnc_close (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_fflush (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_index (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_length (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_substr (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_split (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_tolower (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_toupper (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_gsub (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_sub (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_match (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_sprintf (qse_awk_rtx_t*, const qse_cstr_t*);
#undef MAX
#define MAX QSE_TYPE_UNSIGNED_MAX(qse_size_t)
@ -227,8 +227,7 @@ qse_awk_fnc_t* qse_awk_getfnc (
return fnc;
}
static int fnc_close (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_close (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* v, * a0;
@ -334,8 +333,7 @@ static int flush_io (
return n;
}
static int fnc_fflush (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_fflush (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0;
@ -413,8 +411,7 @@ static int fnc_fflush (
return 0;
}
static int fnc_index (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_index (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0, * a1;
@ -472,8 +469,7 @@ static int fnc_index (
return 0;
}
static int fnc_length (
qse_awk_rtx_t* rtx, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_length (qse_awk_rtx_t* rtx, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* v;
@ -514,8 +510,7 @@ static int fnc_length (
return 0;
}
static int fnc_substr (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_substr (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0, * a1, * a2, * r;
@ -587,8 +582,7 @@ static int fnc_substr (
return 0;
}
static int fnc_split (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0, * a1, * a2, * t1, * t2, ** a1_ref;
@ -839,8 +833,7 @@ static int fnc_split (
return 0;
}
static int fnc_tolower (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_tolower (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_char_t* str;
@ -878,8 +871,7 @@ static int fnc_tolower (
return 0;
}
static int fnc_toupper (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_toupper (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_char_t* str;
@ -1243,20 +1235,17 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
return 0;
}
static int fnc_gsub (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_gsub (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return __substitute (run, 0);
}
static int fnc_sub (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_sub (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return __substitute (run, 1);
}
static int fnc_match (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_match (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0, * a1;
@ -1372,8 +1361,7 @@ static int fnc_match (
return 0;
}
static int fnc_sprintf (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_sprintf (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0;

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 232 2009-07-14 08:06:14Z hyunghwan.chung $
* $Id: run.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -5701,8 +5701,8 @@ static qse_awk_val_t* __eval_call (
* qse_awk_setword has been used */
n = call->what.fnc.handler (
run,
call->what.fnc.oname.ptr,
call->what.fnc.oname.len);
xstr_to_cstr(&call->what.fnc.oname)
);
if (n <= -1)
{
@ -5712,7 +5712,9 @@ static qse_awk_val_t* __eval_call (
* fix it */
qse_awk_rtx_seterror (
run, QSE_AWK_EFNCIMPL,
nde->line, QSE_NULL);
nde->line,
xstr_to_cstr(&call->what.fnc.oname)
);
}
else
{

View File

@ -1,5 +1,5 @@
/*
* $Id: std.c 224 2009-07-07 13:05:10Z hyunghwan.chung $
* $Id: std.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -1014,7 +1014,7 @@ enum
};
static int fnc_math_1 (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl,
qse_awk_rtx_t* run, const qse_cstr_t* fnm,
int type, void* f)
{
qse_size_t nargs;
@ -1063,7 +1063,7 @@ static int fnc_math_1 (
}
static int fnc_math_2 (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl, int type, void* f)
qse_awk_rtx_t* run, const qse_cstr_t* fnm, int type, void* f)
{
qse_size_t nargs;
qse_awk_val_t* a0, * a1;
@ -1115,10 +1115,10 @@ static int fnc_math_2 (
return 0;
}
static int fnc_sin (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_sin (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_1 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_SINL)
FNC_MATH_LD, (void*)sinl
#elif defined(HAVE_SIN)
@ -1131,10 +1131,10 @@ static int fnc_sin (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_cos (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_cos (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_1 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_COSL)
FNC_MATH_LD, (void*)cosl
#elif defined(HAVE_COS)
@ -1147,10 +1147,10 @@ static int fnc_cos (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_tan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_tan (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_1 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_TANL)
FNC_MATH_LD, (void*)tanl
#elif defined(HAVE_TAN)
@ -1163,10 +1163,10 @@ static int fnc_tan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_atan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_atan (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_1 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_ATANL)
FNC_MATH_LD, (void*)atanl
#elif defined(HAVE_ATAN)
@ -1179,10 +1179,10 @@ static int fnc_atan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_atan2 (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_atan2 (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_2 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_ATAN2L)
FNC_MATH_LD, (void*)atan2l
#elif defined(HAVE_ATAN2)
@ -1195,10 +1195,10 @@ static int fnc_atan2 (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_log (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_log (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_1 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_LOGL)
FNC_MATH_LD, (void*)logl
#elif defined(HAVE_LOG)
@ -1211,10 +1211,10 @@ static int fnc_log (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_exp (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_exp (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_1 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_EXPL)
FNC_MATH_LD, (void*)expl
#elif defined(HAVE_EXP)
@ -1227,10 +1227,10 @@ static int fnc_exp (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_sqrt (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_sqrt (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
return fnc_math_1 (
run, fnm, fnl,
run, fnm,
#if defined(HAVE_SQRTL)
FNC_MATH_LD, (void*)sqrtl
#elif defined(HAVE_SQRT)
@ -1243,7 +1243,7 @@ static int fnc_sqrt (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
);
}
static int fnc_int (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_int (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0;
@ -1272,7 +1272,7 @@ static int fnc_int (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return 0;
}
static int fnc_rand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_rand (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_awk_val_t* r;
@ -1294,7 +1294,7 @@ static int fnc_rand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return 0;
}
static int fnc_srand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_srand (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* a0;
@ -1342,7 +1342,7 @@ static int fnc_srand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return 0;
}
static int fnc_system (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
static int fnc_system (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{
qse_size_t nargs;
qse_awk_val_t* v;

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.h 75 2009-02-22 14:10:34Z hyunghwan.chung $
* $Id: tree.h 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -286,8 +286,7 @@ struct qse_awk_nde_call_t
const qse_char_t* spec;
} arg;
int (*handler) (
qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
qse_awk_fnc_fun_t handler;
} fnc;
} what;
qse_awk_nde_t* args;

View File

@ -1,5 +1,5 @@
/*
* $Id: Sed.cpp 191 2009-06-07 13:09:14Z hyunghwan.chung $
* $Id: Sed.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -23,7 +23,7 @@
QSE_BEGIN_NAMESPACE(QSE)
/////////////////////////////////
int Sed::open () throw ()
int Sed::open ()
{
sed = qse_sed_open (this, QSE_SIZEOF(Sed*));
if (sed == QSE_NULL) return -1;
@ -35,7 +35,7 @@ int Sed::open () throw ()
return 0;
}
void Sed::close () throw()
void Sed::close ()
{
if (sed != QSE_NULL)
{
@ -44,59 +44,59 @@ void Sed::close () throw()
}
}
int Sed::compile (const char_t* sptr) throw ()
int Sed::compile (const char_t* sptr)
{
QSE_ASSERT (sed != QSE_NULL);
return qse_sed_comp (sed, sptr, qse_strlen(sptr));
}
int Sed::compile (const char_t* sptr, size_t slen) throw ()
int Sed::compile (const char_t* sptr, size_t slen)
{
QSE_ASSERT (sed != QSE_NULL);
return qse_sed_comp (sed, sptr, slen);
}
int Sed::execute () throw ()
int Sed::execute ()
{
QSE_ASSERT (sed != QSE_NULL);
return qse_sed_exec (sed, xin, xout);
}
int Sed::getOption() const throw ()
int Sed::getOption() const
{
QSE_ASSERT (sed != QSE_NULL);
return qse_sed_getoption (sed);
}
void Sed::setOption (int opt) throw ()
void Sed::setOption (int opt)
{
QSE_ASSERT (sed != QSE_NULL);
qse_sed_setoption (sed, opt);
}
Sed::size_t Sed::getMaxDepth (depth_t id) const throw ()
Sed::size_t Sed::getMaxDepth (depth_t id) const
{
QSE_ASSERT (sed != QSE_NULL);
return qse_sed_getmaxdepth (sed, id);
}
void Sed::setMaxDepth (int ids, size_t depth) throw ()
void Sed::setMaxDepth (int ids, size_t depth)
{
QSE_ASSERT (sed != QSE_NULL);
qse_sed_setmaxdepth (sed, ids, depth);
}
const Sed::char_t* Sed::getErrorMessage () const throw ()
const Sed::char_t* Sed::getErrorMessage () const
{
return (sed == QSE_NULL)? QSE_T(""): qse_sed_geterrmsg (sed);
}
Sed::size_t Sed::getErrorLine () const throw ()
Sed::size_t Sed::getErrorLine () const
{
return (sed == QSE_NULL)? 0: qse_sed_geterrlin (sed);
}
Sed::errnum_t Sed::getErrorNumber () const throw ()
Sed::errnum_t Sed::getErrorNumber () const
{
return (sed == QSE_NULL)? QSE_SED_ENOERR: qse_sed_geterrnum (sed);
}
@ -107,19 +107,19 @@ void Sed::setError (errnum_t err, size_t lin, const cstr_t* args)
qse_sed_seterror (sed, err, lin, args);
}
Sed::size_t Sed::getConsoleLine () throw ()
Sed::size_t Sed::getConsoleLine ()
{
QSE_ASSERT (sed != QSE_NULL);
return qse_sed_getlinnum (sed);
}
void Sed::setConsoleLine (size_t num) throw ()
void Sed::setConsoleLine (size_t num)
{
QSE_ASSERT (sed != QSE_NULL);
qse_sed_setlinnum (sed, num);
}
Sed::ssize_t Sed::xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ()
Sed::ssize_t Sed::xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg)
{
Sed* sed = *(Sed**)QSE_XTN(s);
@ -173,7 +173,7 @@ Sed::ssize_t Sed::xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ()
}
}
Sed::ssize_t Sed::xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ()
Sed::ssize_t Sed::xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg)
{
Sed* sed = *(Sed**)QSE_XTN(s);
@ -233,7 +233,7 @@ const Sed::char_t* Sed::getErrorString (errnum_t num) const
return dflerrstr (sed, num);
}
const Sed::char_t* Sed::xerrstr (sed_t* s, errnum_t num) throw ()
const Sed::char_t* Sed::xerrstr (sed_t* s, errnum_t num)
{
Sed* sed = *(Sed**)QSE_XTN(s);
try

View File

@ -1,5 +1,5 @@
/*
* $Id: StdSed.cpp 191 2009-06-07 13:09:14Z hyunghwan.chung $
* $Id: StdSed.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -25,17 +25,17 @@
QSE_BEGIN_NAMESPACE(QSE)
/////////////////////////////////
void* StdSed::allocMem (qse_size_t n) throw ()
void* StdSed::allocMem (qse_size_t n)
{
return ::malloc (n);
}
void* StdSed::reallocMem (void* ptr, qse_size_t n) throw ()
void* StdSed::reallocMem (void* ptr, qse_size_t n)
{
return ::realloc (ptr, n);
}
void StdSed::freeMem (void* ptr) throw ()
void StdSed::freeMem (void* ptr)
{
::free (ptr);
}