*** empty log message ***
This commit is contained in:
parent
e447b9543c
commit
e144c0ac29
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.65 2006-08-04 16:31:21 bacon Exp $
|
||||
* $Id: awk.c,v 1.66 2006-08-04 17:36:40 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -61,8 +61,7 @@ xp_awk_t* xp_awk_open (void)
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
awk->opt.parse = 0;
|
||||
awk->opt.run = 0;
|
||||
awk->option = 0;
|
||||
awk->errnum = XP_AWK_ENOERR;
|
||||
awk->srcio = XP_NULL;
|
||||
awk->srcio_arg = XP_NULL;
|
||||
@ -158,14 +157,9 @@ void xp_awk_clear (xp_awk_t* awk)
|
||||
awk->tree.chain_tail = XP_NULL;
|
||||
}
|
||||
|
||||
void xp_awk_setparseopt (xp_awk_t* awk, int opt)
|
||||
void xp_awk_setopt (xp_awk_t* awk, int opt)
|
||||
{
|
||||
awk->opt.parse = opt;
|
||||
}
|
||||
|
||||
void xp_awk_setrunopt (xp_awk_t* awk, int opt)
|
||||
{
|
||||
awk->opt.run = opt;
|
||||
awk->option = opt;
|
||||
}
|
||||
|
||||
int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t handler, void* arg)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.88 2006-08-04 16:31:21 bacon Exp $
|
||||
* $Id: awk.h,v 1.89 2006-08-04 17:36:40 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWK_H_
|
||||
@ -11,21 +11,21 @@
|
||||
typedef struct xp_awk_t xp_awk_t;
|
||||
typedef struct xp_awk_val_t xp_awk_val_t;
|
||||
typedef struct xp_awk_extio_t xp_awk_extio_t;
|
||||
typedef struct xp_awk_rex_t xp_awk_rex_t;
|
||||
typedef struct xp_awk_runcb_t xp_awk_runcb_t;
|
||||
|
||||
typedef struct xp_awk_runios_t xp_awk_runios_t;
|
||||
typedef struct xp_awk_runcbs_t xp_awk_runcbs_t;
|
||||
|
||||
typedef void (*xp_awk_cb_t) (xp_awk_t* awk, void* handle, void* arg);
|
||||
|
||||
typedef xp_ssize_t (*xp_awk_io_t) (
|
||||
int cmd, void* arg, xp_char_t* data, xp_size_t count);
|
||||
|
||||
typedef void (*xp_awk_cb_t) (xp_awk_t* awk, void* handle);
|
||||
|
||||
struct xp_awk_extio_t
|
||||
{
|
||||
int type; /* console, file, coproc, pipe */
|
||||
int mode; /* read, write, etc */
|
||||
xp_char_t* name;
|
||||
|
||||
void* handle;
|
||||
int type; /* [IN] console, file, coproc, pipe */
|
||||
int mode; /* [IN] read, write, etc */
|
||||
xp_char_t* name; /* [IN] */
|
||||
void* handle; /* [OUT] */
|
||||
|
||||
/* input buffer */
|
||||
struct
|
||||
@ -39,10 +39,20 @@ struct xp_awk_extio_t
|
||||
xp_awk_extio_t* next;
|
||||
};
|
||||
|
||||
struct xp_awk_runcb_t
|
||||
struct xp_awk_runios_t
|
||||
{
|
||||
xp_awk_io_t pipe;
|
||||
xp_awk_io_t coproc;
|
||||
xp_awk_io_t file;
|
||||
xp_awk_io_t console;
|
||||
void* custom_data;
|
||||
};
|
||||
|
||||
struct xp_awk_runcbs_t
|
||||
{
|
||||
xp_awk_cb_t start;
|
||||
xp_awk_cb_t end;
|
||||
void* custom_data;
|
||||
};
|
||||
|
||||
/* io function commands */
|
||||
@ -68,7 +78,7 @@ enum
|
||||
XP_AWK_IO_CONSOLE_WRITE = 1
|
||||
};
|
||||
|
||||
/* parse options */
|
||||
/* various options */
|
||||
enum
|
||||
{
|
||||
/* allow undeclared variables */
|
||||
@ -104,12 +114,9 @@ enum
|
||||
|
||||
/* support blockless patterns */
|
||||
XP_AWK_BLOCKLESS = (1 << 9),
|
||||
};
|
||||
|
||||
/* run options */
|
||||
enum
|
||||
{
|
||||
XP_AWK_RUNMAIN = (1 << 0) /* execution starts from main */
|
||||
/* execution starts from main */
|
||||
XP_AWK_RUNMAIN = (1 << 10)
|
||||
};
|
||||
|
||||
/* error code */
|
||||
@ -218,17 +225,20 @@ int xp_awk_getsuberrnum (xp_awk_t* awk);
|
||||
const xp_char_t* xp_awk_getsuberrstr (xp_awk_t* awk);
|
||||
|
||||
void xp_awk_clear (xp_awk_t* awk);
|
||||
void xp_awk_setparseopt (xp_awk_t* awk, int opt);
|
||||
void xp_awk_setrunopt (xp_awk_t* awk, int opt);
|
||||
void xp_awk_setopt (xp_awk_t* awk, int opt);
|
||||
|
||||
int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t src, void* arg);
|
||||
int xp_awk_detsrc (xp_awk_t* awk);
|
||||
xp_size_t xp_awk_getsrcline (xp_awk_t* awk);
|
||||
|
||||
int xp_awk_setextio (xp_awk_t* awk, int id, xp_awk_io_t handler, void* arg);
|
||||
|
||||
int xp_awk_parse (xp_awk_t* awk);
|
||||
int xp_awk_run (xp_awk_t* awk, xp_awk_runcb_t* runcb);
|
||||
int xp_awk_stop (xp_awk_t* awk, void* handle);
|
||||
|
||||
int xp_awk_run (xp_awk_t* awk,
|
||||
xp_awk_runcbs_t* runcbs, xp_awk_runios_t* runios);
|
||||
|
||||
int xp_awk_stop (xp_awk_t* awk, void* run);
|
||||
|
||||
/* functions to access internal stack structure */
|
||||
xp_size_t xp_awk_getnargs (void* run);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk_i.h,v 1.39 2006-08-04 16:31:21 bacon Exp $
|
||||
* $Id: awk_i.h,v 1.40 2006-08-04 17:36:40 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWKI_H_
|
||||
@ -35,39 +35,6 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
struct xp_awk_parse_t
|
||||
{
|
||||
int opt;
|
||||
};
|
||||
|
||||
struct xp_awk_run_t
|
||||
{
|
||||
int opt;
|
||||
};
|
||||
|
||||
awk = xp_awk_open ();
|
||||
xp_awk_parse (awk, source_input, source_output);
|
||||
thr = create_thread (5);
|
||||
|
||||
thr[0]->xp_awk_run (awk, input_stream1, output_stream1);
|
||||
thr[1]->xp_awk_run (awk, input_stream2, output_stream2);
|
||||
thr[2]->xp_awk_run (awk, input_stream3, output_stream3);
|
||||
|
||||
xp_awk_setcallback (void* __command_callback (int cmd, void* arg), void* arg);
|
||||
xp_awk_run (awk)
|
||||
{
|
||||
run_stack = malloc (run_stack_size);
|
||||
while ()
|
||||
{
|
||||
if (command_callback) if (command_callback (XP_AWK_ABORT) == yes) break;
|
||||
run with run_stack
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
struct xp_awk_tree_t
|
||||
{
|
||||
xp_size_t nglobals; /* total number of globals */
|
||||
@ -82,11 +49,7 @@ struct xp_awk_tree_t
|
||||
struct xp_awk_t
|
||||
{
|
||||
/* options */
|
||||
struct
|
||||
{
|
||||
int parse;
|
||||
int run;
|
||||
} opt;
|
||||
int option;
|
||||
|
||||
/* io functions */
|
||||
xp_awk_io_t srcio;
|
||||
@ -203,7 +166,6 @@ struct xp_awk_run_t
|
||||
/* extio chain */
|
||||
xp_awk_extio_t* extio;
|
||||
|
||||
int opt;
|
||||
short errnum;
|
||||
short suberrnum;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: func.c,v 1.16 2006-08-03 05:05:47 bacon Exp $
|
||||
* $Id: func.c,v 1.17 2006-08-04 17:36:40 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -103,7 +103,7 @@ xp_awk_bfn_t* xp_awk_getbfn (xp_awk_t* awk, const xp_char_t* name)
|
||||
for (p = __sys_bfn; p->name != XP_NULL; p++)
|
||||
{
|
||||
if (p->valid != 0 &&
|
||||
(awk->opt.parse & p->valid) == 0) continue;
|
||||
(awk->option & p->valid) == 0) continue;
|
||||
|
||||
if (xp_strcmp (p->name, name) == 0) return p;
|
||||
}
|
||||
@ -112,7 +112,7 @@ xp_awk_bfn_t* xp_awk_getbfn (xp_awk_t* awk, const xp_char_t* name)
|
||||
for (p = awk->bfn.user; p != XP_NULL; p = p->next)
|
||||
{
|
||||
if (p->valid != 0 &&
|
||||
(awk->opt.parse & p->valid) == 0) continue;
|
||||
(awk->option & p->valid) == 0) continue;
|
||||
|
||||
if (xp_strcmp (p->name, name) == 0) return p;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.157 2006-08-04 16:31:21 bacon Exp $
|
||||
* $Id: parse.c,v 1.158 2006-08-04 17:36:40 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -454,7 +454,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
||||
|
||||
xp_assert (awk->parse.depth.loop == 0);
|
||||
|
||||
if ((awk->opt.parse & XP_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
|
||||
if ((awk->option & XP_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
|
||||
{
|
||||
xp_size_t nglobals;
|
||||
|
||||
@ -481,7 +481,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
||||
awk->parse.id.block = PARSE_BEGIN;
|
||||
if (__get_token(awk) == -1) return XP_NULL;
|
||||
|
||||
if ((awk->opt.parse & XP_AWK_BLOCKLESS) &&
|
||||
if ((awk->option & XP_AWK_BLOCKLESS) &&
|
||||
(MATCH(awk,TOKEN_NEWLINE) || MATCH(awk,TOKEN_EOF)))
|
||||
{
|
||||
/* when the blockless pattern is supported
|
||||
@ -499,7 +499,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
||||
awk->parse.id.block = PARSE_END;
|
||||
if (__get_token(awk) == -1) return XP_NULL;
|
||||
|
||||
if ((awk->opt.parse & XP_AWK_BLOCKLESS) &&
|
||||
if ((awk->option & XP_AWK_BLOCKLESS) &&
|
||||
(MATCH(awk,TOKEN_NEWLINE) || MATCH(awk,TOKEN_EOF)))
|
||||
{
|
||||
/* when the blockless pattern is supported
|
||||
@ -555,7 +555,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
||||
}
|
||||
}
|
||||
|
||||
if ((awk->opt.parse & XP_AWK_BLOCKLESS) &&
|
||||
if ((awk->option & XP_AWK_BLOCKLESS) &&
|
||||
(MATCH(awk,TOKEN_NEWLINE) || MATCH(awk,TOKEN_EOF)))
|
||||
{
|
||||
/* blockless pattern */
|
||||
@ -630,7 +630,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
PANIC (awk, XP_AWK_EDUPFUNC);
|
||||
}
|
||||
|
||||
if (awk->opt.parse & XP_AWK_UNIQUE)
|
||||
if (awk->option & XP_AWK_UNIQUE)
|
||||
{
|
||||
/* check if it coincides to be a global variable name */
|
||||
if (xp_awk_tab_find (
|
||||
@ -696,7 +696,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
param = XP_STR_BUF(&awk->token.name);
|
||||
param_len = XP_STR_LEN(&awk->token.name);
|
||||
|
||||
if (awk->opt.parse & XP_AWK_UNIQUE)
|
||||
if (awk->option & XP_AWK_UNIQUE)
|
||||
{
|
||||
/* check if a parameter conflicts with a function */
|
||||
if (xp_strxncmp (name_dup, name_len, param, param_len) == 0 ||
|
||||
@ -904,7 +904,7 @@ static xp_awk_nde_t* __parse_block (xp_awk_t* awk, xp_bool_t is_top)
|
||||
nlocals_max = awk->parse.nlocals_max;
|
||||
|
||||
/* local variable declarations */
|
||||
if (awk->opt.parse & XP_AWK_EXPLICIT)
|
||||
if (awk->option & XP_AWK_EXPLICIT)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
@ -1036,7 +1036,7 @@ static xp_awk_t* __add_builtin_globals (xp_awk_t* awk)
|
||||
static xp_awk_t* __add_global (
|
||||
xp_awk_t* awk, const xp_char_t* name, xp_size_t len)
|
||||
{
|
||||
if (awk->opt.parse & XP_AWK_UNIQUE)
|
||||
if (awk->option & XP_AWK_UNIQUE)
|
||||
{
|
||||
/* check if it conflict with a function name */
|
||||
if (xp_awk_map_get(&awk->tree.afns, name, len) != XP_NULL)
|
||||
@ -1107,7 +1107,7 @@ static xp_awk_t* __collect_locals (xp_awk_t* awk, xp_size_t nlocals)
|
||||
|
||||
/* NOTE: it is not checked againt globals names */
|
||||
|
||||
if (awk->opt.parse & XP_AWK_UNIQUE)
|
||||
if (awk->option & XP_AWK_UNIQUE)
|
||||
{
|
||||
/* check if it conflict with a function name */
|
||||
if (xp_awk_map_get (
|
||||
@ -1125,7 +1125,7 @@ static xp_awk_t* __collect_locals (xp_awk_t* awk, xp_size_t nlocals)
|
||||
|
||||
/* check if it conflicts with other local variable names */
|
||||
if (xp_awk_tab_find (&awk->parse.locals,
|
||||
((awk->opt.parse & XP_AWK_SHADING)? nlocals: 0),
|
||||
((awk->option & XP_AWK_SHADING)? nlocals: 0),
|
||||
local, local_len) != (xp_size_t)-1)
|
||||
{
|
||||
PANIC (awk, XP_AWK_EDUPVAR);
|
||||
@ -1609,7 +1609,7 @@ static xp_awk_nde_t* __parse_regex_match (xp_awk_t* awk)
|
||||
|
||||
static xp_awk_nde_t* __parse_bitwise_or (xp_awk_t* awk)
|
||||
{
|
||||
if (awk->opt.parse & XP_AWK_EXTIO)
|
||||
if (awk->option & XP_AWK_EXTIO)
|
||||
{
|
||||
return __parse_bitwise_or_with_extio (awk);
|
||||
}
|
||||
@ -2366,7 +2366,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
return (xp_awk_nde_t*)nde;
|
||||
}
|
||||
|
||||
if (awk->opt.parse & XP_AWK_IMPLICIT)
|
||||
if (awk->option & XP_AWK_IMPLICIT)
|
||||
{
|
||||
nde->type = XP_AWK_NDE_NAMED;
|
||||
nde->next = XP_NULL;
|
||||
@ -2489,7 +2489,7 @@ static xp_awk_nde_t* __parse_hashidx (
|
||||
return (xp_awk_nde_t*)nde;
|
||||
}
|
||||
|
||||
if (awk->opt.parse & XP_AWK_IMPLICIT)
|
||||
if (awk->option & XP_AWK_IMPLICIT)
|
||||
{
|
||||
nde->type = XP_AWK_NDE_NAMEDIDX;
|
||||
nde->next = XP_NULL;
|
||||
@ -3235,7 +3235,7 @@ static int __get_token (xp_awk_t* awk)
|
||||
awk->token.line = awk->lex.line;
|
||||
awk->token.column = awk->lex.column;
|
||||
|
||||
if (line != 0 && (awk->opt.parse & XP_AWK_BLOCKLESS) &&
|
||||
if (line != 0 && (awk->option & XP_AWK_BLOCKLESS) &&
|
||||
(awk->parse.id.block == PARSE_PATTERN ||
|
||||
awk->parse.id.block == PARSE_BEGIN ||
|
||||
awk->parse.id.block == PARSE_END))
|
||||
@ -3280,7 +3280,7 @@ static int __get_token (xp_awk_t* awk)
|
||||
|
||||
if (__get_charstr(awk) == -1) return -1;
|
||||
|
||||
while (awk->opt.parse & XP_AWK_STRCONCAT)
|
||||
while (awk->option & XP_AWK_STRCONCAT)
|
||||
{
|
||||
do
|
||||
{
|
||||
@ -3336,7 +3336,7 @@ static int __get_token (xp_awk_t* awk)
|
||||
{
|
||||
ADD_TOKEN_CHAR (awk, c);
|
||||
GET_CHAR_TO (awk, c);
|
||||
if ((awk->opt.parse & XP_AWK_SHIFT) && c == XP_T('>'))
|
||||
if ((awk->option & XP_AWK_SHIFT) && c == XP_T('>'))
|
||||
{
|
||||
SET_TOKEN_TYPE (awk, TOKEN_RSHIFT);
|
||||
ADD_TOKEN_CHAR (awk, c);
|
||||
@ -3358,7 +3358,7 @@ static int __get_token (xp_awk_t* awk)
|
||||
ADD_TOKEN_CHAR (awk, c);
|
||||
GET_CHAR_TO (awk, c);
|
||||
|
||||
if ((awk->opt.parse & XP_AWK_SHIFT) && c == XP_T('<'))
|
||||
if ((awk->option & XP_AWK_SHIFT) && c == XP_T('<'))
|
||||
{
|
||||
SET_TOKEN_TYPE (awk, TOKEN_LSHIFT);
|
||||
ADD_TOKEN_CHAR (awk, c);
|
||||
@ -3957,7 +3957,7 @@ static int __skip_comment (xp_awk_t* awk)
|
||||
{
|
||||
xp_cint_t c = awk->lex.curc;
|
||||
|
||||
if ((awk->opt.parse & XP_AWK_HASHSIGN) && c == XP_T('#'))
|
||||
if ((awk->option & XP_AWK_HASHSIGN) && c == XP_T('#'))
|
||||
{
|
||||
do
|
||||
{
|
||||
@ -3972,7 +3972,7 @@ static int __skip_comment (xp_awk_t* awk)
|
||||
if (c != XP_T('/')) return 0; /* not a comment */
|
||||
GET_CHAR_TO (awk, c);
|
||||
|
||||
if ((awk->opt.parse & XP_AWK_DBLSLASHES) && c == XP_T('/'))
|
||||
if ((awk->option & XP_AWK_DBLSLASHES) && c == XP_T('/'))
|
||||
{
|
||||
do
|
||||
{
|
||||
@ -4017,7 +4017,7 @@ static int __classify_ident (
|
||||
for (kwp = __kwtab; kwp->name != XP_NULL; kwp++)
|
||||
{
|
||||
if (kwp->valid != 0 &&
|
||||
(awk->opt.parse & kwp->valid) == 0) continue;
|
||||
(awk->option & kwp->valid) == 0) continue;
|
||||
|
||||
if (xp_strxncmp (kwp->name, kwp->name_len, name, len) == 0)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.161 2006-08-04 16:32:38 bacon Exp $
|
||||
* $Id: run.c,v 1.162 2006-08-04 17:36:40 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -222,7 +222,7 @@ void xp_awk_seterrnum (void* run, int errnum)
|
||||
r->errnum = errnum;
|
||||
}
|
||||
|
||||
int xp_awk_run (xp_awk_t* awk, xp_awk_runcb_t* runcb)
|
||||
int xp_awk_run (xp_awk_t* awk, xp_awk_runcbs_t* runcbs, xp_awk_runios_t* runios)
|
||||
{
|
||||
xp_awk_run_t* run;
|
||||
int n;
|
||||
@ -243,7 +243,8 @@ int xp_awk_run (xp_awk_t* awk, xp_awk_runcb_t* runcb)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (runcb->start != XP_NULL) runcb->start (awk, run);
|
||||
if (runcbs->start != XP_NULL)
|
||||
runcbs->start (awk, run, runcbs->custom_data);
|
||||
|
||||
n = __run_main (run);
|
||||
if (n == -1)
|
||||
@ -252,7 +253,8 @@ int xp_awk_run (xp_awk_t* awk, xp_awk_runcb_t* runcb)
|
||||
awk->suberrnum = run->suberrnum;
|
||||
}
|
||||
|
||||
if (runcb->end != XP_NULL) runcb->end (awk, run);
|
||||
if (runcbs->end != XP_NULL)
|
||||
runcbs->end (awk, run, runcbs->custom_data);
|
||||
|
||||
__close_run (run);
|
||||
xp_free (run);
|
||||
@ -260,18 +262,18 @@ int xp_awk_run (xp_awk_t* awk, xp_awk_runcb_t* runcb)
|
||||
return n;
|
||||
}
|
||||
|
||||
int xp_awk_stop (xp_awk_t* awk, void* handle)
|
||||
int xp_awk_stop (xp_awk_t* awk, void* run)
|
||||
{
|
||||
xp_awk_run_t* run = (xp_awk_run_t*)handle;
|
||||
xp_awk_run_t* r = (xp_awk_run_t*)run;
|
||||
|
||||
if (run->awk != awk)
|
||||
if (r->awk != awk)
|
||||
{
|
||||
/* TODO: use awk->errnum or run->errnum??? */
|
||||
run->errnum = XP_AWK_EINVAL;
|
||||
r->errnum = XP_AWK_EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
run->exit_level = EXIT_ABORT;
|
||||
r->exit_level = EXIT_ABORT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -294,7 +296,6 @@ static int __open_run (xp_awk_run_t* run, xp_awk_t* awk)
|
||||
run->icache_count = 0;
|
||||
run->rcache_count = 0;
|
||||
|
||||
run->opt = awk->opt.run;
|
||||
run->errnum = XP_AWK_ENOERR;
|
||||
run->suberrnum = XP_AWK_ENOERR;
|
||||
/*run->tree = &awk->tree; */
|
||||
@ -403,7 +404,7 @@ static int __run_main (xp_awk_run_t* run)
|
||||
|
||||
run->exit_level = EXIT_NONE;
|
||||
|
||||
if (run->opt & XP_AWK_RUNMAIN)
|
||||
if (run->awk->option & XP_AWK_RUNMAIN)
|
||||
{
|
||||
/* TODO: should the main function be user-specifiable? */
|
||||
xp_awk_nde_call_t nde;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.65 2006-08-04 17:02:02 bacon Exp $
|
||||
* $Id: awk.c,v 1.66 2006-08-04 17:36:40 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
@ -493,14 +493,14 @@ static void __stop_run (int sig)
|
||||
signal (SIGINT, __stop_run);
|
||||
}
|
||||
|
||||
static void __on_run_start (xp_awk_t* awk, void* handle)
|
||||
static void __on_run_start (xp_awk_t* awk, void* handle, void* arg)
|
||||
{
|
||||
app_awk = awk;
|
||||
app_run = handle;
|
||||
xp_printf (XP_T("AWK PRORAM ABOUT TO START...\n"));
|
||||
}
|
||||
|
||||
static void __on_run_end (xp_awk_t* awk, void* handle)
|
||||
static void __on_run_end (xp_awk_t* awk, void* handle, void* arg)
|
||||
{
|
||||
app_awk = NULL;
|
||||
app_run = NULL;
|
||||
@ -514,7 +514,8 @@ static int __main (int argc, xp_char_t* argv[])
|
||||
#endif
|
||||
{
|
||||
xp_awk_t* awk;
|
||||
xp_awk_runcb_t runcb;
|
||||
xp_awk_runcbs_t runcbs;
|
||||
xp_awk_runios_t runios;
|
||||
struct src_io src_io = { NULL, NULL };
|
||||
int opt;
|
||||
|
||||
@ -598,7 +599,7 @@ static int __main (int argc, xp_char_t* argv[])
|
||||
|
||||
xp_awk_setopt (awk, opt);
|
||||
|
||||
if (xp_awk_attsrc(awk, process_source, (void*)&src_io) == -1)
|
||||
if (xp_awk_attsrc (awk, process_source, (void*)&src_io) == -1)
|
||||
{
|
||||
xp_awk_close (awk);
|
||||
xp_printf (XP_T("Error: cannot attach source\n"));
|
||||
@ -633,10 +634,17 @@ static int __main (int argc, xp_char_t* argv[])
|
||||
|
||||
signal (SIGINT, __stop_run);
|
||||
|
||||
runcb.start = __on_run_start;
|
||||
runcb.end = __on_run_end;
|
||||
runcbs.start = __on_run_start;
|
||||
runcbs.end = __on_run_end;
|
||||
runcbs.custom_data = XP_NULL;
|
||||
|
||||
if (xp_awk_run (awk, &runcb) == -1)
|
||||
runios.pipe = process_extio_pipe;
|
||||
runios.coproc = XP_NULL;
|
||||
runios.file = process_extio_file;
|
||||
runios.console = process_extio_console;
|
||||
runios.custom_data = XP_NULL;
|
||||
|
||||
if (xp_awk_run (awk, &runcbs, &runios) == -1)
|
||||
{
|
||||
#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(XP_CHAR_IS_WCHAR)
|
||||
xp_printf (
|
||||
|
Loading…
Reference in New Issue
Block a user