added the _instsize field to qse_awk_t and qse_awk_rtx_t to get rid of qse_awk_getxtnstd() and qse_awk_rtx_getxtnstd()
This commit is contained in:
parent
f4a8a5bff7
commit
35a24a56d1
@ -78,8 +78,8 @@ use this extension area to store data associated with the object.
|
|||||||
You can specify the size of the extension area when calling qse_awk_open(),
|
You can specify the size of the extension area when calling qse_awk_open(),
|
||||||
qse_awk_rtx_open(), qse_awk_openstd(), and qse_awk_rtx_openstd().
|
qse_awk_rtx_open(), qse_awk_openstd(), and qse_awk_rtx_openstd().
|
||||||
These functions iniitlize the area to zeros. You can get the pointer
|
These functions iniitlize the area to zeros. You can get the pointer
|
||||||
to the beginning of the area with qse_awk_getxtn(), qse_awk_rtx_getxtn(),
|
to the beginning of the area with qse_awk_getxtn() and qse_awk_rtx_getxtn().
|
||||||
qse_awk_getxtnstd(), qse_awk_rtx_getxtnstd() respectively.
|
|
||||||
|
|
||||||
In the sample above, the string and the buffer used for I/O customization
|
In the sample above, the string and the buffer used for I/O customization
|
||||||
are declared globally. When you have multiple runtime contexts and independent
|
are declared globally. When you have multiple runtime contexts and independent
|
||||||
|
@ -1411,7 +1411,7 @@ private:
|
|||||||
void fini_runctx ();
|
void fini_runctx ();
|
||||||
int dispatch_function (Run* run, const fnc_info_t* fi);
|
int dispatch_function (Run* run, const fnc_info_t* fi);
|
||||||
|
|
||||||
static const char_t* xerrstr (const awk_t* a, errnum_t num);
|
static const char_t* xerrstr (awk_t* a, errnum_t num);
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
@ -93,8 +93,9 @@ typedef qse_flt_t qse_awk_flt_t;
|
|||||||
typedef struct qse_awk_t qse_awk_t;
|
typedef struct qse_awk_t qse_awk_t;
|
||||||
|
|
||||||
#define QSE_AWK_HDR \
|
#define QSE_AWK_HDR \
|
||||||
qse_mmgr_t* mmgr; \
|
qse_size_t _instsize; \
|
||||||
qse_cmgr_t* cmgr
|
qse_mmgr_t* _mmgr; \
|
||||||
|
qse_cmgr_t* _cmgr
|
||||||
|
|
||||||
typedef struct qse_awk_alt_t qse_awk_alt_t;
|
typedef struct qse_awk_alt_t qse_awk_alt_t;
|
||||||
struct qse_awk_alt_t
|
struct qse_awk_alt_t
|
||||||
@ -131,6 +132,7 @@ struct qse_awk_alt_t
|
|||||||
typedef struct qse_awk_rtx_t qse_awk_rtx_t;
|
typedef struct qse_awk_rtx_t qse_awk_rtx_t;
|
||||||
|
|
||||||
#define QSE_AWK_RTX_HDR \
|
#define QSE_AWK_RTX_HDR \
|
||||||
|
qse_size_t _instsize; \
|
||||||
int id; \
|
int id; \
|
||||||
qse_awk_t* awk
|
qse_awk_t* awk
|
||||||
|
|
||||||
@ -1385,7 +1387,7 @@ typedef struct qse_awk_errinf_t qse_awk_errinf_t;
|
|||||||
* object with the qse_awk_seterrstr() function to customize an error string.
|
* object with the qse_awk_seterrstr() function to customize an error string.
|
||||||
*/
|
*/
|
||||||
typedef const qse_char_t* (*qse_awk_errstr_t) (
|
typedef const qse_char_t* (*qse_awk_errstr_t) (
|
||||||
const qse_awk_t* awk, /**< awk */
|
qse_awk_t* awk, /**< awk */
|
||||||
qse_awk_errnum_t num /**< error number */
|
qse_awk_errnum_t num /**< error number */
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1562,23 +1564,17 @@ QSE_EXPORT void qse_awk_close (
|
|||||||
* qse_awk_open().
|
* qse_awk_open().
|
||||||
*/
|
*/
|
||||||
#if defined(QSE_HAVE_INLINE)
|
#if defined(QSE_HAVE_INLINE)
|
||||||
static QSE_INLINE qse_mmgr_t* qse_awk_getmmgr (qse_awk_t* awk) { return ((qse_awk_alt_t*)awk)->mmgr; }
|
static QSE_INLINE void* qse_awk_getxtn (qse_awk_t* awk) { return (void*)((qse_uint8_t*)awk + ((qse_awk_alt_t*)awk)->_instsize); }
|
||||||
static QSE_INLINE qse_cmgr_t* qse_awk_getcmgr (qse_awk_t* awk) { return ((qse_awk_alt_t*)awk)->cmgr; }
|
static QSE_INLINE qse_mmgr_t* qse_awk_getmmgr (qse_awk_t* awk) { return ((qse_awk_alt_t*)awk)->_mmgr; }
|
||||||
static QSE_INLINE void qse_awk_setcmgr (qse_awk_t* awk, qse_cmgr_t* cmgr) { ((qse_awk_alt_t*)awk)->cmgr = cmgr; }
|
static QSE_INLINE qse_cmgr_t* qse_awk_getcmgr (qse_awk_t* awk) { return ((qse_awk_alt_t*)awk)->_cmgr; }
|
||||||
|
static QSE_INLINE void qse_awk_setcmgr (qse_awk_t* awk, qse_cmgr_t* cmgr) { ((qse_awk_alt_t*)awk)->_cmgr = cmgr; }
|
||||||
#else
|
#else
|
||||||
# define qse_awk_getmmgr(awk) (((qse_awk_alt_t*)(awk))->mmgr)
|
# define qse_awk_getxtn(awk) ((void*)((qse_uint8_t*)awk + ((qse_awk_alt_t*)awk)->_instsize))
|
||||||
# define qse_awk_getcmgr(awk) (((qse_awk_alt_t*)(awk))->cmgr)
|
# define qse_awk_getmmgr(awk) (((qse_awk_alt_t*)(awk))->_mmgr)
|
||||||
# define qse_awk_setcmgr(awk,_cmgr) (((qse_awk_alt_t*)(awk))->cmgr = (_cmgr))
|
# define qse_awk_getcmgr(awk) (((qse_awk_alt_t*)(awk))->_cmgr)
|
||||||
|
# define qse_awk_setcmgr(awk,_cmgr) (((qse_awk_alt_t*)(awk))->_cmgr = (_cmgr))
|
||||||
#endif /* QSE_HAVE_INLINE */
|
#endif /* QSE_HAVE_INLINE */
|
||||||
|
|
||||||
/**
|
|
||||||
* The qse_awk_getxtn() function gets the poniter to the beginning
|
|
||||||
* of the extension area created with qse_awk_open ().
|
|
||||||
*/
|
|
||||||
QSE_EXPORT void* qse_awk_getxtn (
|
|
||||||
qse_awk_t* awk
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_getprm() function retrieves primitive functions
|
* The qse_awk_getprm() function retrieves primitive functions
|
||||||
* associated. Actual function pointers are copied into a
|
* associated. Actual function pointers are copied into a
|
||||||
@ -1914,10 +1910,10 @@ QSE_EXPORT void* qse_awk_callocmem (
|
|||||||
#if defined(QSE_HAVE_INLINE)
|
#if defined(QSE_HAVE_INLINE)
|
||||||
static QSE_INLINE void qse_awk_freemem (qse_awk_t* awk, void* ptr)
|
static QSE_INLINE void qse_awk_freemem (qse_awk_t* awk, void* ptr)
|
||||||
{
|
{
|
||||||
QSE_MMGR_FREE (((qse_awk_alt_t*)(awk))->mmgr, ptr);
|
QSE_MMGR_FREE (((qse_awk_alt_t*)(awk))->_mmgr, ptr);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define qse_awk_freemem(awk, ptr) QSE_MMGR_FREE(((qse_awk_alt_t*)(awk))->mmgr, ptr);
|
# define qse_awk_freemem(awk, ptr) QSE_MMGR_FREE(((qse_awk_alt_t*)(awk))->_mmgr, ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -2282,6 +2278,15 @@ QSE_EXPORT int qse_awk_rtx_setofilename (
|
|||||||
|
|
||||||
#if defined(QSE_HAVE_INLINE)
|
#if defined(QSE_HAVE_INLINE)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The qse_awk_rtx_getxtn() function gets the pointer to the extension area
|
||||||
|
* created with qse_awk_rtx_open().
|
||||||
|
*/
|
||||||
|
static QSE_INLINE void* qse_awk_rtx_getxtn (qse_awk_rtx_t* rtx)
|
||||||
|
{
|
||||||
|
return (void*)((qse_uint8_t*)rtx + ((qse_awk_rtx_alt_t*)rtx)->_instsize);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_rtx_getawk() function gets the owner of a runtime context \a rtx.
|
* The qse_awk_rtx_getawk() function gets the owner of a runtime context \a rtx.
|
||||||
* \return owner of a runtime context \a rtx.
|
* \return owner of a runtime context \a rtx.
|
||||||
@ -2306,20 +2311,13 @@ static QSE_INLINE qse_cmgr_t* qse_awk_rtx_getcmgr (qse_awk_rtx_t* rtx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
# define qse_awk_rtx_getxtn(rtx) ((void*)((qse_uint8_t*)rtx + ((qse_awk_rtx_alt_t*)rtx)->_instsize))
|
||||||
# define qse_awk_rtx_getawk(rtx) (((qse_awk_rtx_alt_t*)(rtx))->awk)
|
# define qse_awk_rtx_getawk(rtx) (((qse_awk_rtx_alt_t*)(rtx))->awk)
|
||||||
# define qse_awk_rtx_getmmgr(rtx) (qse_awk_getmmgr(qse_awk_rtx_getawk(rtx)))
|
# define qse_awk_rtx_getmmgr(rtx) (qse_awk_getmmgr(qse_awk_rtx_getawk(rtx)))
|
||||||
# define qse_awk_rtx_getcmgr(rtx) (qse_awk_getcmgr(qse_awk_rtx_getawk(rtx)))
|
# define qse_awk_rtx_getcmgr(rtx) (qse_awk_getcmgr(qse_awk_rtx_getawk(rtx)))
|
||||||
|
|
||||||
#endif /* QSE_HAVE_INLINE */
|
#endif /* QSE_HAVE_INLINE */
|
||||||
|
|
||||||
/**
|
|
||||||
* The qse_awk_rtx_getxtn() function gets the pointer to the extension area
|
|
||||||
* created with qse_awk_rtx_open().
|
|
||||||
*/
|
|
||||||
QSE_EXPORT void* qse_awk_rtx_getxtn (
|
|
||||||
qse_awk_rtx_t* rtx /**< runtime context */
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_rtx_getnvmap() gets the map of named variables
|
* The qse_awk_rtx_getnvmap() gets the map of named variables
|
||||||
*/
|
*/
|
||||||
|
@ -117,15 +117,6 @@ QSE_EXPORT qse_awk_t* qse_awk_openstdwithmmgr (
|
|||||||
qse_awk_errnum_t* errnum /**< pointer to an error number variable */
|
qse_awk_errnum_t* errnum /**< pointer to an error number variable */
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* The qse_awk_getxtnstd() gets the pointer to extension area created with
|
|
||||||
* qse_awk_openstd() or qse_awk_openstdwithmmgr(). You must not call
|
|
||||||
* qse_awk_getxtn() for sunch an object.
|
|
||||||
*/
|
|
||||||
QSE_EXPORT void* qse_awk_getxtnstd (
|
|
||||||
qse_awk_t* awk
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_parsestd() functions parses source script.
|
* The qse_awk_parsestd() functions parses source script.
|
||||||
* The code below shows how to parse a literal string 'BEGIN { print 10; }'
|
* The code below shows how to parse a literal string 'BEGIN { print 10; }'
|
||||||
|
@ -50,6 +50,14 @@ struct rxtn_t
|
|||||||
|
|
||||||
Awk::NoSource Awk::Source::NONE;
|
Awk::NoSource Awk::Source::NONE;
|
||||||
|
|
||||||
|
#if defined(QSE_HAVE_INLINE)
|
||||||
|
static QSE_INLINE xtn_t* GET_XTN(qse_awk_t* awk) { return (xtn_t*)((qse_uint8_t*)qse_awk_getxtn(awk) - QSE_SIZEOF(xtn_t)); }
|
||||||
|
static QSE_INLINE rxtn_t* GET_RXTN(qse_awk_rtx_t* rtx) { return (rxtn_t*)((qse_uint8_t*)qse_awk_rtx_getxtn(rtx) - QSE_SIZEOF(rxtn_t)); }
|
||||||
|
#else
|
||||||
|
#define GET_XTN(awk) ((xtn_t*)((qse_uint8_t*)qse_awk_getxtn(awk) - QSE_SIZEOF(xtn_t)))
|
||||||
|
#define GET_RXTN(rtx) ((rxtn_t*)((qse_uint8_t*)qse_awk_rtx_getxtn(rtx) - QSE_SIZEOF(rxtn_t)))
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
// Awk::RIO
|
// Awk::RIO
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
@ -1039,9 +1047,9 @@ const Awk::char_t* Awk::getErrorString (errnum_t num) const
|
|||||||
return dflerrstr (awk, num);
|
return dflerrstr (awk, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Awk::char_t* Awk::xerrstr (const awk_t* a, errnum_t num)
|
const Awk::char_t* Awk::xerrstr (awk_t* a, errnum_t num)
|
||||||
{
|
{
|
||||||
Awk* awk = *(Awk**)QSE_XTN(a);
|
Awk* awk = *(Awk**)GET_XTN(a);
|
||||||
return awk->getErrorString (num);
|
return awk->getErrorString (num);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,8 +1158,10 @@ int Awk::open ()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->awk->_instsize += QSE_SIZEOF(xtn_t);
|
||||||
|
|
||||||
// associate this Awk object with the underlying awk object
|
// associate this Awk object with the underlying awk object
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (this->awk);
|
xtn_t* xtn = (xtn_t*)GET_XTN(this->awk);
|
||||||
xtn->awk = this;
|
xtn->awk = this;
|
||||||
xtn->ecb.close = fini_xtn;
|
xtn->ecb.close = fini_xtn;
|
||||||
xtn->ecb.clear = clear_xtn;
|
xtn->ecb.clear = clear_xtn;
|
||||||
@ -1229,7 +1239,7 @@ void Awk::close ()
|
|||||||
qse_cmgr_t* Awk::getCmgr () const
|
qse_cmgr_t* Awk::getCmgr () const
|
||||||
{
|
{
|
||||||
if (!this->awk) return QSE_NULL;
|
if (!this->awk) return QSE_NULL;
|
||||||
return this->awk->cmgr;
|
return qse_awk_getcmgr(this->awk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Awk::uponClosing ()
|
void Awk::uponClosing ()
|
||||||
@ -1368,7 +1378,7 @@ int Awk::init_runctx ()
|
|||||||
|
|
||||||
runctx.rtx = rtx;
|
runctx.rtx = rtx;
|
||||||
|
|
||||||
rxtn_t* rxtn = (rxtn_t*)QSE_XTN(rtx);
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
rxtn->run = &runctx;
|
rxtn->run = &runctx;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1766,7 +1776,7 @@ Awk::ssize_t Awk::readSource (
|
|||||||
awk_t* awk, sio_cmd_t cmd, sio_arg_t* arg,
|
awk_t* awk, sio_cmd_t cmd, sio_arg_t* arg,
|
||||||
char_t* data, size_t count)
|
char_t* data, size_t count)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
Source::Data sdat (xtn->awk, Source::READ, arg);
|
Source::Data sdat (xtn->awk, Source::READ, arg);
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
@ -1786,7 +1796,7 @@ Awk::ssize_t Awk::writeSource (
|
|||||||
awk_t* awk, qse_awk_sio_cmd_t cmd, sio_arg_t* arg,
|
awk_t* awk, qse_awk_sio_cmd_t cmd, sio_arg_t* arg,
|
||||||
char_t* data, size_t count)
|
char_t* data, size_t count)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
Source::Data sdat (xtn->awk, Source::WRITE, arg);
|
Source::Data sdat (xtn->awk, Source::WRITE, arg);
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
@ -1804,7 +1814,7 @@ Awk::ssize_t Awk::writeSource (
|
|||||||
|
|
||||||
Awk::ssize_t Awk::pipeHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
Awk::ssize_t Awk::pipeHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
||||||
{
|
{
|
||||||
rxtn_t* rxtn = (rxtn_t*)QSE_XTN(rtx);
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
Awk* awk = rxtn->run->awk;
|
Awk* awk = rxtn->run->awk;
|
||||||
|
|
||||||
QSE_ASSERT ((riod->type & 0xFF) == QSE_AWK_RIO_PIPE);
|
QSE_ASSERT ((riod->type & 0xFF) == QSE_AWK_RIO_PIPE);
|
||||||
@ -1868,7 +1878,7 @@ Awk::ssize_t Awk::pipeHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void*
|
|||||||
|
|
||||||
Awk::ssize_t Awk::fileHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
Awk::ssize_t Awk::fileHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
||||||
{
|
{
|
||||||
rxtn_t* rxtn = (rxtn_t*)QSE_XTN(rtx);
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
Awk* awk = rxtn->run->awk;
|
Awk* awk = rxtn->run->awk;
|
||||||
|
|
||||||
QSE_ASSERT ((riod->type & 0xFF) == QSE_AWK_RIO_FILE);
|
QSE_ASSERT ((riod->type & 0xFF) == QSE_AWK_RIO_FILE);
|
||||||
@ -1932,7 +1942,7 @@ Awk::ssize_t Awk::fileHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void*
|
|||||||
|
|
||||||
Awk::ssize_t Awk::consoleHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
Awk::ssize_t Awk::consoleHandler (rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, void* data, size_t count)
|
||||||
{
|
{
|
||||||
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
Awk* awk = rxtn->run->awk;
|
Awk* awk = rxtn->run->awk;
|
||||||
|
|
||||||
QSE_ASSERT ((riod->type & 0xFF) == QSE_AWK_RIO_CONSOLE);
|
QSE_ASSERT ((riod->type & 0xFF) == QSE_AWK_RIO_CONSOLE);
|
||||||
@ -2114,37 +2124,37 @@ int Awk::nextConsole (Console& io)
|
|||||||
|
|
||||||
int Awk::functionHandler (rtx_t* rtx, const fnc_info_t* fi)
|
int Awk::functionHandler (rtx_t* rtx, const fnc_info_t* fi)
|
||||||
{
|
{
|
||||||
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
return rxtn->run->awk->dispatch_function (rxtn->run, fi);
|
return rxtn->run->awk->dispatch_function (rxtn->run, fi);
|
||||||
}
|
}
|
||||||
|
|
||||||
Awk::flt_t Awk::pow (awk_t* awk, flt_t x, flt_t y)
|
Awk::flt_t Awk::pow (awk_t* awk, flt_t x, flt_t y)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
return xtn->awk->pow (x, y);
|
return xtn->awk->pow (x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Awk::flt_t Awk::mod (awk_t* awk, flt_t x, flt_t y)
|
Awk::flt_t Awk::mod (awk_t* awk, flt_t x, flt_t y)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
return xtn->awk->mod (x, y);
|
return xtn->awk->mod (x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Awk::modopen (awk_t* awk, const mod_spec_t* spec)
|
void* Awk::modopen (awk_t* awk, const mod_spec_t* spec)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
return xtn->awk->modopen (spec);
|
return xtn->awk->modopen (spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Awk::modclose (awk_t* awk, void* handle)
|
void Awk::modclose (awk_t* awk, void* handle)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
xtn->awk->modclose (handle);
|
xtn->awk->modclose (handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Awk::modsym (awk_t* awk, void* handle, const char_t* name)
|
void* Awk::modsym (awk_t* awk, void* handle, const char_t* name)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
return xtn->awk->modsym (handle, name);
|
return xtn->awk->modsym (handle, name);
|
||||||
}
|
}
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
|
@ -82,9 +82,9 @@ typedef struct qse_awk_tree_t qse_awk_tree_t;
|
|||||||
# define QSE_AWK_MAX_RTX_STACK_LIMIT ((qse_size_t)1 << (QSE_SIZEOF_VOID_P * 4))
|
# define QSE_AWK_MAX_RTX_STACK_LIMIT ((qse_size_t)1 << (QSE_SIZEOF_VOID_P * 4))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define QSE_AWK_ALLOC(awk,size) QSE_MMGR_ALLOC((awk)->mmgr,size)
|
#define QSE_AWK_ALLOC(awk,size) QSE_MMGR_ALLOC(qse_awk_getmmgr(awk),size)
|
||||||
#define QSE_AWK_REALLOC(awk,ptr,size) QSE_MMGR_REALLOC((awk)->mmgr,ptr,size)
|
#define QSE_AWK_REALLOC(awk,ptr,size) QSE_MMGR_REALLOC(qse_awk_getmmgr(awk),ptr,size)
|
||||||
#define QSE_AWK_FREE(awk,ptr) QSE_MMGR_FREE((awk)->mmgr,ptr)
|
#define QSE_AWK_FREE(awk,ptr) QSE_MMGR_FREE(qse_awk_getmmgr(awk),ptr)
|
||||||
|
|
||||||
#define QSE_AWK_ISUPPER(awk,c) QSE_ISUPPER(c)
|
#define QSE_AWK_ISUPPER(awk,c) QSE_ISUPPER(c)
|
||||||
#define QSE_AWK_ISLOWER(awk,c) QSE_ISLOWER(c)
|
#define QSE_AWK_ISLOWER(awk,c) QSE_ISLOWER(c)
|
||||||
@ -128,8 +128,8 @@ typedef struct qse_awk_tree_t qse_awk_tree_t;
|
|||||||
#define QSE_AWK_TOWUPPER(awk,c) QSE_TOWUPPER(c)
|
#define QSE_AWK_TOWUPPER(awk,c) QSE_TOWUPPER(c)
|
||||||
#define QSE_AWK_TOWLOWER(awk,c) QSE_TOWLOWER(c)
|
#define QSE_AWK_TOWLOWER(awk,c) QSE_TOWLOWER(c)
|
||||||
|
|
||||||
#define QSE_AWK_STRDUP(awk,str) (qse_strdup(str,(awk)->mmgr))
|
#define QSE_AWK_STRDUP(awk,str) (qse_strdup(str,qse_awk_getmmgr(awk)))
|
||||||
#define QSE_AWK_STRXDUP(awk,str,len) (qse_strxdup(str,len,(awk)->mmgr))
|
#define QSE_AWK_STRXDUP(awk,str,len) (qse_strxdup(str,len,qse_awk_getmmgr(awk)))
|
||||||
|
|
||||||
#define QSE_AWK_BYTE_PRINTABLE(x) ((x) <= 0x7F && (x) != '\\' && QSE_ISMPRINT(x))
|
#define QSE_AWK_BYTE_PRINTABLE(x) ((x) <= 0x7F && (x) != '\\' && QSE_ISMPRINT(x))
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, const qse_awk_prm
|
|||||||
QSE_MMGR_FREE (mmgr, awk);
|
QSE_MMGR_FREE (mmgr, awk);
|
||||||
awk = QSE_NULL;
|
awk = QSE_NULL;
|
||||||
}
|
}
|
||||||
else QSE_MEMSET (QSE_XTN(awk), 0, xtnsize);
|
else QSE_MEMSET (awk + 1, 0, xtnsize);
|
||||||
}
|
}
|
||||||
else if (errnum) *errnum = QSE_AWK_ENOMEM;
|
else if (errnum) *errnum = QSE_AWK_ENOMEM;
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, const qse_awk_prm
|
|||||||
void qse_awk_close (qse_awk_t* awk)
|
void qse_awk_close (qse_awk_t* awk)
|
||||||
{
|
{
|
||||||
qse_awk_fini (awk);
|
qse_awk_fini (awk);
|
||||||
QSE_MMGR_FREE (awk->mmgr, 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)
|
int qse_awk_init (qse_awk_t* awk, qse_mmgr_t* mmgr, const qse_awk_prm_t* prm)
|
||||||
@ -145,8 +145,9 @@ int qse_awk_init (qse_awk_t* awk, qse_mmgr_t* mmgr, const qse_awk_prm_t* prm)
|
|||||||
QSE_MEMSET (awk, 0, QSE_SIZEOF(*awk));
|
QSE_MEMSET (awk, 0, QSE_SIZEOF(*awk));
|
||||||
|
|
||||||
/* remember the memory manager */
|
/* remember the memory manager */
|
||||||
awk->mmgr = mmgr;
|
awk->_instsize = QSE_SIZEOF(*awk);
|
||||||
awk->cmgr = qse_getdflcmgr();
|
awk->_mmgr = mmgr;
|
||||||
|
awk->_cmgr = qse_getdflcmgr();
|
||||||
|
|
||||||
/* initialize error handling fields */
|
/* initialize error handling fields */
|
||||||
awk->errinf.num = QSE_AWK_ENOERR;
|
awk->errinf.num = QSE_AWK_ENOERR;
|
||||||
@ -404,11 +405,6 @@ void qse_awk_clear (qse_awk_t* awk)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void* qse_awk_getxtn (qse_awk_t* awk)
|
|
||||||
{
|
|
||||||
return QSE_XTN(awk);
|
|
||||||
}
|
|
||||||
|
|
||||||
void qse_awk_getprm (qse_awk_t* awk, qse_awk_prm_t* prm)
|
void qse_awk_getprm (qse_awk_t* awk, qse_awk_prm_t* prm)
|
||||||
{
|
{
|
||||||
*prm = awk->prm;
|
*prm = awk->prm;
|
||||||
@ -423,7 +419,7 @@ static int dup_str_opt (qse_awk_t* awk, const void* value, qse_cstr_t* tmp)
|
|||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
tmp->ptr = qse_strdup(value, awk->mmgr);
|
tmp->ptr = qse_strdup(value, qse_awk_getmmgr(awk));
|
||||||
if (!tmp->ptr)
|
if (!tmp->ptr)
|
||||||
{
|
{
|
||||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
|
@ -1020,7 +1020,7 @@ static int __substitute (qse_awk_rtx_t* rtx, qse_awk_int_t max_count)
|
|||||||
s2_free = (qse_char_t*)s2.ptr;
|
s2_free = (qse_char_t*)s2.ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qse_str_init (&new, rtx->awk->mmgr, s2.len) <= -1)
|
if (qse_str_init (&new, qse_awk_rtx_getmmgr(rtx), s2.len) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
goto oops;
|
goto oops;
|
||||||
@ -1381,14 +1381,14 @@ int qse_awk_fnc_sprintf (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
|||||||
qse_mcstr_t cs0;
|
qse_mcstr_t cs0;
|
||||||
qse_mcstr_t x;
|
qse_mcstr_t x;
|
||||||
|
|
||||||
if (qse_mbs_init(&out, rtx->awk->mmgr, 256) <= -1)
|
if (qse_mbs_init(&out, qse_awk_rtx_getmmgr(rtx), 256) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
goto oops_mbs;
|
goto oops_mbs;
|
||||||
}
|
}
|
||||||
out_inited = 1;
|
out_inited = 1;
|
||||||
|
|
||||||
if (qse_mbs_init(&fbu, rtx->awk->mmgr, 256) <= -1)
|
if (qse_mbs_init(&fbu, qse_awk_rtx_getmmgr(rtx), 256) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
goto oops_mbs;
|
goto oops_mbs;
|
||||||
@ -1422,14 +1422,14 @@ int qse_awk_fnc_sprintf (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
|||||||
qse_cstr_t cs0;
|
qse_cstr_t cs0;
|
||||||
qse_cstr_t x;
|
qse_cstr_t x;
|
||||||
|
|
||||||
if (qse_str_init(&out, rtx->awk->mmgr, 256) <= -1)
|
if (qse_str_init(&out, qse_awk_rtx_getmmgr(rtx), 256) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
out_inited = 1;
|
out_inited = 1;
|
||||||
|
|
||||||
if (qse_str_init(&fbu, rtx->awk->mmgr, 256) <= -1)
|
if (qse_str_init(&fbu, qse_awk_rtx_getmmgr(rtx), 256) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
goto oops;
|
goto oops;
|
||||||
|
@ -72,7 +72,7 @@ qse_char_t* qse_awk_strxdup (qse_awk_t* awk, const qse_char_t* s, qse_size_t l)
|
|||||||
|
|
||||||
qse_char_t* qse_awk_cstrdup (qse_awk_t* awk, const qse_cstr_t* s)
|
qse_char_t* qse_awk_cstrdup (qse_awk_t* awk, const qse_cstr_t* s)
|
||||||
{
|
{
|
||||||
qse_char_t* ptr = qse_cstrdup(s, awk->mmgr);
|
qse_char_t* ptr = qse_cstrdup(s, qse_awk_getmmgr(awk));
|
||||||
if (!ptr) qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
if (!ptr) qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
@ -655,7 +655,7 @@ int qse_awk_buildrex (
|
|||||||
if (code || icode)
|
if (code || icode)
|
||||||
{
|
{
|
||||||
p = qse_buildrex (
|
p = qse_buildrex (
|
||||||
awk->mmgr, awk->opt.depth.s.rex_build,
|
qse_awk_getmmgr(awk), awk->opt.depth.s.rex_build,
|
||||||
((awk->opt.trait & QSE_AWK_REXBOUND)? 0: QSE_REX_NOBOUND),
|
((awk->opt.trait & QSE_AWK_REXBOUND)? 0: QSE_REX_NOBOUND),
|
||||||
ptn, len, &err
|
ptn, len, &err
|
||||||
);
|
);
|
||||||
@ -677,7 +677,7 @@ int qse_awk_buildrex (
|
|||||||
|
|
||||||
if (code)
|
if (code)
|
||||||
{
|
{
|
||||||
tre = qse_tre_open (awk->mmgr, 0);
|
tre = qse_tre_open(qse_awk_getmmgr(awk), 0);
|
||||||
if (tre == QSE_NULL)
|
if (tre == QSE_NULL)
|
||||||
{
|
{
|
||||||
*errnum = QSE_AWK_ENOMEM;
|
*errnum = QSE_AWK_ENOMEM;
|
||||||
@ -703,7 +703,7 @@ int qse_awk_buildrex (
|
|||||||
|
|
||||||
if (icode)
|
if (icode)
|
||||||
{
|
{
|
||||||
itre = qse_tre_open (awk->mmgr, 0);
|
itre = qse_tre_open(qse_awk_getmmgr(awk), 0);
|
||||||
if (itre == QSE_NULL)
|
if (itre == QSE_NULL)
|
||||||
{
|
{
|
||||||
if (tre) qse_tre_close (tre);
|
if (tre) qse_tre_close (tre);
|
||||||
@ -797,7 +797,7 @@ int qse_awk_matchrex (
|
|||||||
|
|
||||||
/* submatch is not supported */
|
/* submatch is not supported */
|
||||||
x = qse_matchrex (
|
x = qse_matchrex (
|
||||||
awk->mmgr, awk->opt.depth.s.rex_match, code,
|
qse_awk_getmmgr(awk), awk->opt.depth.s.rex_match, code,
|
||||||
(icase? QSE_REX_IGNORECASE: 0), str, substr, match, &err);
|
(icase? QSE_REX_IGNORECASE: 0), str, substr, match, &err);
|
||||||
if (x <= -1) *errnum = rexerr_to_errnum(err);
|
if (x <= -1) *errnum = rexerr_to_errnum(err);
|
||||||
return x;
|
return x;
|
||||||
@ -873,7 +873,7 @@ int qse_awk_rtx_matchrex (
|
|||||||
#if defined(USE_REX)
|
#if defined(USE_REX)
|
||||||
/* submatch not supported */
|
/* submatch not supported */
|
||||||
x = qse_matchrex (
|
x = qse_matchrex (
|
||||||
rtx->awk->mmgr, rtx->awk->opt.depth.s.rex_match,
|
qse_awk_rtx_getmmgr(rtx), rtx->awk->opt.depth.s.rex_match,
|
||||||
code, (icase? QSE_REX_IGNORECASE: 0),
|
code, (icase? QSE_REX_IGNORECASE: 0),
|
||||||
str, substr, match, &rexerr);
|
str, substr, match, &rexerr);
|
||||||
if (x <= -1) qse_awk_rtx_seterrnum (rtx, rexerr_to_errnum(rexerr), QSE_NULL);
|
if (x <= -1) qse_awk_rtx_seterrnum (rtx, rexerr_to_errnum(rexerr), QSE_NULL);
|
||||||
|
@ -4473,7 +4473,7 @@ static qse_awk_nde_t* parse_primary_mbs (qse_awk_t* awk, const qse_awk_loc_t* xl
|
|||||||
|
|
||||||
/* the MBS token doesn't include a character greater than 0xFF in awk->tok.name though it is a wide character string.
|
/* the MBS token doesn't include a character greater than 0xFF in awk->tok.name though it is a wide character string.
|
||||||
* so i simply use QSE_CMGR_MB8 to store it in a byte string */
|
* so i simply use QSE_CMGR_MB8 to store it in a byte string */
|
||||||
nde->ptr = qse_wcsntombsdupwithcmgr(QSE_STR_PTR(awk->tok.name), wcslen, &mbslen, awk->mmgr, qse_findcmgrbyid(QSE_CMGR_MB8));
|
nde->ptr = qse_wcsntombsdupwithcmgr(QSE_STR_PTR(awk->tok.name), wcslen, &mbslen, qse_awk_getmmgr(awk), qse_findcmgrbyid(QSE_CMGR_MB8));
|
||||||
if (!nde->ptr)
|
if (!nde->ptr)
|
||||||
{
|
{
|
||||||
qse_awk_seterror (awk, QSE_AWK_ENOMEM, QSE_NULL, xloc);
|
qse_awk_seterror (awk, QSE_AWK_ENOMEM, QSE_NULL, xloc);
|
||||||
|
@ -53,9 +53,6 @@
|
|||||||
# error unsupported. qse_awk_int_t too big
|
# error unsupported. qse_awk_int_t too big
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MMGR(rtx) ((rtx)->awk->mmgr)
|
|
||||||
#define CMGR(rtx) ((rtx)->awk->cmgr)
|
|
||||||
|
|
||||||
enum exit_level_t
|
enum exit_level_t
|
||||||
{
|
{
|
||||||
EXIT_NONE,
|
EXIT_NONE,
|
||||||
@ -710,11 +707,6 @@ int qse_awk_rtx_setofilename (qse_awk_rtx_t* rtx, const qse_char_t* name, qse_si
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* qse_awk_rtx_getxtn (qse_awk_rtx_t* rtx)
|
|
||||||
{
|
|
||||||
return QSE_XTN(rtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
qse_htb_t* qse_awk_rtx_getnvmap (qse_awk_rtx_t* rtx)
|
qse_htb_t* qse_awk_rtx_getnvmap (qse_awk_rtx_t* rtx)
|
||||||
{
|
{
|
||||||
return rtx->named;
|
return rtx->named;
|
||||||
@ -794,6 +786,7 @@ qse_awk_rtx_t* qse_awk_rtx_open (qse_awk_t* awk, qse_size_t xtnsize, qse_awk_rio
|
|||||||
|
|
||||||
/* initialize the rtx object */
|
/* initialize the rtx object */
|
||||||
QSE_MEMSET (rtx, 0, QSE_SIZEOF(qse_awk_rtx_t) + xtnsize);
|
QSE_MEMSET (rtx, 0, QSE_SIZEOF(qse_awk_rtx_t) + xtnsize);
|
||||||
|
rtx->_instsize = QSE_SIZEOF(qse_awk_rtx_t);
|
||||||
if (init_rtx(rtx, awk, rio) <= -1)
|
if (init_rtx(rtx, awk, rio) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_freemem (awk, rtx);
|
qse_awk_freemem (awk, rtx);
|
||||||
@ -949,16 +942,16 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
|
|||||||
rtx->inrec.maxflds = 0;
|
rtx->inrec.maxflds = 0;
|
||||||
rtx->inrec.d0 = qse_awk_val_nil;
|
rtx->inrec.d0 = qse_awk_val_nil;
|
||||||
|
|
||||||
if (qse_str_init(&rtx->inrec.line, MMGR(rtx), DEF_BUF_CAPA) <= -1) goto oops_1;
|
if (qse_str_init(&rtx->inrec.line, qse_awk_rtx_getmmgr(rtx), DEF_BUF_CAPA) <= -1) goto oops_1;
|
||||||
if (qse_str_init(&rtx->inrec.linew, MMGR(rtx), DEF_BUF_CAPA) <= -1) goto oops_2;
|
if (qse_str_init(&rtx->inrec.linew, qse_awk_rtx_getmmgr(rtx), DEF_BUF_CAPA) <= -1) goto oops_2;
|
||||||
if (qse_str_init(&rtx->inrec.lineg, MMGR(rtx), DEF_BUF_CAPA) <= -1) goto oops_3;
|
if (qse_str_init(&rtx->inrec.lineg, qse_awk_rtx_getmmgr(rtx), DEF_BUF_CAPA) <= -1) goto oops_3;
|
||||||
if (qse_str_init(&rtx->format.out, MMGR(rtx), 256) <= -1) goto oops_4;
|
if (qse_str_init(&rtx->format.out, qse_awk_rtx_getmmgr(rtx), 256) <= -1) goto oops_4;
|
||||||
if (qse_str_init(&rtx->format.fmt, MMGR(rtx), 256) <= -1) goto oops_5;
|
if (qse_str_init(&rtx->format.fmt, qse_awk_rtx_getmmgr(rtx), 256) <= -1) goto oops_5;
|
||||||
|
|
||||||
if (qse_mbs_init(&rtx->formatmbs.out, MMGR(rtx), 256) <= -1) goto oops_6;
|
if (qse_mbs_init(&rtx->formatmbs.out, qse_awk_rtx_getmmgr(rtx), 256) <= -1) goto oops_6;
|
||||||
if (qse_mbs_init(&rtx->formatmbs.fmt, MMGR(rtx), 256) <= -1) goto oops_7;
|
if (qse_mbs_init(&rtx->formatmbs.fmt, qse_awk_rtx_getmmgr(rtx), 256) <= -1) goto oops_7;
|
||||||
|
|
||||||
rtx->named = qse_htb_open(MMGR(rtx), QSE_SIZEOF(rtx), 1024, 70, QSE_SIZEOF(qse_char_t), 1);
|
rtx->named = qse_htb_open(qse_awk_rtx_getmmgr(rtx), QSE_SIZEOF(rtx), 1024, 70, QSE_SIZEOF(qse_char_t), 1);
|
||||||
if (!rtx->named) goto oops_8;
|
if (!rtx->named) goto oops_8;
|
||||||
*(qse_awk_rtx_t**)QSE_XTN(rtx->named) = rtx;
|
*(qse_awk_rtx_t**)QSE_XTN(rtx->named) = rtx;
|
||||||
qse_htb_setstyle (rtx->named, &style_for_named);
|
qse_htb_setstyle (rtx->named, &style_for_named);
|
||||||
@ -4559,7 +4552,7 @@ static QSE_INLINE int __cmp_str_mbs (qse_awk_rtx_t* rtx, qse_awk_val_t* left, qs
|
|||||||
qse_size_t mbslen;
|
qse_size_t mbslen;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
mbsptr = qse_wcsntombsdupwithcmgr(ls->val.ptr, ls->val.len, &mbslen, MMGR(rtx), CMGR(rtx));
|
mbsptr = qse_wcsntombsdupwithcmgr(ls->val.ptr, ls->val.len, &mbslen, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (!mbsptr)
|
if (!mbsptr)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -6877,7 +6870,7 @@ static int shorten_record (qse_awk_rtx_t* rtx, qse_size_t nflds)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qse_str_init(&tmp, MMGR(rtx), QSE_STR_LEN(&rtx->inrec.line)) <= -1)
|
if (qse_str_init(&tmp, qse_awk_rtx_getmmgr(rtx), QSE_STR_LEN(&rtx->inrec.line)) <= -1)
|
||||||
{
|
{
|
||||||
if (ofs_free) qse_awk_rtx_freemem (rtx, ofs_free);
|
if (ofs_free) qse_awk_rtx_freemem (rtx, ofs_free);
|
||||||
if (nflds > 1) qse_awk_rtx_refdownval (rtx, v);
|
if (nflds > 1) qse_awk_rtx_refdownval (rtx, v);
|
||||||
@ -6994,7 +6987,7 @@ static qse_char_t* idxnde_to_str (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde, qse_ch
|
|||||||
out.type = QSE_AWK_RTX_VALTOSTR_STRPCAT;
|
out.type = QSE_AWK_RTX_VALTOSTR_STRPCAT;
|
||||||
out.u.strpcat = &idxstr;
|
out.u.strpcat = &idxstr;
|
||||||
|
|
||||||
if (qse_str_init(&idxstr, MMGR(rtx), DEF_BUF_CAPA) <= -1)
|
if (qse_str_init(&idxstr, qse_awk_rtx_getmmgr(rtx), DEF_BUF_CAPA) <= -1)
|
||||||
{
|
{
|
||||||
SETERR_LOC (rtx, QSE_AWK_ENOMEM, &nde->loc);
|
SETERR_LOC (rtx, QSE_AWK_ENOMEM, &nde->loc);
|
||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
|
@ -158,6 +158,15 @@ typedef struct ioattr_t
|
|||||||
qse_ntime_t tmout[4];
|
qse_ntime_t tmout[4];
|
||||||
} ioattr_t;
|
} ioattr_t;
|
||||||
|
|
||||||
|
#if defined(QSE_HAVE_INLINE)
|
||||||
|
static QSE_INLINE xtn_t* GET_XTN(qse_awk_t* awk) { return (xtn_t*)((qse_uint8_t*)qse_awk_getxtn(awk) - QSE_SIZEOF(xtn_t)); }
|
||||||
|
static QSE_INLINE rxtn_t* GET_RXTN(qse_awk_rtx_t* rtx) { return (rxtn_t*)((qse_uint8_t*)qse_awk_rtx_getxtn(rtx) - QSE_SIZEOF(rxtn_t)); }
|
||||||
|
#else
|
||||||
|
#define GET_XTN(awk) ((xtn_t*)((qse_uint8_t*)qse_awk_getxtn(awk) - QSE_SIZEOF(xtn_t)))
|
||||||
|
#define GET_RXTN(rtx) ((rxtn_t*)((qse_uint8_t*)qse_awk_rtx_getxtn(rtx) - QSE_SIZEOF(rxtn_t)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static ioattr_t* get_ioattr (qse_htb_t* tab, const qse_char_t* ptr, qse_size_t len);
|
static ioattr_t* get_ioattr (qse_htb_t* tab, const qse_char_t* ptr, qse_size_t len);
|
||||||
|
|
||||||
qse_awk_flt_t qse_awk_stdmathpow (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
|
qse_awk_flt_t qse_awk_stdmathpow (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
|
||||||
@ -222,7 +231,7 @@ void qse_awk_stdmodshutdown (qse_awk_t* awk)
|
|||||||
|
|
||||||
static void* std_mod_open_checked (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
static void* std_mod_open_checked (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = QSE_XTN(awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
|
|
||||||
if (!xtn->stdmod_up)
|
if (!xtn->stdmod_up)
|
||||||
{
|
{
|
||||||
@ -251,9 +260,9 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
tmp[count] = QSE_NULL;
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
modpath = qse_mbsadup (tmp, QSE_NULL, awk->mmgr);
|
modpath = qse_mbsadup (tmp, QSE_NULL, qse_awk_getmmgr(awk));
|
||||||
#else
|
#else
|
||||||
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, awk->mmgr, awk->cmgr);
|
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, qse_awk_getmmgr(awk), qse_awk_getcmgr(awk));
|
||||||
#endif
|
#endif
|
||||||
if (!modpath)
|
if (!modpath)
|
||||||
{
|
{
|
||||||
@ -276,7 +285,7 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
|
|
||||||
lt_dladvise_destroy (&adv);
|
lt_dladvise_destroy (&adv);
|
||||||
|
|
||||||
QSE_MMGR_FREE (awk->mmgr, modpath);
|
QSE_MMGR_FREE (qse_awk_getmmgr(awk), modpath);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
|
|
||||||
@ -293,7 +302,7 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
if (spec->postfix) tmp[count++] = spec->postfix;
|
if (spec->postfix) tmp[count++] = spec->postfix;
|
||||||
tmp[count] = QSE_NULL;
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
modpath = qse_stradup (tmp, QSE_NULL, awk->mmgr);
|
modpath = qse_stradup (tmp, QSE_NULL, qse_awk_getmmgr(awk));
|
||||||
if (!modpath)
|
if (!modpath)
|
||||||
{
|
{
|
||||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -302,7 +311,7 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
|
|
||||||
h = LoadLibrary (modpath);
|
h = LoadLibrary (modpath);
|
||||||
|
|
||||||
QSE_MMGR_FREE (awk->mmgr, modpath);
|
QSE_MMGR_FREE (qse_awk_getmmgr(awk), modpath);
|
||||||
|
|
||||||
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
||||||
return h;
|
return h;
|
||||||
@ -323,9 +332,9 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
tmp[count] = QSE_NULL;
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
modpath = qse_mbsadup (tmp, QSE_NULL, awk->mmgr);
|
modpath = qse_mbsadup (tmp, QSE_NULL, qse_awk_getmmgr(awk));
|
||||||
#else
|
#else
|
||||||
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, awk->mmgr, awk->cmgr);
|
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, qse_awk_getmmgr(awk), qse_awk_getcmgr(awk));
|
||||||
#endif
|
#endif
|
||||||
if (!modpath)
|
if (!modpath)
|
||||||
{
|
{
|
||||||
@ -338,7 +347,7 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
rc = DosLoadModule (errbuf, QSE_COUNTOF(errbuf) - 1, modpath, &h);
|
rc = DosLoadModule (errbuf, QSE_COUNTOF(errbuf) - 1, modpath, &h);
|
||||||
if (rc != NO_ERROR) h = QSE_NULL;
|
if (rc != NO_ERROR) h = QSE_NULL;
|
||||||
|
|
||||||
QSE_MMGR_FREE (awk->mmgr, modpath);
|
QSE_MMGR_FREE (qse_awk_getmmgr(awk), modpath);
|
||||||
|
|
||||||
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
||||||
return h;
|
return h;
|
||||||
@ -360,9 +369,9 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
tmp[count] = QSE_NULL;
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
modpath = qse_mbsadup(tmp, QSE_NULL, awk->mmgr);
|
modpath = qse_mbsadup(tmp, QSE_NULL, qse_awk_getmmgr(awk));
|
||||||
#else
|
#else
|
||||||
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, awk->mmgr, awk->cmgr);
|
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, qse_awk_getmmgr(awk), qse_awk_getcmgr(awk));
|
||||||
#endif
|
#endif
|
||||||
if (!modpath)
|
if (!modpath)
|
||||||
{
|
{
|
||||||
@ -372,7 +381,7 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
|
|
||||||
h = LoadModule (modpath);
|
h = LoadModule (modpath);
|
||||||
|
|
||||||
QSE_MMGR_FREE (awk->mmgr, modpath);
|
QSE_MMGR_FREE (qse_awk_getmmgr(awk), modpath);
|
||||||
|
|
||||||
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
QSE_ASSERT (QSE_SIZEOF(h) <= QSE_SIZEOF(void*));
|
||||||
return h;
|
return h;
|
||||||
@ -391,9 +400,9 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
tmp[count] = QSE_NULL;
|
tmp[count] = QSE_NULL;
|
||||||
|
|
||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
modpath = qse_mbsadup(tmp, QSE_NULL, awk->mmgr);
|
modpath = qse_mbsadup(tmp, QSE_NULL, qse_awk_getmmgr(awk));
|
||||||
#else
|
#else
|
||||||
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, awk->mmgr, awk->cmgr);
|
modpath = qse_wcsatombsdupwithcmgr(tmp, QSE_NULL, qse_awk_getmmgr(awk), qse_awk_getcmgr(awk));
|
||||||
#endif
|
#endif
|
||||||
if (!modpath)
|
if (!modpath)
|
||||||
{
|
{
|
||||||
@ -407,7 +416,7 @@ void* qse_awk_stdmodopen (qse_awk_t* awk, const qse_awk_mod_spec_t* spec)
|
|||||||
qse_awk_seterrfmt (awk, QSE_AWK_ESYSERR, QSE_NULL, QSE_T("%hs"), dlerror());
|
qse_awk_seterrfmt (awk, QSE_AWK_ESYSERR, QSE_NULL, QSE_T("%hs"), dlerror());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSE_MMGR_FREE (awk->mmgr, modpath);
|
QSE_MMGR_FREE (qse_awk_getmmgr(awk), modpath);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
|
|
||||||
@ -442,7 +451,7 @@ void* qse_awk_stdmodsym (qse_awk_t* awk, void* handle, const qse_char_t* name)
|
|||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
mname = (qse_mchar_t*)name;
|
mname = (qse_mchar_t*)name;
|
||||||
#else
|
#else
|
||||||
mname = qse_wcstombsdupwithcmgr(name, QSE_NULL, awk->mmgr, awk->cmgr);
|
mname = qse_wcstombsdupwithcmgr(name, QSE_NULL, qse_awk_getmmgr(awk), qse_awk_getcmgr(awk));
|
||||||
if (!mname)
|
if (!mname)
|
||||||
{
|
{
|
||||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -472,7 +481,7 @@ void* qse_awk_stdmodsym (qse_awk_t* awk, void* handle, const qse_char_t* name)
|
|||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
#else
|
#else
|
||||||
QSE_MMGR_FREE (awk->mmgr, mname);
|
QSE_MMGR_FREE (qse_awk_getmmgr(awk), mname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
@ -488,7 +497,7 @@ qse_awk_t* qse_awk_openstd (qse_size_t xtnsize, qse_awk_errnum_t* errnum)
|
|||||||
|
|
||||||
static void fini_xtn (qse_awk_t* awk)
|
static void fini_xtn (qse_awk_t* awk)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
if (xtn->stdmod_up)
|
if (xtn->stdmod_up)
|
||||||
{
|
{
|
||||||
qse_awk_stdmodshutdown (awk);
|
qse_awk_stdmodshutdown (awk);
|
||||||
@ -527,8 +536,11 @@ qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_aw
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* adjust the object size by the sizeof xtn_t so that qse_getxtn() returns the right pointer. */
|
||||||
|
awk->_instsize += QSE_SIZEOF(xtn_t);
|
||||||
|
|
||||||
/* initialize extension */
|
/* initialize extension */
|
||||||
xtn = (xtn_t*) QSE_XTN (awk);
|
xtn = GET_XTN(awk);
|
||||||
/* the extension area has been cleared in qse_awk_open().
|
/* the extension area has been cleared in qse_awk_open().
|
||||||
* QSE_MEMSET (xtn, 0, QSE_SIZEOF(*xtn));*/
|
* QSE_MEMSET (xtn, 0, QSE_SIZEOF(*xtn));*/
|
||||||
|
|
||||||
@ -560,15 +572,10 @@ oops:
|
|||||||
return QSE_NULL;
|
return QSE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* qse_awk_getxtnstd (qse_awk_t* awk)
|
|
||||||
{
|
|
||||||
return (void*)((xtn_t*)QSE_XTN(awk) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static qse_sio_t* open_sio (qse_awk_t* awk, const qse_char_t* file, int flags)
|
static qse_sio_t* open_sio (qse_awk_t* awk, const qse_char_t* file, int flags)
|
||||||
{
|
{
|
||||||
qse_sio_t* sio;
|
qse_sio_t* sio;
|
||||||
sio = qse_sio_open (awk->mmgr, 0, file, flags);
|
sio = qse_sio_open (qse_awk_getmmgr(awk), 0, file, flags);
|
||||||
if (sio == QSE_NULL)
|
if (sio == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_cstr_t errarg;
|
qse_cstr_t errarg;
|
||||||
@ -582,7 +589,7 @@ static qse_sio_t* open_sio (qse_awk_t* awk, const qse_char_t* file, int flags)
|
|||||||
static qse_sio_t* open_sio_rtx (qse_awk_rtx_t* rtx, const qse_char_t* file, int flags)
|
static qse_sio_t* open_sio_rtx (qse_awk_rtx_t* rtx, const qse_char_t* file, int flags)
|
||||||
{
|
{
|
||||||
qse_sio_t* sio;
|
qse_sio_t* sio;
|
||||||
sio = qse_sio_open (rtx->awk->mmgr, 0, file, flags);
|
sio = qse_sio_open (qse_awk_rtx_getmmgr(rtx), 0, file, flags);
|
||||||
if (sio == QSE_NULL)
|
if (sio == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_cstr_t errarg;
|
qse_cstr_t errarg;
|
||||||
@ -603,7 +610,7 @@ static qse_cstr_t sio_std_names[] =
|
|||||||
static qse_sio_t* open_sio_std (qse_awk_t* awk, qse_sio_std_t std, int flags)
|
static qse_sio_t* open_sio_std (qse_awk_t* awk, qse_sio_std_t std, int flags)
|
||||||
{
|
{
|
||||||
qse_sio_t* sio;
|
qse_sio_t* sio;
|
||||||
sio = qse_sio_openstd (awk->mmgr, 0, std, flags);
|
sio = qse_sio_openstd (qse_awk_getmmgr(awk), 0, std, flags);
|
||||||
if (sio == QSE_NULL) qse_awk_seterrnum (awk, QSE_AWK_EOPEN, &sio_std_names[std]);
|
if (sio == QSE_NULL) qse_awk_seterrnum (awk, QSE_AWK_EOPEN, &sio_std_names[std]);
|
||||||
return sio;
|
return sio;
|
||||||
}
|
}
|
||||||
@ -612,7 +619,7 @@ static qse_sio_t* open_sio_std_rtx (qse_awk_rtx_t* rtx, qse_sio_std_t std, int f
|
|||||||
{
|
{
|
||||||
qse_sio_t* sio;
|
qse_sio_t* sio;
|
||||||
|
|
||||||
sio = qse_sio_openstd (rtx->awk->mmgr, 0, std, flags);
|
sio = qse_sio_openstd (qse_awk_rtx_getmmgr(rtx), 0, std, flags);
|
||||||
if (sio == QSE_NULL) qse_awk_rtx_seterrnum (rtx, QSE_AWK_EOPEN, &sio_std_names[std]);
|
if (sio == QSE_NULL) qse_awk_rtx_seterrnum (rtx, QSE_AWK_EOPEN, &sio_std_names[std]);
|
||||||
return sio;
|
return sio;
|
||||||
}
|
}
|
||||||
@ -739,7 +746,7 @@ static qse_ssize_t sf_in_open (qse_awk_t* awk, qse_awk_sio_arg_t* arg, xtn_t* xt
|
|||||||
}
|
}
|
||||||
|
|
||||||
arg->handle = qse_sio_open (
|
arg->handle = qse_sio_open (
|
||||||
awk->mmgr, 0, path, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR | QSE_SIO_KEEPPATH
|
qse_awk_getmmgr(awk), 0, path, QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR | QSE_SIO_KEEPPATH
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dbuf) qse_awk_freemem (awk, dbuf);
|
if (dbuf) qse_awk_freemem (awk, dbuf);
|
||||||
@ -754,7 +761,7 @@ static qse_ssize_t sf_in_open (qse_awk_t* awk, qse_awk_sio_arg_t* arg, xtn_t* xt
|
|||||||
|
|
||||||
/* TODO: use the system handle(file descriptor) instead of the path? */
|
/* TODO: use the system handle(file descriptor) instead of the path? */
|
||||||
/*syshnd = qse_sio_gethnd(arg->handle);*/
|
/*syshnd = qse_sio_gethnd(arg->handle);*/
|
||||||
if (qse_get_file_attr_with_mmgr(path, 0, &fattr, awk->mmgr) >= 0)
|
if (qse_get_file_attr_with_mmgr(path, 0, &fattr, qse_awk_getmmgr(awk)) >= 0)
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -891,7 +898,7 @@ static qse_ssize_t sf_in_read (qse_awk_t* awk, qse_awk_sio_arg_t* arg, qse_char_
|
|||||||
|
|
||||||
static qse_ssize_t sf_in (qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_sio_arg_t* arg, qse_char_t* data, qse_size_t size)
|
static qse_ssize_t sf_in (qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_sio_arg_t* arg, qse_char_t* data, qse_size_t size)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@ -912,7 +919,7 @@ static qse_ssize_t sf_in (qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_sio_arg
|
|||||||
|
|
||||||
static qse_ssize_t sf_out (qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_sio_arg_t* arg, qse_char_t* data, qse_size_t size)
|
static qse_ssize_t sf_out (qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_sio_arg_t* arg, qse_char_t* data, qse_size_t size)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
@ -947,7 +954,7 @@ static qse_ssize_t sf_out (qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_sio_ar
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case QSE_AWK_PARSESTD_STR:
|
case QSE_AWK_PARSESTD_STR:
|
||||||
xtn->s.out.u.str.buf = qse_str_open (awk->mmgr, 0, 512);
|
xtn->s.out.u.str.buf = qse_str_open (qse_awk_getmmgr(awk), 0, 512);
|
||||||
if (xtn->s.out.u.str.buf == QSE_NULL)
|
if (xtn->s.out.u.str.buf == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1025,7 +1032,7 @@ static qse_ssize_t sf_out (qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_sio_ar
|
|||||||
int qse_awk_parsestd (qse_awk_t* awk, qse_awk_parsestd_t in[], qse_awk_parsestd_t* out)
|
int qse_awk_parsestd (qse_awk_t* awk, qse_awk_parsestd_t in[], qse_awk_parsestd_t* out)
|
||||||
{
|
{
|
||||||
qse_awk_sio_t sio;
|
qse_awk_sio_t sio;
|
||||||
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (in == QSE_NULL || (in[0].type != QSE_AWK_PARSESTD_FILE &&
|
if (in == QSE_NULL || (in[0].type != QSE_AWK_PARSESTD_FILE &&
|
||||||
@ -1183,7 +1190,7 @@ static qse_ssize_t pio_handler_open (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod
|
|||||||
}
|
}
|
||||||
|
|
||||||
handle = qse_pio_open (
|
handle = qse_pio_open (
|
||||||
rtx->awk->mmgr,
|
qse_awk_rtx_getmmgr(rtx),
|
||||||
0,
|
0,
|
||||||
riod->name,
|
riod->name,
|
||||||
QSE_NULL,
|
QSE_NULL,
|
||||||
@ -1280,7 +1287,7 @@ static qse_ssize_t awk_rio_pipe (qse_awk_rtx_t* rtx, qse_awk_rio_cmd_t cmd, qse_
|
|||||||
ioattr_t* ioattr;
|
ioattr_t* ioattr;
|
||||||
rxtn_t* rxtn;
|
rxtn_t* rxtn;
|
||||||
|
|
||||||
rxtn = (rxtn_t*)QSE_XTN(rtx);
|
rxtn = GET_RXTN(rtx);
|
||||||
|
|
||||||
ioattr = get_ioattr(&rxtn->cmgrtab, riod->name, qse_strlen(riod->name));
|
ioattr = get_ioattr(&rxtn->cmgrtab, riod->name, qse_strlen(riod->name));
|
||||||
if (ioattr)
|
if (ioattr)
|
||||||
@ -1327,7 +1334,7 @@ static qse_ssize_t awk_rio_file (qse_awk_rtx_t* rtx, qse_awk_rio_cmd_t cmd, qse_
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = qse_sio_open (rtx->awk->mmgr, 0, riod->name, flags);
|
handle = qse_sio_open (qse_awk_rtx_getmmgr(rtx), 0, riod->name, flags);
|
||||||
if (handle == QSE_NULL)
|
if (handle == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_cstr_t errarg;
|
qse_cstr_t errarg;
|
||||||
@ -1374,12 +1381,12 @@ static qse_ssize_t awk_rio_file (qse_awk_rtx_t* rtx, qse_awk_rio_cmd_t cmd, qse_
|
|||||||
|
|
||||||
static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
|
static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
|
||||||
{
|
{
|
||||||
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
qse_sio_t* sio;
|
qse_sio_t* sio;
|
||||||
|
|
||||||
if (riod->mode == QSE_AWK_RIO_CONSOLE_READ)
|
if (riod->mode == QSE_AWK_RIO_CONSOLE_READ)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*)QSE_XTN(rtx->awk);
|
xtn_t* xtn = (xtn_t*)GET_XTN(rtx->awk);
|
||||||
|
|
||||||
if (rxtn->c.in.files == QSE_NULL)
|
if (rxtn->c.in.files == QSE_NULL)
|
||||||
{
|
{
|
||||||
@ -1671,8 +1678,8 @@ static qse_ssize_t awk_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_cmd_t cmd, q
|
|||||||
|
|
||||||
static void fini_rxtn (qse_awk_rtx_t* rtx)
|
static void fini_rxtn (qse_awk_rtx_t* rtx)
|
||||||
{
|
{
|
||||||
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
/*xtn_t* xtn = (xtn_t*) QSE_XTN (rtx->awk);*/
|
/*xtn_t* xtn = (xtn_t*)GET_XTN(rtx->awk);*/
|
||||||
|
|
||||||
if (rxtn->cmgrtab_inited)
|
if (rxtn->cmgrtab_inited)
|
||||||
{
|
{
|
||||||
@ -1826,12 +1833,12 @@ static int __build_environ (
|
|||||||
/* mbstowcsdup() may fail for invalid encoding. as the environment
|
/* mbstowcsdup() may fail for invalid encoding. as the environment
|
||||||
* variaables are not under control, call mbstowcsalldup() instead
|
* variaables are not under control, call mbstowcsalldup() instead
|
||||||
* to go on despite encoding failure */
|
* to go on despite encoding failure */
|
||||||
kptr = qse_mbstowcsalldupwithcmgr(envarr[count], &klen, rtx->awk->mmgr, rtx->awk->cmgr);
|
kptr = qse_mbstowcsalldupwithcmgr(envarr[count], &klen, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
vptr = qse_mbstowcsalldupwithcmgr(eq + 1, QSE_NULL, rtx->awk->mmgr, rtx->awk->cmgr);
|
vptr = qse_mbstowcsalldupwithcmgr(eq + 1, QSE_NULL, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (kptr == QSE_NULL || vptr == QSE_NULL)
|
if (kptr == QSE_NULL || vptr == QSE_NULL)
|
||||||
{
|
{
|
||||||
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
if (kptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), kptr);
|
||||||
if (vptr) QSE_MMGR_FREE (rtx->awk->mmgr, vptr);
|
if (vptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), vptr);
|
||||||
qse_awk_rtx_refdownval (rtx, v_env);
|
qse_awk_rtx_refdownval (rtx, v_env);
|
||||||
|
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1845,12 +1852,12 @@ static int __build_environ (
|
|||||||
|
|
||||||
*eq = QSE_WT('\0');
|
*eq = QSE_WT('\0');
|
||||||
|
|
||||||
kptr = qse_wcstombsdupwithcmgr(envarr[count], &klen, rtx->awk->mmgr, rtx->awk->cmgr);
|
kptr = qse_wcstombsdupwithcmgr(envarr[count], &klen, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
vptr = qse_wcstombsdupwithcmgr(eq + 1, QSE_NULL, rtx->awk->mmgr, rtx->awk->cmgr);
|
vptr = qse_wcstombsdupwithcmgr(eq + 1, QSE_NULL, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (kptr == QSE_NULL || vptr == QSE_NULL)
|
if (kptr == QSE_NULL || vptr == QSE_NULL)
|
||||||
{
|
{
|
||||||
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
if (kptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), kptr);
|
||||||
if (vptr) QSE_MMGR_FREE (rtx->awk->mmgr, vptr);
|
if (vptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), vptr);
|
||||||
qse_awk_rtx_refdownval (rtx, v_env);
|
qse_awk_rtx_refdownval (rtx, v_env);
|
||||||
|
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1870,8 +1877,8 @@ static int __build_environ (
|
|||||||
(defined(QSE_ENV_CHAR_IS_WCHAR) && defined(QSE_CHAR_IS_WCHAR)))
|
(defined(QSE_ENV_CHAR_IS_WCHAR) && defined(QSE_CHAR_IS_WCHAR)))
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
#else
|
#else
|
||||||
if (vptr) QSE_MMGR_FREE (rtx->awk->mmgr, vptr);
|
if (vptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), vptr);
|
||||||
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
if (kptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), kptr);
|
||||||
#endif
|
#endif
|
||||||
qse_awk_rtx_refdownval (rtx, v_env);
|
qse_awk_rtx_refdownval (rtx, v_env);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1894,8 +1901,8 @@ static int __build_environ (
|
|||||||
(defined(QSE_ENV_CHAR_IS_WCHAR) && defined(QSE_CHAR_IS_WCHAR)))
|
(defined(QSE_ENV_CHAR_IS_WCHAR) && defined(QSE_CHAR_IS_WCHAR)))
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
#else
|
#else
|
||||||
if (vptr) QSE_MMGR_FREE (rtx->awk->mmgr, vptr);
|
if (vptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), vptr);
|
||||||
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
if (kptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), kptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the values previously assigned into the
|
/* the values previously assigned into the
|
||||||
@ -1910,8 +1917,8 @@ static int __build_environ (
|
|||||||
(defined(QSE_ENV_CHAR_IS_WCHAR) && defined(QSE_CHAR_IS_WCHAR)))
|
(defined(QSE_ENV_CHAR_IS_WCHAR) && defined(QSE_CHAR_IS_WCHAR)))
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
#else
|
#else
|
||||||
if (vptr) QSE_MMGR_FREE (rtx->awk->mmgr, vptr);
|
if (vptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), vptr);
|
||||||
if (kptr) QSE_MMGR_FREE (rtx->awk->mmgr, kptr);
|
if (kptr) QSE_MMGR_FREE (qse_awk_rtx_getmmgr(rtx), kptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1931,7 +1938,7 @@ static int build_environ (qse_awk_rtx_t* rtx, int gbl_id)
|
|||||||
qse_env_t env;
|
qse_env_t env;
|
||||||
int xret;
|
int xret;
|
||||||
|
|
||||||
if (qse_env_init (&env, rtx->awk->mmgr, 1) <= -1)
|
if (qse_env_init(&env, qse_awk_rtx_getmmgr(rtx), 1) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
@ -1966,7 +1973,7 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
|||||||
rxtn_t* rxtn;
|
rxtn_t* rxtn;
|
||||||
xtn_t* xtn;
|
xtn_t* xtn;
|
||||||
|
|
||||||
xtn = (xtn_t*)QSE_XTN (awk);
|
xtn = GET_XTN(awk);
|
||||||
|
|
||||||
rio.pipe = awk_rio_pipe;
|
rio.pipe = awk_rio_pipe;
|
||||||
rio.file = awk_rio_file;
|
rio.file = awk_rio_file;
|
||||||
@ -1975,11 +1982,13 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
|||||||
rtx = qse_awk_rtx_open(awk, QSE_SIZEOF(rxtn_t) + xtnsize, &rio);
|
rtx = qse_awk_rtx_open(awk, QSE_SIZEOF(rxtn_t) + xtnsize, &rio);
|
||||||
if (!rtx) return QSE_NULL;
|
if (!rtx) return QSE_NULL;
|
||||||
|
|
||||||
rxtn = (rxtn_t*) QSE_XTN (rtx);
|
rtx->_instsize += QSE_SIZEOF(rxtn_t);
|
||||||
|
|
||||||
|
rxtn = GET_RXTN(rtx);
|
||||||
|
|
||||||
if (rtx->awk->opt.trait & QSE_AWK_RIO)
|
if (rtx->awk->opt.trait & QSE_AWK_RIO)
|
||||||
{
|
{
|
||||||
if (qse_htb_init(&rxtn->cmgrtab, awk->mmgr, 256, 70, QSE_SIZEOF(qse_char_t), 1) <= -1)
|
if (qse_htb_init(&rxtn->cmgrtab, qse_awk_getmmgr(awk), 256, 70, QSE_SIZEOF(qse_char_t), 1) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_close (rtx);
|
qse_awk_rtx_close (rtx);
|
||||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -2032,12 +2041,6 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
|||||||
return rtx;
|
return rtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* qse_awk_rtx_getxtnstd (qse_awk_rtx_t* rtx)
|
|
||||||
{
|
|
||||||
return (void*)((rxtn_t*)QSE_XTN(rtx) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int timeout_code (const qse_char_t* name)
|
static int timeout_code (const qse_char_t* name)
|
||||||
{
|
{
|
||||||
if (qse_strcasecmp (name, QSE_T("rtimeout")) == 0) return 0;
|
if (qse_strcasecmp (name, QSE_T("rtimeout")) == 0) return 0;
|
||||||
@ -2101,7 +2104,7 @@ static int fnc_setioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
|||||||
int i, ret = 0, fret = 0;
|
int i, ret = 0, fret = 0;
|
||||||
int tmout;
|
int tmout;
|
||||||
|
|
||||||
rxtn = (rxtn_t*) QSE_XTN (rtx);
|
rxtn = GET_RXTN(rtx);
|
||||||
QSE_ASSERT (rxtn->cmgrtab_inited == 1);
|
QSE_ASSERT (rxtn->cmgrtab_inited == 1);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
@ -2223,7 +2226,7 @@ static int fnc_getioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
|||||||
ioattr_t* ioattr;
|
ioattr_t* ioattr;
|
||||||
ioattr_t ioattr_buf;
|
ioattr_t ioattr_buf;
|
||||||
|
|
||||||
rxtn = (rxtn_t*) QSE_XTN (rtx);
|
rxtn = GET_RXTN(rtx);
|
||||||
QSE_ASSERT (rxtn->cmgrtab_inited == 1);
|
QSE_ASSERT (rxtn->cmgrtab_inited == 1);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
@ -2305,10 +2308,9 @@ done:
|
|||||||
qse_cmgr_t* qse_awk_rtx_getiocmgrstd (qse_awk_rtx_t* rtx, const qse_char_t* ioname)
|
qse_cmgr_t* qse_awk_rtx_getiocmgrstd (qse_awk_rtx_t* rtx, const qse_char_t* ioname)
|
||||||
{
|
{
|
||||||
#if defined(QSE_CHAR_IS_WCHAR)
|
#if defined(QSE_CHAR_IS_WCHAR)
|
||||||
rxtn_t* rxtn;
|
rxtn_t* rxtn = GET_RXTN(rtx);
|
||||||
ioattr_t* ioattr;
|
ioattr_t* ioattr;
|
||||||
|
|
||||||
rxtn = (rxtn_t*) QSE_XTN (rtx);
|
|
||||||
QSE_ASSERT (rxtn->cmgrtab_inited == 1);
|
QSE_ASSERT (rxtn->cmgrtab_inited == 1);
|
||||||
|
|
||||||
ioattr = get_ioattr(&rxtn->cmgrtab, ioname, qse_strlen(ioname));
|
ioattr = get_ioattr(&rxtn->cmgrtab, ioname, qse_strlen(ioname));
|
||||||
@ -2319,9 +2321,7 @@ qse_cmgr_t* qse_awk_rtx_getiocmgrstd (qse_awk_rtx_t* rtx, const qse_char_t* iona
|
|||||||
|
|
||||||
static int add_globals (qse_awk_t* awk)
|
static int add_globals (qse_awk_t* awk)
|
||||||
{
|
{
|
||||||
xtn_t* xtn;
|
xtn_t* xtn = GET_XTN(awk);
|
||||||
|
|
||||||
xtn = (xtn_t*) QSE_XTN (awk);
|
|
||||||
|
|
||||||
xtn->gbl_argc = qse_awk_addgbl (awk, QSE_T("ARGC"));
|
xtn->gbl_argc = qse_awk_addgbl (awk, QSE_T("ARGC"));
|
||||||
xtn->gbl_argv = qse_awk_addgbl (awk, QSE_T("ARGV"));
|
xtn->gbl_argv = qse_awk_addgbl (awk, QSE_T("ARGV"));
|
||||||
|
@ -217,7 +217,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithmbs (qse_awk_rtx_t* rtx, const qse_mcha
|
|||||||
qse_awk_val_t* v;
|
qse_awk_val_t* v;
|
||||||
qse_wcstr_t tmp;
|
qse_wcstr_t tmp;
|
||||||
|
|
||||||
tmp.ptr = qse_mbstowcsalldupwithcmgr(mbs, &tmp.len, rtx->awk->mmgr, rtx->awk->cmgr);
|
tmp.ptr = qse_mbstowcsalldupwithcmgr(mbs, &tmp.len, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (tmp.ptr == QSE_NULL)
|
if (tmp.ptr == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -236,7 +236,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithwcs (qse_awk_rtx_t* rtx, const qse_wcha
|
|||||||
qse_awk_val_t* v;
|
qse_awk_val_t* v;
|
||||||
qse_mcstr_t tmp;
|
qse_mcstr_t tmp;
|
||||||
|
|
||||||
tmp.ptr = qse_wcstombsdupwithcmgr(wcs, &tmp.len, rtx->awk->mmgr, rtx->awk->cmgr);
|
tmp.ptr = qse_wcstombsdupwithcmgr(wcs, &tmp.len, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (tmp.ptr == QSE_NULL)
|
if (tmp.ptr == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -266,7 +266,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithmxstr (qse_awk_rtx_t* rtx, const qse_mc
|
|||||||
qse_size_t mbslen;
|
qse_size_t mbslen;
|
||||||
|
|
||||||
mbslen = mxstr->len;
|
mbslen = mxstr->len;
|
||||||
tmp.ptr = qse_mbsntowcsalldupwithcmgr(mxstr->ptr, &mbslen, &tmp.len, rtx->awk->mmgr, rtx->awk->cmgr);
|
tmp.ptr = qse_mbsntowcsalldupwithcmgr(mxstr->ptr, &mbslen, &tmp.len, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (tmp.ptr == QSE_NULL)
|
if (tmp.ptr == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -287,7 +287,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithwxstr (qse_awk_rtx_t* rtx, const qse_wc
|
|||||||
qse_size_t wcslen;
|
qse_size_t wcslen;
|
||||||
|
|
||||||
wcslen = wxstr->len;
|
wcslen = wxstr->len;
|
||||||
tmp.ptr = qse_wcsntombsdupwithcmgr(wxstr->ptr, wcslen, &tmp.len, rtx->awk->mmgr, rtx->awk->cmgr);
|
tmp.ptr = qse_wcsntombsdupwithcmgr(wxstr->ptr, wcslen, &tmp.len, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (tmp.ptr == QSE_NULL)
|
if (tmp.ptr == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -500,7 +500,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* rtx)
|
|||||||
val->stat = 0;
|
val->stat = 0;
|
||||||
val->nstr = 0;
|
val->nstr = 0;
|
||||||
val->fcb = 0;
|
val->fcb = 0;
|
||||||
val->map = qse_htb_open(run, 256, 70, free_mapval, same_mapval, run->awk->mmgr);
|
val->map = qse_htb_open(run, 256, 70, free_mapval, same_mapval, qse_awk_rtx_getmmgr(run));
|
||||||
if (val->map == QSE_NULL)
|
if (val->map == QSE_NULL)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_freemem (rtx, val);
|
qse_awk_rtx_freemem (rtx, val);
|
||||||
@ -519,7 +519,7 @@ qse_awk_val_t* qse_awk_rtx_makemapval (qse_awk_rtx_t* rtx)
|
|||||||
val->fcb = 0;
|
val->fcb = 0;
|
||||||
val->map = (qse_htb_t*)(val + 1);
|
val->map = (qse_htb_t*)(val + 1);
|
||||||
|
|
||||||
if (qse_htb_init(val->map, rtx->awk->mmgr, 256, 70, QSE_SIZEOF(qse_char_t), 1) <= -1)
|
if (qse_htb_init(val->map, qse_awk_rtx_getmmgr(rtx), 256, 70, QSE_SIZEOF(qse_char_t), 1) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_freemem (rtx, val);
|
qse_awk_rtx_freemem (rtx, val);
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1071,7 +1071,7 @@ static int mbs_to_str (qse_awk_rtx_t* rtx, const qse_mchar_t* str, qse_size_t st
|
|||||||
mbslen = str_len;
|
mbslen = str_len;
|
||||||
wcslen = out->u.cplcpy.len;
|
wcslen = out->u.cplcpy.len;
|
||||||
/*if (qse_mbsntowcsnallwithcmgr(str, &mbslen, out->u.cplcpy.ptr, &wcslen, qse_findcmgrbyid(QSE_CMGR_MB8)) <= -1 || wcslen >= out->u.cplcpy.len)*/
|
/*if (qse_mbsntowcsnallwithcmgr(str, &mbslen, out->u.cplcpy.ptr, &wcslen, qse_findcmgrbyid(QSE_CMGR_MB8)) <= -1 || wcslen >= out->u.cplcpy.len)*/
|
||||||
if (qse_mbsntowcsnallwithcmgr(str, &mbslen, out->u.cplcpy.ptr, &wcslen, rtx->awk->cmgr) <= -1 || wcslen >= out->u.cplcpy.len)
|
if (qse_mbsntowcsnallwithcmgr(str, &mbslen, out->u.cplcpy.ptr, &wcslen, qse_awk_rtx_getcmgr(rtx)) <= -1 || wcslen >= out->u.cplcpy.len)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL); /* TODO: change error code */
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL); /* TODO: change error code */
|
||||||
return -1;
|
return -1;
|
||||||
@ -1089,8 +1089,8 @@ static int mbs_to_str (qse_awk_rtx_t* rtx, const qse_mchar_t* str, qse_size_t st
|
|||||||
qse_size_t mbslen, wcslen;
|
qse_size_t mbslen, wcslen;
|
||||||
|
|
||||||
mbslen = str_len;
|
mbslen = str_len;
|
||||||
/*tmp = qse_mbsntowcsalldupwithcmgr(str, &mbslen, &wcslen, rtx->awk->mmgr, qse_findcmgrbyid(QSE_CMGR_MB8));*/
|
/*tmp = qse_mbsntowcsalldupwithcmgr(str, &mbslen, &wcslen, qse_awk_rtx_getmmgr(rtx), qse_findcmgrbyid(QSE_CMGR_MB8));*/
|
||||||
tmp = qse_mbsntowcsalldupwithcmgr(str, &mbslen, &wcslen, rtx->awk->mmgr, rtx->awk->cmgr);
|
tmp = qse_mbsntowcsalldupwithcmgr(str, &mbslen, &wcslen, qse_awk_rtx_getmmgr(rtx), qse_awk_rtx_getcmgr(rtx));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1108,7 +1108,7 @@ static int mbs_to_str (qse_awk_rtx_t* rtx, const qse_mchar_t* str, qse_size_t st
|
|||||||
|
|
||||||
qse_str_clear (out->u.strp);
|
qse_str_clear (out->u.strp);
|
||||||
/*n = qse_str_ncatmbs(out->u.strp, str, str_len, qse_findcmgrbyid(QSE_CMGR_MB8));*/
|
/*n = qse_str_ncatmbs(out->u.strp, str, str_len, qse_findcmgrbyid(QSE_CMGR_MB8));*/
|
||||||
n = qse_str_ncatmbs(out->u.strp, str, str_len, rtx->awk->cmgr);
|
n = qse_str_ncatmbs(out->u.strp, str, str_len, qse_awk_rtx_getcmgr(rtx));
|
||||||
if (n == (qse_size_t)-1)
|
if (n == (qse_size_t)-1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1122,7 +1122,7 @@ static int mbs_to_str (qse_awk_rtx_t* rtx, const qse_mchar_t* str, qse_size_t st
|
|||||||
qse_size_t n;
|
qse_size_t n;
|
||||||
|
|
||||||
/*n = qse_str_ncatmbs(out->u.strpcat, str, str_len, qse_findcmgrbyid(QSE_CMGR_MB8));*/
|
/*n = qse_str_ncatmbs(out->u.strpcat, str, str_len, qse_findcmgrbyid(QSE_CMGR_MB8));*/
|
||||||
n = qse_str_ncatmbs(out->u.strpcat, str, str_len, rtx->awk->cmgr);
|
n = qse_str_ncatmbs(out->u.strpcat, str, str_len, qse_awk_rtx_getcmgr(rtx));
|
||||||
if (n == (qse_size_t)-1)
|
if (n == (qse_size_t)-1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1273,14 +1273,14 @@ static int val_flt_to_str (qse_awk_rtx_t* rtx, const qse_awk_val_flt_t* v, qse_a
|
|||||||
tmp_len = rtx->gbl.convfmt.len;
|
tmp_len = rtx->gbl.convfmt.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qse_str_init(&buf, rtx->awk->mmgr, 256) <= -1)
|
if (qse_str_init(&buf, qse_awk_rtx_getmmgr(rtx), 256) <= -1)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
buf_inited = 1;
|
buf_inited = 1;
|
||||||
|
|
||||||
if (qse_str_init(&fbu, rtx->awk->mmgr, 256) <= -1)
|
if (qse_str_init(&fbu, qse_awk_rtx_getmmgr(rtx), 256) <= -1)
|
||||||
{
|
{
|
||||||
qse_str_fini (&buf);
|
qse_str_fini (&buf);
|
||||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
|
||||||
@ -1498,7 +1498,7 @@ qse_mchar_t* qse_awk_rtx_valtombsdupwithcmgr (qse_awk_rtx_t* rtx, const qse_awk_
|
|||||||
|
|
||||||
if (QSE_AWK_RTX_GETVALTYPE(rtx,v) == QSE_AWK_VAL_MBS)
|
if (QSE_AWK_RTX_GETVALTYPE(rtx,v) == QSE_AWK_VAL_MBS)
|
||||||
{
|
{
|
||||||
mbs = qse_mbsxdup(((qse_awk_val_mbs_t*)v)->val.ptr, ((qse_awk_val_mbs_t*)v)->val.len, rtx->awk->mmgr);
|
mbs = qse_mbsxdup(((qse_awk_val_mbs_t*)v)->val.ptr, ((qse_awk_val_mbs_t*)v)->val.len, qse_awk_rtx_getmmgr(rtx));
|
||||||
if (!mbs)
|
if (!mbs)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterror (rtx, QSE_AWK_ENOMEM, QSE_NULL, QSE_NULL);
|
qse_awk_rtx_seterror (rtx, QSE_AWK_ENOMEM, QSE_NULL, QSE_NULL);
|
||||||
@ -1516,10 +1516,10 @@ qse_mchar_t* qse_awk_rtx_valtombsdupwithcmgr (qse_awk_rtx_t* rtx, const qse_awk_
|
|||||||
if (!str0) return QSE_NULL;
|
if (!str0) return QSE_NULL;
|
||||||
|
|
||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
mbs = qse_strxdup(str0, len0, rtx->awk->mmgr);
|
mbs = qse_strxdup(str0, len0, qse_awk_rtx_getmmgr(rtx));
|
||||||
len1 = len0;
|
len1 = len0;
|
||||||
#else
|
#else
|
||||||
mbs = qse_wcsntombsdupwithcmgr(str0, len0, &len1, rtx->awk->mmgr, cmgr);
|
mbs = qse_wcsntombsdupwithcmgr(str0, len0, &len1, qse_awk_rtx_getmmgr(rtx), cmgr);
|
||||||
#endif
|
#endif
|
||||||
qse_awk_rtx_freevalstr (rtx, v, str0);
|
qse_awk_rtx_freevalstr (rtx, v, str0);
|
||||||
if (!mbs)
|
if (!mbs)
|
||||||
@ -1546,7 +1546,7 @@ qse_wchar_t* qse_awk_rtx_valtowcsdupwithcmgr (qse_awk_rtx_t* rtx, const qse_awk_
|
|||||||
{
|
{
|
||||||
qse_size_t mbslen, wcslen;
|
qse_size_t mbslen, wcslen;
|
||||||
mbslen = ((qse_awk_val_mbs_t*)v)->val.len;
|
mbslen = ((qse_awk_val_mbs_t*)v)->val.len;
|
||||||
wcs = qse_mbsntowcsalldupwithcmgr(((qse_awk_val_mbs_t*)v)->val.ptr, &mbslen, &wcslen, rtx->awk->mmgr, cmgr);
|
wcs = qse_mbsntowcsalldupwithcmgr(((qse_awk_val_mbs_t*)v)->val.ptr, &mbslen, &wcslen, qse_awk_rtx_getmmgr(rtx), cmgr);
|
||||||
if (!wcs)
|
if (!wcs)
|
||||||
{
|
{
|
||||||
qse_awk_rtx_seterror (rtx, QSE_AWK_ENOMEM, QSE_NULL, QSE_NULL);
|
qse_awk_rtx_seterror (rtx, QSE_AWK_ENOMEM, QSE_NULL, QSE_NULL);
|
||||||
@ -1562,9 +1562,9 @@ qse_wchar_t* qse_awk_rtx_valtowcsdupwithcmgr (qse_awk_rtx_t* rtx, const qse_awk_
|
|||||||
#if defined(QSE_CHAR_IS_MCHAR)
|
#if defined(QSE_CHAR_IS_MCHAR)
|
||||||
qse_size_t wcslen, mbslen;
|
qse_size_t wcslen, mbslen;
|
||||||
mbslen = ((qse_awk_val_str_t*)v)->val.len;
|
mbslen = ((qse_awk_val_str_t*)v)->val.len;
|
||||||
wcs = qse_mbsntowcsalldupwithcmgr(((qse_awk_val_str_t*)v)->val.ptr, &mbslen, &wcslen, rtx->awk->mmgr, cmgr);
|
wcs = qse_mbsntowcsalldupwithcmgr(((qse_awk_val_str_t*)v)->val.ptr, &mbslen, &wcslen, qse_awk_rtx_getmmgr(rtx), cmgr);
|
||||||
#else
|
#else
|
||||||
wcs = qse_strxdup(((qse_awk_val_str_t*)v)->val.ptr, ((qse_awk_val_str_t*)v)->val.len, rtx->awk->mmgr);
|
wcs = qse_strxdup(((qse_awk_val_str_t*)v)->val.ptr, ((qse_awk_val_str_t*)v)->val.len, qse_awk_rtx_getmmgr(rtx));
|
||||||
#endif
|
#endif
|
||||||
if (!wcs)
|
if (!wcs)
|
||||||
{
|
{
|
||||||
@ -1589,7 +1589,7 @@ qse_wchar_t* qse_awk_rtx_valtowcsdupwithcmgr (qse_awk_rtx_t* rtx, const qse_awk_
|
|||||||
out.type = QSE_AWK_RTX_VALTOSTR_CPLDUP;
|
out.type = QSE_AWK_RTX_VALTOSTR_CPLDUP;
|
||||||
if (qse_awk_rtx_valtostr(rtx, v, &out) <= -1) return QSE_NULL;
|
if (qse_awk_rtx_valtostr(rtx, v, &out) <= -1) return QSE_NULL;
|
||||||
|
|
||||||
wcs = qse_mbsntowcsalldupwithcmgr(out.u.cpldup.ptr, &out.u.cpldup.len, &wcslen, rtx->awk->mmgr, cmgr);
|
wcs = qse_mbsntowcsalldupwithcmgr(out.u.cpldup.ptr, &out.u.cpldup.len, &wcslen, qse_awk_rtx_getmmgr(rtx), cmgr);
|
||||||
qse_awk_rtx_freemem (rtx, out.u.cpldup.ptr);
|
qse_awk_rtx_freemem (rtx, out.u.cpldup.ptr);
|
||||||
if (!wcs)
|
if (!wcs)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +30,7 @@ static qse_ssize_t handle_console (
|
|||||||
qse_char_t* data,
|
qse_char_t* data,
|
||||||
qse_size_t count)
|
qse_size_t count)
|
||||||
{
|
{
|
||||||
console_t* con = qse_awk_rtx_getxtnstd (rtx);
|
console_t* con = qse_awk_rtx_getxtn(rtx);
|
||||||
|
|
||||||
/* this function is called separately for the console input and console
|
/* this function is called separately for the console input and console
|
||||||
* output. however, since i don't maintain underlying resources like
|
* output. however, since i don't maintain underlying resources like
|
||||||
@ -129,7 +129,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get the pointer to the extension area. */
|
/* get the pointer to the extension area. */
|
||||||
con = (console_t*)qse_awk_rtx_getxtnstd (rtx);
|
con = (console_t*)qse_awk_rtx_getxtn(rtx);
|
||||||
/* initialize fields that require non-zero values.
|
/* initialize fields that require non-zero values.
|
||||||
* the entire extension area was initialized to zeros
|
* the entire extension area was initialized to zeros
|
||||||
* when it was created. */
|
* when it was created. */
|
||||||
|
@ -36,7 +36,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
|||||||
/* add global variables G1, G2, and G3. store the IDs to the extension
|
/* add global variables G1, G2, and G3. store the IDs to the extension
|
||||||
* area. the extension area is used for demonstration. there is no special
|
* area. the extension area is used for demonstration. there is no special
|
||||||
* need to use it when adding global variables. */
|
* need to use it when adding global variables. */
|
||||||
ginfo = qse_awk_getxtnstd (awk);
|
ginfo = qse_awk_getxtn(awk);
|
||||||
for (i = 0; i < QSE_COUNTOF(ginfo->g); i++)
|
for (i = 0; i < QSE_COUNTOF(ginfo->g); i++)
|
||||||
{
|
{
|
||||||
qse_char_t name[] = QSE_T("GX");
|
qse_char_t name[] = QSE_T("GX");
|
||||||
|
@ -39,7 +39,8 @@ static qse_ssize_t new_pipe_handler (
|
|||||||
qse_char_t* data, qse_size_t size)
|
qse_char_t* data, qse_size_t size)
|
||||||
{
|
{
|
||||||
struct rtx_xtn_t* xtn;
|
struct rtx_xtn_t* xtn;
|
||||||
xtn = qse_awk_rtx_getxtnstd (rtx);
|
|
||||||
|
xtn = qse_awk_rtx_getxtn(rtx);
|
||||||
|
|
||||||
if (cmd == QSE_AWK_RIO_OPEN)
|
if (cmd == QSE_AWK_RIO_OPEN)
|
||||||
qse_fprintf (QSE_STDERR, QSE_T("LOG: Executing [%s] for piping\n"), riod->name);
|
qse_fprintf (QSE_STDERR, QSE_T("LOG: Executing [%s] for piping\n"), riod->name);
|
||||||
@ -55,7 +56,7 @@ static void extend_pipe_handler (qse_awk_rtx_t* rtx)
|
|||||||
struct rtx_xtn_t* xtn;
|
struct rtx_xtn_t* xtn;
|
||||||
qse_awk_rio_t rio;
|
qse_awk_rio_t rio;
|
||||||
|
|
||||||
xtn = qse_awk_rtx_getxtnstd (rtx);
|
xtn = qse_awk_rtx_getxtn(rtx);
|
||||||
|
|
||||||
/* get the previous handler functions */
|
/* get the previous handler functions */
|
||||||
qse_awk_rtx_getrio (rtx, &rio);
|
qse_awk_rtx_getrio (rtx, &rio);
|
||||||
|
Loading…
Reference in New Issue
Block a user