*** empty log message ***

This commit is contained in:
hyung-hwan 2007-03-10 15:02:31 +00:00
parent 0d30d514e2
commit 6b1ed8104a
5 changed files with 136 additions and 126 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.206 2007-03-10 11:58:34 bacon Exp $ * $Id: awk.h,v 1.207 2007-03-10 15:02:30 bacon Exp $
* *
* {License} * {License}
*/ */
@ -305,14 +305,18 @@ enum
ASE_AWK_ESCALARTOMAP, /* cannot change a scalar value to a map */ ASE_AWK_ESCALARTOMAP, /* cannot change a scalar value to a map */
ASE_AWK_EMAPNOTALLOWED, /* a map is not allowed */ ASE_AWK_EMAPNOTALLOWED, /* a map is not allowed */
ASE_AWK_EVALTYPE, /* wrong value type */ ASE_AWK_EVALTYPE, /* wrong value type */
ASE_AWK_ENEXTCALL, /* next called from BEGIN or END */ ASE_AWK_ERDELETE, /* delete called with a wrong target */
ASE_AWK_ENEXTFILECALL, /* nextfile called from BEGIN or END */ ASE_AWK_ERNEXTBEG, /* next called from BEGIN */
ASE_AWK_ERNEXTEND, /* next called from END */
ASE_AWK_ERNEXTFBEG, /* nextfile called from BEGIN */
ASE_AWK_ERNEXTFEND, /* nextfile called from END */
ASE_AWK_EBFNUSER, /* wrong builtin function implementation */ ASE_AWK_EBFNUSER, /* wrong builtin function implementation */
ASE_AWK_EBFNIMPL, /* builtin function handler failed */ ASE_AWK_EBFNIMPL, /* builtin function handler failed */
ASE_AWK_EIOUSER, /* wrong user io handler implementation */ ASE_AWK_EIOUSER, /* wrong user io handler implementation */
ASE_AWK_EIONONE, /* no such io name found */ ASE_AWK_EIONONE, /* no such io name found */
ASE_AWK_EIOIMPL, /* i/o callback returned an error */ ASE_AWK_EIOIMPL, /* i/o callback returned an error */
ASE_AWK_EIONAME, /* invalid i/o name */ ASE_AWK_EIONMEM, /* i/o name empty */
ASE_AWK_EIONMNL, /* i/o name contains '\0' */
ASE_AWK_EFMTARG, /* arguments to format string not sufficient */ ASE_AWK_EFMTARG, /* arguments to format string not sufficient */
ASE_AWK_EFMTCNV, /* recursion detected in format conversion */ ASE_AWK_EFMTCNV, /* recursion detected in format conversion */
ASE_AWK_ECONVFMTCHAR, /* an invalid character found in CONVFMT */ ASE_AWK_ECONVFMTCHAR, /* an invalid character found in CONVFMT */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: err.c,v 1.90 2007-03-10 11:58:35 bacon Exp $ * $Id: err.c,v 1.91 2007-03-10 15:02:30 bacon Exp $
* *
* {License} * {License}
*/ */
@ -120,14 +120,18 @@ static const ase_char_t* __geterrstr (int errnum)
ASE_T("cannot change a scalar value to a map"), ASE_T("cannot change a scalar value to a map"),
ASE_T("a map is not allowed"), ASE_T("a map is not allowed"),
ASE_T("invalid value type"), ASE_T("invalid value type"),
ASE_T("next cannot be called from the BEGIN or END block"), ASE_T("delete statement called with a wrong target"),
ASE_T("nextfile cannot be called from the BEGIN or END block"), ASE_T("next statement called from the BEGIN block"),
ASE_T("next statement called from the END block"),
ASE_T("nextfile statement called from the BEGIN block"),
ASE_T("nextfile statement called from the END block"),
ASE_T("wrong implementation of built-in function handler"), ASE_T("wrong implementation of built-in function handler"),
ASE_T("built-in function handler returned an error"), ASE_T("built-in function handler returned an error"),
ASE_T("wrong implementation of user-defined io handler"), ASE_T("wrong implementation of user-defined io handler"),
ASE_T("no such io name found"), ASE_T("no such io name found"),
ASE_T("i/o handler returned an error"), ASE_T("i/o handler returned an error"),
ASE_T("invalid i/o name"), ASE_T("i/o name empty"),
ASE_T("i/o name containing a null character"),
ASE_T("not sufficient arguments to formatting sequence"), ASE_T("not sufficient arguments to formatting sequence"),
ASE_T("recursion detected in format conversion"), ASE_T("recursion detected in format conversion"),
ASE_T("invalid character in CONVFMT"), ASE_T("invalid character in CONVFMT"),

