touched up some code
This commit is contained in:
parent
fdce5fc592
commit
efc8d5ceb4
@ -1036,7 +1036,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
mmgr = &xma_mmgr;
|
mmgr = &xma_mmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
awk = qse_awk_openstdwithmmgr (mmgr, 0);
|
awk = qse_awk_openstdwithmmgr (mmgr, 0, QSE_NULL);
|
||||||
/*awk = qse_awk_openstd (0);*/
|
/*awk = qse_awk_openstd (0);*/
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
|
@ -1435,7 +1435,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_open() function creates a new qse_awk_t object. The object
|
* The qse_awk_open() function creates a new #qse_awk_t object. The object
|
||||||
* created can be passed to other qse_awk_xxx() functions and is valid until
|
* created can be passed to other qse_awk_xxx() functions and is valid until
|
||||||
* it is destroyed with the qse_awk_close() function. The function saves the
|
* it is destroyed with the qse_awk_close() function. The function saves the
|
||||||
* memory manager pointer while it copies the contents of the primitive
|
* memory manager pointer while it copies the contents of the primitive
|
||||||
@ -1451,24 +1451,28 @@ extern "C" {
|
|||||||
* &mmgr, // NOT OK because the contents of mmgr is
|
* &mmgr, // NOT OK because the contents of mmgr is
|
||||||
* // invalidated when dummy() returns.
|
* // invalidated when dummy() returns.
|
||||||
* 0,
|
* 0,
|
||||||
* &prm // OK
|
* &prm, // OK
|
||||||
|
* QSE_NULL
|
||||||
* );
|
* );
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
|
* Upon failure, it stores the error number to a variable pointed to
|
||||||
|
* by \a errnum. if \a errnum is #QSE_NULL, no error number is stored.
|
||||||
|
*
|
||||||
* \return a pointer to a qse_awk_t object on success, #QSE_NULL on failure.
|
* \return a pointer to a qse_awk_t object on success, #QSE_NULL on failure.
|
||||||
*/
|
*/
|
||||||
QSE_EXPORT qse_awk_t* qse_awk_open (
|
QSE_EXPORT qse_awk_t* qse_awk_open (
|
||||||
qse_mmgr_t* mmgr, /**< memory manager */
|
qse_mmgr_t* mmgr, /**< memory manager */
|
||||||
qse_size_t xtnsize, /**< extension size in bytes */
|
qse_size_t xtnsize, /**< extension size in bytes */
|
||||||
qse_awk_prm_t* prm /**< pointer to a primitive function structure */
|
const qse_awk_prm_t* prm, /**< pointer to a primitive function structure */
|
||||||
|
qse_awk_errnum_t* errnum /**< pointer to an error number varaible */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_close() function destroys a qse_awk_t object.
|
* The qse_awk_close() function destroys a qse_awk_t object.
|
||||||
* \return 0 on success, -1 on failure
|
|
||||||
*/
|
*/
|
||||||
QSE_EXPORT int qse_awk_close (
|
QSE_EXPORT void qse_awk_close (
|
||||||
qse_awk_t* awk /**< awk */
|
qse_awk_t* awk /**< awk */
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1512,10 +1516,9 @@ QSE_EXPORT void qse_awk_setprm (
|
|||||||
* reuse a qse_awk_t instance that finished being used, you may call
|
* reuse a qse_awk_t instance that finished being used, you may call
|
||||||
* qse_awk_clear() instead of destroying and creating a new
|
* qse_awk_clear() instead of destroying and creating a new
|
||||||
* #qse_awk_t instance using qse_awk_close() and qse_awk_open().
|
* #qse_awk_t instance using qse_awk_close() and qse_awk_open().
|
||||||
*
|
|
||||||
* \return 0 on success, -1 on failure
|
|
||||||
*/
|
*/
|
||||||
QSE_EXPORT int qse_awk_clear (
|
QSE_EXPORT void qse_awk_clear (
|
||||||
qse_awk_t* awk
|
qse_awk_t* awk
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -96,7 +96,8 @@ extern "C" {
|
|||||||
* over qse_awk_open() if you don't need finer-grained customization.
|
* over qse_awk_open() if you don't need finer-grained customization.
|
||||||
*/
|
*/
|
||||||
QSE_EXPORT qse_awk_t* qse_awk_openstd (
|
QSE_EXPORT qse_awk_t* qse_awk_openstd (
|
||||||
qse_size_t xtnsize /**< extension size in bytes */
|
qse_size_t xtnsize, /**< extension size in bytes */
|
||||||
|
qse_awk_errnum_t* errnum /**< pointer to an error number variable */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,8 +106,9 @@ QSE_EXPORT qse_awk_t* qse_awk_openstd (
|
|||||||
* except that you can specify your own memory manager.
|
* except that you can specify your own memory manager.
|
||||||
*/
|
*/
|
||||||
QSE_EXPORT qse_awk_t* qse_awk_openstdwithmmgr (
|
QSE_EXPORT qse_awk_t* qse_awk_openstdwithmmgr (
|
||||||
qse_mmgr_t* mmgr, /**< memory manager */
|
qse_mmgr_t* mmgr, /**< memory manager */
|
||||||
qse_size_t xtnsize /**< extension size in bytes */
|
qse_size_t xtnsize, /**< extension size in bytes */
|
||||||
|
qse_awk_errnum_t* errnum /**< pointer to an error number variable */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1122,10 +1122,11 @@ int Awk::open ()
|
|||||||
prm.modclose = modclose;
|
prm.modclose = modclose;
|
||||||
prm.modsym = modsym;
|
prm.modsym = modsym;
|
||||||
|
|
||||||
awk = qse_awk_open (this->getMmgr(), QSE_SIZEOF(xtn_t), &prm);
|
qse_awk_errnum_t errnum;
|
||||||
|
awk = qse_awk_open (this->getMmgr(), QSE_SIZEOF(xtn_t), &prm, &errnum);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
setError (QSE_AWK_ENOMEM);
|
this->setError (errnum);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,7 +1146,7 @@ int Awk::open ()
|
|||||||
qse_awk_close (awk);
|
qse_awk_close (awk);
|
||||||
awk = QSE_NULL;
|
awk = QSE_NULL;
|
||||||
|
|
||||||
setError (QSE_AWK_ENOMEM);
|
this->setError (QSE_AWK_ENOMEM);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ static int init_token (qse_mmgr_t* mmgr, qse_awk_tok_t* tok)
|
|||||||
|
|
||||||
static void fini_token (qse_awk_tok_t* tok)
|
static void fini_token (qse_awk_tok_t* tok)
|
||||||
{
|
{
|
||||||
if (tok->name != QSE_NULL)
|
if (tok->name)
|
||||||
{
|
{
|
||||||
qse_str_close (tok->name);
|
qse_str_close (tok->name);
|
||||||
tok->name = QSE_NULL;
|
tok->name = QSE_NULL;
|
||||||
@ -63,17 +63,44 @@ static void fini_token (qse_awk_tok_t* tok)
|
|||||||
|
|
||||||
static void clear_token (qse_awk_tok_t* tok)
|
static void clear_token (qse_awk_tok_t* tok)
|
||||||
{
|
{
|
||||||
if (tok->name != QSE_NULL) qse_str_clear (tok->name);
|
if (tok->name) qse_str_clear (tok->name);
|
||||||
tok->type = 0;
|
tok->type = 0;
|
||||||
tok->loc.file = QSE_NULL;
|
tok->loc.file = QSE_NULL;
|
||||||
tok->loc.line = 0;
|
tok->loc.line = 0;
|
||||||
tok->loc.colm = 0;
|
tok->loc.colm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* prm)
|
qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, const qse_awk_prm_t* prm, qse_awk_errnum_t* errnum)
|
||||||
{
|
{
|
||||||
qse_awk_t* awk;
|
qse_awk_t* awk;
|
||||||
|
|
||||||
|
awk = (qse_awk_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_awk_t) + xtnsize);
|
||||||
|
if (awk)
|
||||||
|
{
|
||||||
|
int xret;
|
||||||
|
|
||||||
|
xret = qse_awk_init (awk, mmgr, prm);
|
||||||
|
if (xret <= -1)
|
||||||
|
{
|
||||||
|
if (errnum) *errnum = qse_awk_geterrnum(awk);
|
||||||
|
QSE_MMGR_FREE (mmgr, awk);
|
||||||
|
awk = QSE_NULL;
|
||||||
|
}
|
||||||
|
else QSE_MEMSET (QSE_XTN(awk), 0, xtnsize);
|
||||||
|
}
|
||||||
|
else if (errnum) *errnum = QSE_AWK_ENOMEM;
|
||||||
|
|
||||||
|
return awk;
|
||||||
|
}
|
||||||
|
|
||||||
|
void qse_awk_close (qse_awk_t* awk)
|
||||||
|
{
|
||||||
|
qse_awk_fini (awk);
|
||||||
|
QSE_MMGR_FREE (awk->mmgr, awk);
|
||||||
|
}
|
||||||
|
|
||||||
|
int qse_awk_init (qse_awk_t* awk, qse_mmgr_t* mmgr, const qse_awk_prm_t* prm)
|
||||||
|
{
|
||||||
static qse_htb_style_t treefuncbs =
|
static qse_htb_style_t treefuncbs =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@ -106,16 +133,20 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
|||||||
QSE_HTB_HASHER_DEFAULT
|
QSE_HTB_HASHER_DEFAULT
|
||||||
};
|
};
|
||||||
|
|
||||||
/* allocate the object */
|
/* zero out the object */
|
||||||
awk = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_awk_t) + xtnsize);
|
QSE_MEMSET (awk, 0, QSE_SIZEOF(qse_awk_t));
|
||||||
if (awk == QSE_NULL) return QSE_NULL;
|
|
||||||
|
|
||||||
/* zero out the object + extension area */
|
|
||||||
QSE_MEMSET (awk, 0, QSE_SIZEOF(qse_awk_t) + xtnsize);
|
|
||||||
|
|
||||||
/* remember the memory manager */
|
/* remember the memory manager */
|
||||||
awk->mmgr = mmgr;
|
awk->mmgr = mmgr;
|
||||||
|
|
||||||
|
/* initialize error handling fields */
|
||||||
|
awk->errinf.num = QSE_AWK_ENOERR;
|
||||||
|
awk->errinf.loc.line = 0;
|
||||||
|
awk->errinf.loc.colm = 0;
|
||||||
|
awk->errinf.loc.file = QSE_NULL;
|
||||||
|
awk->errstr = qse_awk_dflerrstr;
|
||||||
|
awk->stopall = 0;
|
||||||
|
|
||||||
/* progagate the primitive functions */
|
/* progagate the primitive functions */
|
||||||
QSE_ASSERT (prm != QSE_NULL);
|
QSE_ASSERT (prm != QSE_NULL);
|
||||||
QSE_ASSERT (prm->math.pow != QSE_NULL);
|
QSE_ASSERT (prm->math.pow != QSE_NULL);
|
||||||
@ -124,48 +155,68 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
|||||||
prm->math.pow == QSE_NULL ||
|
prm->math.pow == QSE_NULL ||
|
||||||
prm->math.mod == QSE_NULL)
|
prm->math.mod == QSE_NULL)
|
||||||
{
|
{
|
||||||
QSE_AWK_FREE (awk, awk);
|
qse_awk_seterrnum (awk, QSE_AWK_EINVAL, QSE_NULL);
|
||||||
return QSE_NULL;
|
goto oops;
|
||||||
}
|
}
|
||||||
awk->prm = *prm;
|
awk->prm = *prm;
|
||||||
|
|
||||||
if (init_token (mmgr, &awk->ptok) == -1) goto oops;
|
if (init_token (mmgr, &awk->ptok) <= -1 ||
|
||||||
if (init_token (mmgr, &awk->tok) == -1) goto oops;
|
init_token (mmgr, &awk->tok) <= -1 ||
|
||||||
if (init_token (mmgr, &awk->ntok) == -1) goto oops;
|
init_token (mmgr, &awk->ntok) <= -1)
|
||||||
|
{
|
||||||
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
awk->opt.trait = QSE_AWK_MODERN;
|
||||||
|
#if defined(__OS2__) || defined(_WIN32) || defined(__DOS__)
|
||||||
|
awk->opt.trait |= QSE_AWK_CRLF;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
awk->tree.ngbls = 0;
|
||||||
|
awk->tree.ngbls_base = 0;
|
||||||
|
awk->tree.begin = QSE_NULL;
|
||||||
|
awk->tree.begin_tail = QSE_NULL;
|
||||||
|
awk->tree.end = QSE_NULL;
|
||||||
|
awk->tree.end_tail = QSE_NULL;
|
||||||
|
awk->tree.chain = QSE_NULL;
|
||||||
|
awk->tree.chain_tail = QSE_NULL;
|
||||||
|
awk->tree.chain_size = 0;
|
||||||
|
|
||||||
/* TODO: initial map size?? */
|
/* TODO: initial map size?? */
|
||||||
awk->tree.funs = qse_htb_open (
|
awk->tree.funs = qse_htb_open (mmgr, QSE_SIZEOF(awk), 512, 70, QSE_SIZEOF(qse_char_t), 1);
|
||||||
mmgr, QSE_SIZEOF(awk), 512, 70, QSE_SIZEOF(qse_char_t), 1
|
awk->parse.funs = qse_htb_open (mmgr, QSE_SIZEOF(awk), 256, 70, QSE_SIZEOF(qse_char_t), 1);
|
||||||
);
|
awk->parse.named = qse_htb_open (mmgr, QSE_SIZEOF(awk), 256, 70, QSE_SIZEOF(qse_char_t), 1);
|
||||||
if (awk->tree.funs == QSE_NULL) goto oops;
|
|
||||||
*(qse_awk_t**)QSE_XTN(awk->tree.funs) = awk;
|
|
||||||
qse_htb_setstyle (awk->tree.funs, &treefuncbs);
|
|
||||||
|
|
||||||
awk->parse.funs = qse_htb_open (
|
|
||||||
mmgr, QSE_SIZEOF(awk), 256, 70, QSE_SIZEOF(qse_char_t), 1
|
|
||||||
);
|
|
||||||
if (awk->parse.funs == QSE_NULL) goto oops;
|
|
||||||
*(qse_awk_t**)QSE_XTN(awk->parse.funs) = awk;
|
|
||||||
qse_htb_setstyle (awk->parse.funs,
|
|
||||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER)
|
|
||||||
);
|
|
||||||
|
|
||||||
awk->parse.named = qse_htb_open (
|
|
||||||
mmgr, QSE_SIZEOF(awk), 256, 70, QSE_SIZEOF(qse_char_t), 1
|
|
||||||
);
|
|
||||||
if (awk->parse.named == QSE_NULL) goto oops;
|
|
||||||
*(qse_awk_t**)QSE_XTN(awk->parse.named) = awk;
|
|
||||||
qse_htb_setstyle (awk->parse.named,
|
|
||||||
qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER)
|
|
||||||
);
|
|
||||||
|
|
||||||
awk->parse.gbls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 128);
|
awk->parse.gbls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 128);
|
||||||
awk->parse.lcls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 64);
|
awk->parse.lcls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 64);
|
||||||
awk->parse.params = qse_lda_open (mmgr, QSE_SIZEOF(awk), 32);
|
awk->parse.params = qse_lda_open (mmgr, QSE_SIZEOF(awk), 32);
|
||||||
|
|
||||||
if (awk->parse.gbls == QSE_NULL ||
|
awk->fnc.sys = QSE_NULL;
|
||||||
|
awk->fnc.user = qse_htb_open (mmgr, QSE_SIZEOF(awk), 512, 70, QSE_SIZEOF(qse_char_t), 1);
|
||||||
|
awk->modtab = qse_rbt_open (mmgr, 0, QSE_SIZEOF(qse_char_t), 1);
|
||||||
|
|
||||||
|
if (awk->tree.funs == QSE_NULL ||
|
||||||
|
awk->parse.funs == QSE_NULL ||
|
||||||
|
awk->parse.named == QSE_NULL ||
|
||||||
|
awk->parse.gbls == QSE_NULL ||
|
||||||
awk->parse.lcls == QSE_NULL ||
|
awk->parse.lcls == QSE_NULL ||
|
||||||
awk->parse.params == QSE_NULL) goto oops;
|
awk->parse.params == QSE_NULL ||
|
||||||
|
awk->fnc.user == QSE_NULL ||
|
||||||
|
awk->modtab == QSE_NULL)
|
||||||
|
{
|
||||||
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(qse_awk_t**)QSE_XTN(awk->tree.funs) = awk;
|
||||||
|
qse_htb_setstyle (awk->tree.funs, &treefuncbs);
|
||||||
|
|
||||||
|
*(qse_awk_t**)QSE_XTN(awk->parse.funs) = awk;
|
||||||
|
qse_htb_setstyle (awk->parse.funs, qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER));
|
||||||
|
|
||||||
|
*(qse_awk_t**)QSE_XTN(awk->parse.named) = awk;
|
||||||
|
qse_htb_setstyle (awk->parse.named, qse_gethtbstyle(QSE_HTB_STYLE_INLINE_KEY_COPIER));
|
||||||
|
|
||||||
*(qse_awk_t**)QSE_XTN(awk->parse.gbls) = awk;
|
*(qse_awk_t**)QSE_XTN(awk->parse.gbls) = awk;
|
||||||
qse_lda_setscale (awk->parse.gbls, QSE_SIZEOF(qse_char_t));
|
qse_lda_setscale (awk->parse.gbls, QSE_SIZEOF(qse_char_t));
|
||||||
@ -179,46 +230,18 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
|
|||||||
qse_lda_setscale (awk->parse.params, QSE_SIZEOF(qse_char_t));
|
qse_lda_setscale (awk->parse.params, QSE_SIZEOF(qse_char_t));
|
||||||
qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE);
|
qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE);
|
||||||
|
|
||||||
awk->opt.trait = QSE_AWK_MODERN;
|
|
||||||
#if defined(__OS2__) || defined(_WIN32) || defined(__DOS__)
|
|
||||||
awk->opt.trait |= QSE_AWK_CRLF;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
awk->errinf.num = QSE_AWK_ENOERR;
|
|
||||||
awk->errinf.loc.line = 0;
|
|
||||||
awk->errinf.loc.colm = 0;
|
|
||||||
awk->errinf.loc.file = QSE_NULL;
|
|
||||||
awk->errstr = qse_awk_dflerrstr;
|
|
||||||
awk->stopall = 0;
|
|
||||||
|
|
||||||
awk->tree.ngbls = 0;
|
|
||||||
awk->tree.ngbls_base = 0;
|
|
||||||
awk->tree.begin = QSE_NULL;
|
|
||||||
awk->tree.begin_tail = QSE_NULL;
|
|
||||||
awk->tree.end = QSE_NULL;
|
|
||||||
awk->tree.end_tail = QSE_NULL;
|
|
||||||
awk->tree.chain = QSE_NULL;
|
|
||||||
awk->tree.chain_tail = QSE_NULL;
|
|
||||||
awk->tree.chain_size = 0;
|
|
||||||
|
|
||||||
awk->fnc.sys = QSE_NULL;
|
|
||||||
awk->fnc.user = qse_htb_open (
|
|
||||||
mmgr, QSE_SIZEOF(awk), 512, 70, QSE_SIZEOF(qse_char_t), 1
|
|
||||||
);
|
|
||||||
if (awk->fnc.user == QSE_NULL) goto oops;
|
|
||||||
*(qse_awk_t**)QSE_XTN(awk->fnc.user) = awk;
|
*(qse_awk_t**)QSE_XTN(awk->fnc.user) = awk;
|
||||||
qse_htb_setstyle (awk->fnc.user, &fncusercbs);
|
qse_htb_setstyle (awk->fnc.user, &fncusercbs);
|
||||||
|
|
||||||
awk->modtab = qse_rbt_open (mmgr, 0, QSE_SIZEOF(qse_char_t), 1);
|
qse_rbt_setstyle (awk->modtab, qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS));
|
||||||
if (awk->modtab == QSE_NULL) goto oops;
|
|
||||||
qse_rbt_setstyle (
|
|
||||||
awk->modtab,
|
|
||||||
qse_getrbtstyle(QSE_RBT_STYLE_INLINE_COPIERS)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (qse_awk_initgbls (awk) <= -1) goto oops;
|
if (qse_awk_initgbls (awk) <= -1)
|
||||||
|
{
|
||||||
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
return awk;
|
return 0;
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
if (awk->modtab) qse_rbt_close (awk->modtab);
|
if (awk->modtab) qse_rbt_close (awk->modtab);
|
||||||
@ -232,17 +255,16 @@ oops:
|
|||||||
fini_token (&awk->ntok);
|
fini_token (&awk->ntok);
|
||||||
fini_token (&awk->tok);
|
fini_token (&awk->tok);
|
||||||
fini_token (&awk->ptok);
|
fini_token (&awk->ptok);
|
||||||
QSE_AWK_FREE (awk, awk);
|
|
||||||
|
|
||||||
return QSE_NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qse_awk_close (qse_awk_t* awk)
|
void qse_awk_fini (qse_awk_t* awk)
|
||||||
{
|
{
|
||||||
qse_awk_ecb_t* ecb;
|
qse_awk_ecb_t* ecb;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (qse_awk_clear (awk) <= -1) return -1;
|
qse_awk_clear (awk);
|
||||||
/*qse_awk_clrfnc (awk);*/
|
/*qse_awk_clrfnc (awk);*/
|
||||||
|
|
||||||
for (ecb = awk->ecb; ecb; ecb = ecb->next)
|
for (ecb = awk->ecb; ecb; ecb = ecb->next)
|
||||||
@ -268,14 +290,8 @@ int qse_awk_close (qse_awk_t* awk)
|
|||||||
/* destroy dynamically allocated options */
|
/* destroy dynamically allocated options */
|
||||||
for (i = 0; i < QSE_COUNTOF(awk->opt.mod); i++)
|
for (i = 0; i < QSE_COUNTOF(awk->opt.mod); i++)
|
||||||
{
|
{
|
||||||
if (awk->opt.mod[i].ptr)
|
if (awk->opt.mod[i].ptr) QSE_AWK_FREE (awk, awk->opt.mod[i].ptr);
|
||||||
QSE_MMGR_FREE (awk->mmgr, awk->opt.mod[i].ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* QSE_AWK_ALLOC, QSE_AWK_FREE, etc can not be used
|
|
||||||
* from the next line onwards */
|
|
||||||
QSE_AWK_FREE (awk, awk);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static qse_rbt_walk_t unload_module (qse_rbt_t* rbt, qse_rbt_pair_t* pair, void* ctx)
|
static qse_rbt_walk_t unload_module (qse_rbt_t* rbt, qse_rbt_pair_t* pair, void* ctx)
|
||||||
@ -290,12 +306,12 @@ static qse_rbt_walk_t unload_module (qse_rbt_t* rbt, qse_rbt_pair_t* pair, void*
|
|||||||
return QSE_RBT_WALK_FORWARD;
|
return QSE_RBT_WALK_FORWARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qse_awk_clear (qse_awk_t* awk)
|
void qse_awk_clear (qse_awk_t* awk)
|
||||||
{
|
{
|
||||||
qse_awk_ecb_t* ecb;
|
qse_awk_ecb_t* ecb;
|
||||||
|
|
||||||
for (ecb = awk->ecb; ecb; ecb = ecb->next)
|
for (ecb = awk->ecb; ecb; ecb = ecb->next)
|
||||||
if (ecb->clear) ecb->clear (awk);
|
if (ecb->clear) ecb->clear (awk);
|
||||||
|
|
||||||
awk->stopall = 0;
|
awk->stopall = 0;
|
||||||
|
|
||||||
@ -368,7 +384,6 @@ int qse_awk_clear (qse_awk_t* awk)
|
|||||||
* failed. this table is cleared in qse_awk_parse().
|
* failed. this table is cleared in qse_awk_parse().
|
||||||
* qse_awk_claersionames (awk);
|
* qse_awk_claersionames (awk);
|
||||||
*/
|
*/
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qse_mmgr_t* qse_awk_getmmgr (qse_awk_t* awk)
|
qse_mmgr_t* qse_awk_getmmgr (qse_awk_t* awk)
|
||||||
@ -429,8 +444,7 @@ int qse_awk_setopt (qse_awk_t* awk, qse_awk_opt_t id, const void* value)
|
|||||||
if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
|
if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
|
||||||
|
|
||||||
idx = id - QSE_AWK_MODPREFIX;
|
idx = id - QSE_AWK_MODPREFIX;
|
||||||
if (awk->opt.mod[idx].ptr)
|
if (awk->opt.mod[idx].ptr) QSE_AWK_FREE (awk, awk->opt.mod[idx].ptr);
|
||||||
QSE_MMGR_FREE (awk->mmgr, awk->opt.mod[idx].ptr);
|
|
||||||
|
|
||||||
awk->opt.mod[idx] = tmp;
|
awk->opt.mod[idx] = tmp;
|
||||||
return 0;
|
return 0;
|
||||||
@ -440,8 +454,7 @@ int qse_awk_setopt (qse_awk_t* awk, qse_awk_opt_t id, const void* value)
|
|||||||
{
|
{
|
||||||
qse_cstr_t tmp;
|
qse_cstr_t tmp;
|
||||||
if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
|
if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
|
||||||
if (awk->opt.incldirs.ptr)
|
if (awk->opt.incldirs.ptr) QSE_AWK_FREE (awk, awk->opt.incldirs.ptr);
|
||||||
QSE_MMGR_FREE (awk->mmgr, awk->opt.incldirs.ptr);
|
|
||||||
awk->opt.incldirs = tmp;
|
awk->opt.incldirs = tmp;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -360,4 +360,16 @@ struct qse_awk_mod_data_t
|
|||||||
qse_awk_mod_t mod;
|
qse_awk_mod_t mod;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int qse_awk_init (qse_awk_t* awk, qse_mmgr_t* mmgr, const qse_awk_prm_t* prm);
|
||||||
|
void qse_awk_fini (qse_awk_t* awk);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -619,7 +619,7 @@ oops:
|
|||||||
prev = awk->sio.inp->prev;
|
prev = awk->sio.inp->prev;
|
||||||
|
|
||||||
QSE_ASSERT (awk->sio.inp->name != QSE_NULL);
|
QSE_ASSERT (awk->sio.inp->name != QSE_NULL);
|
||||||
QSE_MMGR_FREE (awk->mmgr, awk->sio.inp);
|
QSE_AWK_FREE (awk, awk->sio.inp);
|
||||||
|
|
||||||
awk->sio.inp = prev;
|
awk->sio.inp = prev;
|
||||||
}
|
}
|
||||||
@ -660,7 +660,7 @@ void qse_awk_clearsionames (qse_awk_t* awk)
|
|||||||
{
|
{
|
||||||
cur = awk->sio_names;
|
cur = awk->sio_names;
|
||||||
awk->sio_names = cur->link;
|
awk->sio_names = cur->link;
|
||||||
QSE_MMGR_FREE (awk->mmgr, cur);
|
QSE_AWK_FREE (awk, cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -726,7 +726,7 @@ static int end_include (qse_awk_t* awk)
|
|||||||
awk->sio.inp = awk->sio.inp->prev;
|
awk->sio.inp = awk->sio.inp->prev;
|
||||||
|
|
||||||
QSE_ASSERT (cur->name != QSE_NULL);
|
QSE_ASSERT (cur->name != QSE_NULL);
|
||||||
QSE_MMGR_FREE (awk->mmgr, cur);
|
QSE_AWK_FREE (awk, cur);
|
||||||
awk->parse.depth.incl--;
|
awk->parse.depth.incl--;
|
||||||
|
|
||||||
if (x != 0)
|
if (x != 0)
|
||||||
@ -822,7 +822,7 @@ static int begin_include (qse_awk_t* awk)
|
|||||||
oops:
|
oops:
|
||||||
/* i don't need to free 'link' here since it's linked to awk->sio_names
|
/* i don't need to free 'link' here since it's linked to awk->sio_names
|
||||||
* that's freed at the beginning of qse_awk_parse() or by qse_awk_close(). */
|
* that's freed at the beginning of qse_awk_parse() or by qse_awk_close(). */
|
||||||
if (arg) QSE_MMGR_FREE (awk->mmgr, arg);
|
if (arg) QSE_AWK_FREE (awk, arg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5135,7 +5135,7 @@ static qse_awk_nde_t* parse_primary_ident (
|
|||||||
{
|
{
|
||||||
/* the FNC node takes the full name but other
|
/* the FNC node takes the full name but other
|
||||||
* nodes don't. so i need to free it. i know it's ugly. */
|
* nodes don't. so i need to free it. i know it's ugly. */
|
||||||
QSE_MMGR_FREE (awk->mmgr, full.ptr);
|
QSE_AWK_FREE (awk, full.ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1653,7 +1653,7 @@ oops:
|
|||||||
{
|
{
|
||||||
qse_awk_rtx_refdownval (rtx, v[--i]);
|
qse_awk_rtx_refdownval (rtx, v[--i]);
|
||||||
}
|
}
|
||||||
QSE_MMGR_FREE (rtx->awk->mmgr, v);
|
QSE_AWK_FREE (rtx->awk, v);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,9 +379,9 @@ static void* custom_awk_modsym (qse_awk_t* awk, void* handle, const qse_char_t*
|
|||||||
static int add_globals (qse_awk_t* awk);
|
static int add_globals (qse_awk_t* awk);
|
||||||
static int add_functions (qse_awk_t* awk);
|
static int add_functions (qse_awk_t* awk);
|
||||||
|
|
||||||
qse_awk_t* qse_awk_openstd (qse_size_t xtnsize)
|
qse_awk_t* qse_awk_openstd (qse_size_t xtnsize, qse_awk_errnum_t* errnum)
|
||||||
{
|
{
|
||||||
return qse_awk_openstdwithmmgr (QSE_MMGR_GETDFL(), xtnsize);
|
return qse_awk_openstdwithmmgr (QSE_MMGR_GETDFL(), xtnsize, errnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fini_xtn (qse_awk_t* awk)
|
static void fini_xtn (qse_awk_t* awk)
|
||||||
@ -397,7 +397,7 @@ static void clear_xtn (qse_awk_t* awk)
|
|||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
}
|
}
|
||||||
|
|
||||||
qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_errnum_t* errnum)
|
||||||
{
|
{
|
||||||
qse_awk_t* awk;
|
qse_awk_t* awk;
|
||||||
qse_awk_prm_t prm;
|
qse_awk_prm_t prm;
|
||||||
@ -411,7 +411,7 @@ qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
prm.modsym = custom_awk_modsym;
|
prm.modsym = custom_awk_modsym;
|
||||||
|
|
||||||
/* create an object */
|
/* create an object */
|
||||||
awk = qse_awk_open (mmgr, QSE_SIZEOF(xtn_t) + xtnsize, &prm);
|
awk = qse_awk_open (mmgr, QSE_SIZEOF(xtn_t) + xtnsize, &prm, errnum);
|
||||||
if (awk == QSE_NULL) return QSE_NULL;
|
if (awk == QSE_NULL) return QSE_NULL;
|
||||||
|
|
||||||
/* initialize extension */
|
/* initialize extension */
|
||||||
|
@ -102,10 +102,7 @@ qse_dir_t* qse_dir_open (
|
|||||||
}
|
}
|
||||||
else QSE_MEMSET (dir + 1, 0, xtnsize);
|
else QSE_MEMSET (dir + 1, 0, xtnsize);
|
||||||
}
|
}
|
||||||
else
|
else if (errnum) *errnum = QSE_DIR_ENOMEM;
|
||||||
{
|
|
||||||
if (errnum) *errnum = QSE_DIR_ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ qse_dll_t* qse_dll_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (dll + 1, 0, xtnsize);
|
QSE_MEMSET (QSE_XTN(dll), 0, xtnsize);
|
||||||
return dll;
|
return dll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,15 +45,16 @@ qse_env_t* qse_env_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, int fromcurenv)
|
|||||||
qse_env_t* env;
|
qse_env_t* env;
|
||||||
|
|
||||||
env = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_env_t) + xtnsize);
|
env = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_env_t) + xtnsize);
|
||||||
if (env == QSE_NULL) return QSE_NULL;
|
if (env)
|
||||||
|
|
||||||
if (qse_env_init (env, mmgr, fromcurenv) <= -1)
|
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (mmgr, env);
|
if (qse_env_init (env, mmgr, fromcurenv) <= -1)
|
||||||
return QSE_NULL;
|
{
|
||||||
|
QSE_MMGR_FREE (mmgr, env);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
else QSE_MEMSET (QSE_XTN(env), 0, xtnsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (env + 1, 0, xtnsize);
|
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,20 +116,21 @@ static dossetfilesizel_t dos_set_file_size_l = QSE_NULL;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
qse_fio_t* qse_fio_open (
|
qse_fio_t* qse_fio_open (
|
||||||
qse_mmgr_t* mmgr, qse_size_t ext,
|
qse_mmgr_t* mmgr, qse_size_t xtnsize,
|
||||||
const qse_char_t* path, int flags, int mode)
|
const qse_char_t* path, int flags, int mode)
|
||||||
{
|
{
|
||||||
qse_fio_t* fio;
|
qse_fio_t* fio;
|
||||||
|
|
||||||
fio = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_fio_t) + ext);
|
fio = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_fio_t) + xtnsize);
|
||||||
if (fio == QSE_NULL) return QSE_NULL;
|
if (fio)
|
||||||
|
|
||||||
if (qse_fio_init (fio, mmgr, path, flags, mode) <= -1)
|
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (mmgr, fio);
|
if (qse_fio_init (fio, mmgr, path, flags, mode) <= -1)
|
||||||
return QSE_NULL;
|
{
|
||||||
|
QSE_MMGR_FREE (mmgr, fio);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
else QSE_MEMSET (QSE_XTN(fio), 0, xtnsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fio;
|
return fio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ htb_t* qse_htb_open (
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (htb + 1, 0, xtnsize);
|
QSE_MEMSET (QSE_XTN(htb), 0, xtnsize);
|
||||||
return htb;
|
return htb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,11 +92,11 @@ static QSE_INLINE slot_t* alloc_slot (lda_t* lda, void* dptr, size_t dlen)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
lda_t* qse_lda_open (mmgr_t* mmgr, size_t ext, size_t capa)
|
lda_t* qse_lda_open (mmgr_t* mmgr, size_t xtnsize, size_t capa)
|
||||||
{
|
{
|
||||||
lda_t* lda;
|
lda_t* lda;
|
||||||
|
|
||||||
lda = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(lda_t) + ext);
|
lda = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(lda_t) + xtnsize);
|
||||||
if (lda == QSE_NULL) return QSE_NULL;
|
if (lda == QSE_NULL) return QSE_NULL;
|
||||||
|
|
||||||
if (qse_lda_init (lda, mmgr, capa) <= -1)
|
if (qse_lda_init (lda, mmgr, capa) <= -1)
|
||||||
@ -105,6 +105,7 @@ lda_t* qse_lda_open (mmgr_t* mmgr, size_t ext, size_t capa)
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSE_MEMSET (QSE_XTN(lda), 0, xtnsize);
|
||||||
return lda;
|
return lda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,8 +249,9 @@ qse_mux_t* qse_mux_open (
|
|||||||
QSE_MMGR_FREE (mmgr, mux);
|
QSE_MMGR_FREE (mmgr, mux);
|
||||||
mux = QSE_NULL;
|
mux = QSE_NULL;
|
||||||
}
|
}
|
||||||
else QSE_MEMSET (mux + 1, 0, xtnsize);
|
else QSE_MEMSET (QSE_XTN(mux), 0, xtnsize);
|
||||||
}
|
}
|
||||||
|
else if (errnum) *errnum = QSE_MUX_ENOMEM;
|
||||||
|
|
||||||
return mux;
|
return mux;
|
||||||
}
|
}
|
||||||
|
@ -90,10 +90,7 @@ qse_pio_t* qse_pio_open (
|
|||||||
QSE_MMGR_FREE (mmgr, pio);
|
QSE_MMGR_FREE (mmgr, pio);
|
||||||
pio = QSE_NULL;
|
pio = QSE_NULL;
|
||||||
}
|
}
|
||||||
else
|
else QSE_MEMSET (QSE_XTN(pio), 0, xtnsize);
|
||||||
{
|
|
||||||
QSE_MEMSET (pio + 1, 0, xtnsize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pio;
|
return pio;
|
||||||
|
@ -60,7 +60,7 @@ qse_pma_t* qse_pma_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (pma + 1, 0, xtnsize);
|
QSE_MEMSET (QSE_XTN(pma), 0, xtnsize);
|
||||||
return pma;
|
return pma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,11 +131,11 @@ int qse_rex_init (qse_rex_t* rex, qse_mmgr_t* mmgr, qse_rex_node_t* code)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qse_rex_t* qse_rex_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_rex_node_t* code)
|
qse_rex_t* qse_rex_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_rex_node_t* code)
|
||||||
{
|
{
|
||||||
qse_rex_t* rex;
|
qse_rex_t* rex;
|
||||||
|
|
||||||
rex = (qse_rex_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_rex_t) + xtn);
|
rex = (qse_rex_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_rex_t) + xtnsize);
|
||||||
if (rex == QSE_NULL) return QSE_NULL;
|
if (rex == QSE_NULL) return QSE_NULL;
|
||||||
|
|
||||||
if (qse_rex_init (rex, mmgr, code) <= -1)
|
if (qse_rex_init (rex, mmgr, code) <= -1)
|
||||||
@ -144,6 +144,7 @@ qse_rex_t* qse_rex_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_rex_node_t* code)
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSE_MEMSET (QSE_XTN(rex), 0, xtnsize);
|
||||||
return rex;
|
return rex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,15 +103,15 @@ qse_sio_t* qse_sio_open (
|
|||||||
qse_sio_t* sio;
|
qse_sio_t* sio;
|
||||||
|
|
||||||
sio = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_sio_t) + xtnsize);
|
sio = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_sio_t) + xtnsize);
|
||||||
if (sio == QSE_NULL) return QSE_NULL;
|
if (sio)
|
||||||
|
|
||||||
if (qse_sio_init (sio, mmgr, file, flags) <= -1)
|
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (mmgr, sio);
|
if (qse_sio_init (sio, mmgr, file, flags) <= -1)
|
||||||
return QSE_NULL;
|
{
|
||||||
|
QSE_MMGR_FREE (mmgr, sio);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
else QSE_MEMSET (QSE_XTN(sio), 0, xtnsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (sio + 1, 0, xtnsize);
|
|
||||||
return sio;
|
return sio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ str_t* str_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_size_t capa)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QSE_MEMSET (str + 1, 0, xtnsize);
|
QSE_MEMSET (QSE_XTN(str), 0, xtnsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
@ -35,15 +35,16 @@ qse_tio_t* qse_tio_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, int flags)
|
|||||||
qse_tio_t* tio;
|
qse_tio_t* tio;
|
||||||
|
|
||||||
tio = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_tio_t) + xtnsize);
|
tio = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_tio_t) + xtnsize);
|
||||||
if (tio == QSE_NULL) return QSE_NULL;
|
if (tio)
|
||||||
|
|
||||||
if (qse_tio_init (tio, mmgr, flags) <= -1)
|
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (mmgr, tio);
|
if (qse_tio_init (tio, mmgr, flags) <= -1)
|
||||||
return QSE_NULL;
|
{
|
||||||
}
|
QSE_MMGR_FREE (mmgr, tio);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
QSE_MEMSET (tio + 1, 0, xtnsize);
|
else QSE_MEMSET (QSE_XTN(tio), 0, xtnsize);
|
||||||
|
}
|
||||||
return tio;
|
return tio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ qse_tre_t* qse_tre_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (tre + 1, 0, xtnsize);
|
QSE_MEMSET (QSE_XTN(tre), 0, xtnsize);
|
||||||
return tre;
|
return tre;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ qse_xma_t* qse_xma_open (
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (xma + 1, 0, xtnsize);
|
QSE_MEMSET (QSE_XTN(xma), 0, xtnsize);
|
||||||
return xma;
|
return xma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,17 +127,16 @@ qse_htrd_t* qse_htrd_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
{
|
{
|
||||||
qse_htrd_t* htrd;
|
qse_htrd_t* htrd;
|
||||||
|
|
||||||
htrd = (qse_htrd_t*) QSE_MMGR_ALLOC (
|
htrd = (qse_htrd_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_htrd_t) + xtnsize);
|
||||||
mmgr, QSE_SIZEOF(qse_htrd_t) + xtnsize
|
if (htrd)
|
||||||
);
|
|
||||||
if (htrd == QSE_NULL) return QSE_NULL;
|
|
||||||
|
|
||||||
if (qse_htrd_init (htrd, mmgr) <= -1)
|
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (htrd->mmgr, htrd);
|
if (qse_htrd_init (htrd, mmgr) <= -1)
|
||||||
return QSE_NULL;
|
{
|
||||||
|
QSE_MMGR_FREE (mmgr, htrd);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
else QSE_MEMSET (QSE_XTN(htrd), 0, xtnsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return htrd;
|
return htrd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,18 +43,18 @@ qse_httpd_t* qse_httpd_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
{
|
{
|
||||||
qse_httpd_t* httpd;
|
qse_httpd_t* httpd;
|
||||||
|
|
||||||
httpd = (qse_httpd_t*) QSE_MMGR_ALLOC (
|
httpd = (qse_httpd_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_httpd_t) + xtnsize);
|
||||||
mmgr, QSE_SIZEOF(*httpd) + xtnsize
|
if (httpd)
|
||||||
);
|
|
||||||
if (httpd == QSE_NULL) return QSE_NULL;
|
|
||||||
|
|
||||||
if (qse_httpd_init (httpd, mmgr) <= -1)
|
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (httpd->mmgr, httpd);
|
|
||||||
return QSE_NULL;
|
if (qse_httpd_init (httpd, mmgr) <= -1)
|
||||||
|
{
|
||||||
|
QSE_MMGR_FREE (mmgr, httpd);
|
||||||
|
return QSE_NULL;
|
||||||
|
}
|
||||||
|
else QSE_MEMSET (QSE_XTN(httpd), 0, xtnsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MEMSET (httpd + 1, 0, xtnsize);
|
|
||||||
return httpd;
|
return httpd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ qse_upxd_t* qse_upxd_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
|
|
||||||
if (qse_upxd_init (upxd, mmgr) <= -1)
|
if (qse_upxd_init (upxd, mmgr) <= -1)
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (upxd->mmgr, upxd);
|
QSE_MMGR_FREE (mmgr, upxd);
|
||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ qse_sed_t* qse_sed_open (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
|||||||
{
|
{
|
||||||
if (qse_sed_init (sed, mmgr) <= -1)
|
if (qse_sed_init (sed, mmgr) <= -1)
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (sed->mmgr, sed);
|
QSE_MMGR_FREE (mmgr, sed);
|
||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
else QSE_MEMSET (QSE_XTN(sed), 0, xtnsize);
|
else QSE_MEMSET (QSE_XTN(sed), 0, xtnsize);
|
||||||
|
@ -35,7 +35,7 @@ qse_xli_t* qse_xli_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_size_t rootxt
|
|||||||
{
|
{
|
||||||
if (qse_xli_init (xli, mmgr, rootxtnsize) <= -1)
|
if (qse_xli_init (xli, mmgr, rootxtnsize) <= -1)
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (xli->mmgr, xli);
|
QSE_MMGR_FREE (mmgr, xli);
|
||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
else QSE_MEMSET (QSE_XTN(xli), 0, xtnsize);
|
else QSE_MEMSET (QSE_XTN(xli), 0, xtnsize);
|
||||||
@ -78,11 +78,11 @@ int qse_xli_init (qse_xli_t* xli, qse_mmgr_t* mmgr, qse_size_t rootxtnsize)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
qse_xli_seterrnum (xli, QSE_XLI_ENOMEM, QSE_NULL);
|
|
||||||
if (xli->root) QSE_MMGR_FREE (mmgr, xli->root);
|
if (xli->root) QSE_MMGR_FREE (mmgr, xli->root);
|
||||||
if (xli->schema) qse_rbt_close (xli->schema);
|
if (xli->schema) qse_rbt_close (xli->schema);
|
||||||
if (xli->tok.name) qse_str_close (xli->tok.name);
|
if (xli->tok.name) qse_str_close (xli->tok.name);
|
||||||
if (xli->dotted_curkey) qse_str_close (xli->dotted_curkey);
|
if (xli->dotted_curkey) qse_str_close (xli->dotted_curkey);
|
||||||
|
qse_xli_seterrnum (xli, QSE_XLI_ENOMEM, QSE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ int main ()
|
|||||||
qse_openstdsios ();
|
qse_openstdsios ();
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -85,7 +85,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -93,7 +93,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
console_t* con;
|
console_t* con;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -27,7 +27,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
int ret = -1, i, opt;
|
int ret = -1, i, opt;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -19,7 +19,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
int ret = -1, i, opt;
|
int ret = -1, i, opt;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -20,7 +20,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
qse_awk_fun_t* fun;
|
qse_awk_fun_t* fun;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -26,7 +26,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* create a standard awk object */
|
/* create a standard awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -26,7 +26,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
ginfo_t* ginfo;
|
ginfo_t* ginfo;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (QSE_SIZEOF(*ginfo));
|
awk = qse_awk_openstd (QSE_SIZEOF(*ginfo), QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -62,7 +62,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
qse_awk_fnc_spec_t spec;
|
qse_awk_fnc_spec_t spec;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -74,7 +74,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
qse_awk_fnc_spec_t spec;
|
qse_awk_fnc_spec_t spec;
|
||||||
|
|
||||||
/* create an awk object */
|
/* create an awk object */
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -74,7 +74,7 @@ int main ()
|
|||||||
|
|
||||||
qse_openstdsios ();
|
qse_openstdsios ();
|
||||||
|
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -38,7 +38,7 @@ int main ()
|
|||||||
|
|
||||||
qse_openstdsios ();
|
qse_openstdsios ();
|
||||||
|
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
@ -47,7 +47,7 @@ int main ()
|
|||||||
|
|
||||||
qse_openstdsios ();
|
qse_openstdsios ();
|
||||||
|
|
||||||
awk = qse_awk_openstd (0);
|
awk = qse_awk_openstd (0, QSE_NULL);
|
||||||
if (awk == QSE_NULL)
|
if (awk == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open awk\n"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user