touched up code

This commit is contained in:
hyung-hwan 2009-08-21 05:28:03 +00:00
parent b6ca96214a
commit f565bd46cc
9 changed files with 864 additions and 884 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp 258 2009-08-19 14:04:15Z hyunghwan.chung $ * $Id: Awk.hpp 259 2009-08-20 11:28:03Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -164,9 +164,10 @@ public:
ERR_POSVALASSMAP = QSE_AWK_EPOSVALASSMAP, ERR_POSVALASSMAP = QSE_AWK_EPOSVALASSMAP,
ERR_MAPTOSCALAR = QSE_AWK_EMAPTOSCALAR, ERR_MAPTOSCALAR = QSE_AWK_EMAPTOSCALAR,
ERR_SCALARTOMAP = QSE_AWK_ESCALARTOMAP, ERR_SCALARTOMAP = QSE_AWK_ESCALARTOMAP,
ERR_MAPNOTALLOWED = QSE_AWK_EMAPNOTALLOWED, ERR_MAPNA = QSE_AWK_EMAPNA,
ERR_VALTYPE = QSE_AWK_EVALTYPE, ERR_VALTYPE = QSE_AWK_EVALTYPE,
ERR_RDELETE = QSE_AWK_ERDELETE, ERR_RDELETE = QSE_AWK_ERDELETE,
ERR_RRESET = QSE_AWK_ERRESET,
ERR_RNEXTBEG = QSE_AWK_ERNEXTBEG, ERR_RNEXTBEG = QSE_AWK_ERNEXTBEG,
ERR_RNEXTEND = QSE_AWK_ERNEXTEND, ERR_RNEXTEND = QSE_AWK_ERNEXTEND,
ERR_RNEXTFBEG = QSE_AWK_ERNEXTFBEG, ERR_RNEXTFBEG = QSE_AWK_ERNEXTFBEG,

View File

