diff --git a/ase/awk/awk.c b/ase/awk/awk.c index 6859bf79..2ec37fdf 100644 --- a/ase/awk/awk.c +++ b/ase/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.67 2006-08-06 08:15:29 bacon Exp $ + * $Id: awk.c,v 1.68 2006-08-10 16:02:15 bacon Exp $ */ #include @@ -11,10 +11,9 @@ static void __free_afn (void* awk, void* afn); -xp_awk_t* xp_awk_open (void) +xp_awk_t* xp_awk_open (xp_awk_thrlks_t* thrlks) { xp_awk_t* awk; - xp_size_t i; awk = (xp_awk_t*) xp_malloc (xp_sizeof(xp_awk_t)); if (awk == XP_NULL) return XP_NULL; @@ -86,17 +85,21 @@ xp_awk_t* xp_awk_open (void) awk->src.shared.buf_pos = 0; awk->src.shared.buf_len = 0; - for (i = 0; i < xp_countof(awk->extio); i++) awk->extio[i] = XP_NULL; - awk->bfn.sys = XP_NULL; awk->bfn.user = XP_NULL; + awk->run.count = 0; + awk->run.ptr = XP_NULL; + + awk->thr.lks = thrlks; return awk; } int xp_awk_close (xp_awk_t* awk) { - xp_awk_clear (awk); + if (xp_awk_clear (awk) == -1) return -1; + + xp_assert (awk->run.count == 0 && awk->run.ptr == XP_NULL); xp_awk_map_close (&awk->tree.afns); xp_awk_tab_close (&awk->parse.globals); @@ -108,12 +111,21 @@ int xp_awk_close (xp_awk_t* awk) return 0; } -/* TODO: write a function to clear awk->parse data structure. - this would be need either as a separate function or as a part of xp_awk_clear... - do i have to pass an option to xp_awk_clear to do this??? */ -void xp_awk_clear (xp_awk_t* awk) +int xp_awk_clear (xp_awk_t* awk) { -/* TODO: kill all associated run instances... */ + /* you should stop all running instances beforehand */ +/* TODO: can i stop all instances??? */ + if (awk->run.ptr != XP_NULL) + { + awk->errnum = XP_AWK_ERUNNING; + return -1; + } + +/* TOOD: clear bfns when they can be added dynamically + awk->bfn.sys + awk->bfn.user +*/ + awk->src.ios = XP_NULL; awk->src.lex.curc = XP_CHAR_EOF; awk->src.lex.ungotc_count = 0; @@ -160,6 +172,7 @@ void xp_awk_clear (xp_awk_t* awk) } awk->tree.chain_tail = XP_NULL; + return 0; } void xp_awk_setopt (xp_awk_t* awk, int opt) @@ -183,16 +196,3 @@ xp_size_t xp_awk_getsrcline (xp_awk_t* awk) return awk->token.line; } -/* TODO: imrove this... should it close io when it is overridden with a new handler??? */ -int xp_awk_setextio (xp_awk_t* awk, int id, xp_awk_io_t handler, void* arg) -{ - if (id < 0 || id >= xp_countof(awk->extio)) - { - awk->errnum = XP_AWK_EINVAL; - return -1; - } - - awk->extio[id] = handler; - return 0; -} - diff --git a/ase/awk/awk.h b/ase/awk/awk.h index 2d8eeb04..05b3d987 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.93 2006-08-06 15:02:54 bacon Exp $ + * $Id: awk.h,v 1.94 2006-08-10 16:02:15 bacon Exp $ */ #ifndef _XP_AWK_AWK_H_ @@ -12,12 +12,13 @@ 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_thrlks_t xp_awk_thrlks_t; typedef struct xp_awk_srcios_t xp_awk_srcios_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_lk_t) (xp_awk_t* awk, void* arg); 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); @@ -40,6 +41,13 @@ struct xp_awk_extio_t xp_awk_extio_t* next; }; +struct xp_awk_thrlks_t +{ + xp_awk_lk_t lock; + xp_awk_lk_t unlock; + void* custom_data; +}; + struct xp_awk_srcios_t { xp_awk_io_t in; @@ -53,7 +61,6 @@ struct xp_awk_runios_t xp_awk_io_t coproc; xp_awk_io_t file; xp_awk_io_t console; - void* custom_data; }; struct xp_awk_runcbs_t @@ -133,6 +140,9 @@ enum XP_AWK_ENOERR, /* no error */ XP_AWK_ENOMEM, /* out of memory */ XP_AWK_EINVAL, /* invalid parameter */ + XP_AWK_ERUNTIME, /* run-time error */ + XP_AWK_ERUNNING, /* there are running instances */ + XP_AWK_ETOOMANYRUNS, /* too many running instances */ XP_AWK_ESRCINOPEN, XP_AWK_ESRCINCLOSE, @@ -192,8 +202,6 @@ enum XP_AWK_ENEXT, /* next illegal in BEGIN or END block */ XP_AWK_ENEXTFILE, /* nextfile illegal in BEGIN or END block */ XP_AWK_EGETLINE, /* getline expected */ - XP_AWK_EREXBUILD, /* cannot build regexp */ - XP_AWK_EREXMATCH, /* an error occurred in matching regexp */ /* run time error */ XP_AWK_EDIVBYZERO, /* divide by zero */ @@ -209,7 +217,18 @@ enum XP_AWK_ENEXTCALL, /* next called from BEGIN or END */ XP_AWK_ENEXTFILECALL, /* nextfile called from BEGIN or END */ XP_AWK_EIOIMPL, /* wrong implementation of user io handler */ - XP_AWK_EINTERNAL /* internal error */ + XP_AWK_EINTERNAL, /* internal error */ + + /* regular expression error */ + XP_AWK_EREXRPAREN, /* a right parenthesis is expected */ + XP_AWK_EREXRBRACKET, /* a right bracket is expected */ + XP_AWK_EREXRBRACE, /* a right brace is expected */ + XP_AWK_EREXCOLON, /* a colon is expected */ + XP_AWK_EREXCRANGE, /* invalid character range */ + XP_AWK_EREXCCLASS, /* invalid character class */ + XP_AWK_EREXBRANGE, /* invalid boundary range */ + XP_AWK_EREXEND, /* unexpected end of the pattern */ + XP_AWK_EREXGARBAGE /* garbage after the pattern */ }; /* extio types */ @@ -229,19 +248,13 @@ enum extern "C" { #endif -xp_awk_t* xp_awk_open (void); +xp_awk_t* xp_awk_open (xp_awk_thrlks_t* thrlks); int xp_awk_close (xp_awk_t* awk); +int xp_awk_clear (xp_awk_t* awk); int xp_awk_geterrnum (xp_awk_t* awk); -const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk); -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_setopt (xp_awk_t* awk, int opt); - 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); +void xp_awk_setopt (xp_awk_t* awk, int opt); int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios); @@ -249,6 +262,7 @@ int xp_awk_run (xp_awk_t* awk, xp_awk_runios_t* runios, xp_awk_runcbs_t* runcbs); int xp_awk_stop (xp_awk_t* awk, void* run); +int xp_awk_getrunerrnum (xp_awk_t* awk, void* run, int* errnum); /* functions to access internal stack structure */ xp_size_t xp_awk_getnargs (void* run); @@ -262,6 +276,9 @@ xp_long_t xp_awk_strtolong ( const xp_char_t* str, int base, const xp_char_t** endptr); xp_real_t xp_awk_strtoreal (const xp_char_t* str); +/* utility functions to convert an error number ot a string */ +const xp_char_t* xp_awk_geterrstr (int errnum); + #ifdef __cplusplus } #endif diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h index 86e658cb..225dad15 100644 --- a/ase/awk/awk_i.h +++ b/ase/awk/awk_i.h @@ -1,5 +1,5 @@ /* - * $Id: awk_i.h,v 1.42 2006-08-06 15:02:55 bacon Exp $ + * $Id: awk_i.h,v 1.43 2006-08-10 16:02:15 bacon Exp $ */ #ifndef _XP_AWK_AWKI_H_ @@ -103,8 +103,6 @@ struct xp_awk_t } shared; } src; - xp_awk_io_t extio[XP_AWK_EXTIO_NUM]; - /* token */ struct { @@ -122,9 +120,19 @@ struct xp_awk_t xp_awk_bfn_t* user; } bfn; + struct + { + xp_size_t count; + xp_awk_run_t* ptr; + } run; + + struct + { + xp_awk_thrlks_t* lks; + } thr; + /* housekeeping */ - short errnum; - short suberrnum; + int errnum; }; struct xp_awk_chain_t @@ -137,6 +145,7 @@ struct xp_awk_chain_t struct xp_awk_run_t { + int id; xp_awk_map_t named; void** stack; @@ -173,14 +182,17 @@ struct xp_awk_run_t } inrec; /* extio chain */ - xp_awk_extio_t* extio; + struct + { + xp_awk_io_t handler[XP_AWK_EXTIO_NUM]; + xp_awk_extio_t* chain; + } extio; - short errnum; - short suberrnum; + int errnum; - /*xp_awk_tree_t* tree; - xp_size_t nglobals;*/ xp_awk_t* awk; + xp_awk_run_t* prev; + xp_awk_run_t* next; }; #endif diff --git a/ase/awk/err.c b/ase/awk/err.c index 104272b8..e9526d5f 100644 --- a/ase/awk/err.c +++ b/ase/awk/err.c @@ -1,5 +1,5 @@ /* - * $Id: err.c,v 1.34 2006-08-06 15:02:55 bacon Exp $ + * $Id: err.c,v 1.35 2006-08-10 16:02:15 bacon Exp $ */ #include @@ -9,24 +9,16 @@ int xp_awk_geterrnum (xp_awk_t* awk) return awk->errnum; } -int xp_awk_getsuberrnum (xp_awk_t* awk) -{ - if (awk->errnum == XP_AWK_EREXBUILD || - awk->errnum == XP_AWK_EREXMATCH) - { - return awk->suberrnum; - } - - return XP_AWK_ENOERR; -} - -const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk) +const xp_char_t* xp_awk_geterrstr (int errnum) { static const xp_char_t* __errstr[] = { XP_T("no error"), XP_T("out of memory"), XP_T("invalid parameter"), + XP_T("run-time error"), + XP_T("one or more running instances"), + XP_T("too many running instances"), XP_T("cannot open source input"), XP_T("cannot close source input"), @@ -86,8 +78,6 @@ const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk) XP_T("next illegal in BEGIN or END block"), XP_T("nextfile illegal in BEGIN or END block"), XP_T("getline expected"), - XP_T("cannot build the regular expression"), - XP_T("an error occurred in the regular expression match"), XP_T("divide by zero"), XP_T("invalid operand"), @@ -102,24 +92,24 @@ const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk) XP_T("next cannot be called from the BEGIN or END block"), XP_T("nextfile cannot be called from the BEGIN or END block"), XP_T("wrong implementation of user-defined io handler"), - XP_T("internal error that should never have happened") + XP_T("internal error that should never have happened"), + + XP_T("a right parenthesis is expected in the regular expression"), + XP_T("a right bracket is expected in the regular expression"), + XP_T("a right brace is expected in the regular expression"), + XP_T("a colon is expected in the regular expression"), + XP_T("invalid character range in the regular expression"), + XP_T("invalid character class in the regular expression"), + XP_T("invalid boundary range in the regular expression"), + XP_T("unexpected end of the regular expression"), + XP_T("garbage after the regular expression") }; - if (awk->errnum >= 0 && awk->errnum < xp_countof(__errstr)) + if (errnum >= 0 && errnum < xp_countof(__errstr)) { - return __errstr[awk->errnum]; + return __errstr[errnum]; } return XP_T("unknown error"); } -const xp_char_t* xp_awk_getsuberrstr (xp_awk_t* awk) -{ - if (awk->errnum == XP_AWK_EREXBUILD || - awk->errnum == XP_AWK_EREXMATCH) - { - return xp_awk_getrexerrstr (awk->suberrnum); - } - - return XP_T("no error"); -} diff --git a/ase/awk/extio.c b/ase/awk/extio.c index 41667573..73e0c40c 100644 --- a/ase/awk/extio.c +++ b/ase/awk/extio.c @@ -1,5 +1,5 @@ /* - * $Id: extio.c,v 1.26 2006-08-03 09:53:42 bacon Exp $ + * $Id: extio.c,v 1.27 2006-08-10 16:02:15 bacon Exp $ */ #include @@ -86,7 +86,7 @@ int xp_awk_readextio ( xp_awk_run_t* run, int in_type, const xp_char_t* name, xp_str_t* buf, int* errnum) { - xp_awk_extio_t* p = run->extio; + xp_awk_extio_t* p = run->extio.chain; xp_awk_io_t handler; int extio_type, extio_mode, extio_mask, n; @@ -99,7 +99,7 @@ int xp_awk_readextio ( extio_mode = __in_mode_map[in_type]; extio_mask = __in_mask_map[in_type]; - handler = run->awk->extio[extio_type]; + handler = run->extio.handler[extio_type]; if (handler == XP_NULL) { /* no io handler provided */ @@ -157,8 +157,8 @@ int xp_awk_readextio ( } /* chain it */ - p->next = run->extio; - run->extio = p; + p->next = run->extio.chain; + run->extio.chain = p; /* n == 0 indicates that it has reached the end of input. * the user io handler can return 0 for the open request @@ -240,7 +240,7 @@ static int __writeextio ( xp_awk_run_t* run, int out_type, const xp_char_t* name, xp_awk_val_t* v, int* errnum, xp_bool_t nl) { - xp_awk_extio_t* p = run->extio; + xp_awk_extio_t* p = run->extio.chain; xp_awk_io_t handler; xp_str_t buf; xp_char_t* str; @@ -256,7 +256,7 @@ static int __writeextio ( extio_mode = __out_mode_map[out_type]; extio_mask = __out_mask_map[out_type]; - handler = run->awk->extio[extio_type]; + handler = run->extio.handler[extio_type]; if (handler == XP_NULL) { /* no io handler provided */ @@ -342,8 +342,8 @@ static int __writeextio ( } /* chain it */ - p->next = run->extio; - run->extio = p; + p->next = run->extio.chain; + run->extio.chain = p; /* read the comment in xp_awk_readextio */ if (n == 0) return 0; @@ -411,7 +411,7 @@ static int __writeextio ( int xp_awk_nextextio_read ( xp_awk_run_t* run, int in_type, const xp_char_t* name, int* errnum) { - xp_awk_extio_t* p = run->extio; + xp_awk_extio_t* p = run->extio.chain; xp_awk_io_t handler; int extio_type, extio_mode, extio_mask, n; @@ -424,7 +424,7 @@ int xp_awk_nextextio_read ( extio_mode = __in_mode_map[in_type]; extio_mask = __in_mask_map[in_type]; - handler = run->awk->extio[extio_type]; + handler = run->extio.handler[extio_type]; if (handler == XP_NULL) { /* no io handler provided */ @@ -460,7 +460,7 @@ int xp_awk_nextextio_read ( int xp_awk_closeextio_read ( xp_awk_run_t* run, int in_type, const xp_char_t* name, int* errnum) { - xp_awk_extio_t* p = run->extio, * px = XP_NULL; + xp_awk_extio_t* p = run->extio.chain, * px = XP_NULL; xp_awk_io_t handler; int extio_type, extio_mode, extio_mask; @@ -473,7 +473,7 @@ int xp_awk_closeextio_read ( extio_mode = __in_mode_map[in_type]; extio_mask = __in_mask_map[in_type]; - handler = run->awk->extio[extio_type]; + handler = run->extio.handler[extio_type]; if (handler == XP_NULL) { /* no io handler provided */ @@ -488,7 +488,7 @@ int xp_awk_closeextio_read ( { xp_awk_io_t handler; - handler = run->awk->extio[p->type & __MASK_CLEAR]; + handler = run->extio.handler[p->type & __MASK_CLEAR]; if (handler != XP_NULL) { if (handler (XP_AWK_IO_CLOSE, p, XP_NULL, 0) == -1) @@ -500,7 +500,7 @@ int xp_awk_closeextio_read ( } if (px != XP_NULL) px->next = p->next; - else run->extio = p->next; + else run->extio.chain = p->next; xp_free (p->name); xp_free (p); @@ -519,7 +519,7 @@ int xp_awk_closeextio_read ( int xp_awk_closeextio_write ( xp_awk_run_t* run, int out_type, const xp_char_t* name, int* errnum) { - xp_awk_extio_t* p = run->extio, * px = XP_NULL; + xp_awk_extio_t* p = run->extio.chain, * px = XP_NULL; xp_awk_io_t handler; int extio_type, extio_mode, extio_mask; @@ -532,7 +532,7 @@ int xp_awk_closeextio_write ( extio_mode = __out_mode_map[out_type]; extio_mask = __out_mask_map[out_type]; - handler = run->awk->extio[extio_type]; + handler = run->extio.handler[extio_type]; if (handler == XP_NULL) { /* no io handler provided */ @@ -547,7 +547,7 @@ int xp_awk_closeextio_write ( { xp_awk_io_t handler; - handler = run->awk->extio[p->type & __MASK_CLEAR]; + handler = run->extio.handler[p->type & __MASK_CLEAR]; if (handler != XP_NULL) { if (handler (XP_AWK_IO_CLOSE, p, XP_NULL, 0) == -1) @@ -559,7 +559,7 @@ int xp_awk_closeextio_write ( } if (px != XP_NULL) px->next = p->next; - else run->extio = p->next; + else run->extio.chain = p->next; xp_free (p->name); xp_free (p); @@ -578,7 +578,7 @@ int xp_awk_closeextio_write ( int xp_awk_closeextio ( xp_awk_run_t* run, const xp_char_t* name, int* errnum) { - xp_awk_extio_t* p = run->extio, * px = XP_NULL; + xp_awk_extio_t* p = run->extio.chain, * px = XP_NULL; while (p != XP_NULL) { @@ -588,7 +588,7 @@ int xp_awk_closeextio ( { xp_awk_io_t handler; - handler = run->awk->extio[p->type & __MASK_CLEAR]; + handler = run->extio.handler[p->type & __MASK_CLEAR]; if (handler != XP_NULL) { if (handler (XP_AWK_IO_CLOSE, p, XP_NULL, 0) == -1) @@ -600,7 +600,7 @@ int xp_awk_closeextio ( } if (px != XP_NULL) px->next = p->next; - else run->extio = p->next; + else run->extio.chain = p->next; xp_free (p->name); xp_free (p); @@ -622,14 +622,14 @@ void xp_awk_clearextio (xp_awk_run_t* run) xp_awk_io_t handler; int n; - while (run->extio != XP_NULL) + while (run->extio.chain != XP_NULL) { - handler = run->awk->extio[run->extio->type & __MASK_CLEAR]; - next = run->extio->next; + handler = run->extio.handler[run->extio.chain->type & __MASK_CLEAR]; + next = run->extio.chain->next; if (handler != XP_NULL) { - n = handler (XP_AWK_IO_CLOSE, run->extio, XP_NULL, 0); + n = handler (XP_AWK_IO_CLOSE, run->extio.chain, XP_NULL, 0); if (n == -1) { /* TODO: @@ -637,9 +637,9 @@ void xp_awk_clearextio (xp_awk_run_t* run) } } - xp_free (run->extio->name); - xp_free (run->extio); + xp_free (run->extio.chain->name); + xp_free (run->extio.chain); - run->extio = next; + run->extio.chain = next; } } diff --git a/ase/awk/parse.c b/ase/awk/parse.c index e4535822..3440a18d 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.162 2006-08-06 15:02:55 bacon Exp $ + * $Id: parse.c,v 1.163 2006-08-10 16:02:15 bacon Exp $ */ #include @@ -324,9 +324,6 @@ static struct __bvent __bvtab[] = #define PANIC(awk,code) \ do { (awk)->errnum = (code); return XP_NULL; } while (0) -#define PANIC2(awk,code,subcode) \ - do { (awk)->errnum = (code); (awk)->suberrnum = (subcode); return XP_NULL; } while (0) - int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios) { int n = 0; @@ -346,7 +343,6 @@ int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios) if (__add_builtin_globals (awk) == XP_NULL) { n = -1; - xp_awk_clear (awk); goto exit_parse; } @@ -354,7 +350,6 @@ int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios) if (__get_char(awk) == -1) { n = -1; - xp_awk_clear (awk); goto exit_parse; } @@ -362,7 +357,6 @@ int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios) if (__get_token(awk) == -1) { n = -1; - xp_awk_clear (awk); goto exit_parse; } @@ -374,7 +368,6 @@ int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios) if (__parse_progunit (awk) == XP_NULL) { n = -1; - xp_awk_clear (awk); goto exit_parse; } } @@ -386,7 +379,6 @@ int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios) if (__deparse (awk) == -1) { n = -1; - xp_awk_clear (awk); goto exit_parse; } } @@ -395,8 +387,6 @@ exit_parse: if (awk->src.ios->in ( XP_AWK_IO_CLOSE, awk->src.ios->custom_data, XP_NULL, 0) == -1) { - xp_awk_clear (awk); - if (n == 0) { /* this is to keep the earlier error above @@ -406,6 +396,7 @@ exit_parse: } } + if (n == -1) xp_awk_clear (awk); return n; } @@ -2055,7 +2046,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk) { xp_free (nde->buf); xp_free (nde); - PANIC2 (awk, XP_AWK_EREXBUILD, errnum); + PANIC (awk, errnum); } if (__get_token(awk) == -1) diff --git a/ase/awk/rex.c b/ase/awk/rex.c index e51e0def..533b454f 100644 --- a/ase/awk/rex.c +++ b/ase/awk/rex.c @@ -1,5 +1,5 @@ /* - * $Id: rex.c,v 1.17 2006-07-26 16:43:35 bacon Exp $ + * $Id: rex.c,v 1.18 2006-08-10 16:02:15 bacon Exp $ */ #include @@ -219,31 +219,6 @@ static struct __char_class_t __char_class [] = { XP_NULL, 0, XP_NULL } }; -const xp_char_t* xp_awk_getrexerrstr (int errnum) -{ - static const xp_char_t* __errstr[] = - { - XP_T("no error"), - XP_T("out of memory"), - XP_T("a right parenthesis is expected"), - XP_T("a right bracket is expected"), - XP_T("a right brace is expected"), - XP_T("a colon is expected"), - XP_T("invalid character range"), - XP_T("invalid character class"), - XP_T("invalid boundary range"), - XP_T("unexpected end of the regular expression"), - XP_T("garbage after the regular expression") - }; - - if (errnum >= 0 && errnum < xp_countof(__errstr)) - { - return __errstr[errnum]; - } - - return XP_T("unknown error"); -} - void* xp_awk_buildrex (const xp_char_t* ptn, xp_size_t len, int* errnum) { __builder_t builder; @@ -253,7 +228,7 @@ void* xp_awk_buildrex (const xp_char_t* ptn, xp_size_t len, int* errnum) builder.code.buf = (xp_byte_t*) xp_malloc (builder.code.capa); if (builder.code.buf == XP_NULL) { - *errnum = XP_AWK_REX_ENOMEM; + *errnum = XP_AWK_ENOMEM; return XP_NULL; } @@ -281,7 +256,7 @@ void* xp_awk_buildrex (const xp_char_t* ptn, xp_size_t len, int* errnum) if (builder.ptn.curc.type != CT_EOF) { - if (errnum != XP_NULL) *errnum = XP_AWK_REX_EGARBAGE; + if (errnum != XP_NULL) *errnum = XP_AWK_EREXGARBAGE; xp_free (builder.code.buf); return XP_NULL; } @@ -454,7 +429,7 @@ static int __build_atom (__builder_t* builder) if (builder->ptn.curc.type != CT_SPECIAL || builder->ptn.curc.value != XP_T(')')) { - builder->errnum = XP_AWK_REX_ERPAREN; + builder->errnum = XP_AWK_EREXRPAREN; return -1; } } @@ -504,7 +479,7 @@ static int __build_atom (__builder_t* builder) if (builder->ptn.curc.type != CT_SPECIAL || builder->ptn.curc.value != XP_T(']')) { - builder->errnum = XP_AWK_REX_ERBRACKET; + builder->errnum = XP_AWK_EREXRBRACKET; return -1; } @@ -620,7 +595,7 @@ static int __build_charset (__builder_t* builder, struct __code_t* cmd) { /* invalid range */ //xp_printf (XP_T("invalid character set range\n")); - builder->errnum = XP_AWK_REX_ECRANGE; + builder->errnum = XP_AWK_EREXCRANGE; return -1; } @@ -646,7 +621,7 @@ static int __build_cclass (__builder_t* builder, xp_char_t* cc) { /* wrong class name */ //xp_printf (XP_T("wrong class name\n")); - builder->errnum = XP_AWK_REX_ECCLASS; + builder->errnum = XP_AWK_EREXCCLASS; return -1; } @@ -657,7 +632,7 @@ static int __build_cclass (__builder_t* builder, xp_char_t* cc) builder->ptn.curc.value != XP_T(':')) { //xp_printf (XP_T(": expected\n")); - builder->errnum = XP_AWK_REX_ECOLON; + builder->errnum = XP_AWK_EREXCOLON; return -1; } @@ -668,7 +643,7 @@ static int __build_cclass (__builder_t* builder, xp_char_t* cc) builder->ptn.curc.value != XP_T(']')) { //xp_printf (XP_T("] expected\n")); - builder->errnum = XP_AWK_REX_ERBRACKET; + builder->errnum = XP_AWK_EREXRBRACKET; return -1; } @@ -717,7 +692,7 @@ static int __build_boundary (__builder_t* builder, struct __code_t* cmd) if (builder->ptn.curc.type != CT_SPECIAL || builder->ptn.curc.value != XP_T('}')) { - builder->errnum = XP_AWK_REX_ERBRACE; + builder->errnum = XP_AWK_EREXRBRACE; return -1; } @@ -765,7 +740,7 @@ static int __build_range (__builder_t* builder, struct __code_t* cmd) if (cmd->lbound > cmd->ubound) { /* invalid boundary range */ - builder->errnum = XP_AWK_REX_EBRANGE; + builder->errnum = XP_AWK_EREXBRANGE; return -1; } @@ -788,7 +763,7 @@ static int __next_char (__builder_t* builder, int level) { if (builder->ptn.curp >= builder->ptn.end) { - builder->errnum = XP_AWK_REX_EEND; + builder->errnum = XP_AWK_EREXEND; return -1; } @@ -847,7 +822,7 @@ static int __add_code (__builder_t* builder, void* data, xp_size_t len) tmp = (xp_byte_t*) xp_realloc (builder->code.buf, capa); if (tmp == XP_NULL) { - builder->errnum = XP_AWK_REX_ENOMEM; + builder->errnum = XP_AWK_ENOMEM; return -1; } @@ -1214,7 +1189,7 @@ static const xp_byte_t* __match_group ( xp_sizeof(xp_size_t) * cp->ubound); if (grp_len == XP_NULL) { - matcher->errnum = XP_AWK_REX_ENOMEM; + matcher->errnum = XP_AWK_ENOMEM; return XP_NULL; } }