From 5082a77c2e77317e5529cc7f0227c70ab8f3e5ec Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 23 Dec 2006 05:44:17 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.h | 23 ++++++++++------- ase/awk/err.c | 18 +++++++++++--- ase/awk/parse.c | 66 +++++++++++++++++++++++++++---------------------- 3 files changed, 65 insertions(+), 42 deletions(-) diff --git a/ase/awk/awk.h b/ase/awk/awk.h index 4318b2c0..52ff0b2b 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.170 2006-12-19 14:20:30 bacon Exp $ + * $Id: awk.h,v 1.171 2006-12-23 05:44:17 bacon Exp $ */ #ifndef _ASE_AWK_AWK_H_ @@ -236,16 +236,16 @@ enum ASE_AWK_ERUNTIME, /* run-time error */ ASE_AWK_ERUNNING, /* there are running instances */ ASE_AWK_ETOOMANYRUNS, /* too many running instances */ - ASE_AWK_ERECURSION, /* recursion too deep */ + ASE_AWK_ERECUR, /* recursion too deep */ ASE_AWK_ESYSFNS, /* system functions not proper */ - ASE_AWK_ESRCINOPEN, - ASE_AWK_ESRCINCLOSE, - ASE_AWK_ESRCINREAD, + ASE_AWK_ESINOP, + ASE_AWK_ESINCL, + ASE_AWK_ESINRD, - ASE_AWK_ESRCOUTOPEN, - ASE_AWK_ESRCOUTCLOSE, - ASE_AWK_ESRCOUTWRITE, + ASE_AWK_ESOUTOP, + ASE_AWK_ESOUTCL, + ASE_AWK_ESOUTWR, ASE_AWK_ECONINOPEN, ASE_AWK_ECONINCLOSE, @@ -404,9 +404,14 @@ int ase_awk_clear (ase_awk_t* awk); int ase_awk_geterrnum (ase_awk_t* awk); ase_size_t ase_awk_geterrlin (ase_awk_t* awk); const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk); + +void ase_awk_geterror ( + ase_awk_t* awk, int* errnum, + ase_size_t* errlin, const ase_char_t** errmsg); + void ase_awk_seterror ( ase_awk_t* run, int errnum, - ase_size_t errlin, const ase_char_t* msg); + ase_size_t errlin, const ase_char_t* errmsg); int ase_awk_getopt (ase_awk_t* awk); void ase_awk_setopt (ase_awk_t* awk, int opt); diff --git a/ase/awk/err.c b/ase/awk/err.c index 3702128c..7ed85802 100644 --- a/ase/awk/err.c +++ b/ase/awk/err.c @@ -1,5 +1,5 @@ /* - * $Id: err.c,v 1.62 2006-12-19 14:20:30 bacon Exp $ + * $Id: err.c,v 1.63 2006-12-23 05:44:17 bacon Exp $ */ #include @@ -21,14 +21,24 @@ const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk) return awk->errmsg; } + +void ase_awk_geterror ( + ase_awk_t* awk, int* errnum, + ase_size_t* errlin, const ase_char_t** errmsg) +{ + if (errnum != ASE_NULL) *errnum = awk->errnum; + if (errlin != ASE_NULL) *errlin = awk->errlin; + if (errmsg != ASE_NULL) *errmsg = awk->errmsg; +} + void ase_awk_seterror ( ase_awk_t* awk, int errnum, - ase_size_t errlin, const ase_char_t* msg) + ase_size_t errlin, const ase_char_t* errmsg) { awk->errnum = errnum; awk->errlin = errlin; - if (msg == ASE_NULL) awk->errmsg[0] = ASE_T('\0'); - else ase_awk_strxcpy (awk->errmsg, ASE_COUNTOF(awk->errmsg), msg); + if (errmsg == ASE_NULL) awk->errmsg[0] = ASE_T('\0'); + else ase_awk_strxcpy (awk->errmsg, ASE_COUNTOF(awk->errmsg), errmsg); } const ase_char_t* ase_awk_geterrstr (int errnum) diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 341dbb82..9aa0d753 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.226 2006-12-19 14:49:24 bacon Exp $ + * $Id: parse.c,v 1.227 2006-12-23 05:44:17 bacon Exp $ */ #include @@ -379,7 +379,9 @@ static int __parse (ase_awk_t* awk) { /* cannot open the source file. * it doesn't even have to call CLOSE */ - awk->errnum = ASE_AWK_ESRCINOPEN; + ase_awk_seterror ( + awk, ASE_AWK_ESINOP, 0, + ASE_T("cannot open the source input")); return -1; } @@ -441,7 +443,9 @@ exit_parse: { /* this is to keep the earlier error above * that might be more critical than this */ - awk->errnum = ASE_AWK_ESRCINCLOSE; + ase_awk_seterror ( + awk, ASE_AWK_ESINCL, 0, + ASE_T("cannot close the source input")); n = -1; } } @@ -1058,7 +1062,9 @@ static ase_awk_nde_t* __parse_block_dc ( if (awk->parse.depth.cur.block >= awk->parse.depth.max.block) { - awk->errnum = ASE_AWK_ERECURSION; + ase_awk_seterror ( + awk, ASE_AWK_ERECUR, awk->token.prev.line, + ASE_T("block nested too deeply")); return ASE_NULL; } @@ -1411,7 +1417,7 @@ static ase_awk_nde_t* __parse_expression (ase_awk_t* awk, ase_size_t line) if (awk->parse.depth.max.expr > 0 && awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) { - awk->errnum = ASE_AWK_ERECURSION; + awk->errnum = ASE_AWK_ERECUR; return ASE_NULL; } @@ -1969,7 +1975,7 @@ static ase_awk_nde_t* __parse_unary (ase_awk_t* awk, ase_size_t line) if (awk->parse.depth.max.expr > 0 && awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) { - awk->errnum = ASE_AWK_ERECURSION; + awk->errnum = ASE_AWK_ERECUR; return ASE_NULL; } awk->parse.depth.cur.expr++; @@ -2024,7 +2030,7 @@ static ase_awk_nde_t* __parse_unary_exp (ase_awk_t* awk, ase_size_t line) if (awk->parse.depth.max.expr > 0 && awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) { - awk->errnum = ASE_AWK_ERECURSION; + awk->errnum = ASE_AWK_ERECUR; return ASE_NULL; } awk->parse.depth.cur.expr++; @@ -4254,7 +4260,9 @@ static int __get_char (ase_awk_t* awk) awk->src.shared.buf, ASE_COUNTOF(awk->src.shared.buf)); if (n <= -1) { - awk->errnum = ASE_AWK_ESRCINREAD; + ase_awk_seterror ( + awk, ASE_AWK_ESINRD, 0, + ASE_T("cannot read the source input")); return -1; } @@ -4456,7 +4464,7 @@ static int __deparse (ase_awk_t* awk) ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0); if (op <= -1) { - awk->errnum = ASE_AWK_ESRCOUTOPEN; + awk->errnum = ASE_AWK_ESOUTOP; return -1; } @@ -4486,7 +4494,7 @@ static int __deparse (ase_awk_t* awk) ASE_AWK_ASSERT (awk, awk->tree.nglobals > 0); if (ase_awk_putsrcstr (awk, ASE_T("global ")) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); for (i = awk->tree.nbglobals; i < awk->tree.nglobals - 1; i++) { @@ -4495,17 +4503,17 @@ static int __deparse (ase_awk_t* awk) 10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp)); ASE_AWK_ASSERT (awk, len != (ase_size_t)-1); if (ase_awk_putsrcstrx (awk, tmp, len) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); */ if (ase_awk_putsrcstrx (awk, awk->parse.globals.buf[i].name, awk->parse.globals.buf[i].name_len) == -1) { - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } if (ase_awk_putsrcstr (awk, ASE_T(", ")) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } /* @@ -4513,17 +4521,17 @@ static int __deparse (ase_awk_t* awk) 10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp)); ASE_AWK_ASSERT (awk, len != (ase_size_t)-1); if (ase_awk_putsrcstrx (awk, tmp, len) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); */ if (ase_awk_putsrcstrx (awk, awk->parse.globals.buf[i].name, awk->parse.globals.buf[i].name_len) == -1) { - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } if (ase_awk_putsrcstr (awk, ASE_T(";\n\n")) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } df.awk = awk; @@ -4532,19 +4540,19 @@ static int __deparse (ase_awk_t* awk) if (ase_awk_map_walk (&awk->tree.afns, __deparse_func, &df) == -1) { - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } if (awk->tree.begin != ASE_NULL) { if (ase_awk_putsrcstr (awk, ASE_T("BEGIN ")) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); if (ase_awk_prnpt (awk, awk->tree.begin) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); if (__put_char (awk, ASE_T('\n')) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } chain = awk->tree.chain; @@ -4553,28 +4561,28 @@ static int __deparse (ase_awk_t* awk) if (chain->pattern != ASE_NULL) { if (ase_awk_prnptnpt (awk, chain->pattern) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } if (chain->action == ASE_NULL) { /* blockless pattern */ if (__put_char (awk, ASE_T('\n')) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } else { if (chain->pattern != ASE_NULL) { if (__put_char (awk, ASE_T(' ')) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } if (ase_awk_prnpt (awk, chain->action) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } if (__put_char (awk, ASE_T('\n')) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); chain = chain->next; } @@ -4582,12 +4590,12 @@ static int __deparse (ase_awk_t* awk) if (awk->tree.end != ASE_NULL) { if (ase_awk_putsrcstr (awk, ASE_T("END ")) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); if (ase_awk_prnpt (awk, awk->tree.end) == -1) - EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + EXIT_DEPARSE (ASE_AWK_ESOUTWR); } - if (__flush (awk) == -1) EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); + if (__flush (awk) == -1) EXIT_DEPARSE (ASE_AWK_ESOUTWR); exit_deparse: if (awk->src.ios.out ( @@ -4595,7 +4603,7 @@ exit_deparse: { if (n == 0) { - awk->errnum = ASE_AWK_ESRCOUTCLOSE; + awk->errnum = ASE_AWK_ESOUTWR; n = -1; } }