@ -1,4 +1,3 @@
pkginclude_HEADERS = awk.h std.h pkginclude_HEADERS = awk.h std.h
if ENABLE_CXX if ENABLE_CXX

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdAwk.hpp 258 2009-08-19 14:04:15Z hyunghwan.chung $ * $Id: StdAwk.hpp 259 2009-08-20 11:28:03Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -40,14 +40,14 @@ QSE_BEGIN_NAMESPACE(QSE)
/** /**
* Provides a more useful interpreter by overriding primitive methods, * Provides a more useful interpreter by overriding primitive methods,
* the file handler, the pipe handler and implementing common intrinsic * and implementing the file handler, the pipe handler, and common intrinsic
* functions. * functions.
*/ */
class StdAwk: public Awk class StdAwk: public Awk
{ {
public: public:
/** /**
* Implements script input from a file and deparsing into a file. * Implements script I/O from and to a file.
*/ */
class SourceFile: public Source class SourceFile: public Source
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h 258 2009-08-19 14:04:15Z hyunghwan.chung $ * $Id: awk.h 259 2009-08-20 11:28:03Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -723,7 +723,7 @@ enum qse_awk_errnum_t
QSE_AWK_EPOSVALASSMAP, /**< a positional cannot be assigned a map */ QSE_AWK_EPOSVALASSMAP, /**< a positional cannot be assigned a map */
QSE_AWK_EMAPTOSCALAR, /**< map '${0}' not assignable with a scalar */ QSE_AWK_EMAPTOSCALAR, /**< map '${0}' not assignable with a scalar */
QSE_AWK_ESCALARTOMAP, /**< cannot change a scalar value to a map */ QSE_AWK_ESCALARTOMAP, /**< cannot change a scalar value to a map */
QSE_AWK_EMAPNOTALLOWED,/**< map not allowed */ QSE_AWK_EMAPNA, /**< map not allowed */
QSE_AWK_EVALTYPE, /**< invalid value type */ QSE_AWK_EVALTYPE, /**< invalid value type */
QSE_AWK_ERDELETE, /**< 'delete' called with wrong target */ QSE_AWK_ERDELETE, /**< 'delete' called with wrong target */
QSE_AWK_ERRESET, /**< 'reset' called with wrong target */ QSE_AWK_ERRESET, /**< 'reset' called with wrong target */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp 257 2009-08-17 12:10:30Z hyunghwan.chung $ * $Id: Awk.cpp 259 2009-08-20 11:28:03Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -358,9 +358,9 @@ Awk::Value::operator Awk::real_t () const
Awk::Value::operator const Awk::char_t* () const Awk::Value::operator const Awk::char_t* () const
{ {
const char_t* ptr; const Awk::char_t* ptr;
size_t len; size_t len;
if (getStr (&ptr, &len) <= -1) ptr = QSE_T(""); if (Awk::Value::getStr (&ptr, &len) <= -1) ptr = QSE_T("");
return ptr; return ptr;
} }
@ -1783,5 +1783,4 @@ int Awk::sprintf (awk_t* awk, char_t* buf, size_t size,
///////////////////////////////// /////////////////////////////////
QSE_END_NAMESPACE(QSE) QSE_END_NAMESPACE(QSE)
///////////////////////////////// /////////////////////////////////

View File

@ -1,5 +1,5 @@
/* /*
* $Id: fnc.c 256 2009-08-16 13:44:20Z hyunghwan.chung $ * $Id: fnc.c 259 2009-08-20 11:28:03Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -993,7 +993,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
{ {
FREE_A_PTRS (run->awk); FREE_A_PTRS (run->awk);
/* a map is not allowed as the third parameter */ /* a map is not allowed as the third parameter */
qse_awk_rtx_seterrnum (run, QSE_AWK_EMAPNOTALLOWED, QSE_NULL); qse_awk_rtx_seterrnum (run, QSE_AWK_EMAPNA, QSE_NULL);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c 258 2009-08-19 14:04:15Z hyunghwan.chung $ * $Id: parse.c 259 2009-08-20 11:28:03Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -382,20 +382,20 @@ static global_t gtab[] =
#define SETERR_CODE(awk,code) \ #define SETERR_CODE(awk,code) \
qse_awk_seterror (awk, code, QSE_NULL, 0) qse_awk_seterror (awk, code, QSE_NULL, 0)
#define SETERR_LIN(awk,code,line) \ #define SETERR_LOC(awk,code,line) \
qse_awk_seterror (awk, code, QSE_NULL, line) qse_awk_seterror (awk, code, QSE_NULL, line)
#define SETERR_ARG(awk,code,arg,leng) \ #define SETERR_ARG(awk,code,ep,el) \
do { \ do { \
qse_cstr_t __ea; \ qse_cstr_t __ea; \
__ea.len = (leng); __ea.ptr = (arg); \ __ea.len = (el); __ea.ptr = (ep); \
qse_awk_seterror ((awk), (code), &__ea, 0); \ qse_awk_seterror ((awk), (code), &__ea, 0); \
} while (0) } while (0)
#define SETERR_ARG_LOC(awk,code,arg,leng,line) \ #define SETERR_ARG_LOC(awk,code,ep,el,line) \
do { \ do { \
qse_cstr_t __ea; \ qse_cstr_t __ea; \
__ea.len = (leng); __ea.ptr = (arg); \ __ea.len = (el); __ea.ptr = (ep); \
qse_awk_seterror ((awk), (code), &__ea, (line)); \ qse_awk_seterror ((awk), (code), &__ea, (line)); \
} while (0) } while (0)
@ -674,7 +674,7 @@ static int begin_include (qse_awk_t* awk)
); );
if (pair == QSE_NULL) if (pair == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_ENOMEM, awk->ptoken.lin);
goto oops; goto oops;
} }
@ -684,7 +684,7 @@ static int begin_include (qse_awk_t* awk)
arg = (qse_awk_sio_arg_t*) QSE_MMGR_ALLOC (awk->mmgr, QSE_SIZEOF(*arg)); arg = (qse_awk_sio_arg_t*) QSE_MMGR_ALLOC (awk->mmgr, QSE_SIZEOF(*arg));
if (arg == QSE_NULL) if (arg == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_ENOMEM, awk->ptoken.lin);
goto oops; goto oops;
} }
@ -807,7 +807,7 @@ retry:
if (awk->parse.depth.max.incl > 0 && if (awk->parse.depth.max.incl > 0 &&
awk->parse.depth.cur.incl >= awk->parse.depth.max.incl) awk->parse.depth.cur.incl >= awk->parse.depth.max.incl)
{ {
SETERR_LIN (awk, QSE_AWK_EINCLTD, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_EINCLTD, awk->ptoken.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -815,7 +815,7 @@ retry:
if (!MATCH(awk,TOKEN_STR)) if (!MATCH(awk,TOKEN_STR))
{ {
SETERR_LIN (awk, QSE_AWK_EINCLSTR, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_EINCLSTR, awk->ptoken.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -857,7 +857,7 @@ retry:
{ {
/* when QSE_AWK_NEWLINE is set, /* when QSE_AWK_NEWLINE is set,
* BEGIN and { should be located on the same line */ * BEGIN and { should be located on the same line */
SETERR_LIN (awk, QSE_AWK_EBLKBEG, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_EBLKBEG, awk->ptoken.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -885,7 +885,7 @@ retry:
{ {
/* when QSE_AWK_NEWLINE is set, /* when QSE_AWK_NEWLINE is set,
* END and { should be located on the same line */ * END and { should be located on the same line */
SETERR_LIN (awk, QSE_AWK_EBLKEND, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_EBLKEND, awk->ptoken.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -983,7 +983,7 @@ retry:
/* blockless pattern requires QSE_AWK_RIO /* blockless pattern requires QSE_AWK_RIO
* to be ON because the implicit block is * to be ON because the implicit block is
* "print $0" */ * "print $0" */
SETERR_LIN (awk, QSE_AWK_ENOSUP, tline); SETERR_LOC (awk, QSE_AWK_ENOSUP, tline);
return QSE_NULL; return QSE_NULL;
} }
} }
@ -1069,7 +1069,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
name_dup = QSE_AWK_STRXDUP (awk, name, name_len); name_dup = QSE_AWK_STRXDUP (awk, name, name_len);
if (name_dup == QSE_NULL) if (name_dup == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, awk->token.lin); SETERR_LOC (awk, QSE_AWK_ENOMEM, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1155,7 +1155,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
{ {
QSE_AWK_FREE (awk, name_dup); QSE_AWK_FREE (awk, name_dup);
qse_lda_clear (awk->parse.params); qse_lda_clear (awk->parse.params);
SETERR_LIN (awk, QSE_AWK_EPARTM, awk->token.lin); SETERR_LOC (awk, QSE_AWK_EPARTM, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1167,7 +1167,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
QSE_AWK_FREE (awk, name_dup); QSE_AWK_FREE (awk, name_dup);
qse_lda_clear (awk->parse.params); qse_lda_clear (awk->parse.params);
SETERR_LIN (awk, QSE_AWK_ENOMEM, awk->token.lin); SETERR_LOC (awk, QSE_AWK_ENOMEM, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1270,7 +1270,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
QSE_AWK_FREE (awk, name_dup); QSE_AWK_FREE (awk, name_dup);
qse_awk_clrpt (awk, body); qse_awk_clrpt (awk, body);
SETERR_LIN (awk, QSE_AWK_ENOMEM, awk->token.lin); SETERR_LOC (awk, QSE_AWK_ENOMEM, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1289,7 +1289,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
qse_awk_clrpt (awk, body); qse_awk_clrpt (awk, body);
QSE_AWK_FREE (awk, fun); QSE_AWK_FREE (awk, fun);
SETERR_LIN (awk, QSE_AWK_ENOMEM, awk->token.lin); SETERR_LOC (awk, QSE_AWK_ENOMEM, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1373,7 +1373,7 @@ static qse_awk_chain_t* parse_pattern_block (
{ {
qse_awk_clrpt (awk, nde); qse_awk_clrpt (awk, nde);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -1457,8 +1457,8 @@ static qse_awk_nde_t* parse_block (
QSE_LDA_SIZE(awk->parse.lcls) - nlcls); QSE_LDA_SIZE(awk->parse.lcls) - nlcls);
if (head != QSE_NULL) qse_awk_clrpt (awk, head); if (head != QSE_NULL) qse_awk_clrpt (awk, head);
/*SETERR_LIN (awk, QSE_AWK_EEOF, awk->ptoken.lin);*/ /*SETERR_LOC (awk, QSE_AWK_EEOF, awk->ptoken.lin);*/
SETERR_LIN (awk, QSE_AWK_EEOF, awk->token.lin); SETERR_LOC (awk, QSE_AWK_EEOF, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1516,7 +1516,7 @@ static qse_awk_nde_t* parse_block (
QSE_LDA_SIZE(awk->parse.lcls)-nlcls); QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
qse_awk_clrpt (awk, head); qse_awk_clrpt (awk, head);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -1561,7 +1561,7 @@ static qse_awk_nde_t* parse_block_dc (
if (awk->parse.depth.max.block > 0 && if (awk->parse.depth.max.block > 0 &&
awk->parse.depth.cur.block >= awk->parse.depth.max.block) awk->parse.depth.cur.block >= awk->parse.depth.max.block)
{ {
SETERR_LIN (awk, QSE_AWK_EBLKNST, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_EBLKNST, awk->ptoken.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1738,7 +1738,7 @@ static int add_global (
ngbls = QSE_LDA_SIZE (awk->parse.gbls); ngbls = QSE_LDA_SIZE (awk->parse.gbls);
if (ngbls >= QSE_AWK_MAX_GBLS) if (ngbls >= QSE_AWK_MAX_GBLS)
{ {
SETERR_LIN (awk, QSE_AWK_EGBLTM, line); SETERR_LOC (awk, QSE_AWK_EGBLTM, line);
return -1; return -1;
} }
@ -1746,7 +1746,7 @@ static int add_global (
QSE_LDA_SIZE(awk->parse.gbls), QSE_LDA_SIZE(awk->parse.gbls),
(qse_char_t*)name, len) == QSE_LDA_NIL) (qse_char_t*)name, len) == QSE_LDA_NIL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return -1; return -1;
} }
@ -1973,7 +1973,7 @@ static qse_awk_t* collect_locals (
if (QSE_LDA_SIZE(awk->parse.lcls) >= QSE_AWK_MAX_LCLS) if (QSE_LDA_SIZE(awk->parse.lcls) >= QSE_AWK_MAX_LCLS)
{ {
SETERR_LIN (awk, QSE_AWK_ELCLTM, awk->token.lin); SETERR_LOC (awk, QSE_AWK_ELCLTM, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -1982,7 +1982,7 @@ static qse_awk_t* collect_locals (
QSE_LDA_SIZE(awk->parse.lcls), QSE_LDA_SIZE(awk->parse.lcls),
lcl.ptr, lcl.len) == QSE_LDA_NIL) lcl.ptr, lcl.len) == QSE_LDA_NIL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, awk->token.lin); SETERR_LOC (awk, QSE_AWK_ENOMEM, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -2034,7 +2034,7 @@ static qse_awk_nde_t* parse_statement (qse_awk_t* awk, qse_size_t line)
QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_t)); QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2200,7 +2200,7 @@ static qse_awk_nde_t* parse_statement_nb (qse_awk_t* awk, qse_size_t line)
else else
{ {
if (nde != QSE_NULL) qse_awk_clrpt (awk, nde); if (nde != QSE_NULL) qse_awk_clrpt (awk, nde);
SETERR_LIN (awk, QSE_AWK_ESTMEND, awk->ptoken.lin); SETERR_LOC (awk, QSE_AWK_ESTMEND, awk->ptoken.lin);
return QSE_NULL; return QSE_NULL;
} }
@ -2214,7 +2214,7 @@ static qse_awk_nde_t* parse_expression (qse_awk_t* awk, qse_size_t line)
if (awk->parse.depth.max.expr > 0 && if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{ {
SETERR_LIN (awk, QSE_AWK_EEXPRNST, line); SETERR_LOC (awk, QSE_AWK_EEXPRNST, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2275,7 +2275,7 @@ static qse_awk_nde_t* parse_expression0 (qse_awk_t* awk, qse_size_t line)
if (!is_var(x) && x->type != QSE_AWK_NDE_POS) if (!is_var(x) && x->type != QSE_AWK_NDE_POS)
{ {
qse_awk_clrpt (awk, x); qse_awk_clrpt (awk, x);
SETERR_LIN (awk, QSE_AWK_EASSIGN, line); SETERR_LOC (awk, QSE_AWK_EASSIGN, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2300,7 +2300,7 @@ static qse_awk_nde_t* parse_expression0 (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, x); qse_awk_clrpt (awk, x);
qse_awk_clrpt (awk, y); qse_awk_clrpt (awk, y);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2359,7 +2359,7 @@ static qse_awk_nde_t* parse_basic_expr (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, n1); qse_awk_clrpt (awk, n1);
qse_awk_clrpt (awk, n2); qse_awk_clrpt (awk, n2);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2428,7 +2428,7 @@ static qse_awk_nde_t* parse_binary_expr (
qse_awk_clrpt (awk, right); qse_awk_clrpt (awk, right);
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2510,7 +2510,7 @@ static qse_awk_nde_t* parse_in (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, right); qse_awk_clrpt (awk, right);
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_ENOTVAR, line2); SETERR_LOC (awk, QSE_AWK_ENOTVAR, line2);
return QSE_NULL; return QSE_NULL;
} }
@ -2521,7 +2521,7 @@ static qse_awk_nde_t* parse_in (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, right); qse_awk_clrpt (awk, right);
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2666,7 +2666,7 @@ static qse_awk_nde_t* parse_concat (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
qse_awk_clrpt (awk, right); qse_awk_clrpt (awk, right);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2730,7 +2730,7 @@ static qse_awk_nde_t* parse_unary (qse_awk_t* awk, qse_size_t line)
if (awk->parse.depth.max.expr > 0 && if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{ {
SETERR_LIN (awk, QSE_AWK_EEXPRNST, awk->token.lin); SETERR_LOC (awk, QSE_AWK_EEXPRNST, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
awk->parse.depth.cur.expr++; awk->parse.depth.cur.expr++;
@ -2744,7 +2744,7 @@ static qse_awk_nde_t* parse_unary (qse_awk_t* awk, qse_size_t line)
{ {
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2788,7 +2788,7 @@ static qse_awk_nde_t* parse_unary_exp (qse_awk_t* awk, qse_size_t line)
if (awk->parse.depth.max.expr > 0 && if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{ {
SETERR_LIN (awk, QSE_AWK_EEXPRNST, awk->token.lin); SETERR_LOC (awk, QSE_AWK_EEXPRNST, awk->token.lin);
return QSE_NULL; return QSE_NULL;
} }
awk->parse.depth.cur.expr++; awk->parse.depth.cur.expr++;
@ -2802,7 +2802,7 @@ static qse_awk_nde_t* parse_unary_exp (qse_awk_t* awk, qse_size_t line)
{ {
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2844,7 +2844,7 @@ static qse_awk_nde_t* parse_increment (qse_awk_t* awk, qse_size_t line)
* not allowed */ * not allowed */
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_EPREPST, line); SETERR_LOC (awk, QSE_AWK_EPREPST, line);
return QSE_NULL; return QSE_NULL;
} }
else if (opcode1 == -1 && opcode2 == -1) else if (opcode1 == -1 && opcode2 == -1)
@ -2874,7 +2874,7 @@ static qse_awk_nde_t* parse_increment (qse_awk_t* awk, qse_size_t line)
if (!is_var(left) && left->type != QSE_AWK_NDE_POS) if (!is_var(left) && left->type != QSE_AWK_NDE_POS)
{ {
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_EINCDECOPR, line); SETERR_LOC (awk, QSE_AWK_EINCDECOPR, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2883,7 +2883,7 @@ static qse_awk_nde_t* parse_increment (qse_awk_t* awk, qse_size_t line)
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2911,7 +2911,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
awk, QSE_SIZEOF(qse_awk_nde_int_t)); awk, QSE_SIZEOF(qse_awk_nde_int_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2952,7 +2952,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
awk, QSE_SIZEOF(qse_awk_nde_real_t)); awk, QSE_SIZEOF(qse_awk_nde_real_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -2993,7 +2993,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
awk, QSE_SIZEOF(qse_awk_nde_str_t)); awk, QSE_SIZEOF(qse_awk_nde_str_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3006,7 +3006,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
if (nde->ptr == QSE_NULL) if (nde->ptr == QSE_NULL)
{ {
QSE_AWK_FREE (awk, nde); QSE_AWK_FREE (awk, nde);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3038,7 +3038,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
awk, QSE_SIZEOF(qse_awk_nde_rex_t)); awk, QSE_SIZEOF(qse_awk_nde_rex_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3053,7 +3053,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
if (nde->ptr == QSE_NULL) if (nde->ptr == QSE_NULL)
{ {
QSE_AWK_FREE (awk, nde); QSE_AWK_FREE (awk, nde);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3066,7 +3066,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
QSE_AWK_FREE (awk, nde->ptr); QSE_AWK_FREE (awk, nde->ptr);
QSE_AWK_FREE (awk, nde); QSE_AWK_FREE (awk, nde);
SETERR_LIN (awk, errnum, line); SETERR_LOC (awk, errnum, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3095,7 +3095,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
qse_awk_clrpt (awk, prim); qse_awk_clrpt (awk, prim);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3189,7 +3189,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
if (tmp == QSE_NULL) if (tmp == QSE_NULL)
{ {
qse_awk_clrpt (awk, nde); qse_awk_clrpt (awk, nde);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3244,7 +3244,7 @@ static qse_awk_nde_t* parse_primary_nogetline (qse_awk_t* awk, qse_size_t line)
{ {
if (var != QSE_NULL) qse_awk_clrpt (awk, var); if (var != QSE_NULL) qse_awk_clrpt (awk, var);
if (in != QSE_NULL) qse_awk_clrpt (awk, in); if (in != QSE_NULL) qse_awk_clrpt (awk, in);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3341,7 +3341,7 @@ static qse_awk_nde_t* parse_primary (qse_awk_t* awk, qse_size_t line)
{ {
qse_awk_clrpt (awk, left); qse_awk_clrpt (awk, left);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3373,7 +3373,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
QSE_STR_LEN(awk->token.name)); QSE_STR_LEN(awk->token.name));
if (name_dup == QSE_NULL) if (name_dup == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
name_len = QSE_STR_LEN(awk->token.name); name_len = QSE_STR_LEN(awk->token.name);
@ -3442,7 +3442,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
QSE_AWK_FREE (awk, name_dup); QSE_AWK_FREE (awk, name_dup);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3476,7 +3476,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
QSE_AWK_FREE (awk, name_dup); QSE_AWK_FREE (awk, name_dup);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3510,7 +3510,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
QSE_AWK_FREE (awk, name_dup); QSE_AWK_FREE (awk, name_dup);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3556,7 +3556,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
QSE_AWK_FREE (awk, name_dup); QSE_AWK_FREE (awk, name_dup);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3608,7 +3608,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
name_dup, name_len, name_dup, name_len,
&line, QSE_SIZEOF(line)) == QSE_NULL) &line, QSE_SIZEOF(line)) == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
goto exit_func; goto exit_func;
} }
@ -3685,7 +3685,7 @@ static qse_awk_nde_t* parse_hashidx (
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
qse_awk_clrpt (awk, idx); qse_awk_clrpt (awk, idx);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3876,7 +3876,7 @@ make_node:
{ {
if (head != QSE_NULL) qse_awk_clrpt (awk, head); if (head != QSE_NULL) qse_awk_clrpt (awk, head);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -3923,7 +3923,7 @@ make_node:
{ {
QSE_AWK_FREE (awk, call); QSE_AWK_FREE (awk, call);
if (head != QSE_NULL) qse_awk_clrpt (awk, head); if (head != QSE_NULL) qse_awk_clrpt (awk, head);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
} }
@ -4008,7 +4008,7 @@ static qse_awk_nde_t* parse_if (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, then_part); qse_awk_clrpt (awk, then_part);
qse_awk_clrpt (awk, test); qse_awk_clrpt (awk, test);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4065,7 +4065,7 @@ static qse_awk_nde_t* parse_while (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, body); qse_awk_clrpt (awk, body);
qse_awk_clrpt (awk, test); qse_awk_clrpt (awk, test);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4135,7 +4135,7 @@ static qse_awk_nde_t* parse_for (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, init); qse_awk_clrpt (awk, init);
qse_awk_clrpt (awk, body); qse_awk_clrpt (awk, body);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4249,7 +4249,7 @@ static qse_awk_nde_t* parse_for (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, incr); qse_awk_clrpt (awk, incr);
qse_awk_clrpt (awk, body); qse_awk_clrpt (awk, body);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4341,7 +4341,7 @@ static qse_awk_nde_t* parse_dowhile (qse_awk_t* awk, qse_size_t line)
qse_awk_clrpt (awk, body); qse_awk_clrpt (awk, body);
qse_awk_clrpt (awk, test); qse_awk_clrpt (awk, test);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4361,7 +4361,7 @@ static qse_awk_nde_t* parse_break (qse_awk_t* awk, qse_size_t line)
QSE_ASSERT (awk->ptoken.type == TOKEN_BREAK); QSE_ASSERT (awk->ptoken.type == TOKEN_BREAK);
if (awk->parse.depth.cur.loop <= 0) if (awk->parse.depth.cur.loop <= 0)
{ {
SETERR_LIN (awk, QSE_AWK_EBREAK, line); SETERR_LOC (awk, QSE_AWK_EBREAK, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4369,7 +4369,7 @@ static qse_awk_nde_t* parse_break (qse_awk_t* awk, qse_size_t line)
QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_break_t)); QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_break_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4387,7 +4387,7 @@ static qse_awk_nde_t* parse_continue (qse_awk_t* awk, qse_size_t line)
QSE_ASSERT (awk->ptoken.type == TOKEN_CONTINUE); QSE_ASSERT (awk->ptoken.type == TOKEN_CONTINUE);
if (awk->parse.depth.cur.loop <= 0) if (awk->parse.depth.cur.loop <= 0)
{ {
SETERR_LIN (awk, QSE_AWK_ECONTINUE, line); SETERR_LOC (awk, QSE_AWK_ECONTINUE, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4395,7 +4395,7 @@ static qse_awk_nde_t* parse_continue (qse_awk_t* awk, qse_size_t line)
QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_continue_t)); QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_continue_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4417,7 +4417,7 @@ static qse_awk_nde_t* parse_return (qse_awk_t* awk, qse_size_t line)
awk, QSE_SIZEOF(qse_awk_nde_return_t)); awk, QSE_SIZEOF(qse_awk_nde_return_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4455,7 +4455,7 @@ static qse_awk_nde_t* parse_exit (qse_awk_t* awk, qse_size_t line)
QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_exit_t)); QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_exit_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4490,12 +4490,12 @@ static qse_awk_nde_t* parse_next (qse_awk_t* awk, qse_size_t line)
if (awk->parse.id.block == PARSE_BEGIN_BLOCK) if (awk->parse.id.block == PARSE_BEGIN_BLOCK)
{ {
SETERR_LIN (awk, QSE_AWK_ENEXTBEG, line); SETERR_LOC (awk, QSE_AWK_ENEXTBEG, line);
return QSE_NULL; return QSE_NULL;
} }
if (awk->parse.id.block == PARSE_END_BLOCK) if (awk->parse.id.block == PARSE_END_BLOCK)
{ {
SETERR_LIN (awk, QSE_AWK_ENEXTEND, line); SETERR_LOC (awk, QSE_AWK_ENEXTEND, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4503,7 +4503,7 @@ static qse_awk_nde_t* parse_next (qse_awk_t* awk, qse_size_t line)
QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_next_t)); QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_next_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
nde->type = QSE_AWK_NDE_NEXT; nde->type = QSE_AWK_NDE_NEXT;
@ -4519,12 +4519,12 @@ static qse_awk_nde_t* parse_nextfile (qse_awk_t* awk, qse_size_t line, int out)
if (!out && awk->parse.id.block == PARSE_BEGIN_BLOCK) if (!out && awk->parse.id.block == PARSE_BEGIN_BLOCK)
{ {
SETERR_LIN (awk, QSE_AWK_ENEXTFBEG, line); SETERR_LOC (awk, QSE_AWK_ENEXTFBEG, line);
return QSE_NULL; return QSE_NULL;
} }
if (!out && awk->parse.id.block == PARSE_END_BLOCK) if (!out && awk->parse.id.block == PARSE_END_BLOCK)
{ {
SETERR_LIN (awk, QSE_AWK_ENEXTFEND, line); SETERR_LOC (awk, QSE_AWK_ENEXTFEND, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4532,7 +4532,7 @@ static qse_awk_nde_t* parse_nextfile (qse_awk_t* awk, qse_size_t line, int out)
QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_nextfile_t)); QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_nde_nextfile_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4563,7 +4563,7 @@ static qse_awk_nde_t* parse_delete (qse_awk_t* awk, qse_size_t line)
{ {
/* a normal identifier is expected */ /* a normal identifier is expected */
qse_awk_clrpt (awk, var); qse_awk_clrpt (awk, var);
SETERR_LIN (awk, QSE_AWK_EDELETE, line); SETERR_LOC (awk, QSE_AWK_EDELETE, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4571,7 +4571,7 @@ static qse_awk_nde_t* parse_delete (qse_awk_t* awk, qse_size_t line)
awk, QSE_SIZEOF(qse_awk_nde_delete_t)); awk, QSE_SIZEOF(qse_awk_nde_delete_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4603,7 +4603,7 @@ static qse_awk_nde_t* parse_reset (qse_awk_t* awk, qse_size_t line)
{ {
/* a normal identifier is expected */ /* a normal identifier is expected */
qse_awk_clrpt (awk, var); qse_awk_clrpt (awk, var);
SETERR_LIN (awk, QSE_AWK_ERESET, line); SETERR_LOC (awk, QSE_AWK_ERESET, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4611,7 +4611,7 @@ static qse_awk_nde_t* parse_reset (qse_awk_t* awk, qse_size_t line)
awk, QSE_SIZEOF(qse_awk_nde_reset_t)); awk, QSE_SIZEOF(qse_awk_nde_reset_t));
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4767,7 +4767,7 @@ static qse_awk_nde_t* parse_print (qse_awk_t* awk, qse_size_t line, int type)
if (args != QSE_NULL) qse_awk_clrpt (awk, args); if (args != QSE_NULL) qse_awk_clrpt (awk, args);
if (out != QSE_NULL) qse_awk_clrpt (awk, out); if (out != QSE_NULL) qse_awk_clrpt (awk, out);
SETERR_LIN (awk, QSE_AWK_ENOMEM, line); SETERR_LOC (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
@ -4778,7 +4778,7 @@ static qse_awk_nde_t* parse_print (qse_awk_t* awk, qse_size_t line, int type)
if (type == QSE_AWK_NDE_PRINTF && args == QSE_NULL) if (type == QSE_AWK_NDE_PRINTF && args == QSE_NULL)
{ {
if (out != QSE_NULL) qse_awk_clrpt (awk, out); if (out != QSE_NULL) qse_awk_clrpt (awk, out);
SETERR_LIN (awk, QSE_AWK_EPRINTFARG, line); SETERR_LOC (awk, QSE_AWK_EPRINTFARG, line);
return QSE_NULL; return QSE_NULL;
} }
@ -5181,7 +5181,7 @@ static int skip_comment (qse_awk_t* awk)
GET_CHAR_TO (awk, c); GET_CHAR_TO (awk, c);
if (c == QSE_CHAR_EOF) if (c == QSE_CHAR_EOF)
{ {
SETERR_LIN (awk, QSE_AWK_ECMTNC, awk->sio.inp->lin); SETERR_LOC (awk, QSE_AWK_ECMTNC, awk->sio.inp->lin);
return -1; return -1;
} }
@ -5190,7 +5190,7 @@ static int skip_comment (qse_awk_t* awk)
GET_CHAR_TO (awk, c); GET_CHAR_TO (awk, c);
if (c == QSE_CHAR_EOF) if (c == QSE_CHAR_EOF)
{ {
SETERR_LIN (awk, QSE_AWK_ECMTNC, awk->sio.inp->lin); SETERR_LOC (awk, QSE_AWK_ECMTNC, awk->sio.inp->lin);
return -1; return -1;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c 255 2009-08-16 08:08:58Z hyunghwan.chung $ * $Id: val.c 259 2009-08-20 11:28:03Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -60,7 +60,7 @@ qse_awk_val_t* qse_awk_val_negone = (qse_awk_val_t*)&awk_int[0];
qse_awk_val_t* qse_awk_val_zero = (qse_awk_val_t*)&awk_int[1]; qse_awk_val_t* qse_awk_val_zero = (qse_awk_val_t*)&awk_int[1];
qse_awk_val_t* qse_awk_val_one = (qse_awk_val_t*)&awk_int[2]; qse_awk_val_t* qse_awk_val_one = (qse_awk_val_t*)&awk_int[2];
qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* run, qse_long_t v) qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* rtx, qse_long_t v)
{ {
qse_awk_val_int_t* val; qse_awk_val_int_t* val;
@ -87,7 +87,7 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* run, qse_long_t v)
} }
*/ */
if (run->vmgr.ifree == QSE_NULL) if (rtx->vmgr.ifree == QSE_NULL)
{ {
qse_awk_val_ichunk_t* c; qse_awk_val_ichunk_t* c;
/*qse_awk_val_int_t* x;*/ /*qse_awk_val_int_t* x;*/
@ -101,16 +101,16 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* run, qse_long_t v)
/* c = QSE_AWK_ALLOC (run->awk, /* c = QSE_AWK_ALLOC (run->awk,
QSE_SIZEOF(qse_awk_val_chunk_t)+ QSE_SIZEOF(qse_awk_val_chunk_t)+
QSE_SIZEOF(qse_awk_val_int_t)*CHUNKSIZE); */ QSE_SIZEOF(qse_awk_val_int_t)*CHUNKSIZE); */
c = QSE_AWK_ALLOC (run->awk, QSE_SIZEOF(qse_awk_val_ichunk_t)); c = QSE_AWK_ALLOC (rtx->awk, QSE_SIZEOF(qse_awk_val_ichunk_t));
if (c == QSE_NULL) if (c == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
c->next = run->vmgr.ichunk; c->next = rtx->vmgr.ichunk;
/*run->vmgr.ichunk = c;*/ /*run->vmgr.ichunk = c;*/
run->vmgr.ichunk = (qse_awk_val_chunk_t*)c; rtx->vmgr.ichunk = (qse_awk_val_chunk_t*)c;
/*x = (qse_awk_val_int_t*)(c + 1); /*x = (qse_awk_val_int_t*)(c + 1);
for (i = 0; i < CHUNKSIZE-1; i++) for (i = 0; i < CHUNKSIZE-1; i++)
@ -124,11 +124,11 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* run, qse_long_t v)
c->slot[i].nde = (qse_awk_nde_int_t*)&c->slot[i+1]; c->slot[i].nde = (qse_awk_nde_int_t*)&c->slot[i+1];
c->slot[i].nde = QSE_NULL; c->slot[i].nde = QSE_NULL;
run->vmgr.ifree = &c->slot[0]; rtx->vmgr.ifree = &c->slot[0];
} }
val = run->vmgr.ifree; val = rtx->vmgr.ifree;
run->vmgr.ifree = (qse_awk_val_int_t*)val->nde; rtx->vmgr.ifree = (qse_awk_val_int_t*)val->nde;
val->type = QSE_AWK_VAL_INT; val->type = QSE_AWK_VAL_INT;
val->ref = 0; val->ref = 0;
@ -142,7 +142,7 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* run, qse_long_t v)
return (qse_awk_val_t*)val; return (qse_awk_val_t*)val;
} }
qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* run, qse_real_t v) qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* rtx, qse_real_t v)
{ {
qse_awk_val_real_t* val; qse_awk_val_real_t* val;
@ -163,7 +163,7 @@ qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* run, qse_real_t v)
} }
*/ */
if (run->vmgr.rfree == QSE_NULL) if (rtx->vmgr.rfree == QSE_NULL)
{ {
qse_awk_val_rchunk_t* c; qse_awk_val_rchunk_t* c;
/*qse_awk_val_real_t* x;*/ /*qse_awk_val_real_t* x;*/
@ -172,16 +172,16 @@ qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* run, qse_real_t v)
/* c = QSE_AWK_ALLOC (run->awk, /* c = QSE_AWK_ALLOC (run->awk,
QSE_SIZEOF(qse_awk_val_chunk_t)+ QSE_SIZEOF(qse_awk_val_chunk_t)+
QSE_SIZEOF(qse_awk_val_real_t)*CHUNKSIZE); */ QSE_SIZEOF(qse_awk_val_real_t)*CHUNKSIZE); */
c = QSE_AWK_ALLOC (run->awk, QSE_SIZEOF(qse_awk_val_rchunk_t)); c = QSE_AWK_ALLOC (rtx->awk, QSE_SIZEOF(qse_awk_val_rchunk_t));
if (c == QSE_NULL) if (c == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
c->next = run->vmgr.rchunk; c->next = rtx->vmgr.rchunk;
/*run->vmgr.rchunk = c;*/ /*run->vmgr.rchunk = c;*/
run->vmgr.rchunk = (qse_awk_val_chunk_t*)c; rtx->vmgr.rchunk = (qse_awk_val_chunk_t*)c;
/* /*
x = (qse_awk_val_real_t*)(c + 1); x = (qse_awk_val_real_t*)(c + 1);
@ -196,11 +196,11 @@ qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* run, qse_real_t v)
c->slot[i].nde = (qse_awk_nde_real_t*)&c->slot[i+1]; c->slot[i].nde = (qse_awk_nde_real_t*)&c->slot[i+1];
c->slot[i].nde = QSE_NULL; c->slot[i].nde = QSE_NULL;
run->vmgr.rfree = &c->slot[0]; rtx->vmgr.rfree = &c->slot[0];
} }
val = run->vmgr.rfree; val = rtx->vmgr.rfree;
run->vmgr.rfree = (qse_awk_val_real_t*)val->nde; rtx->vmgr.rfree = (qse_awk_val_real_t*)val->nde;
val->type = QSE_AWK_VAL_REAL; val->type = QSE_AWK_VAL_REAL;
val->ref = 0; val->ref = 0;
@ -215,13 +215,13 @@ qse_awk_val_t* qse_awk_rtx_makerealval (qse_awk_rtx_t* run, qse_real_t v)
} }
qse_awk_val_t* qse_awk_rtx_makestrval0 ( qse_awk_val_t* qse_awk_rtx_makestrval0 (
qse_awk_rtx_t* run, const qse_char_t* str) qse_awk_rtx_t* rtx, const qse_char_t* str)
{ {
return qse_awk_rtx_makestrval (run, str, qse_strlen(str)); return qse_awk_rtx_makestrval (rtx, str, qse_strlen(str));
} }
qse_awk_val_t* qse_awk_rtx_makestrval ( qse_awk_val_t* qse_awk_rtx_makestrval (
qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t len) qse_awk_rtx_t* rtx, const qse_char_t* str, qse_size_t len)
{ {
qse_awk_val_str_t* val; qse_awk_val_str_t* val;
qse_size_t rlen = len; qse_size_t rlen = len;
@ -246,12 +246,12 @@ qse_awk_val_t* qse_awk_rtx_makestrval (
}*/ }*/
val = (qse_awk_val_str_t*) QSE_AWK_ALLOC ( val = (qse_awk_val_str_t*) QSE_AWK_ALLOC (
run->awk, rtx->awk,
QSE_SIZEOF(qse_awk_val_str_t) + QSE_SIZEOF(qse_awk_val_str_t) +
(rlen+1)*QSE_SIZEOF(qse_char_t)); (rlen+1)*QSE_SIZEOF(qse_char_t));
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
/* /*
@ -272,15 +272,15 @@ init:
} }
qse_awk_val_t* qse_awk_rtx_makestrval_nodup ( qse_awk_val_t* qse_awk_rtx_makestrval_nodup (
qse_awk_rtx_t* run, qse_char_t* str, qse_size_t len) qse_awk_rtx_t* rtx, qse_char_t* str, qse_size_t len)
{ {
qse_awk_val_str_t* val; qse_awk_val_str_t* val;
val = (qse_awk_val_str_t*) QSE_AWK_ALLOC ( val = (qse_awk_val_str_t*) QSE_AWK_ALLOC (
run->awk, QSE_SIZEOF(qse_awk_val_str_t)); rtx->awk, QSE_SIZEOF(qse_awk_val_str_t));
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
@ -293,7 +293,7 @@ qse_awk_val_t* qse_awk_rtx_makestrval_nodup (
} }
qse_awk_val_t* qse_awk_rtx_makestrval2 ( qse_awk_val_t* qse_awk_rtx_makestrval2 (
qse_awk_rtx_t* run, qse_awk_rtx_t* rtx,
const qse_char_t* str1, qse_size_t len1, const qse_char_t* str1, qse_size_t len1,
const qse_char_t* str2, qse_size_t len2) const qse_char_t* str2, qse_size_t len2)
{ {
@ -320,12 +320,12 @@ qse_awk_val_t* qse_awk_rtx_makestrval2 (
}*/ }*/
val = (qse_awk_val_str_t*) QSE_AWK_ALLOC ( val = (qse_awk_val_str_t*) QSE_AWK_ALLOC (
run->awk, rtx->awk,
QSE_SIZEOF(qse_awk_val_str_t) + QSE_SIZEOF(qse_awk_val_str_t) +
(rlen+1)*QSE_SIZEOF(qse_char_t)); (rlen+1)*QSE_SIZEOF(qse_char_t));
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
@ -349,15 +349,15 @@ init:
} }
qse_awk_val_t* qse_awk_rtx_makenstrval ( qse_awk_val_t* qse_awk_rtx_makenstrval (
qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t len) qse_awk_rtx_t* rtx, const qse_char_t* str, qse_size_t len)
{ {
int x; int x;
qse_awk_val_t* v; qse_awk_val_t* v;
qse_long_t l; qse_long_t l;
qse_real_t r; qse_real_t r;
x = qse_awk_rtx_strtonum (run, 1, str, len, &l, &r); x = qse_awk_rtx_strtonum (rtx, 1, str, len, &l, &r);
v = qse_awk_rtx_makestrval (run, str, len); v = qse_awk_rtx_makestrval (rtx, str, len);
if (v == QSE_NULL) return QSE_NULL; if (v == QSE_NULL) return QSE_NULL;
@ -373,25 +373,25 @@ qse_awk_val_t* qse_awk_rtx_makenstrval (
} }
qse_awk_val_t* qse_awk_rtx_makerexval ( qse_awk_val_t* qse_awk_rtx_makerexval (
qse_awk_rtx_t* run, const qse_char_t* buf, qse_size_t len, void* code) qse_awk_rtx_t* rtx, const qse_char_t* buf, qse_size_t len, void* code)
{ {
qse_awk_val_rex_t* val; qse_awk_val_rex_t* val;
qse_size_t totsz; qse_size_t totsz;
/* the regular expression value holds: /* the regular expression value holds:
* header * - header
* a raw string plus with added a terminating '\0' * - a raw string plus with added a terminating '\0'
* a compiled regular expression * - a compiled regular expression
* the total size is just large enough for all these. * the total size is just large enough for all these.
*/ */
totsz = QSE_SIZEOF(qse_awk_val_rex_t) + totsz = QSE_SIZEOF(qse_awk_val_rex_t) +
(QSE_SIZEOF(*buf) * (len + 1)) + (QSE_SIZEOF(*buf) * (len + 1)) +
QSE_REX_LEN(code); QSE_REX_LEN(code);
val = (qse_awk_val_rex_t*) QSE_AWK_ALLOC (run->awk, totsz); val = (qse_awk_val_rex_t*) QSE_AWK_ALLOC (rtx->awk, totsz);
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
@ -433,7 +433,7 @@ static void same_mapval (qse_map_t* map, void* dptr, qse_size_t dlen)
qse_awk_rtx_refdownval_nofree (run, dptr); qse_awk_rtx_refdownval_nofree (run, dptr);
} }
qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run) qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* rtx)
{ {
qse_awk_val_map_t* val; qse_awk_val_map_t* val;
@ -461,13 +461,13 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
*/ */
val = (qse_awk_val_map_t*) QSE_AWK_ALLOC ( val = (qse_awk_val_map_t*) QSE_AWK_ALLOC (
run->awk, rtx->awk,
QSE_SIZEOF(qse_awk_val_map_t) + QSE_SIZEOF(qse_awk_val_map_t) +
QSE_SIZEOF(qse_map_t) + QSE_SIZEOF(qse_map_t) +
QSE_SIZEOF(run)); QSE_SIZEOF(rtx));
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
@ -476,14 +476,14 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
val->nstr = 0; val->nstr = 0;
val->map = (qse_map_t*)(val + 1); val->map = (qse_map_t*)(val + 1);
val->map = qse_map_init (val->map, run->awk->mmgr, 256, 70); val->map = qse_map_init (val->map, rtx->awk->mmgr, 256, 70);
if (val->map == QSE_NULL) if (val->map == QSE_NULL)
{ {
QSE_AWK_FREE (run->awk, val); QSE_AWK_FREE (rtx->awk, val);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
*(qse_awk_rtx_t**)QSE_XTN(val->map) = run; *(qse_awk_rtx_t**)QSE_XTN(val->map) = rtx;
/* the key is copied inline into a pair and is freed when the pair /* the key is copied inline into a pair and is freed when the pair
* is destroyed */ * is destroyed */
@ -500,21 +500,22 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* run)
return (qse_awk_val_t*)val; return (qse_awk_val_t*)val;
} }
qse_awk_val_t* qse_awk_rtx_makerefval (qse_awk_rtx_t* run, int id, qse_awk_val_t** adr) qse_awk_val_t* qse_awk_rtx_makerefval (
qse_awk_rtx_t* rtx, int id, qse_awk_val_t** adr)
{ {
qse_awk_val_ref_t* val; qse_awk_val_ref_t* val;
if (run->fcache_count > 0) if (rtx->fcache_count > 0)
{ {
val = run->fcache[--run->fcache_count]; val = rtx->fcache[--rtx->fcache_count];
} }
else else
{ {
val = (qse_awk_val_ref_t*) QSE_AWK_ALLOC ( val = (qse_awk_val_ref_t*) QSE_AWK_ALLOC (
run->awk, QSE_SIZEOF(qse_awk_val_ref_t)); rtx->awk, QSE_SIZEOF(qse_awk_val_ref_t));
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL; return QSE_NULL;
} }
} }
@ -659,7 +660,8 @@ void qse_awk_rtx_refdownval (qse_awk_rtx_t* rtx, qse_awk_val_t* val)
#endif #endif
QSE_ASSERTX (val->ref > 0, QSE_ASSERTX (val->ref > 0,
"the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs"); "the reference count of a value should be greater than zero for it"
" to be decremented. check the source code for any bugs");
val->ref--; val->ref--;
if (val->ref <= 0) if (val->ref <= 0)
@ -673,7 +675,8 @@ void qse_awk_rtx_refdownval_nofree (qse_awk_rtx_t* rtx, qse_awk_val_t* val)
if (IS_STATICVAL(val)) return; if (IS_STATICVAL(val)) return;
QSE_ASSERTX (val->ref > 0, QSE_ASSERTX (val->ref > 0,
"the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs"); "the reference count of a value should be greater than zero for it"
" to be decremented. check the source code for any bugs");
val->ref--; val->ref--;
} }
@ -715,56 +718,6 @@ qse_bool_t qse_awk_rtx_valtobool (qse_awk_rtx_t* run, qse_awk_val_t* val)
return QSE_FALSE; return QSE_FALSE;
} }
#if 0
static qse_char_t* str_to_str (
qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t str_len,
int opt, qse_str_t* buf, qse_size_t* len)
{
if (buf == QSE_NULL)
{
qse_char_t* tmp;
tmp = QSE_AWK_STRXDUP (run->awk, str, str_len);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
if (len != QSE_NULL) *len = str_len;
return tmp;
}
else if (opt & QSE_AWK_RTX_VALTOSTR_FIXED)
{
QSE_ASSERT (buf != QSE_NULL && len != QSE_NULL);
if (str_len >= *len)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_EINVAL, QSE_NULL);
*len = str_len + 1;
return QSE_NULL;
}
*len = qse_strncpy ((qse_char_t*)buf, str, str_len);
return (qse_char_t*)buf;
}
else
{
qse_size_t n;
if (opt & QSE_AWK_RTX_VALTOSTR_CLEAR) qse_str_clear (buf);
n = qse_str_ncat (buf, str, str_len);
if (n == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return QSE_NULL;
}
if (len != QSE_NULL) *len = QSE_STR_LEN(buf);
return QSE_STR_PTR(buf);
}
}
#endif
static qse_char_t* str_to_str ( static qse_char_t* str_to_str (
qse_awk_rtx_t* rtx, const qse_char_t* str, qse_size_t str_len, qse_awk_rtx_t* rtx, const qse_char_t* str, qse_size_t str_len,
qse_awk_rtx_valtostr_out_t* out) qse_awk_rtx_valtostr_out_t* out)