cleaned up code a little

- deleted the QSE_AWK_ARGSTOMAIN option.
- enhanced qse_awk_call() a little
This commit is contained in:
2009-02-12 08:23:50 +00:00
parent 44d4f890f4
commit 924f940fba
5 changed files with 45 additions and 25 deletions

View File

@ -577,12 +577,6 @@ public:
OPT_NEXTOFILE = QSE_AWK_NEXTOFILE,
/** Use CR+LF instead of LF for line breaking. */
OPT_CRLF = QSE_AWK_CRLF,
/**
* When set, the values specified in a call to Awk::run
* as the second and the third parameter are passed to
* the function specified as the first parameter.
*/
OPT_ARGSTOMAIN = QSE_AWK_ARGSTOMAIN,
/** Enables the keyword 'reset' */
OPT_RESET = QSE_AWK_RESET,
/** Allows the assignment of a map value to a variable */
@ -878,12 +872,7 @@ public:
* @param args Pointer to an array of character strings.
* If it is specified, the charater strings are passed to
* an AWK program. The values can be accesed with ARGC & ARGV
* inside the AWK program. If Awk::OPT_ARGSTOMAIN is set and
* the name of entry point is specified, the values are
* accessible as arguments to the entry point function.
* In this case, the number of arguments specified in the
* function definition should not exceed the number of
* character string passed here.
* inside the AWK program.
* @param nargs Number of character strings in the array
*
* @return

View File

@ -247,17 +247,14 @@ enum qse_awk_option_t
/* cr + lf by default */
QSE_AWK_CRLF = (1 << 13),
/* pass the arguments to the main function */
QSE_AWK_ARGSTOMAIN = (1 << 14),
/* enable the non-standard keyword reset */
QSE_AWK_RESET = (1 << 15),
QSE_AWK_RESET = (1 << 14),
/* allows the assignment of a map value to a variable */
QSE_AWK_MAPTOVAR = (1 << 16),
QSE_AWK_MAPTOVAR = (1 << 15),
/* allows BEGIN, END, pattern-action blocks */
QSE_AWK_PABLOCK = (1 << 17)
QSE_AWK_PABLOCK = (1 << 16)
};
/* error code */
@ -1117,8 +1114,8 @@ qse_size_t qse_awk_longtostr (
*/
qse_awk_rtx_t* qse_awk_rtx_open (
qse_awk_t* awk,
qse_awk_rio_t* ios,
qse_awk_rcb_t* cbs,
qse_awk_rio_t* rio,
qse_awk_rcb_t* rcb,
const qse_cstr_t* arg,
void* data
);
@ -1137,6 +1134,19 @@ void qse_awk_rtx_close (
/****f* AWK/qse_awk_rtx_loop
* NAME
* qse_awk_rtx_loop - run BEGIN/pattern-action/END blocks
* DESCRIPTION
* The qse_awk_rtx_loop() function executes the BEGIN block, pattern-action
* blocks and the END blocks in an AWk program. Multiple invocations of the
* function for the lifetime of a runtime context is not desirable.
* RETURN
* The qse_awk_rtx_loop() function returns 0 on success and -1 on failure.
* EXAMPLE
* rtx = qse_awk_rtx_open (awk, rio, rcb, QSE_NULL, QSE_NULL);
* if (rtx != QSE_NULL)
* {
* qse_awk_rtx_loop (rtx);
* qse_awk_rtx_close (rtx);
* }
* SYNOPSIS
*/
int qse_awk_rtx_loop (
@ -1147,6 +1157,21 @@ int qse_awk_rtx_loop (
/****f* AWK/qse_awk_rtx_call
* NAME
* qse_awk_rtx_call - call a function
* DESCRIPTION
* The qse_awk_rtx_call() function invokes an AWK function. However, it is
* not able to invoke an intrinsic function such as split().
* The QSE_AWK_PABLOCK option can be turned off to make illegal the BEGIN
* block, pattern-action blocks, and the END block.
* RETURN
* The qse_awk_rtx_call() function returns 0 on success and -1 on failure.
* EXAMPLE
* rtx = qse_awk_rtx_open (awk, rio, rcb, QSE_NULL, QSE_NULL);
* if (rtx != QSE_NULL)
* {
* qse_awk_rtx_call (rtx, QSE_T("init"), QSE_NULL, 0);
* qse_awk_rtx_call (rtx, QSE_T("fini"), QSE_NULL, 0);
* qse_awk_rtx_close (rtx);
* }
* SYNOPSIS
*/
int qse_awk_rtx_call (
@ -1157,7 +1182,6 @@ int qse_awk_rtx_call (
);
/******/
/****f* AWK/qse_awk_stopall
* NAME
* qse_awk_stopall - stop all runtime contexts