*** empty log message ***

This commit is contained in:
hyung-hwan 2006-12-24 17:21:24 +00:00
parent c929b2ca09
commit de505319ea
6 changed files with 87 additions and 43 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.171 2006-12-23 05:44:17 bacon Exp $ * $Id: awk.h,v 1.172 2006-12-24 17:21:24 bacon Exp $
*/ */
#ifndef _ASE_AWK_AWK_H_ #ifndef _ASE_AWK_AWK_H_
@ -463,6 +463,10 @@ int ase_awk_getrunerrnum (ase_awk_run_t* run);
ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run); ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run);
const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run); const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run);
void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum); void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum);
void ase_awk_getrunerror (
ase_awk_run_t* run, int* errnum,
ase_size_t* errlin, const ase_char_t** errmsg);
void ase_awk_setrunerror ( void ase_awk_setrunerror (
ase_awk_run_t* run, int errnum, ase_awk_run_t* run, int errnum,
ase_size_t errlin, const ase_char_t* msg); ase_size_t errlin, const ase_char_t* msg);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: err.c,v 1.63 2006-12-23 05:44:17 bacon Exp $ * $Id: err.c,v 1.64 2006-12-24 17:21:24 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -38,7 +38,11 @@ void ase_awk_seterror (
awk->errnum = errnum; awk->errnum = errnum;
awk->errlin = errlin; awk->errlin = errlin;
if (errmsg == ASE_NULL) awk->errmsg[0] = ASE_T('\0'); if (errmsg == ASE_NULL) awk->errmsg[0] = ASE_T('\0');
else ase_awk_strxcpy (awk->errmsg, ASE_COUNTOF(awk->errmsg), errmsg); else if (awk->errmsg != errmsg)
{
ase_awk_strxcpy (
awk->errmsg, ASE_COUNTOF(awk->errmsg), errmsg);
}
} }
const ase_char_t* ase_awk_geterrstr (int errnum) const ase_char_t* ase_awk_geterrstr (int errnum)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.227 2006-12-23 05:44:17 bacon Exp $ * $Id: parse.c,v 1.228 2006-12-24 17:20:48 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -1395,8 +1395,8 @@ static ase_awk_nde_t* __parse_statement_nb (ase_awk_t* awk, ase_size_t line)
{ {
if (nde != ASE_NULL) ase_awk_clrpt (awk, nde); if (nde != ASE_NULL) ase_awk_clrpt (awk, nde);
ase_awk_seterror ( ase_awk_seterror (
awk, ASE_AWK_ESEMICOLON, awk, ASE_AWK_ESEMICOLON, awk->token.prev.line,
awk->token.prev.line, ASE_NULL); ASE_T("statement not terminated with a semicolon"));
return ASE_NULL; return ASE_NULL;
} }
@ -1417,7 +1417,9 @@ static ase_awk_nde_t* __parse_expression (ase_awk_t* awk, ase_size_t line)
if (awk->parse.depth.max.expr > 0 && if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{ {
awk->errnum = ASE_AWK_ERECUR; ase_awk_seterror (
awk, ASE_AWK_ERECUR, line,
ASE_T("expression nested too deeply"));
return ASE_NULL; return ASE_NULL;
} }
@ -1975,7 +1977,9 @@ static ase_awk_nde_t* __parse_unary (ase_awk_t* awk, ase_size_t line)
if (awk->parse.depth.max.expr > 0 && if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{ {
awk->errnum = ASE_AWK_ERECUR; ase_awk_seterror (
awk, ASE_AWK_ERECUR, awk->token.line,
ASE_T("expression nested too deeply"));
return ASE_NULL; return ASE_NULL;
} }
awk->parse.depth.cur.expr++; awk->parse.depth.cur.expr++;
@ -2030,7 +2034,9 @@ static ase_awk_nde_t* __parse_unary_exp (ase_awk_t* awk, ase_size_t line)
if (awk->parse.depth.max.expr > 0 && if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr) awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{ {
awk->errnum = ASE_AWK_ERECUR; ase_awk_seterror (
awk, ASE_AWK_ERECUR, awk->token.line,
ASE_T("expression nested too deeply"));
return ASE_NULL; return ASE_NULL;
} }
awk->parse.depth.cur.expr++; awk->parse.depth.cur.expr++;
@ -2447,7 +2453,9 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
} }
/* valid expression introducer is expected */ /* valid expression introducer is expected */
awk->errnum = ASE_AWK_EEXPRESSION; ase_awk_seterror (
awk, ASE_AWK_EEXPRESSION, line,
ASE_T("invalid start of an expression"));
return ASE_NULL; return ASE_NULL;
} }
@ -2465,7 +2473,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
ASE_AWK_STR_LEN(&awk->token.name)); ASE_AWK_STR_LEN(&awk->token.name));
if (name_dup == ASE_NULL) if (name_dup == ASE_NULL)
{ {
awk->errnum = ASE_AWK_ENOMEM; ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
name_len = ASE_AWK_STR_LEN(&awk->token.name); name_len = ASE_AWK_STR_LEN(&awk->token.name);
@ -2487,7 +2495,9 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
{ {
/* built-in function should be in the form /* built-in function should be in the form
* of the function call */ * of the function call */
awk->errnum = ASE_AWK_ELPAREN; ase_awk_seterror (
awk, ASE_AWK_ELPAREN, line,
ASE_T("function name without a left parenthesis"));
return ASE_NULL; return ASE_NULL;
} }
@ -2522,7 +2532,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
if (nde == ASE_NULL) if (nde == ASE_NULL)
{ {
ASE_AWK_FREE (awk, name_dup); ASE_AWK_FREE (awk, name_dup);
awk->errnum = ASE_AWK_ENOMEM; ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -2590,11 +2600,16 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
return (ase_awk_nde_t*)nde; return (ase_awk_nde_t*)nde;
} }
awk->sysfns.sprintf (
awk->errmsg, ASE_COUNTOF(awk->errmsg),
ASE_T("undefined identifier '%.*s'"),
name_len, name_dup);
/* undefined variable */ /* undefined variable */
ASE_AWK_FREE (awk, name_dup); ASE_AWK_FREE (awk, name_dup);
ASE_AWK_FREE (awk, nde); ASE_AWK_FREE (awk, nde);
awk->errnum = ASE_AWK_EUNDEF; ase_awk_seterror (awk, ASE_AWK_EUNDEF, line, awk->errmsg);
return ASE_NULL; return ASE_NULL;
} }
} }
@ -2656,7 +2671,7 @@ static ase_awk_nde_t* __parse_hashidx (
if (nde == ASE_NULL) if (nde == ASE_NULL)
{ {
ase_awk_clrpt (awk, idx); ase_awk_clrpt (awk, idx);
awk->errnum = ASE_AWK_ENOMEM; ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -2725,7 +2740,10 @@ static ase_awk_nde_t* __parse_hashidx (
ase_awk_clrpt (awk, idx); ase_awk_clrpt (awk, idx);
ASE_AWK_FREE (awk, nde); ASE_AWK_FREE (awk, nde);
awk->errnum = ASE_AWK_EUNDEF; awk->sysfns.sprintf (
awk->errmsg, ASE_COUNTOF(awk->errmsg),
ASE_T("undefined identifier '%.*s'"), name_len, name);
ase_awk_seterror (awk, ASE_AWK_EUNDEF, line, awk->errmsg);
return ASE_NULL; return ASE_NULL;
} }
@ -3489,7 +3507,7 @@ static ase_awk_nde_t* __parse_print (ase_awk_t* awk, ase_size_t line, int type)
if (args != ASE_NULL) ase_awk_clrpt (awk, args); if (args != ASE_NULL) ase_awk_clrpt (awk, args);
if (out != ASE_NULL) ase_awk_clrpt (awk, out); if (out != ASE_NULL) ase_awk_clrpt (awk, out);
awk->errnum = ASE_AWK_ENOMEM; ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -3500,7 +3518,9 @@ static ase_awk_nde_t* __parse_print (ase_awk_t* awk, ase_size_t line, int type)
if (type == ASE_AWK_NDE_PRINTF && args == ASE_NULL) if (type == ASE_AWK_NDE_PRINTF && args == ASE_NULL)
{ {
if (out != ASE_NULL) ase_awk_clrpt (awk, out); if (out != ASE_NULL) ase_awk_clrpt (awk, out);
awk->errnum = ASE_AWK_EPRINTFARG; ase_awk_seterror (
awk, ASE_AWK_EPRINTFARG, line,
ASE_T("printf not followed by any arguments"));
return ASE_NULL; return ASE_NULL;
} }
@ -3569,9 +3589,11 @@ static int __get_token (ase_awk_t* awk)
if (__unget_char (awk, c) == -1) return -1; if (__unget_char (awk, c) == -1) return -1;
if (__get_number (awk) == -1) return -1; if (__get_number (awk) == -1) return -1;
} }
else else
{ {
awk->errnum = ASE_AWK_ELXCHR; ase_awk_seterror (
awk, ASE_AWK_ELXCHR, awk->token.line,
ASE_T("floating point not followed by any valid digits"));
return -1; return -1;
} }
} }
@ -3957,7 +3979,11 @@ static int __get_token (ase_awk_t* awk)
} }
else else
{ {
awk->errnum = ASE_AWK_ELXCHR; awk->sysfns.sprintf (
awk->errmsg, ASE_COUNTOF(awk->errmsg),
ASE_T("invalid character '%c'"), c);
ase_awk_seterror (
awk, ASE_AWK_ELXCHR, awk->token.line, awk->errmsg);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.307 2006-12-24 15:14:08 bacon Exp $ * $Id: run.c,v 1.308 2006-12-24 17:21:04 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -567,14 +567,26 @@ void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum)
run->errmsg[0] = ASE_T('\0'); run->errmsg[0] = ASE_T('\0');
} }
void ase_awk_getrunerror (
ase_awk_run_t* run, int* errnum,
ase_size_t* errlin, const ase_char_t** errmsg)
{
if (errnum != ASE_NULL) *errnum = run->errnum;
if (errlin != ASE_NULL) *errlin = run->errlin;
if (errmsg != ASE_NULL) *errmsg = run->errmsg;
}
void ase_awk_setrunerror ( void ase_awk_setrunerror (
ase_awk_run_t* run, int errnum, ase_awk_run_t* run, int errnum,
ase_size_t errlin, const ase_char_t* msg) ase_size_t errlin, const ase_char_t* errmsg)
{ {
run->errnum = errnum; run->errnum = errnum;
run->errlin = errlin; run->errlin = errlin;
if (msg == ASE_NULL) run->errmsg[0] = ASE_T('\0'); if (errmsg == ASE_NULL) run->errmsg[0] = ASE_T('\0');
else ase_awk_strxcpy (run->errmsg, ASE_COUNTOF(run->errmsg), msg); else if (errmsg != run->errmsg)
{
ase_awk_strxcpy (run->errmsg, ASE_COUNTOF(run->errmsg), errmsg);
}
} }
int ase_awk_run (ase_awk_t* awk, int ase_awk_run (ase_awk_t* awk,
@ -2367,14 +2379,13 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
if (val->type != ASE_AWK_VAL_MAP) if (val->type != ASE_AWK_VAL_MAP)
{ {
ase_char_t msg[ASE_COUNTOF(run->errmsg)];
run->awk->sysfns.sprintf ( run->awk->sysfns.sprintf (
msg, ASE_COUNTOF(msg), run->errmsg, ASE_COUNTOF(run->errmsg),
ASE_T("%.*s not deletable"), ASE_T("'%.*s' not deletable"),
var->id.name_len, var->id.name); var->id.name_len, var->id.name);
ase_awk_setrunerror (run, ase_awk_setrunerror (
ASE_AWK_ENODEL, run, ASE_AWK_ENODEL, var->line,
var->line, msg); run->errmsg);
return -1; return -1;
} }
@ -2484,14 +2495,13 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
if (val->type != ASE_AWK_VAL_MAP) if (val->type != ASE_AWK_VAL_MAP)
{ {
ase_char_t msg[ASE_COUNTOF(run->errmsg)];
run->awk->sysfns.sprintf ( run->awk->sysfns.sprintf (
msg, ASE_COUNTOF(msg), run->errmsg, ASE_COUNTOF(run->errmsg),
ASE_T("%.*s not deletable"), ASE_T("'%.*s' not deletable"),
var->id.name_len, var->id.name); var->id.name_len, var->id.name);
ase_awk_setrunerror (run, ase_awk_setrunerror (
ASE_AWK_ENODEL, run, ASE_AWK_ENODEL, var->line,
var->line, msg); run->errmsg);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.100 2006-12-16 16:14:40 bacon Exp $ * $Id: val.c,v 1.101 2006-12-24 17:21:24 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -777,7 +777,7 @@ void ase_awk_dprintval (ase_awk_run_t* run, ase_awk_val_t* val)
(long long)((ase_awk_val_int_t*)val)->val); (long long)((ase_awk_val_int_t*)val)->val);
#elif ASE_SIZEOF___INT64 > 0 #elif ASE_SIZEOF___INT64 > 0
__DPRINTF (ASE_T("%I64d"), __DPRINTF (ASE_T("%I64d"),
(__int64)((ase_awk_nde_int_t*)val)->val); (__int64)((ase_awk_val_int_t*)val)->val);
#elif ASE_SIZEOF_LONG > 0 #elif ASE_SIZEOF_LONG > 0
__DPRINTF (ASE_T("%ld"), __DPRINTF (ASE_T("%ld"),
(long)((ase_awk_val_int_t*)val)->val); (long)((ase_awk_val_int_t*)val)->val);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.148 2006-12-24 16:07:13 bacon Exp $ * $Id: awk.c,v 1.149 2006-12-24 17:21:24 bacon Exp $
*/ */
#include <ase/awk/awk.h> #include <ase/awk/awk.h>
@ -783,7 +783,7 @@ static int __main (int argc, ase_char_t* argv[])
#endif #endif
const ase_char_t* mfn = ASE_NULL; const ase_char_t* mfn = ASE_NULL;
opt = ASE_AWK_IMPLICIT | opt = /*ASE_AWK_IMPLICIT | */
ASE_AWK_EXPLICIT | ASE_AWK_EXPLICIT |
ASE_AWK_UNIQUEAFN | ASE_AWK_UNIQUEAFN |
ASE_AWK_HASHSIGN | ASE_AWK_HASHSIGN |
@ -874,7 +874,7 @@ static int __main (int argc, ase_char_t* argv[])
HeapDestroy (sysfns_data.heap); HeapDestroy (sysfns_data.heap);
#endif #endif
awk_printf ( awk_printf (
ASE_T("ERROR: cannot parse awk [%d] %s\n"), ASE_T("ERROR: cannot open awk [%d] %s\n"),
errnum, ase_awk_geterrstr(errnum)); errnum, ase_awk_geterrstr(errnum));
return -1; return -1;
} }
@ -897,7 +897,7 @@ static int __main (int argc, ase_char_t* argv[])
awk_printf ( awk_printf (
ASE_T("ERROR: cannot parse program - line %u [%d] %s\n"), ASE_T("ERROR: cannot parse program - line %u [%d] %s\n"),
(unsigned int)ase_awk_geterrlin(awk), (unsigned int)ase_awk_geterrlin(awk),
errnum, ase_awk_geterrstr(errnum)); errnum, ase_awk_geterrmsg(awk));
ase_awk_close (awk); ase_awk_close (awk);
return -1; return -1;
} }