*** empty log message ***

This commit is contained in:
hyung-hwan 2007-03-02 11:14:35 +00:00
parent 3018cf6373
commit cbc0fffeb2
14 changed files with 781 additions and 652 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.193 2007-03-02 10:06:17 bacon Exp $
* $Id: awk.h,v 1.194 2007-03-02 11:14:33 bacon Exp $
*
* {License}
*/
@ -29,7 +29,6 @@ typedef int (*ase_awk_sprintf_t) (
typedef void (*ase_awk_aprintf_t) (void* custom, const ase_char_t* fmt, ...);
typedef void (*ase_awk_dprintf_t) (void* custom, const ase_char_t* fmt, ...);
typedef void (*ase_awk_abort_t) (void* custom);
typedef void (*ase_awk_lock_t) (void* custom);
typedef ase_ssize_t (*ase_awk_io_t) (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
@ -77,10 +76,6 @@ struct ase_awk_prmfns_t
ase_awk_dprintf_t dprintf; /* required in the debug mode */
ase_awk_abort_t abort; /* required in the debug mode */
/* thread lock */
ase_awk_lock_t lock; /* required if multi-threaded */
ase_awk_lock_t unlock; /* required if multi-threaded */
/* user-defined data passed to the functions above */
void* custom_data; /* optional */
} misc;
@ -404,6 +399,10 @@ void ase_awk_geterror (
void ase_awk_seterrnum (ase_awk_t* awk, int errnum);
void ase_awk_seterror (
ase_awk_t* awk, int errnum, ase_size_t errlin,
const ase_cstr_t* errarg, ase_size_t argcnt);
void ase_awk_seterror_old (
ase_awk_t* run, int errnum,
ase_size_t errlin, const ase_char_t* errmsg);
@ -434,7 +433,7 @@ int ase_awk_run (
ase_awk_runios_t* runios, ase_awk_runcbs_t* runcbs,
ase_awk_runarg_t* runarg, void* custom_data);
int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run);
int ase_awk_stop (ase_awk_run_t* run);
/* functions to access internal stack structure */
ase_size_t ase_awk_getnargs (ase_awk_run_t* run);
@ -461,7 +460,12 @@ 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 (
ase_awk_run_t* run, int errnum, ase_size_t errlin,
const ase_cstr_t* errarg, ase_size_t argcnt);
void ase_awk_setrunerror_old (
ase_awk_run_t* run, int errnum,
ase_size_t errlin, const ase_char_t* msg);

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.105 2007-03-02 10:12:40 bacon Exp $
* $Id: awk_i.h,v 1.106 2007-03-02 11:14:33 bacon Exp $
*
* {License}
*/
@ -30,12 +30,6 @@ typedef struct ase_awk_tree_t ase_awk_tree_t;
#pragma warning (disable: 4296)
#endif
/* TODO: remove this */
#ifdef _WIN32
#include <tchar.h>
#define xp_printf _tprintf
#endif
#define ASE_AWK_MAX_GLOBALS 9999
#define ASE_AWK_MAX_LOCALS 9999
#define ASE_AWK_MAX_PARAMS 9999
@ -67,19 +61,6 @@ typedef struct ase_awk_tree_t ase_awk_tree_t;
#define ASE_AWK_TOUPPER(awk,c) ASE_TOUPPER(&(awk)->prmfns.ccls,c)
#define ASE_AWK_TOLOWER(awk,c) ASE_TOLOWER(&(awk)->prmfns.ccls,c)
#define ASE_AWK_LOCK(awk) \
do { \
if ((awk)->prmfns.misc.lock != ASE_NULL) \
(awk)->prmfns.misc.lock ((awk)->prmfns.misc.custom_data); \
} while (0)
#define ASE_AWK_UNLOCK(awk) \
do { \
if ((awk)->prmfns.misc.unlock != ASE_NULL) \
(awk)->prmfns.misc.unlock ((awk)->prmfns.misc.custom_data); \
} while (0)
struct ase_awk_tree_t
{
ase_size_t nglobals; /* total number of globals */

View File

@ -1,66 +1,12 @@
/*
* $Id: err.c,v 1.74 2007-02-23 08:17:49 bacon Exp $
* $Id: err.c,v 1.75 2007-03-02 11:14:33 bacon Exp $
*
* {License}
*/
#include <ase/awk/awk_i.h>
int ase_awk_geterrnum (ase_awk_t* awk)
{
return awk->errnum;
}
ase_size_t ase_awk_geterrlin (ase_awk_t* awk)
{
return awk->errlin;
}
const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk)
{
if (awk->errmsg[0] == ASE_T('\0'))
return ase_awk_geterrstr (awk->errnum);
return awk->errmsg;
}
void ase_awk_geterror (
ase_awk_t* awk, int* errnum,
ase_size_t* errlin, const ase_char_t** errmsg)
{
if (errnum != ASE_NULL) *errnum = awk->errnum;
if (errlin != ASE_NULL) *errlin = awk->errlin;
if (errmsg != ASE_NULL)
{
if (awk->errmsg[0] == ASE_T('\0'))
*errmsg = ase_awk_geterrstr (awk->errnum);
else
*errmsg = awk->errmsg;
}
}
void ase_awk_seterrnum (ase_awk_t* awk, int errnum)
{
awk->errnum = errnum;
awk->errlin = 0;
awk->errmsg[0] = ASE_T('\0');
}
void ase_awk_seterror (
ase_awk_t* awk, int errnum,
ase_size_t errlin, const ase_char_t* errmsg)
{
awk->errnum = errnum;
awk->errlin = errlin;
if (errmsg == ASE_NULL) awk->errmsg[0] = ASE_T('\0');
else if (awk->errmsg != errmsg)
{
ase_strxcpy (
awk->errmsg, ASE_COUNTOF(awk->errmsg), errmsg);
}
}
const ase_char_t* ase_awk_geterrstr (int errnum)
static const ase_char_t* __geterrstr (int errnum)
{
static const ase_char_t* __errstr[] =
{
@ -157,13 +103,13 @@ const ase_char_t* ase_awk_geterrstr (int errnum)
ASE_T("too many arguments"),
ASE_T("no such function"),
ASE_T("variable not indexable"),
ASE_T("variable not deletable"),
ASE_T("variable '%.*s' not deletable"),
ASE_T("value not a map"),
ASE_T("value not referenceable"),
ASE_T("value not assignable"),
ASE_T("an indexed value cannot be assigned a map"),
ASE_T("a positional value cannot be assigned a map"),
ASE_T("cannot change a map to a scalar value"),
ASE_T("map '%.*s' not assignable with a scalar"),
ASE_T("cannot change a scalar value to a map"),
ASE_T("a map is not allowed"),
ASE_T("wrong value type"),
@ -200,3 +146,276 @@ const ase_char_t* ase_awk_geterrstr (int errnum)
return ASE_T("unknown error");
}
const ase_char_t* ase_awk_geterrstr (int errnum)
{
return __geterrstr (errnum);
}
int ase_awk_geterrnum (ase_awk_t* awk)
{
return awk->errnum;
}
ase_size_t ase_awk_geterrlin (ase_awk_t* awk)
{
return awk->errlin;
}
const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk)
{
if (awk->errmsg[0] == ASE_T('\0'))
return ase_awk_geterrstr (awk->errnum);
return awk->errmsg;
}
void ase_awk_geterror (
ase_awk_t* awk, int* errnum,
ase_size_t* errlin, const ase_char_t** errmsg)
{
if (errnum != ASE_NULL) *errnum = awk->errnum;
if (errlin != ASE_NULL) *errlin = awk->errlin;
if (errmsg != ASE_NULL)
{
if (awk->errmsg[0] == ASE_T('\0'))
*errmsg = ase_awk_geterrstr (awk->errnum);
else
*errmsg = awk->errmsg;
}
}
void ase_awk_seterrnum (ase_awk_t* awk, int errnum)
{
awk->errnum = errnum;
awk->errlin = 0;
awk->errmsg[0] = ASE_T('\0');
}
void ase_awk_seterror (
ase_awk_t* awk, int errnum, ase_size_t errlin,
const ase_cstr_t* errarg, ase_size_t argcnt)
{
const ase_char_t* errfmt;
ASE_AWK_ASSERT (awk, argcnt <= 5);
awk->errnum = errnum;
awk->errlin = errlin;
errfmt = __geterrstr (errnum);
switch (argcnt)
{
case 0:
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg,
ASE_COUNTOF(awk->errmsg),
errfmt);
return;
case 1:
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg,
ASE_COUNTOF(awk->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr);
return;
case 2:
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg,
ASE_COUNTOF(awk->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr);
return;
case 3:
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg,
ASE_COUNTOF(awk->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr,
errarg[2].len, errarg[2].ptr);
return;
case 4:
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg,
ASE_COUNTOF(awk->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr,
errarg[2].len, errarg[2].ptr,
errarg[3].len, errarg[3].ptr);
return;
case 5:
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg,
ASE_COUNTOF(awk->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr,
errarg[2].len, errarg[2].ptr,
errarg[3].len, errarg[3].ptr,
errarg[4].len, errarg[4].ptr);
return;
}
}
void ase_awk_seterror_old (
ase_awk_t* awk, int errnum,
ase_size_t errlin, const ase_char_t* errmsg)
{
awk->errnum = errnum;
awk->errlin = errlin;
if (errmsg == ASE_NULL) awk->errmsg[0] = ASE_T('\0');
else if (awk->errmsg != errmsg)
{
ase_strxcpy (
awk->errmsg, ASE_COUNTOF(awk->errmsg), errmsg);
}
}
int ase_awk_getrunerrnum (ase_awk_run_t* run)
{
return run->errnum;
}
ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run)
{
return run->errlin;
}
const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run)
{
if (run->errmsg[0] == ASE_T('\0'))
return ase_awk_geterrstr (run->errnum);
return run->errmsg;
}
void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum)
{
run->errnum = errnum;
run->errlin = 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)
{
if (run->errmsg[0] == ASE_T('\0'))
*errmsg = ase_awk_geterrstr (run->errnum);
else
*errmsg = run->errmsg;
}
}
void ase_awk_setrunerror (
ase_awk_run_t* run, int errnum, ase_size_t errlin,
const ase_cstr_t* errarg, ase_size_t argcnt)
{
const ase_char_t* errfmt;
ASE_AWK_ASSERT (run->awk, argcnt <= 5);
run->errnum = errnum;
run->errlin = errlin;
errfmt = __geterrstr (errnum);
switch (argcnt)
{
case 0:
run->awk->prmfns.misc.sprintf (
run->awk->prmfns.misc.custom_data,
run->errmsg,
ASE_COUNTOF(run->errmsg),
errfmt);
return;
case 1:
run->awk->prmfns.misc.sprintf (
run->awk->prmfns.misc.custom_data,
run->errmsg,
ASE_COUNTOF(run->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr);
return;
case 2:
run->awk->prmfns.misc.sprintf (
run->awk->prmfns.misc.custom_data,
run->errmsg,
ASE_COUNTOF(run->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr);
return;
case 3:
run->awk->prmfns.misc.sprintf (
run->awk->prmfns.misc.custom_data,
run->errmsg,
ASE_COUNTOF(run->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr,
errarg[2].len, errarg[2].ptr);
return;
case 4:
run->awk->prmfns.misc.sprintf (
run->awk->prmfns.misc.custom_data,
run->errmsg,
ASE_COUNTOF(run->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr,
errarg[2].len, errarg[2].ptr,
errarg[3].len, errarg[3].ptr);
return;
case 5:
run->awk->prmfns.misc.sprintf (
run->awk->prmfns.misc.custom_data,
run->errmsg,
ASE_COUNTOF(run->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr,
errarg[1].len, errarg[1].ptr,
errarg[2].len, errarg[2].ptr,
errarg[3].len, errarg[3].ptr,
errarg[4].len, errarg[4].ptr);
return;
}
}
void ase_awk_setrunerror_old (
ase_awk_run_t* run, int errnum,
ase_size_t errlin, const ase_char_t* errmsg)
{
run->errnum = errnum;
run->errlin = errlin;
if (errmsg == ASE_NULL) run->errmsg[0] = ASE_T('\0');
else if (errmsg != run->errmsg)
{
ase_strxcpy (run->errmsg, ASE_COUNTOF(run->errmsg), errmsg);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: extio.c,v 1.72 2007-02-23 08:17:49 bacon Exp $
* $Id: extio.c,v 1.73 2007-03-02 11:14:33 bacon Exp $
*
* {License}
*/
@ -103,7 +103,7 @@ int ase_awk_readextio (
if (handler == ASE_NULL)
{
/* no io handler provided */
ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1;
}
@ -120,7 +120,7 @@ int ase_awk_readextio (
run->awk, ASE_SIZEOF(ase_awk_extio_t));
if (p == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -128,7 +128,7 @@ int ase_awk_readextio (
if (p->name == ASE_NULL)
{
ASE_AWK_FREE (run->awk, p);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -150,7 +150,7 @@ int ase_awk_readextio (
{
ASE_AWK_FREE (run->awk, p->name);
ASE_AWK_FREE (run->awk, p);
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -223,7 +223,7 @@ int ase_awk_readextio (
if (n <= -1)
{
/* handler error. getline should return -1 */
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ret = -1;
break;
}
@ -322,7 +322,7 @@ int ase_awk_readextio (
if (ase_str_ccat (buf, c) == (ase_size_t)-1)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ret = -1;
break;
}
@ -356,7 +356,7 @@ int ase_awk_readextio (
nr = ase_awk_makeintval (run, lv + 1);
if (nr == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ret = -1;
}
else
@ -422,7 +422,7 @@ int ase_awk_writeextio_str (
if (handler == ASE_NULL)
{
/* no io handler provided */
ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1;
}
@ -451,7 +451,7 @@ int ase_awk_writeextio_str (
run->awk, ASE_SIZEOF(ase_awk_extio_t));
if (p == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -459,7 +459,7 @@ int ase_awk_writeextio_str (
if (p->name == ASE_NULL)
{
ASE_AWK_FREE (run->awk, p);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -478,7 +478,7 @@ int ase_awk_writeextio_str (
{
ASE_AWK_FREE (run->awk, p->name);
ASE_AWK_FREE (run->awk, p);
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -517,7 +517,7 @@ int ase_awk_writeextio_str (
if (n <= -1)
{
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -558,7 +558,7 @@ int ase_awk_flushextio (
if (handler == ASE_NULL)
{
/* no io handler provided */
ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1;
}
@ -572,7 +572,7 @@ int ase_awk_flushextio (
if (n <= -1)
{
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -585,7 +585,7 @@ int ase_awk_flushextio (
if (ok) return 0;
/* there is no corresponding extio for name */
ase_awk_setrunerror (run, ASE_AWK_EIONONE, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIONONE, 0, ASE_NULL);
return -1;
}
@ -612,7 +612,7 @@ int ase_awk_nextextio_read (
if (handler == ASE_NULL)
{
/* no io handler provided */
ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1;
}
@ -628,7 +628,7 @@ int ase_awk_nextextio_read (
/* something is totally wrong */
ASE_AWK_ASSERT (run->awk,
!"should never happen - cannot find the relevant extio entry");
ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL);
return -1;
}
@ -641,7 +641,7 @@ int ase_awk_nextextio_read (
n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
if (n <= -1)
{
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -689,7 +689,7 @@ int ase_awk_nextextio_write (
if (handler == ASE_NULL)
{
/* no io handler provided */
ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1;
}
@ -706,7 +706,7 @@ int ase_awk_nextextio_write (
ASE_AWK_ASSERT (run->awk,
!"should never happen - cannot find the relevant extio entry");
ase_awk_setrunerror (run, ASE_AWK_EINTERN, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL);
return -1;
}
@ -719,7 +719,7 @@ int ase_awk_nextextio_write (
n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
if (n <= -1)
{
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -732,7 +732,7 @@ int ase_awk_nextextio_write (
n = handler (ASE_AWK_IO_NEXT, p, ASE_NULL, 0);
if (n <= -1)
{
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -776,7 +776,7 @@ int ase_awk_closeextio_read (
if (handler == ASE_NULL)
{
/* no io handler provided */
ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1;
}
@ -793,7 +793,7 @@ int ase_awk_closeextio_read (
if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
}
@ -811,7 +811,7 @@ int ase_awk_closeextio_read (
}
/* this is not a run-time error */
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -838,7 +838,7 @@ int ase_awk_closeextio_write (
if (handler == ASE_NULL)
{
/* no io handler provided */
ase_awk_setrunerror (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOUSER, 0, ASE_NULL);
return -1;
}
@ -855,7 +855,7 @@ int ase_awk_closeextio_write (
if (handler (ASE_AWK_IO_CLOSE, p, ASE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
}
@ -873,7 +873,7 @@ int ase_awk_closeextio_write (
}
/* this is not a run-time error */
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
@ -895,7 +895,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)
{
/* this is not a run-time error.*/
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}
}
@ -913,7 +913,7 @@ int ase_awk_closeextio (ase_awk_run_t* run, const ase_char_t* name)
}
/* this is not a run-time error */
ase_awk_setrunerror (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EIOIMPL, 0, ASE_NULL);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: func.c,v 1.98 2007-03-02 10:12:40 bacon Exp $
* $Id: func.c,v 1.99 2007-03-02 11:14:33 bacon Exp $
*
* {License}
*/
@ -56,15 +56,15 @@ void* ase_awk_addbfn (
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg, ASE_COUNTOF(awk->errmsg),
ASE_T("'%.*s' added already"), (int)name_len, name);
ase_awk_seterror (awk, ASE_AWK_EEXIST, 0, awk->errmsg);
ASE_T("'%.*s' added already"), name_len, name);
ase_awk_seterror_old (awk, ASE_AWK_EEXIST, 0, awk->errmsg);
return ASE_NULL;
}
p = (ase_awk_bfn_t*) ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_bfn_t));
if (p == ASE_NULL)
{
ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -72,7 +72,7 @@ void* ase_awk_addbfn (
if (p->name.ptr == ASE_NULL)
{
ASE_AWK_FREE (awk, p);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -88,7 +88,7 @@ void* ase_awk_addbfn (
{
ASE_AWK_FREE (awk, p->name.ptr);
ASE_AWK_FREE (awk, p);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
}
@ -123,7 +123,7 @@ int ase_awk_delbfn (ase_awk_t* awk, const ase_char_t* name, ase_size_t name_len)
pp = p;
}
ase_awk_seterror (awk, ASE_AWK_ENOENT, 0, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOENT, 0, ASE_NULL);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: jni.c,v 1.70 2007-02-24 14:31:44 bacon Exp $
* $Id: jni.c,v 1.71 2007-03-02 11:14:34 bacon Exp $
*
* {License}
*/
@ -1375,7 +1375,7 @@ static int __handle_bfn (
jchar* tmp = (jchar*) malloc (ASE_SIZEOF(jchar)*fnl);
if (tmp == NULL)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1393,14 +1393,14 @@ static int __handle_bfn (
{
if (is_debug(awk)) (*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
name_utf = (*env)->GetStringUTFChars (env, name, JNI_FALSE);
if (name_utf == NULL)
{
(*env)->DeleteLocalRef (env, name);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1427,7 +1427,7 @@ static int __handle_bfn (
{
if (is_debug(awk)) (*env)->ExceptionDescribe (env);
(*env)->ExceptionClear (env);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1467,7 +1467,7 @@ static int __handle_bfn (
if (tmp == NULL)
{
(*env)->DeleteLocalRef (env, args);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1494,7 +1494,7 @@ static int __handle_bfn (
(*env)->ExceptionClear (env);
}
(*env)->DeleteLocalRef (env, args);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1529,7 +1529,7 @@ static int __handle_bfn (
if (v == NULL)
{
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1545,7 +1545,7 @@ static int __handle_bfn (
if (v == NULL)
{
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1561,7 +1561,7 @@ static int __handle_bfn (
if (v == NULL)
{
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1576,7 +1576,7 @@ static int __handle_bfn (
if (v == NULL)
{
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1591,7 +1591,7 @@ static int __handle_bfn (
if (v == NULL)
{
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1608,7 +1608,7 @@ static int __handle_bfn (
if (ptr == NULL)
{
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1621,7 +1621,7 @@ static int __handle_bfn (
{
(*env)->ReleaseStringChars (env, ret, ptr);
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}
@ -1638,7 +1638,7 @@ static int __handle_bfn (
{
(*env)->ReleaseStringChars (env, ret, ptr);
(*env)->DeleteLocalRef (env, ret);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, msg_nomem);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, msg_nomem);
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.246 2007-02-24 14:31:44 bacon Exp $
* $Id: parse.c,v 1.247 2007-03-02 11:14:34 bacon Exp $
*
* {License}
*/
@ -264,14 +264,16 @@ static struct __kwent __kwtab[] =
{ ASE_NULL, 0, 0, 0 }
};
struct __bvent
typedef struct global_t global_t;
struct global_t
{
const ase_char_t* name;
ase_size_t name_len;
int valid;
};
static struct __bvent __bvtab[] =
static global_t gtab[] =
{
{ ASE_T("ARGC"), 4, 0 },
{ ASE_T("ARGV"), 4, 0 },
@ -316,7 +318,7 @@ static struct __bvent __bvtab[] =
#define ADD_TOKEN_CHAR(awk,c) \
do { \
if (ase_str_ccat(&(awk)->token.name,(c)) == (ase_size_t)-1) { \
ase_awk_seterror (awk, ASE_AWK_ENOMEM, (awk)->token.line, ASE_NULL); \
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, (awk)->token.line, ASE_NULL); \
return -1; \
} \
} while (0)
@ -327,7 +329,7 @@ static struct __bvent __bvtab[] =
do { \
if (MATCH(awk,TOKEN_EOF)) \
{ \
ase_awk_seterror ( \
ase_awk_seterror_old ( \
awk, ASE_AWK_EENDSRC, \
(awk)->token.prev.line, ASE_NULL); \
} \
@ -339,7 +341,7 @@ static struct __bvent __bvtab[] =
msg, \
ASE_STR_LEN(&(awk)->token.name), \
ASE_STR_BUF(&(awk)->token.name)); \
ase_awk_seterror ( \
ase_awk_seterror_old ( \
awk, code, (awk)->token.line, \
(awk)->errmsg); \
} \
@ -392,6 +394,13 @@ void ase_awk_setmaxdepth (ase_awk_t* awk, int types, ase_size_t depth)
}
}
const ase_char_t* ase_awk_getglobalname (
ase_awk_t* awk, ase_size_t idx, ase_size_t* len)
{
*len = gtab[idx].name_len;
return gtab[idx].name;
}
int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios)
{
int n;
@ -425,7 +434,7 @@ static int __parse (ase_awk_t* awk)
{
/* cannot open the source file.
* it doesn't even have to call CLOSE */
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ESINOP, 0,
ASE_T("cannot open the source input"));
return -1;
@ -489,7 +498,7 @@ exit_parse:
{
/* this is to keep the earlier error above
* that might be more critical than this */
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ESINCL, 0,
ASE_T("cannot close the source input"));
n = -1;
@ -543,7 +552,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk)
{
/* when the blockless pattern is supported
* BEGIN and { should be located on the same line */
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EBLKBEG, awk->token.prev.line,
ASE_T("BEGIN not followed by a left bracket on the same line"));
return ASE_NULL;
@ -551,7 +560,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk)
if (!MATCH(awk,TOKEN_LBRACE))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELBRACE, awk->token.prev.line,
ASE_T("BEGIN not followed by a left bracket"));
return ASE_NULL;
@ -570,7 +579,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk)
{
/* when the blockless pattern is supported
* END and { should be located on the same line */
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EBLKEND, awk->token.prev.line,
ASE_T("END not followed by a left bracket on the same line"));
return ASE_NULL;
@ -578,7 +587,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk)
if (!MATCH(awk,TOKEN_LBRACE))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELBRACE, awk->token.prev.line,
ASE_T("END not followed by a left bracket"));
return ASE_NULL;
@ -662,7 +671,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk)
if (!MATCH(awk,TOKEN_LBRACE))
{
ase_awk_clrpt (awk, ptn);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELBRACE,
(MATCH(awk,TOKEN_EOF)? awk->token.prev.line: awk->token.line),
ASE_T("not a valid start of a block"));
@ -703,7 +712,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
/* cannot find a valid identifier for a function name */
if (MATCH(awk,TOKEN_EOF))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EIDENT, awk->token.prev.line,
ASE_T("function definition without a name"));
}
@ -716,7 +725,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_STR_LEN(&awk->token.name),
ASE_STR_BUF(&awk->token.name));
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EIDENT, awk->token.line,
awk->errmsg);
}
@ -735,7 +744,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_T("built-in function '%.*s' redefined"),
name_len, name);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EBFNRED, awk->token.line,
awk->errmsg);
@ -751,7 +760,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_T("function '%.*s' redefined"),
name_len, name);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EAFNRED, awk->token.line,
awk->errmsg);
@ -772,7 +781,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_T("global variable '%.*s' redefined"),
name_len, name);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EGBLRED, awk->token.line,
awk->errmsg);
@ -784,7 +793,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
name_dup = ase_strxdup (name, name_len, &awk->prmfns.mmgr);
if (name_dup == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, awk->token.line, ASE_NULL);
return ASE_NULL;
}
@ -802,7 +811,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
/* a function name is not followed by a left parenthesis */
ASE_AWK_FREE (awk, name_dup);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELPAREN, awk->token.line,
ASE_T("function name not followed by a left parenthesis"));
return ASE_NULL;
@ -842,13 +851,13 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
if (MATCH(awk,TOKEN_EOF))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSRC, awk->token.prev.line,
ASE_NULL);
}
else if (MATCH(awk,TOKEN_RPAREN))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EIDENT, awk->token.prev.line,
ASE_T("premature end of parameter list"));
}
@ -861,7 +870,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_STR_LEN(&awk->token.name),
ASE_STR_BUF(&awk->token.name));
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EIDENT, awk->token.line,
awk->errmsg);
}
@ -887,7 +896,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_T("conflicting parameter '%.*s' with the function"),
param_len, param);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EDUPPAR, awk->token.line,
awk->errmsg);
@ -915,7 +924,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_T("duplicate parameter '%.*s'"),
param_len, param);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EDUPPAR, awk->token.line,
awk->errmsg);
@ -929,7 +938,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_AWK_FREE (awk, name_dup);
ase_awk_tab_clear (&awk->parse.params);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EPARTM, awk->token.line,
ASE_T("too many parameters in the parameter list"));
@ -943,7 +952,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_AWK_FREE (awk, name_dup);
ase_awk_tab_clear (&awk->parse.params);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, awk->token.line, ASE_NULL);
return ASE_NULL;
@ -992,7 +1001,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
if (MATCH(awk,TOKEN_EOF))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSRC, awk->token.prev.line,
ASE_NULL);
}
@ -1005,7 +1014,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_STR_LEN(&awk->token.name),
ASE_STR_BUF(&awk->token.name));
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELBRACE, awk->token.line,
awk->errmsg);
}
@ -1041,7 +1050,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ASE_AWK_FREE (awk, name_dup);
ase_awk_clrpt (awk, body);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, awk->token.line, ASE_NULL);
return ASE_NULL;
}
@ -1058,7 +1067,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
ase_awk_clrpt (awk, body);
ASE_AWK_FREE (awk, afn);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, awk->token.line, ASE_NULL);
return ASE_NULL;
}
@ -1123,7 +1132,7 @@ static ase_awk_chain_t* __parse_pattern_block (
{
ase_awk_clrpt (awk, nde);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -1194,7 +1203,7 @@ static ase_awk_nde_t* __parse_block (
ase_awk_tab_getsize(&awk->parse.locals) - nlocals);
if (head != ASE_NULL) ase_awk_clrpt (awk, head);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSRC, awk->token.prev.line,
ASE_NULL);
return ASE_NULL;
@ -1242,7 +1251,7 @@ static ase_awk_nde_t* __parse_block (
ase_awk_tab_getsize(&awk->parse.locals)-nlocals);
ase_awk_clrpt (awk, head);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -1288,7 +1297,7 @@ static ase_awk_nde_t* __parse_block_dc (
if (awk->parse.depth.cur.block >= awk->parse.depth.max.block)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ERECUR, awk->token.prev.line,
ASE_T("block nested too deeply"));
return ASE_NULL;
@ -1303,7 +1312,7 @@ static ase_awk_nde_t* __parse_block_dc (
static ase_awk_t* __add_builtin_globals (ase_awk_t* awk)
{
struct __bvent* p = __bvtab;
global_t* p = gtab;
ase_awk_t* tmp;
awk->tree.nbglobals = 0;
@ -1348,7 +1357,7 @@ static ase_awk_t* __add_global (
ASE_T("built-in function '%.*s' redefined"),
len, name);
ase_awk_seterror (awk, ASE_AWK_EBFNRED, line, awk->errmsg);
ase_awk_seterror_old (awk, ASE_AWK_EBFNRED, line, awk->errmsg);
return ASE_NULL;
}
@ -1362,7 +1371,7 @@ static ase_awk_t* __add_global (
ASE_T("function '%.*s' redefined"),
len, name);
ase_awk_seterror (awk, ASE_AWK_EAFNRED, line, awk->errmsg);
ase_awk_seterror_old (awk, ASE_AWK_EAFNRED, line, awk->errmsg);
return ASE_NULL;
}
}
@ -1377,20 +1386,20 @@ static ase_awk_t* __add_global (
ASE_T("duplicate global variable '%.*s'"),
len, name);
ase_awk_seterror (awk, ASE_AWK_EDUPGBL, line, awk->errmsg);
ase_awk_seterror_old (awk, ASE_AWK_EDUPGBL, line, awk->errmsg);
return ASE_NULL;
}
}
if (ase_awk_tab_getsize(&awk->parse.globals) >= ASE_AWK_MAX_GLOBALS)
{
ase_awk_seterror (awk, ASE_AWK_EGBLTM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_EGBLTM, line, ASE_NULL);
return ASE_NULL;
}
if (ase_awk_tab_add (&awk->parse.globals, name, len) == (ase_size_t)-1)
{
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -1405,7 +1414,7 @@ static ase_awk_t* __collect_globals (ase_awk_t* awk)
{
if (MATCH(awk,TOKEN_EOF))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSRC, awk->token.prev.line,
ASE_NULL);
return ASE_NULL;
@ -1419,7 +1428,7 @@ static ase_awk_t* __collect_globals (ase_awk_t* awk)
ASE_STR_LEN(&awk->token.name),
ASE_STR_BUF(&awk->token.name));
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EIDENT, awk->token.line,
awk->errmsg);
return ASE_NULL;
@ -1464,7 +1473,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals)
{
if (MATCH(awk,TOKEN_EOF))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSRC, awk->token.prev.line,
ASE_NULL);
return ASE_NULL;
@ -1478,7 +1487,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals)
ASE_STR_LEN(&awk->token.name),
ASE_STR_BUF(&awk->token.name));
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EIDENT, awk->token.line,
awk->errmsg);
return ASE_NULL;
@ -1501,7 +1510,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals)
ASE_T("built-in function '%.*s' redefined"),
local_len, local);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EBFNRED, awk->token.line,
awk->errmsg);
return ASE_NULL;
@ -1517,7 +1526,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals)
ASE_T("function '%.*s' redefined"),
local_len, local);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EAFNRED, awk->token.line,
awk->errmsg);
return ASE_NULL;
@ -1534,7 +1543,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals)
ASE_T("parameter '%.*s' redefined"),
local_len, local);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EPARRED, awk->token.line,
awk->errmsg);
return ASE_NULL;
@ -1551,14 +1560,14 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals)
ASE_T("duplicate local variable '%.*s'"),
local_len, local);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EDUPLCL, awk->token.line, awk->errmsg);
return ASE_NULL;
}
if (ase_awk_tab_getsize(&awk->parse.locals) >= ASE_AWK_MAX_LOCALS)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELCLTM, awk->token.line, ASE_NULL);
return ASE_NULL;
}
@ -1566,7 +1575,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals)
if (ase_awk_tab_add (
&awk->parse.locals, local, local_len) == (ase_size_t)-1)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, awk->token.line, ASE_NULL);
return ASE_NULL;
}
@ -1602,7 +1611,7 @@ static ase_awk_nde_t* __parse_statement (ase_awk_t* awk, ase_size_t line)
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -1751,13 +1760,13 @@ static ase_awk_nde_t* __parse_statement_nb (ase_awk_t* awk, ase_size_t line)
if (MATCH(awk,TOKEN_EOF))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSRC,
awk->token.prev.line, ASE_NULL);
}
else
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ESCOLON, awk->token.prev.line,
ASE_T("statement not terminated with a semicolon"));
}
@ -1781,7 +1790,7 @@ static ase_awk_nde_t* __parse_expression (ase_awk_t* awk, ase_size_t line)
if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ERECUR, line,
ASE_T("expression nested too deeply"));
return ASE_NULL;
@ -1814,7 +1823,7 @@ static ase_awk_nde_t* __parse_expression0 (ase_awk_t* awk, ase_size_t line)
if (!__is_var(x) && x->type != ASE_AWK_NDE_POS)
{
ase_awk_clrpt (awk, x);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EASSIGN, line,
ASE_T("invalid assignment expression"));
return ASE_NULL;
@ -1841,7 +1850,7 @@ static ase_awk_nde_t* __parse_expression0 (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, x);
ase_awk_clrpt (awk, y);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -1880,13 +1889,13 @@ static ase_awk_nde_t* __parse_basic_expr (ase_awk_t* awk, ase_size_t line)
{
if (MATCH(awk,TOKEN_EOF))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSRC,
awk->token.prev.line, ASE_NULL);
}
else
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ECOLON,
awk->token.line, ASE_NULL);
}
@ -1911,7 +1920,7 @@ static ase_awk_nde_t* __parse_basic_expr (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, n1);
ase_awk_clrpt (awk, n2);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -1977,7 +1986,7 @@ static ase_awk_nde_t* __parse_binary_expr (
ase_awk_clrpt (awk, right);
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2060,7 +2069,7 @@ static ase_awk_nde_t* __parse_in (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, right);
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOTVAR, line2,
ASE_T("right-hand side of the 'in' operator not a variable"));
return ASE_NULL;
@ -2073,7 +2082,7 @@ static ase_awk_nde_t* __parse_in (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, right);
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2177,7 +2186,7 @@ static ase_awk_nde_t* __parse_bitwise_or_with_extio (ase_awk_t* awk, ase_size_t
{
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2200,7 +2209,7 @@ static ase_awk_nde_t* __parse_bitwise_or_with_extio (ase_awk_t* awk, ase_size_t
ase_awk_clrpt (awk, left);
/* TODO: support coprocess */
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EGETLINE, line,
ASE_T("coprocess not supported by getline"));
return ASE_NULL;
@ -2220,7 +2229,7 @@ static ase_awk_nde_t* __parse_bitwise_or_with_extio (ase_awk_t* awk, ase_size_t
ase_awk_clrpt (awk, right);
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2337,7 +2346,7 @@ static ase_awk_nde_t* __parse_concat (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, left);
ase_awk_clrpt (awk, right);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2401,7 +2410,7 @@ static ase_awk_nde_t* __parse_unary (ase_awk_t* awk, ase_size_t line)
if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ERECUR, awk->token.line,
ASE_T("expression nested too deeply"));
return ASE_NULL;
@ -2417,7 +2426,7 @@ static ase_awk_nde_t* __parse_unary (ase_awk_t* awk, ase_size_t line)
{
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2461,7 +2470,7 @@ static ase_awk_nde_t* __parse_unary_exp (ase_awk_t* awk, ase_size_t line)
if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ERECUR, awk->token.line,
ASE_T("expression nested too deeply"));
return ASE_NULL;
@ -2477,7 +2486,7 @@ static ase_awk_nde_t* __parse_unary_exp (ase_awk_t* awk, ase_size_t line)
{
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2520,7 +2529,7 @@ static ase_awk_nde_t* __parse_increment (ase_awk_t* awk, ase_size_t line)
* not allowed */
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELVALUE, line,
ASE_T("both prefix and postfix increment/decrement operator present"));
return ASE_NULL;
@ -2551,7 +2560,7 @@ static ase_awk_nde_t* __parse_increment (ase_awk_t* awk, ase_size_t line)
{
ase_awk_clrpt (awk, left);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2580,7 +2589,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
awk, ASE_SIZEOF(ase_awk_nde_int_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2623,7 +2632,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
awk, ASE_SIZEOF(ase_awk_nde_real_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2666,7 +2675,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
awk, ASE_SIZEOF(ase_awk_nde_str_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2682,7 +2691,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
if (nde->buf == ASE_NULL)
{
ASE_AWK_FREE (awk, nde);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2713,7 +2722,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
awk, ASE_SIZEOF(ase_awk_nde_rex_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2730,7 +2739,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
if (nde->buf == ASE_NULL)
{
ASE_AWK_FREE (awk, nde);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2744,7 +2753,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
ASE_AWK_FREE (awk, nde->buf);
ASE_AWK_FREE (awk, nde);
ase_awk_seterror (
ase_awk_seterror_old (
awk, errnum, line, ASE_NULL);
return ASE_NULL;
}
@ -2774,7 +2783,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
if (nde == ASE_NULL)
{
ase_awk_clrpt (awk, prim);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2869,7 +2878,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
{
ase_awk_clrpt (awk, nde);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2926,7 +2935,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
if (var != ASE_NULL) ase_awk_clrpt (awk, var);
if (in != ASE_NULL) ase_awk_clrpt (awk, in);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -2943,7 +2952,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
}
/* valid expression introducer is expected */
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EEXPRES,
(MATCH(awk,TOKEN_EOF)? awk->token.prev.line: line),
ASE_T("invalid expression"));
@ -2964,7 +2973,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
&awk->prmfns.mmgr);
if (name_dup == ASE_NULL)
{
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
name_len = ASE_STR_LEN(&awk->token.name);
@ -2994,7 +3003,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
ASE_AWK_FREE (awk, name_dup);
ase_awk_seterror (awk, ASE_AWK_ELPAREN, line, awk->errmsg);
ase_awk_seterror_old (awk, ASE_AWK_ELPAREN, line, awk->errmsg);
return ASE_NULL;
}
@ -3030,7 +3039,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
if (nde == ASE_NULL)
{
ASE_AWK_FREE (awk, name_dup);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3108,7 +3117,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
ASE_AWK_FREE (awk, name_dup);
ASE_AWK_FREE (awk, nde);
ase_awk_seterror (awk, ASE_AWK_EUNDEF, line, awk->errmsg);
ase_awk_seterror_old (awk, ASE_AWK_EUNDEF, line, awk->errmsg);
return ASE_NULL;
}
}
@ -3173,7 +3182,7 @@ static ase_awk_nde_t* __parse_hashidx (
if (nde == ASE_NULL)
{
ase_awk_clrpt (awk, idx);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3246,7 +3255,7 @@ static ase_awk_nde_t* __parse_hashidx (
awk->prmfns.misc.custom_data,
awk->errmsg, ASE_COUNTOF(awk->errmsg),
ASE_T("undefined identifier '%.*s'"), name_len, name);
ase_awk_seterror (awk, ASE_AWK_EUNDEF, line, awk->errmsg);
ase_awk_seterror_old (awk, ASE_AWK_EUNDEF, line, awk->errmsg);
return ASE_NULL;
}
@ -3322,7 +3331,7 @@ static ase_awk_nde_t* __parse_fncall (
{
if (head != ASE_NULL) ase_awk_clrpt (awk, head);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3428,7 +3437,7 @@ static ase_awk_nde_t* __parse_if (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, then_part);
ase_awk_clrpt (awk, test);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3489,7 +3498,7 @@ static ase_awk_nde_t* __parse_while (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, body);
ase_awk_clrpt (awk, test);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3564,7 +3573,7 @@ static ase_awk_nde_t* __parse_for (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, init);
ase_awk_clrpt (awk, body);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3672,7 +3681,7 @@ static ase_awk_nde_t* __parse_for (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, incr);
ase_awk_clrpt (awk, body);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3762,7 +3771,7 @@ static ase_awk_nde_t* __parse_dowhile (ase_awk_t* awk, ase_size_t line)
ase_awk_clrpt (awk, body);
ase_awk_clrpt (awk, test);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3783,7 +3792,7 @@ static ase_awk_nde_t* __parse_break (ase_awk_t* awk, ase_size_t line)
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_BREAK);
if (awk->parse.depth.cur.loop <= 0)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EBREAK, line,
ASE_T("break statement outside a loop"));
return ASE_NULL;
@ -3793,7 +3802,7 @@ static ase_awk_nde_t* __parse_break (ase_awk_t* awk, ase_size_t line)
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_break_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3812,7 +3821,7 @@ static ase_awk_nde_t* __parse_continue (ase_awk_t* awk, ase_size_t line)
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_CONTINUE);
if (awk->parse.depth.cur.loop <= 0)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ECONTINUE, line,
ASE_T("continue statement outside a loop"));
return ASE_NULL;
@ -3822,7 +3831,7 @@ static ase_awk_nde_t* __parse_continue (ase_awk_t* awk, ase_size_t line)
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_continue_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3845,7 +3854,7 @@ static ase_awk_nde_t* __parse_return (ase_awk_t* awk, ase_size_t line)
awk, ASE_SIZEOF(ase_awk_nde_return_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3884,7 +3893,7 @@ static ase_awk_nde_t* __parse_exit (ase_awk_t* awk, ase_size_t line)
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_exit_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3920,14 +3929,14 @@ static ase_awk_nde_t* __parse_next (ase_awk_t* awk, ase_size_t line)
if (awk->parse.id.block == PARSE_BEGIN_BLOCK)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENEXT, line,
ASE_T("next statement in BEGIN block"));
return ASE_NULL;
}
if (awk->parse.id.block == PARSE_END_BLOCK)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENEXT, line,
ASE_T("next statement in END block"));
return ASE_NULL;
@ -3937,7 +3946,7 @@ static ase_awk_nde_t* __parse_next (ase_awk_t* awk, ase_size_t line)
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_next_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -3954,14 +3963,14 @@ static ase_awk_nde_t* __parse_nextfile (ase_awk_t* awk, ase_size_t line, int out
if (awk->parse.id.block == PARSE_BEGIN_BLOCK)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENEXTFILE, line,
ASE_T("nextfile statement in BEGIN block"));
return ASE_NULL;
}
if (awk->parse.id.block == PARSE_END_BLOCK)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENEXTFILE, line,
ASE_T("nextfile statement in END block"));
return ASE_NULL;
@ -3971,7 +3980,7 @@ static ase_awk_nde_t* __parse_nextfile (ase_awk_t* awk, ase_size_t line, int out
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_nextfile_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -4006,7 +4015,7 @@ static ase_awk_nde_t* __parse_delete (ase_awk_t* awk, ase_size_t line)
/* a normal identifier is expected */
ase_awk_clrpt (awk, var);
ase_awk_seterror (awk, ASE_AWK_EIDENT, line,
ase_awk_seterror_old (awk, ASE_AWK_EIDENT, line,
ASE_T("'delete' not followed by a normal variable"));
return ASE_NULL;
}
@ -4015,7 +4024,7 @@ static ase_awk_nde_t* __parse_delete (ase_awk_t* awk, ase_size_t line)
awk, ASE_SIZEOF(ase_awk_nde_delete_t));
if (nde == ASE_NULL)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -4155,7 +4164,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 (out != ASE_NULL) ase_awk_clrpt (awk, out);
ase_awk_seterror (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
ase_awk_seterror_old (awk, ASE_AWK_ENOMEM, line, ASE_NULL);
return ASE_NULL;
}
@ -4166,7 +4175,7 @@ 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 (out != ASE_NULL) ase_awk_clrpt (awk, out);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EPRINTFARG, line,
ASE_T("printf not followed by any arguments"));
return ASE_NULL;
@ -4248,7 +4257,7 @@ static int __get_token (ase_awk_t* awk)
/*
else
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELXCHR, awk->token.line,
ASE_T("floating point not followed by any valid digits"));
return -1;
@ -4634,7 +4643,7 @@ static int __get_token (ase_awk_t* awk)
awk->prmfns.misc.custom_data,
awk->errmsg, ASE_COUNTOF(awk->errmsg),
ASE_T("invalid character '%c'"), c);
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELXCHR, awk->token.line, awk->errmsg);
return -1;
}
@ -4781,7 +4790,7 @@ static int __get_string (
if (c == ASE_CHAR_EOF)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDSTR, awk->token.line,
ASE_T("string not closed with a quote"));
return -1;
@ -4942,7 +4951,7 @@ static int __get_char (ase_awk_t* awk)
awk->src.shared.buf, ASE_COUNTOF(awk->src.shared.buf));
if (n <= -1)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ESINRD, 0,
ASE_T("cannot read the source input"));
return -1;
@ -4974,7 +4983,7 @@ static int __unget_char (ase_awk_t* awk, ase_cint_t c)
{
if (awk->src.lex.ungotc_count >= ASE_COUNTOF(awk->src.lex.ungotc))
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ELXUNG, awk->src.lex.line, ASE_NULL);
return -1;
}
@ -5022,7 +5031,7 @@ static int __skip_comment (ase_awk_t* awk)
GET_CHAR_TO (awk, c);
if (c == ASE_CHAR_EOF)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDCMT, awk->src.lex.line,
ASE_T("comment not properly closed"));
return -1;
@ -5033,7 +5042,7 @@ static int __skip_comment (ase_awk_t* awk)
GET_CHAR_TO (awk, c);
if (c == ASE_CHAR_EOF)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_EENDCMT, awk->src.lex.line,
ASE_T("comment not properly closed"));
return -1;
@ -5145,7 +5154,7 @@ static int __deparse (ase_awk_t* awk)
ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0);
if (op <= -1)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ESOUTOP, 0,
ASE_T("cannot open the source output"));
return -1;
@ -5171,7 +5180,7 @@ static int __deparse (ase_awk_t* awk)
#define EXIT_DEPARSE(num) \
do { \
n = -1; \
ase_awk_seterror (awk, num, 0, ASE_NULL); \
ase_awk_seterror_old (awk, num, 0, ASE_NULL); \
goto exit_deparse; \
} while(0)
@ -5320,7 +5329,7 @@ exit_deparse:
{
if (n == 0)
{
ase_awk_seterror (
ase_awk_seterror_old (
awk, ASE_AWK_ESOUTCL, 0,
ASE_T("cannot close the source output"));
n = -1;

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.h,v 1.4 2007-02-03 10:47:41 bacon Exp $
* $Id: parse.h,v 1.5 2007-03-02 11:14:34 bacon Exp $
*
* {License}
*/
@ -19,6 +19,9 @@ int ase_awk_putsrcstr (ase_awk_t* awk, const ase_char_t* str);
int ase_awk_putsrcstrx (
ase_awk_t* awk, const ase_char_t* str, ase_size_t len);
const ase_char_t* ase_awk_getglobalname (
ase_awk_t* awk, ase_size_t idx, ase_size_t* len);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: rec.c,v 1.15 2007-02-23 08:17:49 bacon Exp $
* $Id: rec.c,v 1.16 2007-03-02 11:14:34 bacon Exp $
*
* {License}
*/
@ -32,7 +32,7 @@ int ase_awk_setrec (
if (ase_str_ncpy (&run->inrec.line, str, len) == (ase_size_t)-1)
{
ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -42,7 +42,7 @@ int ase_awk_setrec (
if (v == ASE_NULL)
{
ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -56,7 +56,7 @@ int ase_awk_setrec (
{
errnum = run->errnum;
ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL);
return -1;
}
}
@ -66,7 +66,7 @@ int ase_awk_setrec (
{
errnum = run->errnum;
ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL);
return -1;
}
@ -77,7 +77,7 @@ int ase_awk_setrec (
if (v == ASE_NULL)
{
ase_awk_clrrec (run, ase_false);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -143,7 +143,7 @@ static int __split_record (ase_awk_run_t* run)
{
if (fs_free != ASE_NULL)
ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL);
return -1;
}
}
@ -172,7 +172,7 @@ static int __split_record (ase_awk_run_t* run)
if (tmp == ASE_NULL)
{
if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -201,7 +201,7 @@ static int __split_record (ase_awk_run_t* run)
{
if (fs_free != ASE_NULL)
ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror (run, errnum, 0, ASE_NULL);
ase_awk_setrunerror_old (run, errnum, 0, ASE_NULL);
return -1;
}
}
@ -217,7 +217,7 @@ static int __split_record (ase_awk_run_t* run)
if (run->inrec.flds[run->inrec.nflds].val == ASE_NULL)
{
if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -234,7 +234,7 @@ static int __split_record (ase_awk_run_t* run)
v = ase_awk_makeintval (run, (ase_long_t)nflds);
if (v == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -312,7 +312,7 @@ static int __recomp_record_fields (
ASE_SIZEOF(*run->inrec.flds) * max);
if (tmp == ASE_NULL)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -323,7 +323,7 @@ static int __recomp_record_fields (
run->awk, ASE_SIZEOF(*run->inrec.flds) * max);
if (tmp == ASE_NULL)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -352,7 +352,7 @@ static int __recomp_record_fields (
run->global.ofs.ptr,
run->global.ofs.len) == (ase_size_t)-1)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -370,7 +370,7 @@ static int __recomp_record_fields (
if (ase_str_ncat (
&run->inrec.line, str, len) == (ase_size_t)-1)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -378,7 +378,7 @@ static int __recomp_record_fields (
tmp = ase_awk_makestrval (run, str,len);
if (tmp == ASE_NULL)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -400,7 +400,7 @@ static int __recomp_record_fields (
if (ase_str_cat (
&run->inrec.line, ASE_T("")) == (ase_size_t)-1)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -427,7 +427,7 @@ static int __recomp_record_fields (
if (ase_str_ncat (&run->inrec.line,
tmp->buf, tmp->len) == (ase_size_t)-1)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}
@ -441,7 +441,7 @@ static int __recomp_record_fields (
v = ase_awk_makeintval (run, (ase_long_t)max);
if (v == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return -1;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.112 2007-02-28 11:00:33 bacon Exp $
* $Id: val.c,v 1.113 2007-03-02 11:14:34 bacon Exp $
*
* {License}
*/
@ -481,7 +481,7 @@ ase_char_t* ase_awk_valtostr (
v->type);
#endif
ase_awk_setrunerror (run, ASE_AWK_EVALTYPE, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EVALTYPE, 0, ASE_NULL);
return ASE_NULL;
}
@ -495,7 +495,7 @@ static ase_char_t* __str_to_str (
tmp = ase_strxdup (str, str_len, &run->awk->prmfns.mmgr);
if (tmp == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -510,7 +510,7 @@ static ase_char_t* __str_to_str (
n = ase_str_ncat (buf, str, str_len);
if (n == (ase_size_t)-1)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -537,7 +537,7 @@ static ase_char_t* __val_int_to_str (
run->awk, 2 * ASE_SIZEOF(ase_char_t));
if (tmp == ASE_NULL)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -552,7 +552,7 @@ static ase_char_t* __val_int_to_str (
if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_str_clear (buf);
if (ase_str_cat (buf, ASE_T("0")) == (ase_size_t)-1)
{
ase_awk_setrunerror (
ase_awk_setrunerror_old (
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -572,7 +572,7 @@ static ase_char_t* __val_int_to_str (
run->awk, (l + 1) * ASE_SIZEOF(ase_char_t));
if (tmp == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -590,7 +590,7 @@ static ase_char_t* __val_int_to_str (
if (ase_str_nccat (
buf, ASE_T(' '), l) == (ase_size_t)-1)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
}
@ -636,14 +636,14 @@ static ase_char_t* __val_real_to_str (
if (ase_str_open (&out, 256, &run->awk->prmfns.mmgr) == ASE_NULL)
{
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
if (ase_str_open (&fbu, 256, &run->awk->prmfns.mmgr) == ASE_NULL)
{
ase_str_close (&out);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -670,7 +670,7 @@ static ase_char_t* __val_real_to_str (
{
ase_str_close (&fbu);
ase_str_close (&out);
ase_awk_setrunerror (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
return ASE_NULL;
}
@ -738,7 +738,7 @@ int ase_awk_valtonum (
v->type);
#endif
ase_awk_setrunerror (run, ASE_AWK_EVALTYPE, 0, ASE_NULL);
ase_awk_setrunerror_old (run, ASE_AWK_EVALTYPE, 0, ASE_NULL);
return -1; /* error */
}

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c,v 1.13 2007-02-24 14:32:10 bacon Exp $
* $Id: err.c,v 1.14 2007-03-02 11:14:35 bacon Exp $
*
* {License}
*/

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.179 2007-03-01 14:40:13 bacon Exp $
* $Id: awk.c,v 1.180 2007-03-02 11:14:35 bacon Exp $
*/
#include <ase/awk/awk.h>
@ -646,9 +646,7 @@ static BOOL WINAPI stop_run (DWORD ctrl_type)
static void stop_run (int sig)
{
signal (SIGINT, SIG_IGN);
ase_awk_stop (ase_awk_getrunawk(app_run), app_run);
/*ase_awk_stopall (app_awk); */
/*ase_awk_stopall (ase_awk_getrunawk(app_run)); */
ase_awk_stop (app_run);
signal (SIGINT, stop_run);
}
#endif
@ -862,8 +860,6 @@ static int awk_main (int argc, ase_char_t* argv[])
prmfns.misc.sprintf = custom_awk_sprintf;
prmfns.misc.aprintf = custom_awk_aprintf;
prmfns.misc.dprintf = custom_awk_dprintf;
prmfns.misc.lock = NULL;
prmfns.misc.unlock = NULL;
prmfns.misc.custom_data = NULL;
if ((awk = ase_awk_open(&prmfns, ASE_NULL, &errnum)) == ASE_NULL)

View File

@ -1,5 +1,5 @@
/*
* $Id: types.h,v 1.74 2007-02-24 14:32:44 bacon Exp $
* $Id: types.h,v 1.75 2007-03-02 11:14:33 bacon Exp $
*
* {License}
*/
@ -230,6 +230,7 @@ typedef int ase_mcint_t;
#endif
#endif
typedef struct ase_cstr_t ase_cstr_t;
typedef struct ase_mmgr_t ase_mmgr_t;
typedef struct ase_ccls_t ase_ccls_t;
@ -240,6 +241,12 @@ typedef void (*ase_free_t) (void* custom, void* ptr);
typedef ase_bool_t (*ase_isccls_t) (void* custom, ase_cint_t c);
typedef ase_cint_t (*ase_toccls_t) (void* custom, ase_cint_t c);
struct ase_cstr_t
{
const ase_char_t* ptr;
ase_size_t len;
};
struct ase_mmgr_t
{
ase_malloc_t malloc;