View File

@ -1,5 +1,5 @@
/* /*
* $Id: extio.c,v 1.75 2007-03-10 11:58:35 bacon Exp $ * $Id: extio.c,v 1.76 2007-03-10 15:02:30 bacon Exp $
* *
* {License} * {License}
*/ */
@ -100,7 +100,7 @@ int ase_awk_readextio (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -149,7 +149,8 @@ int ase_awk_readextio (
{ {
ASE_AWK_FREE (run->awk, p->name); ASE_AWK_FREE (run->awk, p->name);
ASE_AWK_FREE (run->awk, p); ASE_AWK_FREE (run->awk, p);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (
run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -222,7 +223,8 @@ int ase_awk_readextio (
if (n <= -1) if (n <= -1)
{ {
/* handler error. getline should return -1 */ /* handler error. getline should return -1 */
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (
run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
ret = -1; ret = -1;
break; break;
} }
@ -420,7 +422,7 @@ int ase_awk_writeextio_str (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -478,7 +480,8 @@ int ase_awk_writeextio_str (
{ {
ASE_AWK_FREE (run->awk, p->name); ASE_AWK_FREE (run->awk, p->name);
ASE_AWK_FREE (run->awk, p); ASE_AWK_FREE (run->awk, p);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (
run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -517,7 +520,8 @@ int ase_awk_writeextio_str (
if (n <= -1) if (n <= -1)
{ {
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (
run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -555,7 +559,7 @@ int ase_awk_flushextio (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -569,7 +573,8 @@ int ase_awk_flushextio (
if (n <= -1) if (n <= -1)
{ {
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (
run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -582,7 +587,7 @@ int ase_awk_flushextio (
if (ok) return 0; if (ok) return 0;
/* there is no corresponding extio for name */ /* there is no corresponding extio for name */
ase_awk_setrunerror_old (run, ASE_AWK_EIONONE, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIONONE, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -606,7 +611,7 @@ int ase_awk_nextextio_read (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -622,7 +627,7 @@ int ase_awk_nextextio_read (
/* something is totally wrong */ /* something is totally wrong */
ASE_ASSERT ( ASE_ASSERT (
!"should never happen - cannot find the relevant extio entry"); !"should never happen - cannot find the relevant extio entry");
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -635,7 +640,7 @@ int ase_awk_nextextio_read (
n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0); n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
if (n <= -1) if (n <= -1)
{ {
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -680,7 +685,7 @@ int ase_awk_nextextio_write (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -696,7 +701,7 @@ int ase_awk_nextextio_write (
/* something is totally wrong */ /* something is totally wrong */
ASE_ASSERT (!"should never happen - cannot find the relevant extio entry"); ASE_ASSERT (!"should never happen - cannot find the relevant extio entry");
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -709,7 +714,7 @@ int ase_awk_nextextio_write (
n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0); n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
if (n <= -1) if (n <= -1)
{ {
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -722,7 +727,7 @@ int ase_awk_nextextio_write (
n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0); n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
if (n <= -1) if (n <= -1)
{ {
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -763,7 +768,7 @@ int ase_awk_closeextio_read (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -780,7 +785,7 @@ int ase_awk_closeextio_read (
if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1) if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
{ {
/* this is not a run-time error.*/ /* this is not a run-time error.*/
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -798,7 +803,7 @@ int ase_awk_closeextio_read (
} }
/* this is not a run-time error */ /* this is not a run-time error */
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -822,7 +827,7 @@ int ase_awk_closeextio_write (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -839,7 +844,7 @@ int ase_awk_closeextio_write (
if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1) if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
{ {
/* this is not a run-time error.*/ /* this is not a run-time error.*/
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -857,7 +862,7 @@ int ase_awk_closeextio_write (
} }
/* this is not a run-time error */ /* this is not a run-time error */
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -879,7 +884,7 @@ int ase_awk_closeextio (ase_awk_run_t* run, const ase_char_t* name)
if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1) if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
{ {
/* this is not a run-time error.*/ /* this is not a run-time error.*/
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -897,7 +902,7 @@ int ase_awk_closeextio (ase_awk_run_t* run, const ase_char_t* name)
} }
/* this is not a run-time error */ /* this is not a run-time error */
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: rec.c,v 1.17 2007-03-06 14:51:53 bacon Exp $ * $Id: rec.c,v 1.18 2007-03-10 15:02:31 bacon Exp $
* *
* {License} * {License}
*/ */
@ -32,8 +32,8 @@ int ase_awk_setrec (
if (ase_str_ncpy (&run->inrec.line, str, len) == (ase_size_t)-1) if (ase_str_ncpy (&run->inrec.line, str, len) == (ase_size_t)-1)
{ {
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL); run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -42,7 +42,7 @@ int ase_awk_setrec (
if (v == ASE_NULL) if (v == ASE_NULL)
{ {
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -54,9 +54,7 @@ int ase_awk_setrec (
if (__split_record (run) == -1) if (__split_record (run) == -1)
{ {
errnum = run->errnum;
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -64,9 +62,7 @@ int ase_awk_setrec (
{ {
if (__recomp_record_fields (run, idx, str, len) == -1) if (__recomp_record_fields (run, idx, str, len) == -1)
{ {
errnum = run->errnum;
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL);
return -1; return -1;
} }
@ -77,7 +73,7 @@ int ase_awk_setrec (
if (v == ASE_NULL) if (v == ASE_NULL)
{ {
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -143,7 +139,7 @@ static int __split_record (ase_awk_run_t* run)
{ {
if (fs_free != ASE_NULL) if (fs_free != ASE_NULL)
ASE_AWK_FREE (run->awk, fs_free); ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL); ase_awk_setrunerror (run, errnum, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -171,7 +167,7 @@ static int __split_record (ase_awk_run_t* run)
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free); if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -200,7 +196,7 @@ static int __split_record (ase_awk_run_t* run)
{ {
if (fs_free != ASE_NULL) if (fs_free != ASE_NULL)
ASE_AWK_FREE (run->awk, fs_free); ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL); ase_awk_setrunerror (run, errnum, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -215,7 +211,7 @@ static int __split_record (ase_awk_run_t* run)
if (run->inrec.flds[run->inrec.nflds].val == ASE_NULL) if (run->inrec.flds[run->inrec.nflds].val == ASE_NULL)
{ {
if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free); if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -232,7 +228,7 @@ static int __split_record (ase_awk_run_t* run)
v = ase_awk_makeintval (run, (ase_long_t)nflds); v = ase_awk_makeintval (run, (ase_long_t)nflds);
if (v == ASE_NULL) if (v == ASE_NULL)
{ {
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -309,8 +305,8 @@ static int __recomp_record_fields (
ASE_SIZEOF(*run->inrec.flds) * max); ASE_SIZEOF(*run->inrec.flds) * max);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL); run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -320,8 +316,8 @@ static int __recomp_record_fields (
run->awk, ASE_SIZEOF(*run->inrec.flds) * max); run->awk, ASE_SIZEOF(*run->inrec.flds) * max);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL); run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
if (run->inrec.flds != ASE_NULL) if (run->inrec.flds != ASE_NULL)
@ -349,8 +345,8 @@ static int __recomp_record_fields (
run->global.ofs.ptr, run->global.ofs.ptr,
run->global.ofs.len) == (ase_size_t)-1) run->global.ofs.len) == (ase_size_t)-1)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL); run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -367,16 +363,16 @@ static int __recomp_record_fields (
if (ase_str_ncat ( if (ase_str_ncat (
&run->inrec.line, str, len) == (ase_size_t)-1) &run->inrec.line, str, len) == (ase_size_t)-1)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL); run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
tmp = ase_awk_makestrval (run, str,len); tmp = ase_awk_makestrval (run, str,len);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL); run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }
@ -397,8 +393,8 @@ static int __recomp_record_fields (
if (ase_str_cat ( if (ase_str_cat (
&run->inrec.line, ASE_T("")) == (ase_size_t)-1) &run->inrec.line, ASE_T("")) == (ase_size_t)-1)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL); run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.342 2007-03-10 11:58:35 bacon Exp $ * $Id: run.c,v 1.343 2007-03-10 15:02:31 bacon Exp $
* *
* {License} * {License}
*/ */
@ -2171,16 +2171,14 @@ static int __run_next (ase_awk_run_t* run, ase_awk_nde_next_t* nde)
* check that explicitly */ * check that explicitly */
if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin) if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENEXTCALL, nde->line, run, ASE_AWK_ERNEXTBEG, nde->line, ASE_NULL, 0);
ASE_T("next called from the BEGIN block"));
return -1; return -1;
} }
else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end) else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENEXTCALL, nde->line, run, ASE_AWK_ERNEXTEND, nde->line, ASE_NULL, 0);
ASE_T("next called from the END block"));
return -1; return -1;
} }
@ -2195,16 +2193,14 @@ static int __run_nextinfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
/* normal nextfile statement */ /* normal nextfile statement */
if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin) if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENEXTCALL, nde->line, run, ASE_AWK_ERNEXTFBEG, nde->line, ASE_NULL, 0);
ASE_T("nextfile called from the BEGIN block"));
return -1; return -1;
} }
else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end) else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENEXTCALL, nde->line, run, ASE_AWK_ERNEXTFEND, nde->line, ASE_NULL, 0);
ASE_T("nextfile called from the END block"));
return -1; return -1;
} }
@ -2372,8 +2368,8 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
if (key == ASE_NULL) if (key == ASE_NULL)
{ {
ase_awk_setrunerror_old (run, /* change the error line */
run->errnum, var->line, ASE_NULL); run->errlin = var->line;
return -1; return -1;
} }
@ -2431,8 +2427,8 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
{ {
ase_awk_refupval (run, tmp); ase_awk_refupval (run, tmp);
ase_awk_refdownval (run, tmp); ase_awk_refdownval (run, tmp);
ase_awk_setrunerror_old (run,
run->errnum, var->line, ASE_NULL); run->errlin = var->line;
return -1; return -1;
} }
} }
@ -2486,8 +2482,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
if (key == ASE_NULL) if (key == ASE_NULL)
{ {
ase_awk_setrunerror_old (run, run->errlin = var->line;
run->errnum, var->line, ASE_NULL);
return -1; return -1;
} }
@ -2505,9 +2500,9 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
ASE_ASSERTX ( ASE_ASSERTX (
!"should never happen - wrong target for delete", !"should never happen - wrong target for delete",
"the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc"); "the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc");
ase_awk_setrunerror_old (
run, ASE_AWK_EINTERN, var->line, ase_awk_setrunerror (
ASE_T("delete statement called with a wrong target")); run, ASE_AWK_ERDELETE, var->line, ASE_NULL, 0);
return -1; return -1;
} }
@ -2543,8 +2538,9 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
if (out == ASE_NULL) if (out == ASE_NULL)
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
ase_awk_setrunerror_old (
run, run->errnum, nde->line, ASE_NULL); /* change the error line */
run->errlin = nde->line;
return -1; return -1;
} }
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
@ -2553,9 +2549,8 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
{ {
/* the destination name is empty */ /* the destination name is empty */
ASE_AWK_FREE (run->awk, out); ASE_AWK_FREE (run->awk, out);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_EIONAME, nde->line, run, ASE_AWK_EIONMEM, nde->line, ASE_NULL, 0);
ASE_T("destination name empty in print"));
return -1; return -1;
} }
@ -2567,9 +2562,9 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
{ {
/* if so, it skips writing */ /* if so, it skips writing */
ASE_AWK_FREE (run->awk, out); ASE_AWK_FREE (run->awk, out);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_EIONAME, nde->line, run, ASE_AWK_EIONMNL, nde->line,
ASE_T("destination name containing a null character in print")); ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -2590,8 +2585,8 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out);
ase_awk_setrunerror_old ( /* change the error line */
run, run->errnum, nde->line, ASE_NULL); run->errlin = nde->line;
return -1; return -1;
} }
} }
@ -2620,8 +2615,8 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out);
ase_awk_setrunerror_old ( /* change the error line */
run, run->errnum, nde->line, ASE_NULL); run->errlin = nde->line;
return -1; return -1;
} }
} }
@ -2639,8 +2634,8 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out);
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
ase_awk_setrunerror_old ( /* change the error line */
run, run->errnum, nde->line, ASE_NULL); run->errlin = nde->line;
return -1; return -1;
} }
@ -2655,7 +2650,9 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out);
ase_awk_setrunerror_old (run, run->errnum, nde->line, ASE_NULL);
/* change the error line */
run->errlin = nde->line;
return -1; return -1;
} }
@ -2693,8 +2690,9 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
if (out == ASE_NULL) if (out == ASE_NULL)
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
ase_awk_setrunerror_old (
run, run->errnum, nde->line, ASE_NULL); /* change the error line */
run->errlin = nde->line;
return -1; return -1;
} }
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
@ -2703,9 +2701,8 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
{ {
/* the output destination name is empty. */ /* the output destination name is empty. */
ASE_AWK_FREE (run->awk, out); ASE_AWK_FREE (run->awk, out);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_EIONAME, nde->line, run, ASE_AWK_EIONMEM, nde->line, ASE_NULL, 0);
ASE_T("destination name empty in printf"));
return -1; return -1;
} }
@ -2716,9 +2713,9 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
/* the output destination name contains a null /* the output destination name contains a null
* character. */ * character. */
ASE_AWK_FREE (run->awk, out); ASE_AWK_FREE (run->awk, out);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_EIONAME, nde->line, run, ASE_AWK_EIONMNL, nde->line,
ASE_T("destination name containing a null character in printf")); ASE_NULL, 0);
return -1; return -1;
} }
} }
@ -2757,8 +2754,9 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out);
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
ase_awk_setrunerror_old (
run, run->errnum, nde->line, ASE_NULL); /* change the error line */
run->errlin = nde->line;
return -1; return -1;
} }
} }
@ -2773,8 +2771,9 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out);
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
ase_awk_setrunerror_old (
run, run->errnum, nde->line, ASE_NULL); /* change the error line */
run->errlin = nde->line;
return -1; return -1;
} }
} }
@ -2907,7 +2906,7 @@ static ase_awk_val_t* __eval_group (ase_awk_run_t* run, ase_awk_nde_t* nde)
/* __eval_binop_in evaluates the ASE_AWK_NDE_GRP specially. /* __eval_binop_in evaluates the ASE_AWK_NDE_GRP specially.
* so this function should never be reached. */ * so this function should never be reached. */
ASE_ASSERT (!"should never happen - NDE_GRP only for in"); ASE_ASSERT (!"should never happen - NDE_GRP only for in");
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, nde->line, ASE_NULL); ase_awk_setrunerror (run, ASE_AWK_EINTERN, nde->line, ASE_NULL, 0);
return ASE_NULL; return ASE_NULL;
} }
@ -3010,8 +3009,8 @@ static ase_awk_val_t* __do_assignment (
{ {
ASE_ASSERT ( ASE_ASSERT (
!"should never happen - invalid variable type"); !"should never happen - invalid variable type");
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_EINTERN, var->line, ASE_NULL); run, ASE_AWK_EINTERN, var->line, ASE_NULL, 0);
return ASE_NULL; return ASE_NULL;
} }
@ -3055,8 +3054,8 @@ static ase_awk_val_t* __do_assignment_scalar (
var->id.name, var->id.name_len, val, ASE_NULL); var->id.name, var->id.name_len, val, ASE_NULL);
if (n < 0) if (n < 0)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, var->line, run->errmsg); run, ASE_AWK_ENOMEM, var->line, ASE_NULL, 0);
return ASE_NULL; return ASE_NULL;
} }
@ -3156,8 +3155,8 @@ static ase_awk_val_t* __do_assignment_map (
tmp = ase_awk_makemapval (run); tmp = ase_awk_makemapval (run);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, var->line, ASE_NULL); run, ASE_AWK_ENOMEM, var->line, ASE_NULL, 0);
return ASE_NULL; return ASE_NULL;
} }
@ -3172,8 +3171,8 @@ static ase_awk_val_t* __do_assignment_map (
ase_awk_refupval (run, tmp); ase_awk_refupval (run, tmp);
ase_awk_refdownval (run, tmp); ase_awk_refdownval (run, tmp);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, var->line, ASE_NULL); run, ASE_AWK_ENOMEM, var->line, ASE_NULL, 0);
return ASE_NULL; return ASE_NULL;
} }
@ -3185,7 +3184,9 @@ static ase_awk_val_t* __do_assignment_map (
if (ase_awk_setglobal (run, var->id.idxa, tmp) == -1) if (ase_awk_setglobal (run, var->id.idxa, tmp) == -1)
{ {
ase_awk_refdownval (run, tmp); ase_awk_refdownval (run, tmp);
ase_awk_setrunerror_old (run, run->errnum, var->line, ASE_NULL);
/* change error line */
run->errlin = var->line;
return ASE_NULL; return ASE_NULL;
} }
ase_awk_refdownval (run, tmp); ase_awk_refdownval (run, tmp);
@ -3275,8 +3276,8 @@ static ase_awk_val_t* __do_assignment_pos (
run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len);
if (str == ASE_NULL) if (str == ASE_NULL)
{ {
ase_awk_setrunerror_old ( /* change error line */
run, run->errnum, pos->line, ASE_NULL); run->errlin = pos->line;
return ASE_NULL; return ASE_NULL;
} }
} }
@ -4860,8 +4861,8 @@ static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde)
!"should never happen - invalid opcode"); !"should never happen - invalid opcode");
ase_awk_refdownval (run, left); ase_awk_refdownval (run, left);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_EINTERN, nde->line, ASE_NULL); run, ASE_AWK_EINTERN, nde->line, ASE_NULL, 0);
return ASE_NULL; return ASE_NULL;
} }
@ -5139,8 +5140,8 @@ static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde)
!"should never happen - invalid opcode"); !"should never happen - invalid opcode");
ase_awk_refdownval (run, left); ase_awk_refdownval (run, left);
ase_awk_setrunerror_old ( ase_awk_setrunerror (
run, ASE_AWK_EINTERN, nde->line, ASE_NULL); run, ASE_AWK_EINTERN, nde->line, ASE_NULL, 0);
return ASE_NULL; return ASE_NULL;
} }
@ -6260,8 +6261,8 @@ static ase_char_t* __idxnde_to_str (
if (str == ASE_NULL) if (str == ASE_NULL)
{ {
ase_awk_refdownval (run, idx); ase_awk_refdownval (run, idx);
ase_awk_setrunerror_old ( /* change error line */
run, run->errnum, nde->line, ASE_NULL); run->errlin = nde->line;
return ASE_NULL; return ASE_NULL;
} }