added some code to support module calls using module-name::function-name syntax to awk.
reorganized a few awk error code
This commit is contained in:
parent
3cec861547
commit
11b9829c9b
@ -418,9 +418,9 @@ typedef qse_bool_t (*qse_awk_isemptyrex_t) (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_fnc_fun_t type defines a intrinsic function handler.
|
||||
* The qse_awk_fnc_impl_t type defines a intrinsic function handler.
|
||||
*/
|
||||
typedef int (*qse_awk_fnc_fun_t) (
|
||||
typedef int (*qse_awk_fnc_impl_t) (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
const qse_cstr_t* name /**< function name */
|
||||
);
|
||||
@ -472,9 +472,9 @@ struct qse_awk_sio_arg_t
|
||||
typedef struct qse_awk_sio_arg_t qse_awk_sio_arg_t;
|
||||
|
||||
/**
|
||||
* The qse_awk_sio_fun_t type defines a source IO function
|
||||
* The qse_awk_sio_impl_t type defines a source IO function
|
||||
*/
|
||||
typedef qse_ssize_t (*qse_awk_sio_fun_t) (
|
||||
typedef qse_ssize_t (*qse_awk_sio_impl_t) (
|
||||
qse_awk_t* awk,
|
||||
qse_awk_sio_cmd_t cmd,
|
||||
qse_awk_sio_arg_t* arg,
|
||||
@ -571,9 +571,9 @@ struct qse_awk_rio_arg_t
|
||||
typedef struct qse_awk_rio_arg_t qse_awk_rio_arg_t;
|
||||
|
||||
/**
|
||||
* The qse_awk_rio_fun_t type defines a runtime I/O handler.
|
||||
* The qse_awk_rio_impl_t type defines a runtime I/O handler.
|
||||
*/
|
||||
typedef qse_ssize_t (*qse_awk_rio_fun_t) (
|
||||
typedef qse_ssize_t (*qse_awk_rio_impl_t) (
|
||||
qse_awk_rtx_t* rtx,
|
||||
qse_awk_rio_cmd_t cmd,
|
||||
qse_awk_rio_arg_t* riod,
|
||||
@ -661,8 +661,8 @@ typedef struct qse_awk_prm_t qse_awk_prm_t;
|
||||
*/
|
||||
struct qse_awk_sio_t
|
||||
{
|
||||
qse_awk_sio_fun_t in; /**< input script stream handler */
|
||||
qse_awk_sio_fun_t out; /**< output script stream handler */
|
||||
qse_awk_sio_impl_t in; /**< input script stream handler */
|
||||
qse_awk_sio_impl_t out; /**< output script stream handler */
|
||||
};
|
||||
typedef struct qse_awk_sio_t qse_awk_sio_t;
|
||||
|
||||
@ -674,14 +674,56 @@ typedef struct qse_awk_sio_t qse_awk_sio_t;
|
||||
*/
|
||||
struct qse_awk_rio_t
|
||||
{
|
||||
qse_awk_rio_fun_t pipe; /**< pipe handler */
|
||||
qse_awk_rio_fun_t file; /**< file handler */
|
||||
qse_awk_rio_fun_t console; /**< console handler */
|
||||
qse_awk_rio_impl_t pipe; /**< pipe handler */
|
||||
qse_awk_rio_impl_t file; /**< file handler */
|
||||
qse_awk_rio_impl_t console; /**< console handler */
|
||||
};
|
||||
typedef struct qse_awk_rio_t qse_awk_rio_t;
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
typedef struct qse_awk_mod_t qse_awk_mod_t;
|
||||
typedef struct qse_awk_mod_info_t qse_awk_mod_info_t;
|
||||
|
||||
enum qse_awk_mod_type_t
|
||||
{
|
||||
QSE_AWK_MOD_FNC = 0 /*,
|
||||
QSE_AWK_MOD_VAR */
|
||||
};
|
||||
typedef enum qse_awk_mod_type_t qse_awk_mod_type_t;
|
||||
|
||||
struct qse_awk_mod_info_t
|
||||
{
|
||||
qse_awk_mod_type_t type;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
int min; /* min. numbers of argument for a function */
|
||||
int max; /* max. numbers of argument for a function */
|
||||
} arg;
|
||||
qse_awk_fnc_impl_t impl;
|
||||
} f;
|
||||
} u;
|
||||
};
|
||||
|
||||
typedef int (*qse_awk_mod_query_t) (
|
||||
qse_awk_t* awk,
|
||||
const qse_char_t* name,
|
||||
qse_awk_mod_info_t* info
|
||||
);
|
||||
|
||||
struct qse_awk_mod_t
|
||||
{
|
||||
qse_awk_mod_query_t query;
|
||||
int (*init) (qse_awk_t* awk, qse_awk_rtx_t* rtx);
|
||||
void (*fini) (qse_awk_t* awk, qse_awk_rtx_t* rtx);
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* The qse_awk_ecb_close_t type defines the callback function
|
||||
* called when an awk object is closed.
|
||||
@ -973,15 +1015,15 @@ enum qse_awk_errnum_t
|
||||
QSE_AWK_EGBLTM, /**< too many global variables */
|
||||
QSE_AWK_ELCLTM, /**< too many local variables */
|
||||
QSE_AWK_EPARTM, /**< too many parameters */
|
||||
QSE_AWK_EDELETE, /**< 'delete' not followed by variable */
|
||||
QSE_AWK_ERESET, /**< 'reset' not followed by variable */
|
||||
QSE_AWK_ESEGTM, /**< too many identifier segments */
|
||||
QSE_AWK_EBADARG, /**< bad argument */
|
||||
QSE_AWK_ENOARG, /**< no argument */
|
||||
QSE_AWK_EBREAK, /**< 'break' outside a loop */
|
||||
QSE_AWK_ECONTINUE, /**< 'continue' outside a loop */
|
||||
QSE_AWK_ENEXTBEG, /**< 'next' illegal in BEGIN block */
|
||||
QSE_AWK_ENEXTEND, /**< 'next' illegal in END block */
|
||||
QSE_AWK_ENEXTFBEG, /**< 'nextfile' illegal in BEGIN block */
|
||||
QSE_AWK_ENEXTFEND, /**< 'nextfile' illegal in END block */
|
||||
QSE_AWK_EPRINTFARG,/**< 'printf' not followed by argument */
|
||||
QSE_AWK_EPREPST, /**< both prefix and postfix incr/decr operator present */
|
||||
QSE_AWK_EINCDECOPR,/**< illegal operand for incr/decr operator */
|
||||
QSE_AWK_EINCLSTR, /**< 'include' not followed by a string */
|
||||
@ -1008,8 +1050,6 @@ enum qse_awk_errnum_t
|
||||
QSE_AWK_ESCALARTOMAP, /**< cannot change a scalar value to a map */
|
||||
QSE_AWK_EMAPNA, /**< map not allowed */
|
||||
QSE_AWK_EVALTYPE, /**< invalid value type */
|
||||
QSE_AWK_ERDELETE, /**< 'delete' called with wrong target */
|
||||
QSE_AWK_ERRESET, /**< 'reset' called with wrong target */
|
||||
QSE_AWK_ERNEXTBEG, /**< 'next' called from BEGIN block */
|
||||
QSE_AWK_ERNEXTEND, /**< 'next' called from END block */
|
||||
QSE_AWK_ERNEXTFBEG, /**< 'nextfile' called from BEGIN block */
|
||||
@ -1247,9 +1287,9 @@ extern qse_awk_val_t* qse_awk_val_one;
|
||||
* @return a pointer to a qse_awk_t object on success, #QSE_NULL on failure.
|
||||
*/
|
||||
qse_awk_t* qse_awk_open (
|
||||
qse_mmgr_t* mmgr, /**< memory manager */
|
||||
qse_size_t xtn, /**< extension size in bytes */
|
||||
qse_awk_prm_t* prm /**< pointer to a primitive function structure */
|
||||
qse_mmgr_t* mmgr, /**< memory manager */
|
||||
qse_size_t xtnsize, /**< extension size in bytes */
|
||||
qse_awk_prm_t* prm /**< pointer to a primitive function structure */
|
||||
);
|
||||
|
||||
/**
|
||||
@ -1484,14 +1524,14 @@ int qse_awk_findgbl (
|
||||
* The qse_awk_addfnc() function adds an intrinsic function.
|
||||
*/
|
||||
void* qse_awk_addfnc (
|
||||
qse_awk_t* awk,
|
||||
const qse_char_t* name,
|
||||
qse_size_t name_len,
|
||||
int when_valid,
|
||||
qse_size_t min_args,
|
||||
qse_size_t max_args,
|
||||
const qse_char_t* arg_spec,
|
||||
qse_awk_fnc_fun_t handler
|
||||
qse_awk_t* awk,
|
||||
const qse_char_t* name,
|
||||
qse_size_t name_len,
|
||||
int when_valid,
|
||||
qse_size_t min_args,
|
||||
qse_size_t max_args,
|
||||
const qse_char_t* arg_spec,
|
||||
qse_awk_fnc_impl_t handler
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -163,7 +163,7 @@ int qse_awk_parsestd (
|
||||
*/
|
||||
qse_awk_rtx_t* qse_awk_rtx_openstd (
|
||||
qse_awk_t* awk,
|
||||
qse_size_t xtn,
|
||||
qse_size_t xtnsize,
|
||||
const qse_char_t* id,
|
||||
const qse_char_t* icf[],
|
||||
const qse_char_t* ocf[],
|
||||
|
@ -29,7 +29,7 @@
|
||||
* in a path name.
|
||||
*/
|
||||
|
||||
typedef int (*qse_glob_cbfun_t) (
|
||||
typedef int (*qse_glob_cbimpl_t) (
|
||||
const qse_cstr_t* path,
|
||||
void* cbctx
|
||||
);
|
||||
@ -54,24 +54,24 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* The qse_glob() function finds path names matchin the @a pattern.
|
||||
* It calls the call-back function @a cbfun for each path name found.
|
||||
* It calls the call-back function @a cbimpl for each path name found.
|
||||
*
|
||||
* @return -1 on failure, 0 on no match, 1 if matches are found.
|
||||
*/
|
||||
int qse_glob (
|
||||
const qse_char_t* pattern,
|
||||
qse_glob_cbfun_t cbfun,
|
||||
void* cbctx,
|
||||
int flags,
|
||||
qse_mmgr_t* mmgr
|
||||
const qse_char_t* pattern,
|
||||
qse_glob_cbimpl_t cbimpl,
|
||||
void* cbctx,
|
||||
int flags,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
|
||||
int qse_globwithcmgr (
|
||||
const qse_char_t* pattern,
|
||||
qse_glob_cbfun_t cbfun,
|
||||
void* cbctx,
|
||||
int flags,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_char_t* pattern,
|
||||
qse_glob_cbimpl_t cbimpl,
|
||||
void* cbctx,
|
||||
int flags,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_cmgr_t* cmgr
|
||||
);
|
||||
|
||||
|
@ -81,9 +81,9 @@ enum qse_tio_misc_t
|
||||
typedef struct qse_tio_t qse_tio_t;
|
||||
|
||||
/**
|
||||
* The qse_tio_io_fun_t types define a text I/O handler.
|
||||
* The qse_tio_io_impl_t types define a text I/O handler.
|
||||
*/
|
||||
typedef qse_ssize_t (*qse_tio_io_fun_t) (
|
||||
typedef qse_ssize_t (*qse_tio_io_impl_t) (
|
||||
qse_tio_t* tio,
|
||||
qse_tio_cmd_t cmd,
|
||||
void* data,
|
||||
@ -92,7 +92,7 @@ typedef qse_ssize_t (*qse_tio_io_fun_t) (
|
||||
|
||||
struct qse_tio_io_t
|
||||
{
|
||||
qse_tio_io_fun_t fun;
|
||||
qse_tio_io_impl_t fun;
|
||||
struct
|
||||
{
|
||||
qse_size_t capa;
|
||||
@ -200,7 +200,7 @@ void qse_tio_setcmgr (
|
||||
*/
|
||||
int qse_tio_attachin (
|
||||
qse_tio_t* tio,
|
||||
qse_tio_io_fun_t input,
|
||||
qse_tio_io_impl_t input,
|
||||
qse_mchar_t* bufptr,
|
||||
qse_size_t bufcapa
|
||||
);
|
||||
@ -219,7 +219,7 @@ int qse_tio_detachin (
|
||||
*/
|
||||
int qse_tio_attachout (
|
||||
qse_tio_t* tio,
|
||||
qse_tio_io_fun_t output,
|
||||
qse_tio_io_impl_t output,
|
||||
qse_mchar_t* bufptr,
|
||||
qse_size_t bufcapa
|
||||
);
|
||||
|
@ -61,7 +61,7 @@
|
||||
*
|
||||
* The input and output streams needed by qse_sed_exec() are implemented in
|
||||
* the form of callback functions. You should implement two functions
|
||||
* conforming to the ::qse_sed_io_fun_t type.
|
||||
* conforming to the ::qse_sed_io_impl_t type.
|
||||
*/
|
||||
typedef struct qse_sed_t qse_sed_t;
|
||||
|
||||
@ -324,10 +324,10 @@ struct qse_sed_io_arg_t
|
||||
typedef struct qse_sed_io_arg_t qse_sed_io_arg_t;
|
||||
|
||||
/**
|
||||
* The qse_sed_io_fun_t type defines an I/O handler. I/O handlers are called by
|
||||
* The qse_sed_io_impl_t type defines an I/O handler. I/O handlers are called by
|
||||
* qse_sed_exec().
|
||||
*/
|
||||
typedef qse_ssize_t (*qse_sed_io_fun_t) (
|
||||
typedef qse_ssize_t (*qse_sed_io_impl_t) (
|
||||
qse_sed_t* sed,
|
||||
qse_sed_io_cmd_t cmd,
|
||||
qse_sed_io_arg_t* arg,
|
||||
@ -564,7 +564,7 @@ void qse_sed_pushecb (
|
||||
*/
|
||||
int qse_sed_comp (
|
||||
qse_sed_t* sed, /**< stream editor */
|
||||
qse_sed_io_fun_t inf /**< script stream reader */
|
||||
qse_sed_io_impl_t inf /**< script stream reader */
|
||||
);
|
||||
|
||||
/**
|
||||
@ -573,8 +573,8 @@ int qse_sed_comp (
|
||||
*/
|
||||
int qse_sed_exec (
|
||||
qse_sed_t* sed, /**< stream editor */
|
||||
qse_sed_io_fun_t inf, /**< stream reader */
|
||||
qse_sed_io_fun_t outf /**< stream writer */
|
||||
qse_sed_io_impl_t inf, /**< stream reader */
|
||||
qse_sed_io_impl_t outf /**< stream writer */
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -64,9 +64,9 @@ struct qse_stx_io_arg_t
|
||||
typedef struct qse_stx_io_arg_t qse_stx_io_arg_t;
|
||||
|
||||
/**
|
||||
* The qse_stx_io_fun_t type defines an I/O handler function.
|
||||
* The qse_stx_io_impl_t type defines an I/O handler function.
|
||||
*/
|
||||
typedef qse_ssize_t (*qse_stx_io_fun_t) (
|
||||
typedef qse_ssize_t (*qse_stx_io_impl_t) (
|
||||
qse_stx_t* stx,
|
||||
qse_stx_io_cmd_t cmd,
|
||||
qse_stx_io_arg_t* arg,
|
||||
@ -79,8 +79,8 @@ typedef qse_ssize_t (*qse_stx_io_fun_t) (
|
||||
*/
|
||||
struct qse_stx_io_t
|
||||
{
|
||||
qse_stx_io_fun_t in;
|
||||
qse_stx_io_fun_t out;
|
||||
qse_stx_io_impl_t in;
|
||||
qse_stx_io_impl_t out;
|
||||
};
|
||||
typedef struct qse_stx_io_t qse_stx_io_t;
|
||||
|
||||
|
@ -8,7 +8,7 @@ AM_CPPFLAGS = \
|
||||
lib_LTLIBRARIES = libqseawk.la
|
||||
libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h err.h rio.h val.h fnc.h misc.h parse.h run.h tree.h
|
||||
libqseawk_la_LDFLAGS = -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||
libqseawk_la_LIBADD = -lqsecmn $(LIBM)
|
||||
libqseawk_la_LIBADD = -lqsecmn $(LIBM) -lltdl
|
||||
|
||||
if ENABLE_CXX
|
||||
lib_LTLIBRARIES += libqseawkxx.la
|
||||
|
@ -295,7 +295,7 @@ AM_CPPFLAGS = \
|
||||
lib_LTLIBRARIES = libqseawk.la $(am__append_1) $(am__append_2)
|
||||
libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h err.h rio.h val.h fnc.h misc.h parse.h run.h tree.h
|
||||
libqseawk_la_LDFLAGS = -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||
libqseawk_la_LIBADD = -lqsecmn $(LIBM)
|
||||
libqseawk_la_LIBADD = -lqsecmn $(LIBM) -lltdl
|
||||
@ENABLE_CXX_TRUE@libqseawkxx_la_SOURCES = Awk.cpp StdAwk.cpp
|
||||
@ENABLE_CXX_TRUE@libqseawkxx_la_LDFLAGS = -L. -L../cmn -L$(libdir) -version-info 1:0:0 -no-undefined
|
||||
@ENABLE_CXX_TRUE@libqseawkxx_la_LIBADD = -lqseawk -lqsecmn $(LIBM)
|
||||
|
@ -72,7 +72,7 @@ static void clear_token (qse_awk_tok_t* tok)
|
||||
tok->loc.colm = 0;
|
||||
}
|
||||
|
||||
qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_awk_prm_t* prm)
|
||||
qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* prm)
|
||||
{
|
||||
qse_awk_t* awk;
|
||||
|
||||
@ -109,11 +109,11 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_awk_prm_t* prm)
|
||||
};
|
||||
|
||||
/* allocate the object */
|
||||
awk = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_awk_t) + xtn);
|
||||
awk = QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_awk_t) + xtnsize);
|
||||
if (awk == QSE_NULL) return QSE_NULL;
|
||||
|
||||
/* zero out the object */
|
||||
QSE_MEMSET (awk, 0, QSE_SIZEOF(qse_awk_t) + xtn);
|
||||
/* zero out the object + extension area */
|
||||
QSE_MEMSET (awk, 0, QSE_SIZEOF(qse_awk_t) + xtnsize);
|
||||
|
||||
/* remember the memory manager */
|
||||
awk->mmgr = mmgr;
|
||||
|
@ -174,8 +174,8 @@ struct qse_awk_t
|
||||
/* source code management */
|
||||
struct
|
||||
{
|
||||
qse_awk_sio_fun_t inf;
|
||||
qse_awk_sio_fun_t outf;
|
||||
qse_awk_sio_impl_t inf;
|
||||
qse_awk_sio_impl_t outf;
|
||||
|
||||
qse_awk_sio_lxc_t last;
|
||||
|
||||
@ -236,6 +236,7 @@ struct qse_awk_t
|
||||
|
||||
qse_bool_t stopall;
|
||||
qse_awk_ecb_t* ecb;
|
||||
qse_awk_mod_t* mod;
|
||||
};
|
||||
|
||||
struct qse_awk_chain_t
|
||||
@ -340,7 +341,7 @@ struct qse_awk_rtx_t
|
||||
/* rio chain */
|
||||
struct
|
||||
{
|
||||
qse_awk_rio_fun_t handler[QSE_AWK_RIO_NUM];
|
||||
qse_awk_rio_impl_t handler[QSE_AWK_RIO_NUM];
|
||||
qse_awk_rio_arg_t* chain;
|
||||
} rio;
|
||||
|
||||
@ -352,7 +353,7 @@ struct qse_awk_rtx_t
|
||||
struct
|
||||
{
|
||||
qse_char_t* ptr;
|
||||
qse_size_t len; /* length */
|
||||
qse_size_t len; /* length */
|
||||
qse_size_t inc; /* increment */
|
||||
} tmp;
|
||||
} format;
|
||||
|
@ -88,15 +88,15 @@ const qse_char_t* qse_awk_dflerrstr (const qse_awk_t* awk, qse_awk_errnum_t errn
|
||||
QSE_T("too many global variables"),
|
||||
QSE_T("too many local variables"),
|
||||
QSE_T("too many parameters"),
|
||||
QSE_T("'delete' not followed by variable"),
|
||||
QSE_T("'reset' not followed by variable"),
|
||||
QSE_T("too many identifier segments"),
|
||||
QSE_T("bad argument"),
|
||||
QSE_T("no argument provided"),
|
||||
QSE_T("'break' outside a loop"),
|
||||
QSE_T("'continue' outside a loop"),
|
||||
QSE_T("'next' illegal in the BEGIN block"),
|
||||
QSE_T("'next' illegal in the END block"),
|
||||
QSE_T("'nextfile' illegal in the BEGIN block"),
|
||||
QSE_T("'nextfile' illegal in the END block"),
|
||||
QSE_T("'printf' not followed by argument"),
|
||||
QSE_T("both prefix and postfix increment/decrement operator present"),
|
||||
QSE_T("illegal operand for increment/decrement operator"),
|
||||
QSE_T("'include' not followed by a string"),
|
||||
@ -116,20 +116,18 @@ const qse_char_t* qse_awk_dflerrstr (const qse_awk_t* awk, qse_awk_errnum_t errn
|
||||
QSE_T("right-hand side of the 'in' operator not a map nor nil"),
|
||||
QSE_T("value not referenceable"),
|
||||
QSE_T("value not assignable"),
|
||||
QSE_T("an indexed value cannot be assigned a map"),
|
||||
QSE_T("a positional value cannot be assigned a map"),
|
||||
QSE_T("indexed value cannot be assigned a map"),
|
||||
QSE_T("positional value cannot be assigned a map"),
|
||||
QSE_T("map '${0}' not assignable with a scalar"),
|
||||
QSE_T("cannot change a scalar value to a map"),
|
||||
QSE_T("map not allowed"),
|
||||
QSE_T("invalid value type"),
|
||||
QSE_T("'delete' called with wrong target"),
|
||||
QSE_T("'reset' called with wrong target"),
|
||||
QSE_T("'next' called from BEGIN block"),
|
||||
QSE_T("'next' called from END block"),
|
||||
QSE_T("'nextfile' called from BEGIN block"),
|
||||
QSE_T("'nextfile' called from END block"),
|
||||
QSE_T("intrinsic function handler for '${0}' failed"),
|
||||
QSE_T("wrong implementation of user-defined io handler"),
|
||||
QSE_T("wrong implementation of user-defined I/O handler"),
|
||||
QSE_T("I/O handler returned an error"),
|
||||
QSE_T("no such I/O name found"),
|
||||
QSE_T("I/O name empty"),
|
||||
|
@ -99,7 +99,7 @@ void* qse_awk_addfnc (
|
||||
int when_valid,
|
||||
qse_size_t min_args, qse_size_t max_args,
|
||||
const qse_char_t* arg_spec,
|
||||
qse_awk_fnc_fun_t handler)
|
||||
qse_awk_fnc_impl_t handler)
|
||||
{
|
||||
qse_awk_fnc_t* fnc;
|
||||
qse_size_t fnc_size;
|
||||
@ -111,6 +111,10 @@ void* qse_awk_addfnc (
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* Note it doesn't check if it conflicts with a keyword.
|
||||
* such a function registered won't take effect because
|
||||
* the word is treated as a keyword */
|
||||
|
||||
if (qse_awk_getfnc (awk, name, name_len) != QSE_NULL)
|
||||
{
|
||||
qse_cstr_t errarg;
|
||||
|
@ -22,7 +22,6 @@
|
||||
#define _QSE_LIB_AWK_FNC_H_
|
||||
|
||||
typedef struct qse_awk_fnc_t qse_awk_fnc_t;
|
||||
|
||||
struct qse_awk_fnc_t
|
||||
{
|
||||
struct
|
||||
@ -42,7 +41,7 @@ struct qse_awk_fnc_t
|
||||
qse_char_t* spec;
|
||||
} arg;
|
||||
|
||||
qse_awk_fnc_fun_t handler;
|
||||
qse_awk_fnc_impl_t handler;
|
||||
|
||||
/*qse_awk_fnc_t* next;*/
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -89,10 +89,10 @@ static int out_mask_map[] =
|
||||
|
||||
static int find_rio_in (
|
||||
qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
|
||||
qse_awk_rio_arg_t** rio, qse_awk_rio_fun_t* fun)
|
||||
qse_awk_rio_arg_t** rio, qse_awk_rio_impl_t* fun)
|
||||
{
|
||||
qse_awk_rio_arg_t* p = run->rio.chain;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int io_type, io_mode, io_mask;
|
||||
|
||||
QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_type_map));
|
||||
@ -297,7 +297,7 @@ int qse_awk_rtx_readio (
|
||||
const qse_char_t* name, qse_str_t* buf)
|
||||
{
|
||||
qse_awk_rio_arg_t* p;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int ret;
|
||||
|
||||
qse_awk_val_t* rs;
|
||||
@ -673,7 +673,7 @@ int qse_awk_rtx_writeio_str (
|
||||
const qse_char_t* name, qse_char_t* str, qse_size_t len)
|
||||
{
|
||||
qse_awk_rio_arg_t* p = run->rio.chain;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int io_type, io_mode, io_mask;
|
||||
qse_ssize_t n;
|
||||
|
||||
@ -816,7 +816,7 @@ int qse_awk_rtx_flushio (
|
||||
qse_awk_rtx_t* run, int out_type, const qse_char_t* name)
|
||||
{
|
||||
qse_awk_rio_arg_t* p = run->rio.chain;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
qse_ssize_t n;
|
||||
int ok = 0;
|
||||
@ -871,7 +871,7 @@ int qse_awk_rtx_nextio_read (
|
||||
qse_awk_rtx_t* run, int in_type, const qse_char_t* name)
|
||||
{
|
||||
qse_awk_rio_arg_t* p = run->rio.chain;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
qse_ssize_t n;
|
||||
|
||||
@ -949,7 +949,7 @@ int qse_awk_rtx_nextio_write (
|
||||
qse_awk_rtx_t* run, int out_type, const qse_char_t* name)
|
||||
{
|
||||
qse_awk_rio_arg_t* p = run->rio.chain;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
qse_ssize_t n;
|
||||
|
||||
@ -1022,7 +1022,7 @@ int qse_awk_rtx_closio_read (
|
||||
qse_awk_rtx_t* run, int in_type, const qse_char_t* name)
|
||||
{
|
||||
qse_awk_rio_arg_t* p = run->rio.chain, * px = QSE_NULL;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
|
||||
QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_type_map));
|
||||
@ -1047,7 +1047,7 @@ int qse_awk_rtx_closio_read (
|
||||
if (p->type == (io_type | io_mask) &&
|
||||
qse_strcmp (p->name, name) == 0)
|
||||
{
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
|
||||
handler = run->rio.handler[p->type & IO_MASK_CLEAR];
|
||||
if (handler != QSE_NULL)
|
||||
@ -1081,7 +1081,7 @@ int qse_awk_rtx_closio_write (
|
||||
qse_awk_rtx_t* run, int out_type, const qse_char_t* name)
|
||||
{
|
||||
qse_awk_rio_arg_t* p = run->rio.chain, * px = QSE_NULL;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
int io_type, /*io_mode,*/ io_mask;
|
||||
|
||||
QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_type_map));
|
||||
@ -1106,7 +1106,7 @@ int qse_awk_rtx_closio_write (
|
||||
if (p->type == (io_type | io_mask) &&
|
||||
qse_strcmp (p->name, name) == 0)
|
||||
{
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
|
||||
handler = run->rio.handler[p->type & IO_MASK_CLEAR];
|
||||
if (handler != QSE_NULL)
|
||||
@ -1147,7 +1147,7 @@ int qse_awk_rtx_closeio (
|
||||
* regardless of the io type */
|
||||
if (qse_strcmp (p->name, name) == 0)
|
||||
{
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
qse_awk_rio_rwcmode_t rwcmode = QSE_AWK_RIO_CLOSE_FULL;
|
||||
|
||||
if (opt != QSE_NULL)
|
||||
@ -1232,7 +1232,7 @@ int qse_awk_rtx_closeio (
|
||||
void qse_awk_rtx_cleario (qse_awk_rtx_t* run)
|
||||
{
|
||||
qse_awk_rio_arg_t* next;
|
||||
qse_awk_rio_fun_t handler;
|
||||
qse_awk_rio_impl_t handler;
|
||||
qse_ssize_t n;
|
||||
|
||||
while (run->rio.chain != QSE_NULL)
|
||||
|
@ -695,7 +695,7 @@ qse_htb_t* qse_awk_rtx_getnvmap (qse_awk_rtx_t* rtx)
|
||||
}
|
||||
|
||||
qse_awk_rtx_t* qse_awk_rtx_open (
|
||||
qse_awk_t* awk, qse_size_t xtn, qse_awk_rio_t* rio)
|
||||
qse_awk_t* awk, qse_size_t xtnsize, qse_awk_rio_t* rio)
|
||||
{
|
||||
qse_awk_rtx_t* rtx;
|
||||
|
||||
@ -718,7 +718,7 @@ qse_awk_rtx_t* qse_awk_rtx_open (
|
||||
|
||||
/* allocate the storage for the rtx object */
|
||||
rtx = (qse_awk_rtx_t*) QSE_AWK_ALLOC (
|
||||
awk, QSE_SIZEOF(qse_awk_rtx_t) + xtn);
|
||||
awk, QSE_SIZEOF(qse_awk_rtx_t) + xtnsize);
|
||||
if (rtx == QSE_NULL)
|
||||
{
|
||||
/* if it fails, the failure is reported thru
|
||||
@ -727,7 +727,8 @@ qse_awk_rtx_t* qse_awk_rtx_open (
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* initialize the run object */
|
||||
/* initialize the rtx object */
|
||||
QSE_MEMSET (rtx, 0, QSE_SIZEOF(qse_awk_rtx_t) + xtnsize);
|
||||
if (init_rtx (rtx, awk, rio) <= -1)
|
||||
{
|
||||
QSE_AWK_FREE (awk, rtx);
|
||||
@ -830,9 +831,6 @@ static int init_rtx (qse_awk_rtx_t* rtx, qse_awk_t* awk, qse_awk_rio_t* rio)
|
||||
QSE_HTB_HASHER_DEFAULT
|
||||
};
|
||||
|
||||
/* zero out the runtime context excluding the extension */
|
||||
QSE_MEMSET (rtx, 0, QSE_SIZEOF(qse_awk_rtx_t));
|
||||
|
||||
rtx->awk = awk;
|
||||
|
||||
CLRERR (rtx);
|
||||
@ -2629,14 +2627,13 @@ static int run_delete (qse_awk_rtx_t* rtx, qse_awk_nde_delete_t* nde)
|
||||
case QSE_AWK_NDE_LCLIDX:
|
||||
case QSE_AWK_NDE_ARGIDX:
|
||||
return run_delete_nonnamed (rtx, var);
|
||||
|
||||
}
|
||||
|
||||
QSE_ASSERTX (
|
||||
!"should never happen - wrong target for delete",
|
||||
"the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc");
|
||||
|
||||
SETERR_LOC (rtx, QSE_AWK_ERDELETE, &var->loc);
|
||||
SETERR_LOC (rtx, QSE_AWK_EBADARG, &var->loc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2687,7 +2684,7 @@ static int run_reset (qse_awk_rtx_t* rtx, qse_awk_nde_reset_t* nde)
|
||||
!"should never happen - wrong target for reset",
|
||||
"the reset statement can only be called with plain variables");
|
||||
|
||||
SETERR_LOC (rtx, QSE_AWK_ERRESET, &var->loc);
|
||||
SETERR_LOC (rtx, QSE_AWK_EBADARG, &var->loc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <qse/cmn/time.h>
|
||||
#include <qse/cmn/path.h>
|
||||
#include <qse/cmn/htb.h>
|
||||
#include <qse/cmn/rbt.h>
|
||||
#include <qse/cmn/env.h>
|
||||
#include <qse/cmn/alg.h>
|
||||
#include <qse/cmn/stdio.h> /* TODO: remove dependency on qse_vsprintf */
|
||||
@ -48,6 +49,7 @@
|
||||
/* anything ? */
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# include <ltdl.h>
|
||||
#endif
|
||||
|
||||
#ifndef QSE_HAVE_CONFIG_H
|
||||
@ -109,6 +111,9 @@ typedef struct xtn_t
|
||||
int gbl_argv;
|
||||
int gbl_environ;
|
||||
int gbl_procinfo;
|
||||
|
||||
qse_rbt_t modtab;
|
||||
qse_awk_ecb_t ecb;
|
||||
} xtn_t;
|
||||
|
||||
typedef struct rxtn_t
|
||||
@ -136,6 +141,8 @@ typedef struct rxtn_t
|
||||
|
||||
int cmgrtab_inited;
|
||||
qse_htb_t cmgrtab;
|
||||
|
||||
qse_awk_rtx_ecb_t ecb;
|
||||
} rxtn_t;
|
||||
|
||||
typedef struct ioattr_t
|
||||
@ -307,11 +314,37 @@ static int custom_awk_sprintf (
|
||||
static int add_globals (qse_awk_t* awk);
|
||||
static int add_functions (qse_awk_t* awk);
|
||||
|
||||
static int query_module (
|
||||
qse_awk_t* awk, const qse_char_t* name, qse_awk_mod_info_t* info);
|
||||
static int init_module (qse_awk_t* awk, qse_awk_rtx_t* rtx);
|
||||
static void fini_module (qse_awk_t* awk, qse_awk_rtx_t* rtx);
|
||||
|
||||
static qse_awk_mod_t awk_mod =
|
||||
{
|
||||
query_module,
|
||||
init_module,
|
||||
fini_module
|
||||
};
|
||||
|
||||
qse_awk_t* qse_awk_openstd (qse_size_t xtnsize)
|
||||
{
|
||||
return qse_awk_openstdwithmmgr (QSE_MMGR_GETDFL(), xtnsize);
|
||||
}
|
||||
|
||||
static void fini_xtn (qse_awk_t* awk)
|
||||
{
|
||||
xtn_t* xtn;
|
||||
xtn = (xtn_t*) QSE_XTN (awk);
|
||||
qse_rbt_fini (&xtn->modtab);
|
||||
}
|
||||
|
||||
static void clear_xtn (qse_awk_t* awk)
|
||||
{
|
||||
xtn_t* xtn;
|
||||
xtn = (xtn_t*) QSE_XTN (awk);
|
||||
qse_rbt_clear (&xtn->modtab);
|
||||
}
|
||||
|
||||
qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
||||
{
|
||||
qse_awk_t* awk;
|
||||
@ -338,7 +371,6 @@ qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
||||
|
||||
/* initialize extension */
|
||||
xtn = (xtn_t*) QSE_XTN (awk);
|
||||
QSE_MEMSET (xtn, 0, QSE_SIZEOF(xtn_t));
|
||||
|
||||
/* add intrinsic global variables and functions */
|
||||
if (add_globals(awk) <= -1 ||
|
||||
@ -348,6 +380,19 @@ qse_awk_t* qse_awk_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* TODO: change the way to set this... */
|
||||
awk->mod = &awk_mod;
|
||||
|
||||
if (qse_rbt_init (&xtn->modtab, mmgr, QSE_SIZEOF(qse_char_t), 0) <= -1)
|
||||
{
|
||||
qse_awk_close (awk);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
xtn->ecb.close = fini_xtn;
|
||||
xtn->ecb.clear = clear_xtn;
|
||||
qse_awk_pushecb (awk, &xtn->ecb);
|
||||
|
||||
return awk;
|
||||
}
|
||||
|
||||
@ -1874,12 +1919,6 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
||||
const qse_char_t* ocf[],
|
||||
qse_cmgr_t* cmgr)
|
||||
{
|
||||
static qse_awk_rtx_ecb_t ecb =
|
||||
{
|
||||
QSE_FV (.close, fini_rxtn),
|
||||
QSE_FV (.stmt, QSE_NULL)
|
||||
};
|
||||
|
||||
qse_awk_rtx_t* rtx;
|
||||
qse_awk_rio_t rio;
|
||||
rxtn_t* rxtn;
|
||||
@ -1897,11 +1936,9 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
||||
QSE_SIZEOF(rxtn_t) + xtnsize,
|
||||
&rio
|
||||
);
|
||||
|
||||
if (rtx == QSE_NULL) return QSE_NULL;
|
||||
|
||||
rxtn = (rxtn_t*) QSE_XTN (rtx);
|
||||
QSE_MEMSET (rxtn, 0, QSE_SIZEOF(rxtn_t));
|
||||
|
||||
if (rtx->awk->option & QSE_AWK_RIO)
|
||||
{
|
||||
@ -1918,7 +1955,8 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
||||
rxtn->cmgrtab_inited = 1;
|
||||
}
|
||||
|
||||
qse_awk_rtx_pushecb (rtx, &ecb);
|
||||
rxtn->ecb.close = fini_rxtn;
|
||||
qse_awk_rtx_pushecb (rtx, &rxtn->ecb);
|
||||
|
||||
rxtn->seed = (qse_gettime (&now) <= -1)? 0u: (qse_long_t)now;
|
||||
/* i don't care if the seed becomes negative or overflows.
|
||||
@ -2432,3 +2470,82 @@ static int add_functions (qse_awk_t* awk)
|
||||
qse_awk_addfnc (awk, QSE_T("getioattr"), 9, QSE_AWK_RIO, 2, 2, QSE_NULL, fnc_getioattr) == QSE_NULL) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int query_module (
|
||||
qse_awk_t* awk, const qse_char_t* name, qse_awk_mod_info_t* info)
|
||||
{
|
||||
const qse_char_t* dc;
|
||||
qse_awk_mod_query_t query;
|
||||
xtn_t* xtn;
|
||||
qse_rbt_pair_t* pair;
|
||||
|
||||
xtn = (xtn_t*)QSE_XTN(awk);
|
||||
|
||||
/* TODO: support module calls with deeper levels ... */
|
||||
dc = qse_strstr (name, QSE_T("::"));
|
||||
QSE_ASSERT (dc != QSE_NULL);
|
||||
|
||||
#if defined(_WIN32)
|
||||
/*TODO: implemente this */
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOIMPL, QSE_NULL);
|
||||
return -1;
|
||||
#elif defined(__OS2__)
|
||||
/*TODO: implemente this */
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOIMPL, QSE_NULL);
|
||||
return -1;
|
||||
#elif defined(__DOS__)
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOIMPL, QSE_NULL);
|
||||
return -1;
|
||||
#else
|
||||
|
||||
pair = qse_rbt_search (&xtn->modtab, name, dc - name);
|
||||
if (pair)
|
||||
{
|
||||
/*query = QSE_RBT_VPTR(pair)->query;*/
|
||||
}
|
||||
else
|
||||
{
|
||||
void* dh;
|
||||
const qse_mchar_t* mod;
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
mod = qse_mbsxdup (name, dc - name, QSE_NULL, awk->mmgr);
|
||||
#else
|
||||
mod = qse_wcsntombsdup (name, dc - name, QSE_NULL, awk->mmgr);
|
||||
#endif
|
||||
if (!mod)
|
||||
{
|
||||
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
dh = lt_dlopen (mod);
|
||||
QSE_MMGR_FREE (awk->mmgr, mod);
|
||||
|
||||
if (!dh)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
query = lt_dlsym (dh, QSE_MT("query"));
|
||||
if (!query)
|
||||
{
|
||||
lt_dlclose (dh);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return query (awk, dc + 2, info);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static int init_module (qse_awk_t* awk, qse_awk_rtx_t* rtx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fini_module (qse_awk_t* awk, qse_awk_rtx_t* rtx)
|
||||
{
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ struct qse_awk_nde_fncall_t
|
||||
const qse_char_t* spec;
|
||||
} arg;
|
||||
|
||||
qse_awk_fnc_fun_t handler;
|
||||
qse_awk_fnc_impl_t handler;
|
||||
} fnc;
|
||||
} u;
|
||||
qse_awk_nde_t* args;
|
||||
|
@ -79,7 +79,7 @@ typedef struct stack_node_t stack_node_t;
|
||||
|
||||
struct glob_t
|
||||
{
|
||||
qse_glob_cbfun_t cbfun;
|
||||
qse_glob_cbimpl_t cbimpl;
|
||||
void* cbctx;
|
||||
|
||||
qse_mmgr_t* mmgr;
|
||||
@ -707,7 +707,7 @@ static int handle_non_wild_segments (glob_t* g, segment_t* seg)
|
||||
if (!seg->next && path_exists(g, QSE_STR_PTR(&g->path)) > 0)
|
||||
{
|
||||
/* reached the last segment. match if the path exists */
|
||||
if (g->cbfun (QSE_STR_CSTR(&g->path), g->cbctx) <= -1) return -1;
|
||||
if (g->cbimpl (QSE_STR_CSTR(&g->path), g->cbctx) <= -1) return -1;
|
||||
g->expanded = 1;
|
||||
}
|
||||
}
|
||||
@ -803,7 +803,7 @@ entry:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g->cbfun (QSE_STR_CSTR(&g->path), g->cbctx) <= -1) goto oops;
|
||||
if (g->cbimpl (QSE_STR_CSTR(&g->path), g->cbctx) <= -1) goto oops;
|
||||
g->expanded = 1;
|
||||
}
|
||||
}
|
||||
@ -871,14 +871,14 @@ oops:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int qse_globwithcmgr (const qse_char_t* pattern, qse_glob_cbfun_t cbfun, void* cbctx, int flags, qse_mmgr_t* mmgr, qse_cmgr_t* cmgr)
|
||||
int qse_globwithcmgr (const qse_char_t* pattern, qse_glob_cbimpl_t cbimpl, void* cbctx, int flags, qse_mmgr_t* mmgr, qse_cmgr_t* cmgr)
|
||||
{
|
||||
segment_t seg;
|
||||
glob_t g;
|
||||
int x;
|
||||
|
||||
QSE_MEMSET (&g, 0, QSE_SIZEOF(g));
|
||||
g.cbfun = cbfun;
|
||||
g.cbimpl = cbimpl;
|
||||
g.cbctx = cbctx;
|
||||
g.mmgr = mmgr;
|
||||
g.cmgr = cmgr;
|
||||
@ -928,8 +928,8 @@ int qse_globwithcmgr (const qse_char_t* pattern, qse_glob_cbfun_t cbfun, void* c
|
||||
return g.expanded;
|
||||
}
|
||||
|
||||
int qse_glob (const qse_char_t* pattern, qse_glob_cbfun_t cbfun, void* cbctx, int flags, qse_mmgr_t* mmgr)
|
||||
int qse_glob (const qse_char_t* pattern, qse_glob_cbimpl_t cbimpl, void* cbctx, int flags, qse_mmgr_t* mmgr)
|
||||
{
|
||||
return qse_globwithcmgr (pattern, cbfun, cbctx, flags, mmgr, qse_getdflcmgr());
|
||||
return qse_globwithcmgr (pattern, cbimpl, cbctx, flags, mmgr, qse_getdflcmgr());
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ void qse_tio_setcmgr (qse_tio_t* tio, qse_cmgr_t* cmgr)
|
||||
}
|
||||
|
||||
int qse_tio_attachin (
|
||||
qse_tio_t* tio, qse_tio_io_fun_t input,
|
||||
qse_tio_t* tio, qse_tio_io_impl_t input,
|
||||
qse_mchar_t* bufptr, qse_size_t bufcapa)
|
||||
{
|
||||
qse_mchar_t* xbufptr;
|
||||
@ -206,7 +206,7 @@ int qse_tio_detachin (qse_tio_t* tio)
|
||||
}
|
||||
|
||||
int qse_tio_attachout (
|
||||
qse_tio_t* tio, qse_tio_io_fun_t output,
|
||||
qse_tio_t* tio, qse_tio_io_impl_t output,
|
||||
qse_mchar_t* bufptr, qse_size_t bufcapa)
|
||||
{
|
||||
qse_mchar_t* xbufptr;
|
||||
|
@ -345,6 +345,7 @@ struct httpd_xtn_t
|
||||
#if defined(HAVE_SSL)
|
||||
SSL_CTX* ssl_ctx;
|
||||
#endif
|
||||
qse_httpd_ecb_t ecb;
|
||||
};
|
||||
|
||||
#if defined(HAVE_SSL)
|
||||
@ -412,22 +413,17 @@ qse_httpd_t* qse_httpd_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
||||
qse_httpd_t* httpd;
|
||||
httpd_xtn_t* xtn;
|
||||
|
||||
static qse_httpd_ecb_t std_ecb =
|
||||
{
|
||||
QSE_FV(.close, cleanup_standard_httpd)
|
||||
};
|
||||
|
||||
httpd = qse_httpd_open (mmgr, QSE_SIZEOF(httpd_xtn_t) + xtnsize);
|
||||
if (httpd == QSE_NULL) return QSE_NULL;
|
||||
|
||||
xtn = (httpd_xtn_t*)qse_httpd_getxtn (httpd);
|
||||
QSE_MEMSET (xtn, 0, QSE_SIZEOF(httpd_xtn_t) + xtnsize);
|
||||
|
||||
#if defined(HAVE_SSL)
|
||||
/*init_xtn_ssl (xtn, "http01.pem", "http01.key");*/
|
||||
#endif
|
||||
|
||||
qse_httpd_pushecb (httpd, &std_ecb);
|
||||
xtn->ecb.close = cleanup_standard_httpd;
|
||||
qse_httpd_pushecb (httpd, &xtn->ecb);
|
||||
return httpd;
|
||||
}
|
||||
|
||||
|
@ -1965,7 +1965,7 @@ static int get_command (qse_sed_t* sed, qse_sed_cmd_t* cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int qse_sed_comp (qse_sed_t* sed, qse_sed_io_fun_t inf)
|
||||
int qse_sed_comp (qse_sed_t* sed, qse_sed_io_impl_t inf)
|
||||
{
|
||||
qse_cint_t c;
|
||||
qse_sed_cmd_t* cmd = QSE_NULL;
|
||||
@ -3902,8 +3902,7 @@ static int emit_output (qse_sed_t* sed, int skipline)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int qse_sed_exec (qse_sed_t* sed, qse_sed_io_fun_t inf, qse_sed_io_fun_t outf)
|
||||
int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
|
||||
{
|
||||
qse_ssize_t n;
|
||||
int ret = 0;
|
||||
|
@ -104,7 +104,7 @@ struct qse_sed_t
|
||||
/** source text pointers */
|
||||
struct
|
||||
{
|
||||
qse_sed_io_fun_t fun; /**< input stream handler */
|
||||
qse_sed_io_impl_t fun; /**< input stream handler */
|
||||
qse_sed_io_arg_t arg;
|
||||
qse_char_t buf[1024];
|
||||
int eof;
|
||||
@ -156,7 +156,7 @@ struct qse_sed_t
|
||||
/** data needed for output streams and files */
|
||||
struct
|
||||
{
|
||||
qse_sed_io_fun_t fun; /**< an output handler */
|
||||
qse_sed_io_impl_t fun; /**< an output handler */
|
||||
qse_sed_io_arg_t arg; /**< output handling data */
|
||||
|
||||
qse_char_t buf[2048];
|
||||
@ -174,7 +174,7 @@ struct qse_sed_t
|
||||
/** data needed for input streams */
|
||||
struct
|
||||
{
|
||||
qse_sed_io_fun_t fun; /**< an input handler */
|
||||
qse_sed_io_impl_t fun; /**< an input handler */
|
||||
qse_sed_io_arg_t arg; /**< input handling data */
|
||||
|
||||
qse_char_t xbuf[1]; /**< a read-ahead buffer */
|
||||
|
@ -101,18 +101,7 @@ qse_sed_t* qse_sed_openstd (qse_size_t xtnsize)
|
||||
|
||||
qse_sed_t* qse_sed_openstdwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
|
||||
{
|
||||
qse_sed_t* sed;
|
||||
xtn_t* xtn;
|
||||
|
||||
/* create an object */
|
||||
sed = qse_sed_open (mmgr, QSE_SIZEOF(xtn_t) + xtnsize);
|
||||
if (sed == QSE_NULL) return QSE_NULL;
|
||||
|
||||
/* initialize extension */
|
||||
xtn = (xtn_t*) QSE_XTN (sed);
|
||||
QSE_MEMSET (xtn, 0, QSE_SIZEOF(xtn_t));
|
||||
|
||||
return sed;
|
||||
return qse_sed_open (mmgr, QSE_SIZEOF(xtn_t) + xtnsize);
|
||||
}
|
||||
|
||||
void* qse_sed_getxtnstd (qse_sed_t* sed)
|
||||
|
2
qse/regress/awk/lang-049.awk
Normal file
2
qse/regress/awk/lang-049.awk
Normal file
@ -0,0 +1,2 @@
|
||||
# this should cause a syntax error since printf requries an argument
|
||||
BEGIN { printf; }
|
@ -1352,7 +1352,7 @@ BEGIN {
|
||||
printf ("%s\n",10.34);
|
||||
}
|
||||
|
||||
ERROR: CODE 104 LINE 3 COLUMN 2 - recursion detected in format conversion
|
||||
ERROR: CODE 102 LINE 3 COLUMN 2 - recursion detected in format conversion
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk --newline=on -d- -f lang-014.awk </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
@ -2454,6 +2454,10 @@ BEGIN {
|
||||
127.0.0.1
|
||||
192.168.1.1
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk --newline=on -d- -f lang-049.awk </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
ERROR: CODE 60 LINE 2 COLUMN 9 - no argument provided
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk --newline=on -F: -f columnate.awk passwd.dat </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
root x 0 0 root /root /bin/bash
|
||||
|
@ -1352,7 +1352,7 @@ BEGIN {
|
||||
printf ("%s\n",10.34);
|
||||
}
|
||||
|
||||
ERROR: CODE 104 LINE 3 COLUMN 2 - recursion detected in format conversion
|
||||
ERROR: CODE 102 LINE 3 COLUMN 2 - recursion detected in format conversion
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk -m 500000 --newline=on -d- -f lang-014.awk </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
@ -2454,6 +2454,10 @@ BEGIN {
|
||||
127.0.0.1
|
||||
192.168.1.1
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk -m 500000 --newline=on -d- -f lang-049.awk </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
ERROR: CODE 60 LINE 2 COLUMN 9 - no argument provided
|
||||
--------------------------------------------------------------------------------
|
||||
[CMD] qseawk -m 500000 --newline=on -F: -f columnate.awk passwd.dat </dev/stdin 2>&1
|
||||
--------------------------------------------------------------------------------
|
||||
root x 0 0 root /root /bin/bash
|
||||
|
@ -175,6 +175,7 @@ PROGS="
|
||||
lang-046.awk!lang-046.dat2!!--newline=on -d- -vdatadir=@abs_srcdir@ -vdatafile=lang-046.dat1
|
||||
lang-047.awk!!!--newline=on --tolerant=on -d-
|
||||
lang-048.awk!!!--newline=on --extraops=on -d-
|
||||
lang-049.awk!!!--newline=on -d-
|
||||
|
||||
columnate.awk!passwd.dat!!--newline=on -F:
|
||||
levenshtein-utests.awk!!!--newline=on --include=on
|
||||
|
@ -25,7 +25,7 @@ const qse_char_t* src = QSE_T("BEGIN { print \"hello, world\" | \"dir\"; }");
|
||||
|
||||
struct rtx_xtn_t
|
||||
{
|
||||
qse_awk_rio_fun_t old_pipe_handler;
|
||||
qse_awk_rio_impl_t old_pipe_handler;
|
||||
};
|
||||
|
||||
static qse_ssize_t new_pipe_handler (
|
||||
|
Loading…
x
Reference in New Issue
Block a user