*** empty log message ***

This commit is contained in:
hyung-hwan 2007-01-02 12:25:18 +00:00
parent d2feccde0f
commit fad47e1027
8 changed files with 225 additions and 228 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.176 2007-01-01 15:07:25 bacon Exp $ * $Id: awk.h,v 1.177 2007-01-02 12:25:18 bacon Exp $
*/ */
#ifndef _ASE_AWK_AWK_H_ #ifndef _ASE_AWK_AWK_H_
@ -308,7 +308,7 @@ enum
ASE_AWK_EPOSIDX, /* wrong position index */ ASE_AWK_EPOSIDX, /* wrong position index */
ASE_AWK_EARGTF, /* too few arguments */ ASE_AWK_EARGTF, /* too few arguments */
ASE_AWK_EARGTM, /* too many arguments */ ASE_AWK_EARGTM, /* too many arguments */
ASE_AWK_ENOSUCHFN, /* no such function */ ASE_AWK_EFNNONE, /* no such function */
ASE_AWK_ENOTIDX, /* variable not indexable */ ASE_AWK_ENOTIDX, /* variable not indexable */
ASE_AWK_ENOTDEL, /* variable not deletable */ ASE_AWK_ENOTDEL, /* variable not deletable */
ASE_AWK_ENOTMAP, /* value not a map */ ASE_AWK_ENOTMAP, /* value not a map */
@ -322,14 +322,14 @@ enum
ASE_AWK_EVALTYPE, /* wrong value type */ ASE_AWK_EVALTYPE, /* wrong value type */
ASE_AWK_ENEXTCALL, /* next called from BEGIN or END */ ASE_AWK_ENEXTCALL, /* next called from BEGIN or END */
ASE_AWK_ENEXTFILECALL, /* nextfile called from BEGIN or END */ ASE_AWK_ENEXTFILECALL, /* nextfile called from BEGIN or END */
ASE_AWK_EIOIMPL, /* wrong user io handler implementation */ ASE_AWK_EBFNUSER, /* wrong builtin function implementation */
ASE_AWK_EBFNIMPL, /* wrong builtin function implementation */ ASE_AWK_EBFNIMPL, /* builtin function handler failed */
ASE_AWK_EBFNFAIL, /* builtin function handler failed */ ASE_AWK_EIOUSER, /* wrong user io handler implementation */
ASE_AWK_ENOSUCHIO, /* no such io name found */ ASE_AWK_EIONONE, /* no such io name found */
ASE_AWK_EIOHANDLER, /* i/o callback returned an error */ ASE_AWK_EIOIMPL, /* i/o callback returned an error */
ASE_AWK_EIONAME, /* invalid i/o name */ ASE_AWK_EIONAME, /* invalid i/o name */
ASE_AWK_EFMTARG, /* arguments to format string not sufficient */ ASE_AWK_EFMTARG, /* arguments to format string not sufficient */
ASE_AWK_EFMTCONV, /* 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 */
ASE_AWK_EOFMTCHAR, /* an invalid character found in OFMT */ ASE_AWK_EOFMTCHAR, /* an invalid character found in OFMT */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: err.c,v 1.67 2006-12-30 08:54:43 bacon Exp $ * $Id: err.c,v 1.68 2007-01-02 12:25:18 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -156,9 +156,9 @@ const ase_char_t* ase_awk_geterrstr (int errnum)
ASE_T("wrong value type"), ASE_T("wrong value type"),
ASE_T("next cannot be called from the BEGIN or END block"), ASE_T("next cannot be called from the BEGIN or END block"),
ASE_T("nextfile cannot be called from the BEGIN or END block"), ASE_T("nextfile cannot be called from the BEGIN or END block"),
ASE_T("wrong implementation of user-defined io handler"),
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("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("invalid i/o name"),

View File

@ -1,5 +1,5 @@
/* /*
* $Id: extio.c,v 1.68 2006-12-30 08:54:43 bacon Exp $ * $Id: extio.c,v 1.69 2007-01-02 12:25:18 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -100,7 +100,7 @@ int ase_awk_readextio (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
run->errnum = ASE_AWK_EIOIMPL; /* TODO: change the error code */ ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1; return -1;
} }
@ -117,7 +117,7 @@ int ase_awk_readextio (
run->awk, ASE_SIZEOF(ase_awk_extio_t)); run->awk, ASE_SIZEOF(ase_awk_extio_t));
if (p == ASE_NULL) if (p == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -125,7 +125,7 @@ int ase_awk_readextio (
if (p->name == ASE_NULL) if (p->name == ASE_NULL)
{ {
ASE_AWK_FREE (run->awk, p); ASE_AWK_FREE (run->awk, p);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -147,7 +147,7 @@ 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);
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
@ -218,12 +218,11 @@ int ase_awk_readextio (
break; break;
} }
n = handler (ASE_AWK_IO_READ, p, n = handler (ASE_AWK_IO_READ, p, p->in.buf, ASE_COUNTOF(p->in.buf));
p->in.buf, ASE_COUNTOF(p->in.buf));
if (n <= -1) if (n <= -1)
{ {
/* handler error. getline should return -1 */ /* handler error. getline should return -1 */
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ret = -1; ret = -1;
break; break;
} }
@ -309,7 +308,7 @@ int ase_awk_readextio (
if (ase_awk_str_ccat (buf, c) == (ase_size_t)-1) if (ase_awk_str_ccat (buf, c) == (ase_size_t)-1)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ret = -1; ret = -1;
break; break;
} }
@ -343,7 +342,7 @@ int ase_awk_readextio (
nr = ase_awk_makeintval (run, lv + 1); nr = ase_awk_makeintval (run, lv + 1);
if (nr == ASE_NULL) if (nr == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ret = -1; ret = -1;
} }
else else
@ -409,7 +408,7 @@ int ase_awk_writeextio_str (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
run->errnum = ASE_AWK_EIOIMPL; /* TODO: change the error code */ ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1; return -1;
} }
@ -438,7 +437,7 @@ int ase_awk_writeextio_str (
run->awk, ASE_SIZEOF(ase_awk_extio_t)); run->awk, ASE_SIZEOF(ase_awk_extio_t));
if (p == ASE_NULL) if (p == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -446,7 +445,7 @@ int ase_awk_writeextio_str (
if (p->name == ASE_NULL) if (p->name == ASE_NULL)
{ {
ASE_AWK_FREE (run->awk, p); ASE_AWK_FREE (run->awk, p);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -465,7 +464,7 @@ 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);
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
@ -504,7 +503,7 @@ int ase_awk_writeextio_str (
if (n <= -1) if (n <= -1)
{ {
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
@ -545,7 +544,7 @@ int ase_awk_flushextio (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
run->errnum = ASE_AWK_EIOIMPL; /* TODO: change the error code */ ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1; return -1;
} }
@ -559,7 +558,7 @@ int ase_awk_flushextio (
if (n <= -1) if (n <= -1)
{ {
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
@ -572,7 +571,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 */
run->errnum = ASE_AWK_ENOSUCHIO; ase_awk_setrunerror (run, ASE_AWK_EIONONE, 0, ASE_NULL);
return -1; return -1;
} }
@ -599,7 +598,7 @@ int ase_awk_nextextio_read (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
run->errnum = ASE_AWK_EIOIMPL; /* TODO: change the error code */ ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1; return -1;
} }
@ -615,7 +614,7 @@ int ase_awk_nextextio_read (
/* something is totally wrong */ /* something is totally wrong */
ASE_AWK_ASSERT (run->awk, ASE_AWK_ASSERT (run->awk,
!"should never happen - cannot find the relevant extio entry"); !"should never happen - cannot find the relevant extio entry");
run->errnum = ASE_AWK_EINTERN; ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL);
return -1; return -1;
} }
@ -628,8 +627,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)
{ {
/* TODO: is this errnum correct? */ ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
run->errnum = ASE_AWK_EIOHANDLER;
return -1; return -1;
} }
@ -677,7 +675,7 @@ int ase_awk_nextextio_write (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
run->errnum = ASE_AWK_EIOIMPL; /* TODO: change the error code */ ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1; return -1;
} }
@ -694,7 +692,7 @@ int ase_awk_nextextio_write (
ASE_AWK_ASSERT (run->awk, ASE_AWK_ASSERT (run->awk,
!"should never happen - cannot find the relevant extio entry"); !"should never happen - cannot find the relevant extio entry");
run->errnum = ASE_AWK_EINTERN; ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL);
return -1; return -1;
} }
@ -707,8 +705,20 @@ 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)
{ {
/* TODO: is this errnum correct? */ ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
run->errnum = ASE_AWK_EIOHANDLER; return -1;
}
if (p->out.eos)
{
/* no more streams. */
return 0;
}
n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
if (n <= -1)
{
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
@ -752,7 +762,7 @@ int ase_awk_closeextio_read (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
run->errnum = ASE_AWK_EIOIMPL; /* TODO: change the error code */ ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1; return -1;
} }
@ -769,7 +779,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.*/
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -787,7 +797,7 @@ int ase_awk_closeextio_read (
} }
/* this is not a run-time error */ /* this is not a run-time error */
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
@ -814,7 +824,7 @@ int ase_awk_closeextio_write (
if (handler == ASE_NULL) if (handler == ASE_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
run->errnum = ASE_AWK_EIOIMPL; /* TODO: change the error code */ ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1; return -1;
} }
@ -831,7 +841,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.*/
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -849,7 +859,7 @@ int ase_awk_closeextio_write (
} }
/* this is not a run-time error */ /* this is not a run-time error */
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
@ -871,7 +881,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.*/
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -889,7 +899,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 */
run->errnum = ASE_AWK_EIOHANDLER; ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: func.c,v 1.85 2006-12-17 14:56:06 bacon Exp $ * $Id: func.c,v 1.86 2007-01-02 12:25:18 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -51,14 +51,14 @@ void* ase_awk_addbfn (
if (ase_awk_getbfn (awk, name, name_len) != ASE_NULL) if (ase_awk_getbfn (awk, name, name_len) != ASE_NULL)
{ {
awk->errnum = ASE_AWK_EEXIST; ase_awk_seterror (awk, ASE_AWK_EEXIST, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
p = (ase_awk_bfn_t*) ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_bfn_t)); p = (ase_awk_bfn_t*) ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_bfn_t));
if (p == ASE_NULL) if (p == ASE_NULL)
{ {
awk->errnum = ASE_AWK_ENOMEM; ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -66,7 +66,7 @@ void* ase_awk_addbfn (
if (p->name.ptr == ASE_NULL) if (p->name.ptr == ASE_NULL)
{ {
ASE_AWK_FREE (awk, p); ASE_AWK_FREE (awk, p);
awk->errnum = ASE_AWK_ENOMEM; ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -82,7 +82,7 @@ void* ase_awk_addbfn (
{ {
ASE_AWK_FREE (awk, p->name.ptr); ASE_AWK_FREE (awk, p->name.ptr);
ASE_AWK_FREE (awk, p); ASE_AWK_FREE (awk, p);
awk->errnum = ASE_AWK_ENOMEM; ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
} }
@ -117,7 +117,7 @@ int ase_awk_delbfn (ase_awk_t* awk, const ase_char_t* name, ase_size_t name_len)
pp = p; pp = p;
} }
awk->errnum = ASE_AWK_ENOENT; ase_awk_seterror (awk, ASE_AWK_ENOENT, 0, ASE_NULL);
return -1; return -1;
} }
@ -223,7 +223,7 @@ static int __bfn_close (
} }
n = ase_awk_closeextio (run, name); n = ase_awk_closeextio (run, name);
if (n == -1 && run->errnum != ASE_AWK_EIOHANDLER) if (n == -1 && run->errnum != ASE_AWK_EIOIMPL)
{ {
if (a0->type != ASE_AWK_VAL_STR) if (a0->type != ASE_AWK_VAL_STR)
ASE_AWK_FREE (run->awk, name); ASE_AWK_FREE (run->awk, name);
@ -254,8 +254,8 @@ static int __flush_extio (
n2 = ase_awk_flushextio (run, extio, name); n2 = ase_awk_flushextio (run, extio, name);
if (n2 == -1) if (n2 == -1)
{ {
if (run->errnum == ASE_AWK_EIOHANDLER) n = -1; if (run->errnum == ASE_AWK_EIOIMPL) n = -1;
else if (run->errnum == ASE_AWK_ENOSUCHIO) else if (run->errnum == ASE_AWK_EIONONE)
{ {
if (n != 0) n = -2; if (n != 0) n = -2;
} }
@ -284,13 +284,13 @@ static int __bfn_fflush (
/* flush the console output */ /* flush the console output */
n = ase_awk_flushextio (run, ASE_AWK_OUT_CONSOLE, ASE_T("")); n = ase_awk_flushextio (run, ASE_AWK_OUT_CONSOLE, ASE_T(""));
if (n == -1 && if (n == -1 &&
run->errnum != ASE_AWK_EIOHANDLER && run->errnum != ASE_AWK_EIOIMPL &&
run->errnum != ASE_AWK_ENOSUCHIO) run->errnum != ASE_AWK_EIONONE)
{ {
return -1; return -1;
} }
/* fflush() should return -1 on EIOHANDLER and ENOSUCHIO */ /* fflush() should return -1 on EIOIMPL and EIONONE */
} }
else else
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.c,v 1.43 2006-12-19 14:20:30 bacon Exp $ * $Id: jni.c,v 1.44 2007-01-02 12:25:18 bacon Exp $
*/ */
#include <stdio.h> #include <stdio.h>
@ -1013,7 +1013,7 @@ static int __handle_bfn (
* so clear it to prevent it from being thrown */ * so clear it to prevent it from being thrown */
if ((*env)->ExceptionOccurred (env)) if ((*env)->ExceptionOccurred (env))
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
ase_awk_setrunerrnum (run, ASE_AWK_EBFNIMPL); ase_awk_setrunerrnum (run, ASE_AWK_EBFNUSER);
return -1; return -1;
} }
@ -1074,10 +1074,10 @@ static int __handle_bfn (
(*env)->ExceptionDescribe (env); (*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env); (*env)->ExceptionClear (env);
(*env)->DeleteLocalRef (env, args); (*env)->DeleteLocalRef (env, args);
ase_awk_setrunerrnum (run, ASE_AWK_EBFNFAIL); ase_awk_setrunerrnum (run, ASE_AWK_EBFNIMPL);
// TODO: // TODO:
//ase_awk_setrunerror (run, ASE_AWK_EBFNFAIL, "EXCEPTION:...."); //ase_awk_setrunerror (run, ASE_AWK_EBFNIMPL, "EXCEPTION:....");
return -1; return -1;
} }
@ -1195,7 +1195,7 @@ static int __handle_bfn (
else else
{ {
(*env)->DeleteLocalRef (env, ret); (*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerrnum (run, ASE_AWK_EBFNIMPL); ase_awk_setrunerrnum (run, ASE_AWK_EBFNUSER);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: rec.c,v 1.11 2006-12-13 14:16:12 bacon Exp $ * $Id: rec.c,v 1.12 2007-01-02 12:25:18 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -30,7 +30,8 @@ int ase_awk_setrec (
if (ase_awk_str_ncpy (&run->inrec.line, str, len) == (ase_size_t)-1) if (ase_awk_str_ncpy (&run->inrec.line, str, len) == (ase_size_t)-1)
{ {
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -39,7 +40,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);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -53,7 +54,7 @@ int ase_awk_setrec (
{ {
errnum = run->errnum; errnum = run->errnum;
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
run->errnum = errnum; ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -63,7 +64,7 @@ int ase_awk_setrec (
{ {
errnum = run->errnum; errnum = run->errnum;
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
run->errnum = errnum; ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
return -1; return -1;
} }
@ -74,7 +75,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);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -140,7 +141,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);
run->errnum = errnum; ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -169,7 +170,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);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -198,7 +199,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);
run->errnum = errnum; ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -214,7 +215,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);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -231,7 +232,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)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -309,7 +310,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)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -319,7 +321,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)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
if (run->inrec.flds != ASE_NULL) if (run->inrec.flds != ASE_NULL)
@ -347,7 +350,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)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -364,14 +368,16 @@ static int __recomp_record_fields (
if (ase_awk_str_ncat ( if (ase_awk_str_ncat (
&run->inrec.line, str, len) == (ase_size_t)-1) &run->inrec.line, str, len) == (ase_size_t)-1)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
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)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -392,7 +398,8 @@ static int __recomp_record_fields (
if (ase_awk_str_cat ( if (ase_awk_str_cat (
&run->inrec.line, ASE_T("")) == (ase_size_t)-1) &run->inrec.line, ASE_T("")) == (ase_size_t)-1)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -418,7 +425,8 @@ static int __recomp_record_fields (
if (ase_awk_str_ncat (&run->inrec.line, if (ase_awk_str_ncat (&run->inrec.line,
tmp->buf, tmp->len) == (ase_size_t)-1) tmp->buf, tmp->len) == (ase_size_t)-1)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -431,7 +439,7 @@ static int __recomp_record_fields (
v = ase_awk_makeintval (run, (ase_long_t)max); v = ase_awk_makeintval (run, (ase_long_t)max);
if (v == ASE_NULL) if (v == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.315 2007-01-01 15:10:37 bacon Exp $ * $Id: run.c,v 1.316 2007-01-02 12:24:45 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -27,12 +27,6 @@ enum exit_level_t
EXIT_ABORT EXIT_ABORT
}; };
#define PANIC(run,code) \
do { (run)->errnum = (code); return ASE_NULL; } while (0)
#define PANIC_I(run,code) \
do { (run)->errnum = (code); return -1; } while (0)
#define DEFAULT_CONVFMT ASE_T("%.6g") #define DEFAULT_CONVFMT ASE_T("%.6g")
#define DEFAULT_OFMT ASE_T("%.6g") #define DEFAULT_OFMT ASE_T("%.6g")
#define DEFAULT_OFS ASE_T(" ") #define DEFAULT_OFS ASE_T(" ")
@ -279,7 +273,7 @@ static int __set_global (
idx != ASE_AWK_GLOBAL_ARGV) idx != ASE_AWK_GLOBAL_ARGV)
{ {
/* TODO: better error code */ /* TODO: better error code */
run->errnum = ASE_AWK_ESCALARTOMAP; ase_awk_setrunerror (run, ASE_AWK_ESCALARTOMAP, 0, ASE_NULL);
return -1; return -1;
} }
@ -297,7 +291,7 @@ static int __set_global (
if (convfmt_ptr[i] == ASE_T('\0')) if (convfmt_ptr[i] == ASE_T('\0'))
{ {
ASE_AWK_FREE (run->awk, convfmt_ptr); ASE_AWK_FREE (run->awk, convfmt_ptr);
run->errnum = ASE_AWK_ECONVFMTCHAR; ase_awk_setrunerror (run, ASE_AWK_ECONVFMTCHAR, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -397,7 +391,7 @@ static int __set_global (
if (ofmt_ptr[i] == ASE_T('\0')) if (ofmt_ptr[i] == ASE_T('\0'))
{ {
ASE_AWK_FREE (run->awk, ofmt_ptr); ASE_AWK_FREE (run->awk, ofmt_ptr);
run->errnum = ASE_AWK_ECONVFMTCHAR; ase_awk_setrunerror (run, ASE_AWK_ECONVFMTCHAR, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -522,7 +516,7 @@ int ase_awk_setfilename (
tmp = ase_awk_makestrval (run, name, len); tmp = ase_awk_makestrval (run, name, len);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -548,7 +542,7 @@ int ase_awk_setofilename (
tmp = ase_awk_makestrval (run, name, len); tmp = ase_awk_makestrval (run, name, len);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -827,6 +821,8 @@ static int __init_run (
run->fcache_count = 0; run->fcache_count = 0;
run->errnum = ASE_AWK_ENOERR; run->errnum = ASE_AWK_ENOERR;
run->errlin = 0;
run->errmsg[0] = ASE_T('\0');
run->inrec.buf_pos = 0; run->inrec.buf_pos = 0;
run->inrec.buf_len = 0; run->inrec.buf_len = 0;
@ -1050,7 +1046,7 @@ static int __build_runarg (
v_argv = ase_awk_makemapval (run); v_argv = ase_awk_makemapval (run);
if (v_argv == ASE_NULL) if (v_argv == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
ase_awk_refupval (run, v_argv); ase_awk_refupval (run, v_argv);
@ -1064,7 +1060,7 @@ static int __build_runarg (
if (v_tmp == ASE_NULL) if (v_tmp == ASE_NULL)
{ {
ase_awk_refdownval (run, v_argv); ase_awk_refdownval (run, v_argv);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -1088,7 +1084,7 @@ static int __build_runarg (
* map will be freeed when v_argv is freed */ * map will be freeed when v_argv is freed */
ase_awk_refdownval (run, v_argv); ase_awk_refdownval (run, v_argv);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -1098,7 +1094,7 @@ static int __build_runarg (
if (v_argc == ASE_NULL) if (v_argc == ASE_NULL)
{ {
ase_awk_refdownval (run, v_argv); ase_awk_refdownval (run, v_argv);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -1153,7 +1149,7 @@ static int __update_fnr (ase_awk_run_t* run, ase_size_t fnr)
tmp = ase_awk_makeintval (run, fnr); tmp = ase_awk_makeintval (run, fnr);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -1202,7 +1198,7 @@ static int __set_globals_to_default (ase_awk_run_t* run)
tmp = ase_awk_makestrval0 (run, gtab[i].str); tmp = ase_awk_makestrval0 (run, gtab[i].str);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -1255,7 +1251,8 @@ static int __run_main (
* the successful __raw_push. it is ok because * the successful __raw_push. it is ok because
* the values pushed so far are all ase_awk_val_nil */ * the values pushed so far are all ase_awk_val_nil */
run->stack_top = saved_stack_top; run->stack_top = saved_stack_top;
PANIC_I (run, ASE_AWK_ENOMEM); ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
} }
} }
@ -1328,7 +1325,10 @@ static int __run_main (
} }
__cleanup_globals (run); __cleanup_globals (run);
run->stack_top = saved_stack_top; run->stack_top = saved_stack_top;
PANIC_I (run, ASE_AWK_ENOMEM);
ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
} }
tmp->type = ASE_AWK_NDE_STR; tmp->type = ASE_AWK_NDE_STR;
@ -1347,7 +1347,10 @@ static int __run_main (
} }
__cleanup_globals (run); __cleanup_globals (run);
run->stack_top = saved_stack_top; run->stack_top = saved_stack_top;
PANIC_I (run, ASE_AWK_ENOMEM);
ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
} }
tmp->len = runarg[i].len; tmp->len = runarg[i].len;
@ -1388,7 +1391,10 @@ static int __run_main (
/* pops off global variables in a decent way */ /* pops off global variables in a decent way */
__cleanup_globals (run); __cleanup_globals (run);
__raw_pop_times (run, run->awk->tree.nglobals); __raw_pop_times (run, run->awk->tree.nglobals);
PANIC_I (run, ASE_AWK_ENOMEM);
ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
} }
if (__raw_push(run,(void*)saved_stack_top) == -1) if (__raw_push(run,(void*)saved_stack_top) == -1)
@ -1396,7 +1402,10 @@ static int __run_main (
run->stack_top = saved_stack_top; run->stack_top = saved_stack_top;
__cleanup_globals (run); __cleanup_globals (run);
__raw_pop_times (run, run->awk->tree.nglobals); __raw_pop_times (run, run->awk->tree.nglobals);
PANIC_I (run, ASE_AWK_ENOMEM);
ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
} }
/* secure space for a return value */ /* secure space for a return value */
@ -1405,7 +1414,10 @@ static int __run_main (
run->stack_top = saved_stack_top; run->stack_top = saved_stack_top;
__cleanup_globals (run); __cleanup_globals (run);
__raw_pop_times (run, run->awk->tree.nglobals); __raw_pop_times (run, run->awk->tree.nglobals);
PANIC_I (run, ASE_AWK_ENOMEM);
ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
} }
/* secure space for nargs */ /* secure space for nargs */
@ -1414,7 +1426,10 @@ static int __run_main (
run->stack_top = saved_stack_top; run->stack_top = saved_stack_top;
__cleanup_globals (run); __cleanup_globals (run);
__raw_pop_times (run, run->awk->tree.nglobals); __raw_pop_times (run, run->awk->tree.nglobals);
PANIC_I (run, ASE_AWK_ENOMEM);
ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
} }
run->stack_base = saved_stack_top; run->stack_base = saved_stack_top;
@ -1510,8 +1525,7 @@ static int __run_main (
static int __run_pattern_blocks (ase_awk_run_t* run) static int __run_pattern_blocks (ase_awk_run_t* run)
{ {
// ase_ssize_t n; int n;
ase_bool_t need_to_close = ase_false;
run->inrec.buf_pos = 0; run->inrec.buf_pos = 0;
run->inrec.buf_len = 0; run->inrec.buf_len = 0;
@ -1521,65 +1535,21 @@ static int __run_pattern_blocks (ase_awk_run_t* run)
while (run->exit_level != EXIT_GLOBAL && while (run->exit_level != EXIT_GLOBAL &&
run->exit_level != EXIT_ABORT) run->exit_level != EXIT_ABORT)
{ {
int x;
run->exit_level = EXIT_NONE; run->exit_level = EXIT_NONE;
x = __read_record (run); n = __read_record (run);
if (x == -1) if (n == -1) return -1; /* error */
{ if (n == 0) break; /* end of input */
int saved = run->errnum;
/* don't care about the result of input close */
// ase_awk_closeextio_read (
// run, ASE_AWK_IN_CONSOLE, ASE_T(""));
run->errnum = saved;
return -1;
}
need_to_close = ase_true;
if (x == 0) break; /* end of input */
__update_fnr (run, run->global.fnr + 1); __update_fnr (run, run->global.fnr + 1);
if (run->awk->tree.chain != ASE_NULL) if (run->awk->tree.chain != ASE_NULL)
{ {
if (__run_pattern_block_chain ( if (__run_pattern_block_chain (
run, run->awk->tree.chain) == -1) run, run->awk->tree.chain) == -1) return -1;
{
int saved = run->errnum;
// ase_awk_closeextio_read (
// run, ASE_AWK_IN_CONSOLE, ASE_T(""));
run->errnum = saved;
return -1;
}
} }
} }
/* In case of getline, the code would make getline return -1,
* and make this function return 0 after having checked
* if closextio has returned -1 and errnum has been set to
* ASE_AWK_EIOHANDLER. But this part of the code ends the input for
* the implicit pattern-block loop, which is totally different
* from getline. so it returns -1 as long as closeextio returns
* -1 regardless of the value of errnum. */
if (need_to_close)
{
/* TODO: do i have to close exito here...
n = ase_awk_closeextio_read (
run, ASE_AWK_IN_CONSOLE, ASE_T(""));
if (n == -1)
{
if (run->errnum == ASE_AWK_EIOHANDLER)
PANIC_I (run, ASE_AWK_ECINCL);
else return -1;
}
*/
}
return 0; return 0;
} }
@ -1705,7 +1675,7 @@ static int __run_block (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
if (run->depth.max.block > 0 && if (run->depth.max.block > 0 &&
run->depth.cur.block >= run->depth.max.block) run->depth.cur.block >= run->depth.max.block)
{ {
run->errnum = ASE_AWK_ERECUR; ase_awk_setrunerror (run, ASE_AWK_ERECUR, nde->line, ASE_NULL);
return -1;; return -1;;
} }
@ -1738,7 +1708,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
{ {
ase_awk_refdownval (run, run->inrec.d0); ase_awk_refdownval (run, run->inrec.d0);
if (run->errnum == ASE_AWK_EIOHANDLER) if (run->errnum == ASE_AWK_EIOIMPL)
{ {
ase_awk_setrunerror ( ase_awk_setrunerror (
run, ASE_AWK_ECOUTDT, nde->line, ASE_NULL); run, ASE_AWK_ECOUTDT, nde->line, ASE_NULL);
@ -1753,7 +1723,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
{ {
ase_awk_refdownval (run, run->inrec.d0); ase_awk_refdownval (run, run->inrec.d0);
if (run->errnum == ASE_AWK_EIOHANDLER) if (run->errnum == ASE_AWK_EIOIMPL)
{ {
ase_awk_setrunerror ( ase_awk_setrunerror (
run, ASE_AWK_ECOUTDT, nde->line, ASE_NULL); run, ASE_AWK_ECOUTDT, nde->line, ASE_NULL);
@ -2308,8 +2278,9 @@ static int __run_nextinfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
n = ase_awk_nextextio_read (run, ASE_AWK_IN_CONSOLE, ASE_T("")); n = ase_awk_nextextio_read (run, ASE_AWK_IN_CONSOLE, ASE_T(""));
if (n == -1) if (n == -1)
{ {
if (run->errnum == ASE_AWK_EIOHANDLER) if (run->errnum == ASE_AWK_EIOIMPL)
run->errnum = ASE_AWK_ECINNX; run->errnum = ASE_AWK_ECINNX;
ase_awk_setrunerror ( ase_awk_setrunerror (
run, run->errnum, nde->line, ASE_NULL); run, run->errnum, nde->line, ASE_NULL);
return -1; return -1;
@ -2341,8 +2312,9 @@ static int __run_nextoutfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
n = ase_awk_nextextio_write (run, ASE_AWK_OUT_CONSOLE, ASE_T("")); n = ase_awk_nextextio_write (run, ASE_AWK_OUT_CONSOLE, ASE_T(""));
if (n == -1) if (n == -1)
{ {
if (run->errnum == ASE_AWK_EIOHANDLER) if (run->errnum == ASE_AWK_EIOIMPL)
run->errnum = ASE_AWK_ECOUTNX; run->errnum = ASE_AWK_ECOUTNX;
ase_awk_setrunerror ( ase_awk_setrunerror (
run, run->errnum, nde->line, ASE_NULL); run, run->errnum, nde->line, ASE_NULL);
return -1; return -1;
@ -2683,7 +2655,7 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
run, nde->out_type, dst, run, nde->out_type, dst,
ASE_AWK_STR_BUF(&run->inrec.line), ASE_AWK_STR_BUF(&run->inrec.line),
ASE_AWK_STR_LEN(&run->inrec.line)); ASE_AWK_STR_LEN(&run->inrec.line));
if (n < 0 /*&& run->errnum != ASE_AWK_EIOHANDLER*/) if (n < 0 /*&& 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 ( ase_awk_setrunerror (
@ -2713,7 +2685,7 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
run, nde->out_type, dst, run, nde->out_type, dst,
run->global.ofs.ptr, run->global.ofs.ptr,
run->global.ofs.len); run->global.ofs.len);
if (n < 0 /*&& run->errnum != ASE_AWK_EIOHANDLER*/) if (n < 0 /*&& 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 ( ase_awk_setrunerror (
@ -2733,7 +2705,7 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
ase_awk_refupval (run, v); ase_awk_refupval (run, v);
n = ase_awk_writeextio_val (run, nde->out_type, dst, v); n = ase_awk_writeextio_val (run, nde->out_type, dst, v);
if (n < 0 /*&& run->errnum != ASE_AWK_EIOHANDLER*/) if (n < 0 /*&& 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_refdownval (run, v); ase_awk_refdownval (run, v);
@ -2750,7 +2722,7 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
n = ase_awk_writeextio_str ( n = ase_awk_writeextio_str (
run, nde->out_type, dst, run, nde->out_type, dst,
run->global.ors.ptr, run->global.ors.len); run->global.ors.ptr, run->global.ors.len);
if (n < 0 /*&& run->errnum != ASE_AWK_EIOHANDLER*/) if (n < 0 /*&& 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 (run, run->errnum, nde->line, ASE_NULL); ase_awk_setrunerror (run, run->errnum, nde->line, ASE_NULL);
@ -2857,7 +2829,7 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
/* the remaining arguments are ignored as the format cannot /* the remaining arguments are ignored as the format cannot
* contain any % characters */ * contain any % characters */
n = ase_awk_writeextio_val (run, nde->out_type, dst, v); n = ase_awk_writeextio_val (run, nde->out_type, dst, v);
if (n < 0 /*&& run->errnum != ASE_AWK_EIOHANDLER*/) if (n < 0 /*&& 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_refdownval (run, v); ase_awk_refdownval (run, v);
@ -2903,7 +2875,7 @@ static int __formatted_output (
if (ptr == ASE_NULL) return -1; if (ptr == ASE_NULL) return -1;
n = ase_awk_writeextio_str (run, out_type, dst, ptr, len); n = ase_awk_writeextio_str (run, out_type, dst, ptr, len);
if (n < 0 /*&& run->errnum != ASE_AWK_EIOHANDLER*/) return -1; if (n < 0 /*&& run->errnum != ASE_AWK_EIOIMPL*/) return -1;
return 0; return 0;
} }
@ -3280,6 +3252,7 @@ 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 (run, run->errnum, var->line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
ase_awk_refdownval (run, tmp); ase_awk_refdownval (run, tmp);
@ -3363,7 +3336,12 @@ static ase_awk_val_t* __do_assignment_pos (
{ {
str = ase_awk_valtostr ( str = ase_awk_valtostr (
run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len);
if (str == ASE_NULL) return ASE_NULL; if (str == ASE_NULL)
{
ase_awk_setrunerror (
run, run->errnum, pos->line, ASE_NULL);
return ASE_NULL;
}
} }
n = ase_awk_setrec (run, (ase_size_t)lv, str, len); n = ase_awk_setrec (run, (ase_size_t)lv, str, len);
@ -3836,12 +3814,9 @@ static int __cmp_int_str (
} }
} }
str = ase_awk_valtostr (run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); str = ase_awk_valtostr (
if (str == ASE_NULL) run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len);
{ if (str == ASE_NULL) return CMP_ERROR;
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return CMP_ERROR;
}
if (run->global.ignorecase) if (run->global.ignorecase)
{ {
@ -3910,12 +3885,9 @@ static int __cmp_real_str (
return 0; return 0;
} }
str = ase_awk_valtostr (run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len); str = ase_awk_valtostr (
if (str == ASE_NULL) run, left, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &len);
{ if (str == ASE_NULL) return CMP_ERROR;
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return CMP_ERROR;
}
if (run->global.ignorecase) if (run->global.ignorecase)
{ {
@ -5275,7 +5247,7 @@ static ase_awk_val_t* __eval_afn (ase_awk_run_t* run, ase_awk_nde_t* nde)
if (pair == ASE_NULL) if (pair == ASE_NULL)
{ {
ase_awk_setrunerror ( ase_awk_setrunerror (
run, ASE_AWK_ENOSUCHFN, nde->line, ASE_NULL); run, ASE_AWK_EFNNONE, nde->line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6038,13 +6010,15 @@ static ase_awk_val_t* __eval_getline (ase_awk_run_t* run, ase_awk_nde_t* nde)
if (n < 0) if (n < 0)
{ {
if (run->errnum != ASE_AWK_EIOHANDLER) if (run->errnum != ASE_AWK_EIOIMPL)
{ {
ase_awk_str_close (&buf); ase_awk_str_close (&buf);
ase_awk_setrunerror (
run, run->errnum, nde->line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
/* if run->errnum == ASE_AWK_EIOHANDLER, /* if run->errnum == ASE_AWK_EIOIMPL,
* make getline return -1 */ * make getline return -1 */
n = -1; n = -1;
} }
@ -6158,11 +6132,10 @@ static int __read_record (ase_awk_run_t* run)
run, ASE_AWK_IN_CONSOLE, ASE_T(""), &run->inrec.line); run, ASE_AWK_IN_CONSOLE, ASE_T(""), &run->inrec.line);
if (n < 0) if (n < 0)
{ {
int errnum = run->errnum; int saved = run->errnum;
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
run->errnum = if (saved == ASE_AWK_EIOIMPL) saved = ASE_AWK_ECINDT;
(errnum == ASE_AWK_EIOHANDLER)? ase_awk_setrunerror (run, saved, 0, ASE_NULL);
ASE_AWK_ECINDT: errnum;
return -1; return -1;
} }
/* /*
@ -6221,7 +6194,7 @@ static int __shorten_record (ase_awk_run_t* run, ase_size_t nflds)
if (ase_awk_str_open (&tmp, if (ase_awk_str_open (&tmp,
ASE_AWK_STR_LEN(&run->inrec.line), run->awk) == ASE_NULL) ASE_AWK_STR_LEN(&run->inrec.line), run->awk) == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -6232,7 +6205,7 @@ static int __shorten_record (ase_awk_run_t* run, ase_size_t nflds)
if (ofs_free != ASE_NULL) if (ofs_free != ASE_NULL)
ASE_AWK_FREE (run->awk, ofs_free); ASE_AWK_FREE (run->awk, ofs_free);
if (nflds > 1) ase_awk_refdownval (run, v); if (nflds > 1) ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -6243,7 +6216,7 @@ static int __shorten_record (ase_awk_run_t* run, ase_size_t nflds)
if (ofs_free != ASE_NULL) if (ofs_free != ASE_NULL)
ASE_AWK_FREE (run->awk, ofs_free); ASE_AWK_FREE (run->awk, ofs_free);
if (nflds > 1) ase_awk_refdownval (run, v); if (nflds > 1) ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
} }
@ -6255,7 +6228,7 @@ static int __shorten_record (ase_awk_run_t* run, ase_size_t nflds)
run, ASE_AWK_STR_BUF(&tmp), ASE_AWK_STR_LEN(&tmp)); run, ASE_AWK_STR_BUF(&tmp), ASE_AWK_STR_LEN(&tmp));
if (v == ASE_NULL) if (v == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1; return -1;
} }
@ -6296,6 +6269,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 (
run, run->errnum, nde->line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6342,6 +6317,8 @@ static ase_char_t* __idxnde_to_str (
{ {
ase_awk_refdownval (run, idx); ase_awk_refdownval (run, idx);
ase_awk_str_close (&idxstr); ase_awk_str_close (&idxstr);
ase_awk_setrunerror (
run, run->errnum, nde->line, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6370,7 +6347,7 @@ ase_char_t* ase_awk_format (
do { \ do { \
if (ase_awk_str_ccat (out, (c)) == -1) \ if (ase_awk_str_ccat (out, (c)) == -1) \
{ \ { \
run->errnum = ASE_AWK_ENOMEM; \ ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL); \
return ASE_NULL; \ return ASE_NULL; \
} \ } \
} while (0) } while (0)
@ -6379,7 +6356,7 @@ ase_char_t* ase_awk_format (
do { \ do { \
if (ase_awk_str_ccat (fbu, (c)) == -1) \ if (ase_awk_str_ccat (fbu, (c)) == -1) \
{ \ { \
run->errnum = ASE_AWK_ENOMEM; \ ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL); \
return ASE_NULL; \ return ASE_NULL; \
} \ } \
} while (0) } while (0)
@ -6448,7 +6425,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = ase_awk_getarg (run, stack_arg_idx); v = ase_awk_getarg (run, stack_arg_idx);
@ -6459,7 +6436,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = val; v = val;
@ -6498,7 +6475,7 @@ ase_char_t* ase_awk_format (
GROW (&run->format.tmp); GROW (&run->format.tmp);
if (run->format.tmp.ptr == ASE_NULL) if (run->format.tmp.ptr == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6551,7 +6528,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = ase_awk_getarg (run, stack_arg_idx); v = ase_awk_getarg (run, stack_arg_idx);
@ -6562,7 +6539,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = val; v = val;
@ -6601,7 +6578,7 @@ ase_char_t* ase_awk_format (
GROW (&run->format.tmp); GROW (&run->format.tmp);
if (run->format.tmp.ptr == ASE_NULL) if (run->format.tmp.ptr == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6671,7 +6648,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = ase_awk_getarg (run, stack_arg_idx); v = ase_awk_getarg (run, stack_arg_idx);
@ -6682,7 +6659,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = val; v = val;
@ -6723,7 +6700,7 @@ ase_char_t* ase_awk_format (
GROW (&run->format.tmp); GROW (&run->format.tmp);
if (run->format.tmp.ptr == ASE_NULL) if (run->format.tmp.ptr == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6758,7 +6735,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = ase_awk_getarg (run, stack_arg_idx); v = ase_awk_getarg (run, stack_arg_idx);
@ -6769,7 +6746,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = val; v = val;
@ -6801,7 +6778,7 @@ ase_char_t* ase_awk_format (
GROW (&run->format.tmp); GROW (&run->format.tmp);
if (run->format.tmp.ptr == ASE_NULL) if (run->format.tmp.ptr == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6829,7 +6806,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = ase_awk_getarg (run, stack_arg_idx); v = ase_awk_getarg (run, stack_arg_idx);
@ -6840,7 +6817,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = val; v = val;
@ -6881,7 +6858,7 @@ ase_char_t* ase_awk_format (
else else
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_EVALTYPE; ase_awk_setrunerror (run, ASE_AWK_EVALTYPE, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -6895,7 +6872,7 @@ ase_char_t* ase_awk_format (
if (ase_awk_str_ccat (out, ASE_T(' ')) == -1) if (ase_awk_str_ccat (out, ASE_T(' ')) == -1)
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
width--; width--;
@ -6907,7 +6884,7 @@ ase_char_t* ase_awk_format (
if (ase_awk_str_ccat (out, ch) == -1) if (ase_awk_str_ccat (out, ch) == -1)
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
} }
@ -6919,7 +6896,7 @@ ase_char_t* ase_awk_format (
if (ase_awk_str_ccat (out, ASE_T(' ')) == -1) if (ase_awk_str_ccat (out, ASE_T(' ')) == -1)
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
width--; width--;
@ -6938,7 +6915,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = ase_awk_getarg (run, stack_arg_idx); v = ase_awk_getarg (run, stack_arg_idx);
@ -6949,7 +6926,7 @@ ase_char_t* ase_awk_format (
{ {
if (stack_arg_idx >= nargs_on_stack) if (stack_arg_idx >= nargs_on_stack)
{ {
run->errnum = ASE_AWK_EFMTARG; ase_awk_setrunerror (run, ASE_AWK_EFMTARG, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
v = val; v = val;
@ -6977,7 +6954,7 @@ ase_char_t* ase_awk_format (
if (v == val) if (v == val)
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_EFMTCONV; ase_awk_setrunerror (run, ASE_AWK_EFMTCNV, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -7004,7 +6981,7 @@ ase_char_t* ase_awk_format (
if (str_free != ASE_NULL) if (str_free != ASE_NULL)
ASE_AWK_FREE (run->awk, str_free); ASE_AWK_FREE (run->awk, str_free);
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
width--; width--;
@ -7018,7 +6995,7 @@ ase_char_t* ase_awk_format (
if (str_free != ASE_NULL) if (str_free != ASE_NULL)
ASE_AWK_FREE (run->awk, str_free); ASE_AWK_FREE (run->awk, str_free);
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
} }
@ -7032,7 +7009,7 @@ ase_char_t* ase_awk_format (
if (ase_awk_str_ccat (out, ASE_T(' ')) == -1) if (ase_awk_str_ccat (out, ASE_T(' ')) == -1)
{ {
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
width--; width--;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.101 2006-12-24 17:21:24 bacon Exp $ * $Id: val.c,v 1.102 2007-01-02 12:25:18 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -470,7 +470,7 @@ ase_char_t* ase_awk_valtostr (
ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtostr\n"), ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtostr\n"),
v->type); v->type);
run->errnum = ASE_AWK_EVALTYPE; ase_awk_setrunerror (run, ASE_AWK_EVALTYPE, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -484,7 +484,7 @@ static ase_char_t* __str_to_str (
tmp = ase_awk_strxdup (run->awk, str, str_len); tmp = ase_awk_strxdup (run->awk, str, str_len);
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -499,7 +499,7 @@ static ase_char_t* __str_to_str (
n = ase_awk_str_ncat (buf, str, str_len); n = ase_awk_str_ncat (buf, str, str_len);
if (n == (ase_size_t)-1) if (n == (ase_size_t)-1)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -526,7 +526,8 @@ static ase_char_t* __val_int_to_str (
run->awk, 2 * ASE_SIZEOF(ase_char_t)); run->awk, 2 * ASE_SIZEOF(ase_char_t));
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -540,7 +541,8 @@ static ase_char_t* __val_int_to_str (
if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_awk_str_clear (buf); if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_awk_str_clear (buf);
if (ase_awk_str_cat (buf, ASE_T("0")) == (ase_size_t)-1) if (ase_awk_str_cat (buf, ASE_T("0")) == (ase_size_t)-1)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -559,7 +561,7 @@ static ase_char_t* __val_int_to_str (
run->awk, (l + 1) * ASE_SIZEOF(ase_char_t)); run->awk, (l + 1) * ASE_SIZEOF(ase_char_t));
if (tmp == ASE_NULL) if (tmp == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -577,7 +579,7 @@ static ase_char_t* __val_int_to_str (
if (ase_awk_str_nccat ( if (ase_awk_str_nccat (
buf, ASE_T(' '), l) == (ase_size_t)-1) buf, ASE_T(' '), l) == (ase_size_t)-1)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
} }
@ -623,14 +625,14 @@ static ase_char_t* __val_real_to_str (
if (ase_awk_str_open (&out, 256, run->awk) == ASE_NULL) if (ase_awk_str_open (&out, 256, run->awk) == ASE_NULL)
{ {
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
if (ase_awk_str_open (&fbu, 256, run->awk) == ASE_NULL) if (ase_awk_str_open (&fbu, 256, run->awk) == ASE_NULL)
{ {
ase_awk_str_close (&out); ase_awk_str_close (&out);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -657,7 +659,7 @@ static ase_char_t* __val_real_to_str (
{ {
ase_awk_str_close (&fbu); ase_awk_str_close (&fbu);
ase_awk_str_close (&out); ase_awk_str_close (&out);
run->errnum = ASE_AWK_ENOMEM; ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL; return ASE_NULL;
} }
@ -725,7 +727,7 @@ int ase_awk_valtonum (
v->type); v->type);
#endif #endif
run->errnum = ASE_AWK_EVALTYPE; ase_awk_setrunerror (run, ASE_AWK_EVALTYPE, 0, ASE_NULL);
return -1; /* error */ return -1; /* error */
} }