*** empty log message ***
This commit is contained in:
parent
8eab6e3349
commit
6fa4030f96
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.h,v 1.203 2007-03-06 14:16:52 bacon Exp $
|
* $Id: awk.h,v 1.204 2007-03-06 14:51:51 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -26,9 +26,7 @@ typedef ase_real_t (*ase_awk_pow_t) (void* custom, ase_real_t x, ase_real_t y);
|
|||||||
typedef int (*ase_awk_sprintf_t) (
|
typedef int (*ase_awk_sprintf_t) (
|
||||||
void* custom, ase_char_t* buf, ase_size_t size,
|
void* custom, ase_char_t* buf, ase_size_t size,
|
||||||
const ase_char_t* fmt, ...);
|
const ase_char_t* fmt, ...);
|
||||||
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_dprintf_t) (void* custom, const ase_char_t* fmt, ...);
|
||||||
typedef void (*ase_awk_abort_t) (void* custom);
|
|
||||||
|
|
||||||
typedef ase_ssize_t (*ase_awk_io_t) (
|
typedef ase_ssize_t (*ase_awk_io_t) (
|
||||||
int cmd, void* arg, ase_char_t* data, ase_size_t count);
|
int cmd, void* arg, ase_char_t* data, ase_size_t count);
|
||||||
@ -72,9 +70,7 @@ struct ase_awk_prmfns_t
|
|||||||
/* utilities */
|
/* utilities */
|
||||||
ase_awk_pow_t pow; /* required */
|
ase_awk_pow_t pow; /* required */
|
||||||
ase_awk_sprintf_t sprintf; /* required */
|
ase_awk_sprintf_t sprintf; /* required */
|
||||||
ase_awk_aprintf_t aprintf; /* required in the debug mode */
|
|
||||||
ase_awk_dprintf_t dprintf; /* required in the debug mode */
|
ase_awk_dprintf_t dprintf; /* required in the debug mode */
|
||||||
ase_awk_abort_t abort; /* required in the debug mode */
|
|
||||||
|
|
||||||
/* user-defined data passed to the functions above */
|
/* user-defined data passed to the functions above */
|
||||||
void* custom_data; /* optional */
|
void* custom_data; /* optional */
|
||||||
@ -376,17 +372,6 @@ enum
|
|||||||
ASE_AWK_EXTIO_CONSOLE_WRITE = 1
|
ASE_AWK_EXTIO_CONSOLE_WRITE = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
/* assertion statement */
|
|
||||||
#ifdef NDEBUG
|
|
||||||
#define ASE_AWK_ASSERT(awk,expr) ((void)0)
|
|
||||||
#define ASE_AWK_ASSERTX(awk,expr,desc) ((void)0)
|
|
||||||
#else
|
|
||||||
#define ASE_AWK_ASSERT(awk,expr) (void)((expr) || \
|
|
||||||
(ase_awk_assertfail (awk, ASE_T(#expr), ASE_NULL, ASE_T(__FILE__), __LINE__), 0))
|
|
||||||
#define ASE_AWK_ASSERTX(awk,expr,desc) (void)((expr) || \
|
|
||||||
(ase_awk_assertfail (awk, ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -511,12 +496,6 @@ ase_size_t ase_awk_longtostr (
|
|||||||
ase_long_t value, int radix, const ase_char_t* prefix,
|
ase_long_t value, int radix, const ase_char_t* prefix,
|
||||||
ase_char_t* buf, ase_size_t size);
|
ase_char_t* buf, ase_size_t size);
|
||||||
|
|
||||||
/* abort function for assertion. use ASE_AWK_ASSERT instead */
|
|
||||||
int ase_awk_assertfail (ase_awk_t* awk,
|
|
||||||
const ase_char_t* expr, const ase_char_t* desc,
|
|
||||||
const ase_char_t* file, int line);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: err.c,v 1.86 2007-03-06 13:19:28 bacon Exp $
|
* $Id: err.c,v 1.87 2007-03-06 14:51:51 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -213,7 +213,7 @@ void ase_awk_seterror (
|
|||||||
const ase_char_t* errfmt;
|
const ase_char_t* errfmt;
|
||||||
ase_size_t fmtlen;
|
ase_size_t fmtlen;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, argcnt <= 5);
|
ASE_ASSERT (argcnt <= 5);
|
||||||
|
|
||||||
awk->errnum = errnum;
|
awk->errnum = errnum;
|
||||||
awk->errlin = errlin;
|
awk->errlin = errlin;
|
||||||
@ -370,7 +370,7 @@ void ase_awk_setrunerror (
|
|||||||
const ase_char_t* errfmt;
|
const ase_char_t* errfmt;
|
||||||
ase_size_t fmtlen;
|
ase_size_t fmtlen;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, argcnt <= 5);
|
ASE_ASSERT (argcnt <= 5);
|
||||||
|
|
||||||
run->errnum = errnum;
|
run->errnum = errnum;
|
||||||
run->errlin = errlin;
|
run->errlin = errlin;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: extio.c,v 1.73 2007-03-02 11:14:33 bacon Exp $
|
* $Id: extio.c,v 1.74 2007-03-06 14:51:52 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -87,12 +87,9 @@ int ase_awk_readextio (
|
|||||||
ase_size_t line_len = 0;
|
ase_size_t line_len = 0;
|
||||||
ase_char_t c = ASE_T('\0'), pc;
|
ase_char_t c = ASE_T('\0'), pc;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_type_map));
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_type_map));
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_mode_map));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_mask_map));
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_mode_map));
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_mask_map));
|
|
||||||
|
|
||||||
/* translate the in_type into the relevant extio type and mode */
|
/* translate the in_type into the relevant extio type and mode */
|
||||||
extio_type = __in_type_map[in_type];
|
extio_type = __in_type_map[in_type];
|
||||||
@ -294,7 +291,7 @@ int ase_awk_readextio (
|
|||||||
const ase_char_t* match_ptr;
|
const ase_char_t* match_ptr;
|
||||||
ase_size_t match_len;
|
ase_size_t match_len;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, run->global.rs != ASE_NULL);
|
ASE_ASSERT (run->global.rs != ASE_NULL);
|
||||||
|
|
||||||
n = ase_awk_matchrex (
|
n = ase_awk_matchrex (
|
||||||
run->awk, run->global.rs,
|
run->awk, run->global.rs,
|
||||||
@ -311,7 +308,7 @@ int ase_awk_readextio (
|
|||||||
{
|
{
|
||||||
/* the match should be found at the end of
|
/* the match should be found at the end of
|
||||||
* the current buffer */
|
* the current buffer */
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
ASE_STR_BUF(buf) + ASE_STR_LEN(buf) ==
|
ASE_STR_BUF(buf) + ASE_STR_LEN(buf) ==
|
||||||
match_ptr + match_len);
|
match_ptr + match_len);
|
||||||
|
|
||||||
@ -406,12 +403,9 @@ int ase_awk_writeextio_str (
|
|||||||
ase_awk_io_t handler;
|
ase_awk_io_t handler;
|
||||||
int extio_type, extio_mode, extio_mask, n;
|
int extio_type, extio_mode, extio_mask, n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
|
||||||
|
|
||||||
/* translate the out_type into the relevant extio type and mode */
|
/* translate the out_type into the relevant extio type and mode */
|
||||||
extio_type = __out_type_map[out_type];
|
extio_type = __out_type_map[out_type];
|
||||||
@ -542,12 +536,9 @@ int ase_awk_flushextio (
|
|||||||
int extio_type, /*extio_mode,*/ extio_mask, n;
|
int extio_type, /*extio_mode,*/ extio_mask, n;
|
||||||
ase_bool_t ok = ase_false;
|
ase_bool_t ok = ase_false;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
|
||||||
|
|
||||||
/* translate the out_type into the relevant extio type and mode */
|
/* translate the out_type into the relevant extio type and mode */
|
||||||
extio_type = __out_type_map[out_type];
|
extio_type = __out_type_map[out_type];
|
||||||
@ -596,12 +587,9 @@ int ase_awk_nextextio_read (
|
|||||||
ase_awk_io_t handler;
|
ase_awk_io_t handler;
|
||||||
int extio_type, /*extio_mode,*/ extio_mask, n;
|
int extio_type, /*extio_mode,*/ extio_mask, n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_type_map));
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_type_map));
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_mode_map));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_mask_map));
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_mode_map));
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_mask_map));
|
|
||||||
|
|
||||||
/* translate the in_type into the relevant extio type and mode */
|
/* translate the in_type into the relevant extio type and mode */
|
||||||
extio_type = __in_type_map[in_type];
|
extio_type = __in_type_map[in_type];
|
||||||
@ -626,7 +614,7 @@ int ase_awk_nextextio_read (
|
|||||||
if (p == ASE_NULL)
|
if (p == ASE_NULL)
|
||||||
{
|
{
|
||||||
/* something is totally wrong */
|
/* something is totally wrong */
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
!"should never happen - cannot find the relevant extio entry");
|
!"should never happen - cannot find the relevant extio entry");
|
||||||
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL);
|
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
@ -673,12 +661,9 @@ int ase_awk_nextextio_write (
|
|||||||
ase_awk_io_t handler;
|
ase_awk_io_t handler;
|
||||||
int extio_type, /*extio_mode,*/ extio_mask, n;
|
int extio_type, /*extio_mode,*/ extio_mask, n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
|
||||||
|
|
||||||
/* translate the out_type into the relevant extio type and mode */
|
/* translate the out_type into the relevant extio type and mode */
|
||||||
extio_type = __out_type_map[out_type];
|
extio_type = __out_type_map[out_type];
|
||||||
@ -703,8 +688,7 @@ int ase_awk_nextextio_write (
|
|||||||
if (p == ASE_NULL)
|
if (p == ASE_NULL)
|
||||||
{
|
{
|
||||||
/* something is totally wrong */
|
/* something is totally wrong */
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (!"should never happen - cannot find the relevant extio entry");
|
||||||
!"should never happen - cannot find the relevant extio entry");
|
|
||||||
|
|
||||||
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL);
|
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, 0, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
@ -760,12 +744,9 @@ int ase_awk_closeextio_read (
|
|||||||
ase_awk_io_t handler;
|
ase_awk_io_t handler;
|
||||||
int extio_type, /*extio_mode,*/ extio_mask;
|
int extio_type, /*extio_mode,*/ extio_mask;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_type_map));
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_type_map));
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_mode_map));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (in_type >= 0 && in_type <= ASE_COUNTOF(__in_mask_map));
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_mode_map));
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
|
||||||
in_type >= 0 && in_type <= ASE_COUNTOF(__in_mask_map));
|
|
||||||
|
|
||||||
/* translate the in_type into the relevant extio type and mode */
|
/* translate the in_type into the relevant extio type and mode */
|
||||||
extio_type = __in_type_map[in_type];
|
extio_type = __in_type_map[in_type];
|
||||||
@ -822,12 +803,9 @@ int ase_awk_closeextio_write (
|
|||||||
ase_awk_io_t handler;
|
ase_awk_io_t handler;
|
||||||
int extio_type, /*extio_mode,*/ extio_mask;
|
int extio_type, /*extio_mode,*/ extio_mask;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_type_map));
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mode_map));
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
|
||||||
out_type >= 0 && out_type <= ASE_COUNTOF(__out_mask_map));
|
|
||||||
|
|
||||||
/* translate the out_type into the relevant extio type and mode */
|
/* translate the out_type into the relevant extio type and mode */
|
||||||
extio_type = __out_type_map[out_type];
|
extio_type = __out_type_map[out_type];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: func.c,v 1.99 2007-03-02 11:14:33 bacon Exp $
|
* $Id: func.c,v 1.100 2007-03-06 14:51:52 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -182,11 +182,11 @@ static int __bfn_close (
|
|||||||
ase_size_t len;
|
ase_size_t len;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 1);
|
ASE_ASSERT (nargs == 1);
|
||||||
/* TODO: support close (xxx, "to"/"from") like gawk */
|
/* TODO: support close (xxx, "to"/"from") like gawk */
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
ASE_AWK_ASSERT (run->awk, a0 != ASE_NULL);
|
ASE_ASSERT (a0 != ASE_NULL);
|
||||||
|
|
||||||
if (a0->type == ASE_AWK_VAL_STR)
|
if (a0->type == ASE_AWK_VAL_STR)
|
||||||
{
|
{
|
||||||
@ -283,7 +283,7 @@ static int __bfn_fflush (
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 0 || nargs == 1);
|
ASE_ASSERT (nargs == 0 || nargs == 1);
|
||||||
|
|
||||||
if (nargs == 0)
|
if (nargs == 0)
|
||||||
{
|
{
|
||||||
@ -377,7 +377,7 @@ static int __bfn_index (
|
|||||||
ase_long_t idx;
|
ase_long_t idx;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 2);
|
ASE_ASSERT (nargs == 2);
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
a1 = ase_awk_getarg (run, 1);
|
a1 = ase_awk_getarg (run, 1);
|
||||||
@ -439,7 +439,7 @@ static int __bfn_length (
|
|||||||
ase_size_t len;
|
ase_size_t len;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 1);
|
ASE_ASSERT (nargs == 1);
|
||||||
|
|
||||||
v = ase_awk_getarg (run, 0);
|
v = ase_awk_getarg (run, 0);
|
||||||
if (v->type == ASE_AWK_VAL_STR)
|
if (v->type == ASE_AWK_VAL_STR)
|
||||||
@ -477,7 +477,7 @@ static int __bfn_substr (
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs >= 2 && nargs <= 3);
|
ASE_ASSERT (nargs >= 2 && nargs <= 3);
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
a1 = ase_awk_getarg (run, 1);
|
a1 = ase_awk_getarg (run, 1);
|
||||||
@ -553,13 +553,13 @@ static int __bfn_split (
|
|||||||
int errnum;
|
int errnum;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs >= 2 && nargs <= 3);
|
ASE_ASSERT (nargs >= 2 && nargs <= 3);
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
a1 = ase_awk_getarg (run, 1);
|
a1 = ase_awk_getarg (run, 1);
|
||||||
a2 = (nargs >= 3)? ase_awk_getarg (run, 2): ASE_NULL;
|
a2 = (nargs >= 3)? ase_awk_getarg (run, 2): ASE_NULL;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, a1->type == ASE_AWK_VAL_REF);
|
ASE_ASSERT (a1->type == ASE_AWK_VAL_REF);
|
||||||
|
|
||||||
if (((ase_awk_val_ref_t*)a1)->id >= ASE_AWK_VAL_REF_NAMEDIDX &&
|
if (((ase_awk_val_ref_t*)a1)->id >= ASE_AWK_VAL_REF_NAMEDIDX &&
|
||||||
((ase_awk_val_ref_t*)a1)->id <= ASE_AWK_VAL_REF_ARGIDX)
|
((ase_awk_val_ref_t*)a1)->id <= ASE_AWK_VAL_REF_ARGIDX)
|
||||||
@ -723,7 +723,7 @@ static int __bfn_split (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
(tok != ASE_NULL && tok_len > 0) || tok_len == 0);
|
(tok != ASE_NULL && tok_len > 0) || tok_len == 0);
|
||||||
|
|
||||||
/* create the field string */
|
/* create the field string */
|
||||||
@ -743,7 +743,7 @@ static int __bfn_split (
|
|||||||
/* put it into the map */
|
/* put it into the map */
|
||||||
key_len = ase_awk_longtostr (
|
key_len = ase_awk_longtostr (
|
||||||
num, 10, ASE_NULL, key, ASE_COUNTOF(key));
|
num, 10, ASE_NULL, key, ASE_COUNTOF(key));
|
||||||
ASE_AWK_ASSERT (run->awk, key_len != (ase_size_t)-1);
|
ASE_ASSERT (key_len != (ase_size_t)-1);
|
||||||
|
|
||||||
/* don't forget to update the reference count when you
|
/* don't forget to update the reference count when you
|
||||||
* handle the assignment-like situation. anyway, it is
|
* handle the assignment-like situation. anyway, it is
|
||||||
@ -797,7 +797,7 @@ static int __bfn_tolower (
|
|||||||
ase_awk_val_t* a0, * r;
|
ase_awk_val_t* a0, * r;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 1);
|
ASE_ASSERT (nargs == 1);
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
|
|
||||||
@ -837,7 +837,7 @@ static int __bfn_toupper (
|
|||||||
ase_awk_val_t* a0, * r;
|
ase_awk_val_t* a0, * r;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 1);
|
ASE_ASSERT (nargs == 1);
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
|
|
||||||
@ -885,13 +885,13 @@ static int __substitute (ase_awk_run_t* run, ase_long_t max_count)
|
|||||||
ase_long_t sub_count;
|
ase_long_t sub_count;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs >= 2 && nargs <= 3);
|
ASE_ASSERT (nargs >= 2 && nargs <= 3);
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
a1 = ase_awk_getarg (run, 1);
|
a1 = ase_awk_getarg (run, 1);
|
||||||
a2 = (nargs >= 3)? ase_awk_getarg (run, 2): ASE_NULL;
|
a2 = (nargs >= 3)? ase_awk_getarg (run, 2): ASE_NULL;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, a2 == ASE_NULL || a2->type == ASE_AWK_VAL_REF);
|
ASE_ASSERT (a2 == ASE_NULL || a2->type == ASE_AWK_VAL_REF);
|
||||||
|
|
||||||
#define FREE_A_PTRS(awk) \
|
#define FREE_A_PTRS(awk) \
|
||||||
do { \
|
do { \
|
||||||
@ -1184,7 +1184,7 @@ static int __bfn_match (
|
|||||||
ase_size_t mat_len;
|
ase_size_t mat_len;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 2);
|
ASE_ASSERT (nargs == 2);
|
||||||
|
|
||||||
a0 = ase_awk_getarg (run, 0);
|
a0 = ase_awk_getarg (run, 0);
|
||||||
a1 = ase_awk_getarg (run, 1);
|
a1 = ase_awk_getarg (run, 1);
|
||||||
@ -1299,7 +1299,7 @@ static int __bfn_sprintf (
|
|||||||
ase_str_t out, fbu;
|
ase_str_t out, fbu;
|
||||||
|
|
||||||
nargs = ase_awk_getnargs (run);
|
nargs = ase_awk_getnargs (run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs > 0);
|
ASE_ASSERT (nargs > 0);
|
||||||
|
|
||||||
if (ase_str_open (&out, 256, &run->awk->prmfns.mmgr) == ASE_NULL)
|
if (ase_str_open (&out, 256, &run->awk->prmfns.mmgr) == ASE_NULL)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: jni.c,v 1.71 2007-03-02 11:14:34 bacon Exp $
|
* $Id: jni.c,v 1.72 2007-03-06 14:51:52 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -116,11 +116,6 @@ static ase_real_t awk_pow (void* custom, ase_real_t x, ase_real_t y)
|
|||||||
return pow (x, y);
|
return pow (x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void awk_abort (void* custom)
|
|
||||||
{
|
|
||||||
abort ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static int awk_sprintf (
|
static int awk_sprintf (
|
||||||
void* custom, ase_char_t* buf, ase_size_t size,
|
void* custom, ase_char_t* buf, ase_size_t size,
|
||||||
const ase_char_t* fmt, ...)
|
const ase_char_t* fmt, ...)
|
||||||
@ -135,14 +130,6 @@ static int awk_sprintf (
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void awk_printf (void* custom, const ase_char_t* fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start (ap, fmt);
|
|
||||||
ase_vfprintf (stdout, fmt, ap);
|
|
||||||
va_end (ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void awk_dprintf (void* custom, const ase_char_t* fmt, ...)
|
static void awk_dprintf (void* custom, const ase_char_t* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -151,6 +138,21 @@ static void awk_dprintf (void* custom, const ase_char_t* fmt, ...)
|
|||||||
va_end (ap);
|
va_end (ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void ase_assert_abort (void)
|
||||||
|
{
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ase_assert_printf (const ase_char_t* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
va_start (ap, fmt);
|
||||||
|
ase_vfprintf (stdout, fmt, ap);
|
||||||
|
va_end (ap);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void throw_exception (
|
static void throw_exception (
|
||||||
JNIEnv* env, const ase_char_t* msg, jint code, jint line)
|
JNIEnv* env, const ase_char_t* msg, jint code, jint line)
|
||||||
{
|
{
|
||||||
@ -268,9 +270,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
|
|||||||
|
|
||||||
prmfns.misc.pow = awk_pow;
|
prmfns.misc.pow = awk_pow;
|
||||||
prmfns.misc.sprintf = awk_sprintf;
|
prmfns.misc.sprintf = awk_sprintf;
|
||||||
prmfns.misc.aprintf = awk_printf;
|
|
||||||
prmfns.misc.dprintf = awk_dprintf;
|
prmfns.misc.dprintf = awk_dprintf;
|
||||||
prmfns.misc.abort = awk_abort;
|
|
||||||
prmfns.misc.custom_data = NULL;
|
prmfns.misc.custom_data = NULL;
|
||||||
|
|
||||||
awk_data = (awk_data_t*) malloc (sizeof(awk_data_t));
|
awk_data = (awk_data_t*) malloc (sizeof(awk_data_t));
|
||||||
@ -466,13 +466,13 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jstring m
|
|||||||
run_data.double_class = (*env)->FindClass (env, "java/lang/Double");
|
run_data.double_class = (*env)->FindClass (env, "java/lang/Double");
|
||||||
run_data.object_class = (*env)->FindClass (env, "java/lang/Object");
|
run_data.object_class = (*env)->FindClass (env, "java/lang/Object");
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, run_data.string_class != NULL);
|
ASE_ASSERT (run_data.string_class != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.integer_class != NULL);
|
ASE_ASSERT (run_data.integer_class != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.short_class != NULL);
|
ASE_ASSERT (run_data.short_class != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.long_class != NULL);
|
ASE_ASSERT (run_data.long_class != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.float_class != NULL);
|
ASE_ASSERT (run_data.float_class != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.double_class != NULL);
|
ASE_ASSERT (run_data.double_class != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.object_class != NULL);
|
ASE_ASSERT (run_data.object_class != NULL);
|
||||||
|
|
||||||
run_data.integer_init = (*env)->GetMethodID (
|
run_data.integer_init = (*env)->GetMethodID (
|
||||||
env, run_data.integer_class, "<init>", "(I)V");
|
env, run_data.integer_class, "<init>", "(I)V");
|
||||||
@ -485,11 +485,11 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jstring m
|
|||||||
run_data.double_init = (*env)->GetMethodID (
|
run_data.double_init = (*env)->GetMethodID (
|
||||||
env, run_data.double_class, "<init>", "(D)V");
|
env, run_data.double_class, "<init>", "(D)V");
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, run_data.integer_init != NULL);
|
ASE_ASSERT (run_data.integer_init != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.long_init != NULL);
|
ASE_ASSERT (run_data.long_init != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.short_init != NULL);
|
ASE_ASSERT (run_data.short_init != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.float_init != NULL);
|
ASE_ASSERT (run_data.float_init != NULL);
|
||||||
ASE_AWK_ASSERT (awk, run_data.double_init != NULL);
|
ASE_ASSERT (run_data.double_init != NULL);
|
||||||
|
|
||||||
run_data.integer_value = (*env)->GetMethodID (
|
run_data.integer_value = (*env)->GetMethodID (
|
||||||
env, run_data.integer_class, "intValue", "()I");
|
env, run_data.integer_class, "intValue", "()I");
|
||||||
@ -502,15 +502,15 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj, jstring m
|
|||||||
run_data.double_value = (*env)->GetMethodID (
|
run_data.double_value = (*env)->GetMethodID (
|
||||||
env, run_data.double_class, "doubleValue", "()D");
|
env, run_data.double_class, "doubleValue", "()D");
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (awk, run_data.integer_value != NULL,
|
ASE_ASSERTX (run_data.integer_value != NULL,
|
||||||
"The Integer class must has the method - int intValue()");
|
"The Integer class must has the method - int intValue()");
|
||||||
ASE_AWK_ASSERTX (awk, run_data.long_value != NULL,
|
ASE_ASSERTX (run_data.long_value != NULL,
|
||||||
"The Long class must has the method - long longValue()");
|
"The Long class must has the method - long longValue()");
|
||||||
ASE_AWK_ASSERTX (awk, run_data.short_value != NULL,
|
ASE_ASSERTX (run_data.short_value != NULL,
|
||||||
"The Short class must has the method - short shortValue()");
|
"The Short class must has the method - short shortValue()");
|
||||||
ASE_AWK_ASSERTX (awk, run_data.float_value != NULL,
|
ASE_ASSERTX (run_data.float_value != NULL,
|
||||||
"The Float class must has the method - float floatValue()");
|
"The Float class must has the method - float floatValue()");
|
||||||
ASE_AWK_ASSERTX (awk, run_data.double_value != NULL,
|
ASE_ASSERTX (run_data.double_value != NULL,
|
||||||
"The Double class must has the method - double doubleValue()");
|
"The Double class must has the method - double doubleValue()");
|
||||||
|
|
||||||
runio_data.env = env;
|
runio_data.env = env;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: map.c,v 1.36 2007-02-23 08:17:49 bacon Exp $
|
* $Id: map.c,v 1.37 2007-03-06 14:51:52 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -23,9 +23,7 @@ ase_awk_map_t* ase_awk_map_open (
|
|||||||
ase_awk_map_t* map, void* owner, ase_size_t capa,
|
ase_awk_map_t* map, void* owner, ase_size_t capa,
|
||||||
void(*freeval)(void*,void*), ase_awk_t* awk)
|
void(*freeval)(void*,void*), ase_awk_t* awk)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERTX (awk, capa > 0,
|
ASE_ASSERTX (capa > 0, "the initial capacity should be greater than 0");
|
||||||
"the capacity of a map should be greater than 0");
|
|
||||||
|
|
||||||
|
|
||||||
if (map == ASE_NULL)
|
if (map == ASE_NULL)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: misc.c,v 1.52 2007-02-24 14:31:44 bacon Exp $
|
* $Id: misc.c,v 1.53 2007-03-06 14:51:52 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -26,7 +26,7 @@ ase_long_t ase_awk_strxtolong (
|
|||||||
ase_size_t rem;
|
ase_size_t rem;
|
||||||
int digit, negative = 0;
|
int digit, negative = 0;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, base < 37);
|
ASE_ASSERT (base < 37);
|
||||||
|
|
||||||
p = str;
|
p = str;
|
||||||
end = str + len;
|
end = str + len;
|
||||||
@ -838,7 +838,7 @@ ase_char_t* ase_awk_strxntokbyrex (
|
|||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, n == 1);
|
ASE_ASSERT (n == 1);
|
||||||
|
|
||||||
if (match_len == 0)
|
if (match_len == 0)
|
||||||
{
|
{
|
||||||
@ -903,26 +903,3 @@ exit_loop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ase_awk_assertfail (ase_awk_t* awk,
|
|
||||||
const ase_char_t* expr, const ase_char_t* desc,
|
|
||||||
const ase_char_t* file, int line)
|
|
||||||
{
|
|
||||||
if (desc == ASE_NULL)
|
|
||||||
{
|
|
||||||
awk->prmfns.misc.aprintf (
|
|
||||||
awk->prmfns.misc.custom_data,
|
|
||||||
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n"),
|
|
||||||
file, line, expr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
awk->prmfns.misc.aprintf (
|
|
||||||
awk->prmfns.misc.custom_data,
|
|
||||||
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n\nDESCRIPTION:\n%s\n"),
|
|
||||||
file, line, expr, desc);
|
|
||||||
|
|
||||||
}
|
|
||||||
awk->prmfns.misc.abort (awk->prmfns.misc.custom_data);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parse.c,v 1.252 2007-03-06 13:19:28 bacon Exp $
|
* $Id: parse.c,v 1.253 2007-03-06 14:51:52 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -426,19 +426,19 @@ int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios)
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (awk,
|
ASE_ASSERTX (
|
||||||
srcios != ASE_NULL && srcios->in != ASE_NULL,
|
srcios != ASE_NULL && srcios->in != ASE_NULL,
|
||||||
"the source code input stream must be provided at least");
|
"the source code input stream must be provided at least");
|
||||||
ASE_AWK_ASSERT (awk, awk->parse.depth.cur.loop == 0);
|
ASE_ASSERT (awk->parse.depth.cur.loop == 0);
|
||||||
ASE_AWK_ASSERT (awk, awk->parse.depth.cur.expr == 0);
|
ASE_ASSERT (awk->parse.depth.cur.expr == 0);
|
||||||
|
|
||||||
ase_awk_clear (awk);
|
ase_awk_clear (awk);
|
||||||
ase_memcpy (&awk->src.ios, srcios, ASE_SIZEOF(awk->src.ios));
|
ase_memcpy (&awk->src.ios, srcios, ASE_SIZEOF(awk->src.ios));
|
||||||
|
|
||||||
n = __parse (awk);
|
n = __parse (awk);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->parse.depth.cur.loop == 0);
|
ASE_ASSERT (awk->parse.depth.cur.loop == 0);
|
||||||
ASE_AWK_ASSERT (awk, awk->parse.depth.cur.expr == 0);
|
ASE_ASSERT (awk->parse.depth.cur.expr == 0);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -447,7 +447,7 @@ static int __parse (ase_awk_t* awk)
|
|||||||
{
|
{
|
||||||
int n = 0, op;
|
int n = 0, op;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->src.ios.in != ASE_NULL);
|
ASE_ASSERT (awk->src.ios.in != ASE_NULL);
|
||||||
|
|
||||||
op = awk->src.ios.in (
|
op = awk->src.ios.in (
|
||||||
ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0);
|
ASE_AWK_IO_OPEN, awk->src.ios.custom_data, ASE_NULL, 0);
|
||||||
@ -539,7 +539,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk)
|
|||||||
function name (parameter-list) { statement }
|
function name (parameter-list) { statement }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->parse.depth.cur.loop == 0);
|
ASE_ASSERT (awk->parse.depth.cur.loop == 0);
|
||||||
|
|
||||||
if ((awk->option & ASE_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
|
if ((awk->option & ASE_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
|
||||||
{
|
{
|
||||||
@ -642,7 +642,7 @@ static ase_awk_t* __parse_progunit (ase_awk_t* awk)
|
|||||||
ptn = __parse_expression (awk, awk->token.line);
|
ptn = __parse_expression (awk, awk->token.line);
|
||||||
if (ptn == ASE_NULL) return ASE_NULL;
|
if (ptn == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, ptn->next == ASE_NULL);
|
ASE_ASSERT (ptn->next == ASE_NULL);
|
||||||
|
|
||||||
if (MATCH(awk,TOKEN_COMMA))
|
if (MATCH(awk,TOKEN_COMMA))
|
||||||
{
|
{
|
||||||
@ -724,7 +724,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
/* eat up the keyword 'function' and get the next token */
|
/* eat up the keyword 'function' and get the next token */
|
||||||
ASE_AWK_ASSERT (awk, MATCH(awk,TOKEN_FUNCTION));
|
ASE_ASSERT (MATCH(awk,TOKEN_FUNCTION));
|
||||||
if (__get_token(awk) == -1) return ASE_NULL;
|
if (__get_token(awk) == -1) return ASE_NULL;
|
||||||
|
|
||||||
/* match a function name */
|
/* match a function name */
|
||||||
@ -821,7 +821,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* make sure that parameter table is empty */
|
/* make sure that parameter table is empty */
|
||||||
ASE_AWK_ASSERT (awk, ase_awk_tab_getsize(&awk->parse.params) == 0);
|
ASE_ASSERT (ase_awk_tab_getsize(&awk->parse.params) == 0);
|
||||||
|
|
||||||
/* read parameter list */
|
/* read parameter list */
|
||||||
if (MATCH(awk,TOKEN_RPAREN))
|
if (MATCH(awk,TOKEN_RPAREN))
|
||||||
@ -1076,7 +1076,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* duplicate functions should have been detected previously */
|
/* duplicate functions should have been detected previously */
|
||||||
ASE_AWK_ASSERT (awk, n != 0);
|
ASE_ASSERT (n != 0);
|
||||||
|
|
||||||
afn->name = pair->key; /* do some trick to save a string. */
|
afn->name = pair->key; /* do some trick to save a string. */
|
||||||
afn->name_len = pair->key_len;
|
afn->name_len = pair->key_len;
|
||||||
@ -1089,7 +1089,7 @@ static ase_awk_nde_t* __parse_begin (ase_awk_t* awk)
|
|||||||
{
|
{
|
||||||
ase_awk_nde_t* nde;
|
ase_awk_nde_t* nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, MATCH(awk,TOKEN_LBRACE));
|
ASE_ASSERT (MATCH(awk,TOKEN_LBRACE));
|
||||||
|
|
||||||
if (__get_token(awk) == -1) return ASE_NULL;
|
if (__get_token(awk) == -1) return ASE_NULL;
|
||||||
nde = awk->parse.parse_block (awk, awk->token.prev.line, ase_true);
|
nde = awk->parse.parse_block (awk, awk->token.prev.line, ase_true);
|
||||||
@ -1103,7 +1103,7 @@ static ase_awk_nde_t* __parse_end (ase_awk_t* awk)
|
|||||||
{
|
{
|
||||||
ase_awk_nde_t* nde;
|
ase_awk_nde_t* nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, MATCH(awk,TOKEN_LBRACE));
|
ASE_ASSERT (MATCH(awk,TOKEN_LBRACE));
|
||||||
|
|
||||||
if (__get_token(awk) == -1) return ASE_NULL;
|
if (__get_token(awk) == -1) return ASE_NULL;
|
||||||
nde = awk->parse.parse_block (awk, awk->token.prev.line, ase_true);
|
nde = awk->parse.parse_block (awk, awk->token.prev.line, ase_true);
|
||||||
@ -1123,7 +1123,7 @@ static ase_awk_chain_t* __parse_pattern_block (
|
|||||||
if (blockless) nde = ASE_NULL;
|
if (blockless) nde = ASE_NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (awk, MATCH(awk,TOKEN_LBRACE));
|
ASE_ASSERT (MATCH(awk,TOKEN_LBRACE));
|
||||||
if (__get_token(awk) == -1) return ASE_NULL;
|
if (__get_token(awk) == -1) return ASE_NULL;
|
||||||
nde = awk->parse.parse_block (awk, line, ase_true);
|
nde = awk->parse.parse_block (awk, line, ase_true);
|
||||||
if (nde == ASE_NULL) return ASE_NULL;
|
if (nde == ASE_NULL) return ASE_NULL;
|
||||||
@ -1296,7 +1296,7 @@ static ase_awk_nde_t* __parse_block_dc (
|
|||||||
{
|
{
|
||||||
ase_awk_nde_t* nde;
|
ase_awk_nde_t* nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->parse.depth.max.block > 0);
|
ASE_ASSERT (awk->parse.depth.max.block > 0);
|
||||||
|
|
||||||
if (awk->parse.depth.cur.block >= awk->parse.depth.max.block)
|
if (awk->parse.depth.cur.block >= awk->parse.depth.max.block)
|
||||||
{
|
{
|
||||||
@ -1818,7 +1818,7 @@ static ase_awk_nde_t* __parse_expression0 (ase_awk_t* awk, ase_size_t line)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, x->next == ASE_NULL);
|
ASE_ASSERT (x->next == ASE_NULL);
|
||||||
if (!__is_var(x) && x->type != ASE_AWK_NDE_POS)
|
if (!__is_var(x) && x->type != ASE_AWK_NDE_POS)
|
||||||
{
|
{
|
||||||
ase_awk_clrpt (awk, x);
|
ase_awk_clrpt (awk, x);
|
||||||
@ -2599,7 +2599,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
|
|||||||
}
|
}
|
||||||
nde->len = ASE_STR_LEN(&awk->token.name);
|
nde->len = ASE_STR_LEN(&awk->token.name);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk,
|
ASE_ASSERT (
|
||||||
ASE_STR_LEN(&awk->token.name) ==
|
ASE_STR_LEN(&awk->token.name) ==
|
||||||
ase_strlen(ASE_STR_BUF(&awk->token.name)));
|
ase_strlen(ASE_STR_BUF(&awk->token.name)));
|
||||||
|
|
||||||
@ -2642,7 +2642,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
|
|||||||
}
|
}
|
||||||
nde->len = ASE_STR_LEN(&awk->token.name);
|
nde->len = ASE_STR_LEN(&awk->token.name);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk,
|
ASE_ASSERT (
|
||||||
ASE_STR_LEN(&awk->token.name) ==
|
ASE_STR_LEN(&awk->token.name) ==
|
||||||
ase_strlen(ASE_STR_BUF(&awk->token.name)));
|
ase_strlen(ASE_STR_BUF(&awk->token.name)));
|
||||||
|
|
||||||
@ -2704,7 +2704,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
|
|||||||
|
|
||||||
ase_str_clear (&awk->token.name);
|
ase_str_clear (&awk->token.name);
|
||||||
if (__get_rexstr (awk) == -1) return ASE_NULL;
|
if (__get_rexstr (awk) == -1) return ASE_NULL;
|
||||||
ASE_AWK_ASSERT (awk, MATCH(awk,TOKEN_REX));
|
ASE_ASSERT (MATCH(awk,TOKEN_REX));
|
||||||
|
|
||||||
nde = (ase_awk_nde_rex_t*) ASE_AWK_MALLOC (
|
nde = (ase_awk_nde_rex_t*) ASE_AWK_MALLOC (
|
||||||
awk, ASE_SIZEOF(ase_awk_nde_rex_t));
|
awk, ASE_SIZEOF(ase_awk_nde_rex_t));
|
||||||
@ -2797,7 +2797,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
|
|||||||
|
|
||||||
/* parse subsequent expressions separated by a comma, if any */
|
/* parse subsequent expressions separated by a comma, if any */
|
||||||
last = nde;
|
last = nde;
|
||||||
ASE_AWK_ASSERT (awk, last->next == ASE_NULL);
|
ASE_ASSERT (last->next == ASE_NULL);
|
||||||
|
|
||||||
while (MATCH(awk,TOKEN_COMMA))
|
while (MATCH(awk,TOKEN_COMMA))
|
||||||
{
|
{
|
||||||
@ -2816,7 +2816,7 @@ static ase_awk_nde_t* __parse_primary (ase_awk_t* awk, ase_size_t line)
|
|||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, tmp->next == ASE_NULL);
|
ASE_ASSERT (tmp->next == ASE_NULL);
|
||||||
last->next = tmp;
|
last->next = tmp;
|
||||||
last = tmp;
|
last = tmp;
|
||||||
}
|
}
|
||||||
@ -2951,7 +2951,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line)
|
|||||||
ase_size_t name_len;
|
ase_size_t name_len;
|
||||||
ase_awk_bfn_t* bfn;
|
ase_awk_bfn_t* bfn;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, MATCH(awk,TOKEN_IDENT));
|
ASE_ASSERT (MATCH(awk,TOKEN_IDENT));
|
||||||
|
|
||||||
name_dup = ase_strxdup (
|
name_dup = ase_strxdup (
|
||||||
ASE_STR_BUF(&awk->token.name),
|
ASE_STR_BUF(&awk->token.name),
|
||||||
@ -3128,7 +3128,7 @@ static ase_awk_nde_t* __parse_hashidx (
|
|||||||
|
|
||||||
if (idx == ASE_NULL)
|
if (idx == ASE_NULL)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (awk, last == ASE_NULL);
|
ASE_ASSERT (last == ASE_NULL);
|
||||||
idx = tmp; last = tmp;
|
idx = tmp; last = tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3139,7 +3139,7 @@ static ase_awk_nde_t* __parse_hashidx (
|
|||||||
}
|
}
|
||||||
while (MATCH(awk,TOKEN_COMMA));
|
while (MATCH(awk,TOKEN_COMMA));
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, idx != ASE_NULL);
|
ASE_ASSERT (idx != ASE_NULL);
|
||||||
|
|
||||||
if (!MATCH(awk,TOKEN_RBRACK))
|
if (!MATCH(awk,TOKEN_RBRACK))
|
||||||
{
|
{
|
||||||
@ -3664,7 +3664,7 @@ static ase_awk_nde_t* __parse_dowhile (ase_awk_t* awk, ase_size_t line)
|
|||||||
ase_awk_nde_t* test, * body;
|
ase_awk_nde_t* test, * body;
|
||||||
ase_awk_nde_while_t* nde;
|
ase_awk_nde_while_t* nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_DO);
|
ASE_ASSERT (awk->token.prev.type == TOKEN_DO);
|
||||||
|
|
||||||
body = __parse_statement (awk, awk->token.line);
|
body = __parse_statement (awk, awk->token.line);
|
||||||
if (body == ASE_NULL) return ASE_NULL;
|
if (body == ASE_NULL) return ASE_NULL;
|
||||||
@ -3749,7 +3749,7 @@ static ase_awk_nde_t* __parse_break (ase_awk_t* awk, ase_size_t line)
|
|||||||
{
|
{
|
||||||
ase_awk_nde_break_t* nde;
|
ase_awk_nde_break_t* nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_BREAK);
|
ASE_ASSERT (awk->token.prev.type == TOKEN_BREAK);
|
||||||
if (awk->parse.depth.cur.loop <= 0)
|
if (awk->parse.depth.cur.loop <= 0)
|
||||||
{
|
{
|
||||||
ase_awk_seterror_old (
|
ase_awk_seterror_old (
|
||||||
@ -3778,7 +3778,7 @@ static ase_awk_nde_t* __parse_continue (ase_awk_t* awk, ase_size_t line)
|
|||||||
{
|
{
|
||||||
ase_awk_nde_continue_t* nde;
|
ase_awk_nde_continue_t* nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_CONTINUE);
|
ASE_ASSERT (awk->token.prev.type == TOKEN_CONTINUE);
|
||||||
if (awk->parse.depth.cur.loop <= 0)
|
if (awk->parse.depth.cur.loop <= 0)
|
||||||
{
|
{
|
||||||
ase_awk_seterror_old (
|
ase_awk_seterror_old (
|
||||||
@ -3808,7 +3808,7 @@ static ase_awk_nde_t* __parse_return (ase_awk_t* awk, ase_size_t line)
|
|||||||
ase_awk_nde_return_t* nde;
|
ase_awk_nde_return_t* nde;
|
||||||
ase_awk_nde_t* val;
|
ase_awk_nde_t* val;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_RETURN);
|
ASE_ASSERT (awk->token.prev.type == TOKEN_RETURN);
|
||||||
|
|
||||||
nde = (ase_awk_nde_return_t*) ASE_AWK_MALLOC (
|
nde = (ase_awk_nde_return_t*) ASE_AWK_MALLOC (
|
||||||
awk, ASE_SIZEOF(ase_awk_nde_return_t));
|
awk, ASE_SIZEOF(ase_awk_nde_return_t));
|
||||||
@ -3847,7 +3847,7 @@ static ase_awk_nde_t* __parse_exit (ase_awk_t* awk, ase_size_t line)
|
|||||||
ase_awk_nde_exit_t* nde;
|
ase_awk_nde_exit_t* nde;
|
||||||
ase_awk_nde_t* val;
|
ase_awk_nde_t* val;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_EXIT);
|
ASE_ASSERT (awk->token.prev.type == TOKEN_EXIT);
|
||||||
|
|
||||||
nde = (ase_awk_nde_exit_t*)
|
nde = (ase_awk_nde_exit_t*)
|
||||||
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_exit_t));
|
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_awk_nde_exit_t));
|
||||||
@ -3885,7 +3885,7 @@ static ase_awk_nde_t* __parse_next (ase_awk_t* awk, ase_size_t line)
|
|||||||
{
|
{
|
||||||
ase_awk_nde_next_t* nde;
|
ase_awk_nde_next_t* nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_NEXT);
|
ASE_ASSERT (awk->token.prev.type == TOKEN_NEXT);
|
||||||
|
|
||||||
if (awk->parse.id.block == PARSE_BEGIN_BLOCK)
|
if (awk->parse.id.block == PARSE_BEGIN_BLOCK)
|
||||||
{
|
{
|
||||||
@ -3958,7 +3958,7 @@ static ase_awk_nde_t* __parse_delete (ase_awk_t* awk, ase_size_t line)
|
|||||||
ase_awk_nde_delete_t* nde;
|
ase_awk_nde_delete_t* nde;
|
||||||
ase_awk_nde_t* var;
|
ase_awk_nde_t* var;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->token.prev.type == TOKEN_DELETE);
|
ASE_ASSERT (awk->token.prev.type == TOKEN_DELETE);
|
||||||
if (!MATCH(awk,TOKEN_IDENT))
|
if (!MATCH(awk,TOKEN_IDENT))
|
||||||
{
|
{
|
||||||
SET_ERROR_0 (
|
SET_ERROR_0 (
|
||||||
@ -4128,7 +4128,7 @@ static ase_awk_nde_t* __parse_print (ase_awk_t* awk, ase_size_t line, int type)
|
|||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (awk,
|
ASE_ASSERTX (
|
||||||
type == ASE_AWK_NDE_PRINT || type == ASE_AWK_NDE_PRINTF,
|
type == ASE_AWK_NDE_PRINT || type == ASE_AWK_NDE_PRINTF,
|
||||||
"the node type should be either ASE_AWK_NDE_PRINT or ASE_AWK_NDE_PRINTF");
|
"the node type should be either ASE_AWK_NDE_PRINT or ASE_AWK_NDE_PRINTF");
|
||||||
|
|
||||||
@ -4623,7 +4623,7 @@ static int __get_number (ase_awk_t* awk)
|
|||||||
{
|
{
|
||||||
ase_cint_t c;
|
ase_cint_t c;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, ASE_STR_LEN(&awk->token.name) == 0);
|
ASE_ASSERT (ASE_STR_LEN(&awk->token.name) == 0);
|
||||||
SET_TOKEN_TYPE (awk, TOKEN_INT);
|
SET_TOKEN_TYPE (awk, TOKEN_INT);
|
||||||
|
|
||||||
c = awk->src.lex.curc;
|
c = awk->src.lex.curc;
|
||||||
@ -5113,7 +5113,7 @@ static int __deparse (ase_awk_t* awk)
|
|||||||
struct __deparse_func_t df;
|
struct __deparse_func_t df;
|
||||||
int n = 0, op;
|
int n = 0, op;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->src.ios.out != ASE_NULL);
|
ASE_ASSERT (awk->src.ios.out != ASE_NULL);
|
||||||
|
|
||||||
awk->src.shared.buf_len = 0;
|
awk->src.shared.buf_len = 0;
|
||||||
awk->src.shared.buf_pos = 0;
|
awk->src.shared.buf_pos = 0;
|
||||||
@ -5156,7 +5156,7 @@ static int __deparse (ase_awk_t* awk)
|
|||||||
{
|
{
|
||||||
ase_size_t i/*, len*/;
|
ase_size_t i/*, len*/;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->tree.nglobals > 0);
|
ASE_ASSERT (awk->tree.nglobals > 0);
|
||||||
if (ase_awk_putsrcstr (awk, ASE_T("global ")) == -1)
|
if (ase_awk_putsrcstr (awk, ASE_T("global ")) == -1)
|
||||||
EXIT_DEPARSE (ASE_AWK_ESOUTWR);
|
EXIT_DEPARSE (ASE_AWK_ESOUTWR);
|
||||||
|
|
||||||
@ -5165,7 +5165,7 @@ static int __deparse (ase_awk_t* awk)
|
|||||||
/*
|
/*
|
||||||
len = ase_awk_longtostr ((ase_long_t)i,
|
len = ase_awk_longtostr ((ase_long_t)i,
|
||||||
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
|
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
|
||||||
ASE_AWK_ASSERT (awk, len != (ase_size_t)-1);
|
ASE_ASSERT (len != (ase_size_t)-1);
|
||||||
if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
|
if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
|
||||||
EXIT_DEPARSE (ASE_AWK_ESOUTWR);
|
EXIT_DEPARSE (ASE_AWK_ESOUTWR);
|
||||||
*/
|
*/
|
||||||
@ -5183,7 +5183,7 @@ static int __deparse (ase_awk_t* awk)
|
|||||||
/*
|
/*
|
||||||
len = ase_awk_longtostr ((ase_long_t)i,
|
len = ase_awk_longtostr ((ase_long_t)i,
|
||||||
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
|
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
|
||||||
ASE_AWK_ASSERT (awk, len != (ase_size_t)-1);
|
ASE_ASSERT (len != (ase_size_t)-1);
|
||||||
if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
|
if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
|
||||||
EXIT_DEPARSE (ASE_AWK_ESOUTWR);
|
EXIT_DEPARSE (ASE_AWK_ESOUTWR);
|
||||||
*/
|
*/
|
||||||
@ -5313,8 +5313,7 @@ static int __deparse_func (ase_awk_pair_t* pair, void* arg)
|
|||||||
ase_awk_afn_t* afn = (ase_awk_afn_t*)pair->val;
|
ase_awk_afn_t* afn = (ase_awk_afn_t*)pair->val;
|
||||||
ase_size_t i, n;
|
ase_size_t i, n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (df->awk, ase_strxncmp (
|
ASE_ASSERT (ase_strxncmp (pair->key, pair->key_len, afn->name, afn->name_len) == 0);
|
||||||
pair->key, pair->key_len, afn->name, afn->name_len) == 0);
|
|
||||||
|
|
||||||
if (ase_awk_putsrcstr (df->awk, ASE_T("function ")) == -1) return -1;
|
if (ase_awk_putsrcstr (df->awk, ASE_T("function ")) == -1) return -1;
|
||||||
if (ase_awk_putsrcstr (df->awk, afn->name) == -1) return -1;
|
if (ase_awk_putsrcstr (df->awk, afn->name) == -1) return -1;
|
||||||
@ -5324,7 +5323,7 @@ static int __deparse_func (ase_awk_pair_t* pair, void* arg)
|
|||||||
{
|
{
|
||||||
n = ase_awk_longtostr (i++, 10,
|
n = ase_awk_longtostr (i++, 10,
|
||||||
ASE_T("__param"), df->tmp, df->tmp_len);
|
ASE_T("__param"), df->tmp, df->tmp_len);
|
||||||
ASE_AWK_ASSERT (df->awk, n != (ase_size_t)-1);
|
ASE_ASSERT (n != (ase_size_t)-1);
|
||||||
if (ase_awk_putsrcstrx (df->awk, df->tmp, n) == -1) return -1;
|
if (ase_awk_putsrcstrx (df->awk, df->tmp, n) == -1) return -1;
|
||||||
if (i >= afn->nargs) break;
|
if (i >= afn->nargs) break;
|
||||||
if (ase_awk_putsrcstr (df->awk, ASE_T(", ")) == -1) return -1;
|
if (ase_awk_putsrcstr (df->awk, ASE_T(", ")) == -1) return -1;
|
||||||
@ -5361,7 +5360,7 @@ static int __flush (ase_awk_t* awk)
|
|||||||
{
|
{
|
||||||
ase_ssize_t n;
|
ase_ssize_t n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, awk->src.ios.out != ASE_NULL);
|
ASE_ASSERT (awk->src.ios.out != ASE_NULL);
|
||||||
|
|
||||||
while (awk->src.shared.buf_pos < awk->src.shared.buf_len)
|
while (awk->src.shared.buf_pos < awk->src.shared.buf_len)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: rec.c,v 1.16 2007-03-02 11:14:34 bacon Exp $
|
* $Id: rec.c,v 1.17 2007-03-06 14:51:53 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@ int ase_awk_setrec (
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, run->inrec.d0->type == ASE_AWK_VAL_NIL);
|
ASE_ASSERT (run->inrec.d0->type == ASE_AWK_VAL_NIL);
|
||||||
/* d0 should be cleared before the next line is reached
|
/* d0 should be cleared before the next line is reached
|
||||||
* as it doesn't call ase_awk_refdownval on run->inrec.d0 */
|
* as it doesn't call ase_awk_refdownval on run->inrec.d0 */
|
||||||
run->inrec.d0 = v;
|
run->inrec.d0 = v;
|
||||||
@ -99,7 +99,7 @@ static int __split_record (ase_awk_run_t* run)
|
|||||||
int errnum;
|
int errnum;
|
||||||
|
|
||||||
/* inrec should be cleared before __split_record is called */
|
/* inrec should be cleared before __split_record is called */
|
||||||
ASE_AWK_ASSERT (run->awk, run->inrec.nflds == 0);
|
ASE_ASSERT (run->inrec.nflds == 0);
|
||||||
|
|
||||||
/* get FS */
|
/* get FS */
|
||||||
fs = ase_awk_getglobal (run, ASE_AWK_GLOBAL_FS);
|
fs = ase_awk_getglobal (run, ASE_AWK_GLOBAL_FS);
|
||||||
@ -156,8 +156,7 @@ static int __split_record (ase_awk_run_t* run)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT ((tok != ASE_NULL && tok_len > 0) || tok_len == 0);
|
||||||
(tok != ASE_NULL && tok_len > 0) || tok_len == 0);
|
|
||||||
|
|
||||||
nflds++;
|
nflds++;
|
||||||
len = ASE_STR_LEN(&run->inrec.line) -
|
len = ASE_STR_LEN(&run->inrec.line) -
|
||||||
@ -206,8 +205,7 @@ static int __split_record (ase_awk_run_t* run)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT ((tok != ASE_NULL && tok_len > 0) || tok_len == 0);
|
||||||
(tok != ASE_NULL && tok_len > 0) || tok_len == 0);
|
|
||||||
|
|
||||||
run->inrec.flds[run->inrec.nflds].ptr = tok;
|
run->inrec.flds[run->inrec.nflds].ptr = tok;
|
||||||
run->inrec.flds[run->inrec.nflds].len = tok_len;
|
run->inrec.flds[run->inrec.nflds].len = tok_len;
|
||||||
@ -240,7 +238,7 @@ static int __split_record (ase_awk_run_t* run)
|
|||||||
|
|
||||||
if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_NF, v) == -1) return -1;
|
if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_NF, v) == -1) return -1;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nflds == run->inrec.nflds);
|
ASE_ASSERT (nflds == run->inrec.nflds);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,12 +255,11 @@ int ase_awk_clrrec (ase_awk_run_t* run, ase_bool_t skip_inrec_line)
|
|||||||
|
|
||||||
if (run->inrec.nflds > 0)
|
if (run->inrec.nflds > 0)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, run->inrec.flds != ASE_NULL);
|
ASE_ASSERT (run->inrec.flds != ASE_NULL);
|
||||||
|
|
||||||
for (i = 0; i < run->inrec.nflds; i++)
|
for (i = 0; i < run->inrec.nflds; i++)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (run->inrec.flds[i].val != ASE_NULL);
|
||||||
run->inrec.flds[i].val != ASE_NULL);
|
|
||||||
ase_awk_refdownval (run, run->inrec.flds[i].val);
|
ase_awk_refdownval (run, run->inrec.flds[i].val);
|
||||||
}
|
}
|
||||||
run->inrec.nflds = 0;
|
run->inrec.nflds = 0;
|
||||||
@ -277,7 +274,7 @@ int ase_awk_clrrec (ase_awk_run_t* run, ase_bool_t skip_inrec_line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, run->inrec.nflds == 0);
|
ASE_ASSERT (run->inrec.nflds == 0);
|
||||||
if (!skip_inrec_line) ase_str_clear (&run->inrec.line);
|
if (!skip_inrec_line) ase_str_clear (&run->inrec.line);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
@ -293,7 +290,7 @@ static int __recomp_record_fields (
|
|||||||
/* recomposes the record and the fields when $N has been assigned
|
/* recomposes the record and the fields when $N has been assigned
|
||||||
* a new value and recomputes NF accordingly */
|
* a new value and recomputes NF accordingly */
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, lv > 0);
|
ASE_ASSERT (lv > 0);
|
||||||
max = (lv > run->inrec.nflds)? lv: run->inrec.nflds;
|
max = (lv > run->inrec.nflds)? lv: run->inrec.nflds;
|
||||||
|
|
||||||
nflds = run->inrec.nflds;
|
nflds = run->inrec.nflds;
|
||||||
@ -427,21 +424,23 @@ static int __recomp_record_fields (
|
|||||||
if (ase_str_ncat (&run->inrec.line,
|
if (ase_str_ncat (&run->inrec.line,
|
||||||
tmp->buf, tmp->len) == (ase_size_t)-1)
|
tmp->buf, tmp->len) == (ase_size_t)-1)
|
||||||
{
|
{
|
||||||
ase_awk_setrunerror_old (
|
ase_awk_setrunerror (
|
||||||
run, ASE_AWK_ENOMEM, 0, ASE_NULL);
|
run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v = ase_awk_getglobal (run, ASE_AWK_GLOBAL_NF);
|
v = ase_awk_getglobal (run, ASE_AWK_GLOBAL_NF);
|
||||||
ASE_AWK_ASSERT (run->awk, v->type == ASE_AWK_VAL_INT);
|
ASE_ASSERT (v->type == ASE_AWK_VAL_INT);
|
||||||
|
|
||||||
if (((ase_awk_val_int_t*)v)->val != max)
|
if (((ase_awk_val_int_t*)v)->val != max)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
ase_awk_setrunerror_old (run, ASE_AWK_ENOMEM, 0, ASE_NULL);
|
ase_awk_setrunerror (
|
||||||
|
run, ASE_AWK_ENOMEM, 0, ASE_NULL, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: rex.c,v 1.78 2007-03-06 14:16:52 bacon Exp $
|
* $Id: rex.c,v 1.79 2007-03-06 14:51:53 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -395,14 +395,14 @@ int ase_awk_matchrex (
|
|||||||
|
|
||||||
void ase_awk_freerex (ase_awk_t* awk, void* code)
|
void ase_awk_freerex (ase_awk_t* awk, void* code)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (awk, code != ASE_NULL);
|
ASE_ASSERT (code != ASE_NULL);
|
||||||
ASE_AWK_FREE (awk, code);
|
ASE_AWK_FREE (awk, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
ase_bool_t ase_awk_isemptyrex (ase_awk_t* awk, void* code)
|
ase_bool_t ase_awk_isemptyrex (ase_awk_t* awk, void* code)
|
||||||
{
|
{
|
||||||
rhdr_t* rhdr = (rhdr_t*) code;
|
rhdr_t* rhdr = (rhdr_t*) code;
|
||||||
ASE_AWK_ASSERT (awk, rhdr != ASE_NULL);
|
ASE_ASSERT (rhdr != ASE_NULL);
|
||||||
|
|
||||||
/* an empty regular expression look like:
|
/* an empty regular expression look like:
|
||||||
* | expression |
|
* | expression |
|
||||||
@ -601,7 +601,7 @@ static int __build_atom (builder_t* builder)
|
|||||||
n = __build_charset (builder, cmd);
|
n = __build_charset (builder, cmd);
|
||||||
if (n == -1) return -1;
|
if (n == -1) return -1;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (builder->awk, n != 0);
|
ASE_ASSERT (n != 0);
|
||||||
|
|
||||||
if (builder->ptn.curc.type != CT_SPECIAL ||
|
if (builder->ptn.curc.type != CT_SPECIAL ||
|
||||||
builder->ptn.curc.value != ASE_T(']'))
|
builder->ptn.curc.value != ASE_T(']'))
|
||||||
@ -618,8 +618,7 @@ static int __build_atom (builder_t* builder)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (builder->awk,
|
ASE_ASSERT (builder->ptn.curc.type == CT_NORMAL);
|
||||||
builder->ptn.curc.type == CT_NORMAL);
|
|
||||||
|
|
||||||
tmp.cmd = CMD_ORD_CHAR;
|
tmp.cmd = CMD_ORD_CHAR;
|
||||||
tmp.negate = 0;
|
tmp.negate = 0;
|
||||||
@ -1150,7 +1149,7 @@ static const ase_byte_t* __match_atom (
|
|||||||
__match_group
|
__match_group
|
||||||
};
|
};
|
||||||
|
|
||||||
ASE_AWK_ASSERT (matcher->awk,
|
ASE_ASSERT (
|
||||||
((code_t*)base)->cmd >= 0 &&
|
((code_t*)base)->cmd >= 0 &&
|
||||||
((code_t*)base)->cmd < ASE_COUNTOF(matchers));
|
((code_t*)base)->cmd < ASE_COUNTOF(matchers));
|
||||||
|
|
||||||
@ -1164,7 +1163,7 @@ static const ase_byte_t* __match_bol (
|
|||||||
const code_t* cp;
|
const code_t* cp;
|
||||||
|
|
||||||
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
||||||
ASE_AWK_ASSERT (matcher->awk, cp->cmd == CMD_BOL);
|
ASE_ASSERT (cp->cmd == CMD_BOL);
|
||||||
|
|
||||||
mat->matched = (mat->match_ptr == matcher->match.str.ptr ||
|
mat->matched = (mat->match_ptr == matcher->match.str.ptr ||
|
||||||
(cp->lbound == cp->ubound && cp->lbound == 0));
|
(cp->lbound == cp->ubound && cp->lbound == 0));
|
||||||
@ -1180,7 +1179,7 @@ static const ase_byte_t* __match_eol (
|
|||||||
const code_t* cp;
|
const code_t* cp;
|
||||||
|
|
||||||
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
||||||
ASE_AWK_ASSERT (matcher->awk, cp->cmd == CMD_EOL);
|
ASE_ASSERT (cp->cmd == CMD_EOL);
|
||||||
|
|
||||||
mat->matched = (mat->match_ptr == matcher->match.str.end ||
|
mat->matched = (mat->match_ptr == matcher->match.str.end ||
|
||||||
(cp->lbound == cp->ubound && cp->lbound == 0));
|
(cp->lbound == cp->ubound && cp->lbound == 0));
|
||||||
@ -1197,7 +1196,7 @@ static const ase_byte_t* __match_any_char (
|
|||||||
ase_size_t si = 0, lbound, ubound;
|
ase_size_t si = 0, lbound, ubound;
|
||||||
|
|
||||||
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
||||||
ASE_AWK_ASSERT (matcher->awk, cp->cmd == CMD_ANY_CHAR);
|
ASE_ASSERT (cp->cmd == CMD_ANY_CHAR);
|
||||||
|
|
||||||
lbound = cp->lbound;
|
lbound = cp->lbound;
|
||||||
ubound = cp->ubound;
|
ubound = cp->ubound;
|
||||||
@ -1250,7 +1249,7 @@ static const ase_byte_t* __match_ord_char (
|
|||||||
ase_char_t cc;
|
ase_char_t cc;
|
||||||
|
|
||||||
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
||||||
ASE_AWK_ASSERT (matcher->awk, cp->cmd == CMD_ORD_CHAR);
|
ASE_ASSERT (cp->cmd == CMD_ORD_CHAR);
|
||||||
|
|
||||||
lbound = cp->lbound;
|
lbound = cp->lbound;
|
||||||
ubound = cp->ubound;
|
ubound = cp->ubound;
|
||||||
@ -1352,7 +1351,7 @@ static const ase_byte_t* __match_charset (
|
|||||||
cshdr_t* cshdr;
|
cshdr_t* cshdr;
|
||||||
|
|
||||||
cp = (code_t*)p; p += ASE_SIZEOF(*cp);
|
cp = (code_t*)p; p += ASE_SIZEOF(*cp);
|
||||||
ASE_AWK_ASSERT (matcher->awk, cp->cmd == CMD_CHARSET);
|
ASE_ASSERT (cp->cmd == CMD_CHARSET);
|
||||||
|
|
||||||
cshdr = (cshdr_t*)p; p += ASE_SIZEOF(*cshdr);
|
cshdr = (cshdr_t*)p; p += ASE_SIZEOF(*cshdr);
|
||||||
|
|
||||||
@ -1404,7 +1403,7 @@ static const ase_byte_t* __match_group (
|
|||||||
ase_size_t si = 0, grp_len_static[16], * grp_len;
|
ase_size_t si = 0, grp_len_static[16], * grp_len;
|
||||||
|
|
||||||
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
cp = (const code_t*)p; p += ASE_SIZEOF(*cp);
|
||||||
ASE_AWK_ASSERT (matcher->awk, cp->cmd == CMD_GROUP);
|
ASE_ASSERT (cp->cmd == CMD_GROUP);
|
||||||
|
|
||||||
mat->matched = ase_false;
|
mat->matched = ase_false;
|
||||||
mat->match_len = 0;
|
mat->match_len = 0;
|
||||||
@ -1485,7 +1484,7 @@ static const ase_byte_t* __match_group (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (matcher->awk, cp->ubound > cp->lbound);
|
ASE_ASSERT (cp->ubound > cp->lbound);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1532,7 +1531,7 @@ static const ase_byte_t* __match_occurrences (
|
|||||||
matcher_t* matcher, ase_size_t si, const ase_byte_t* p,
|
matcher_t* matcher, ase_size_t si, const ase_byte_t* p,
|
||||||
ase_size_t lbound, ase_size_t ubound, match_t* mat)
|
ase_size_t lbound, ase_size_t ubound, match_t* mat)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (matcher->awk, si >= lbound && si <= ubound);
|
ASE_ASSERT (si >= lbound && si <= ubound);
|
||||||
/* the match has been found */
|
/* the match has been found */
|
||||||
|
|
||||||
if (lbound == ubound || p >= mat->branch_end)
|
if (lbound == ubound || p >= mat->branch_end)
|
||||||
@ -1585,7 +1584,7 @@ static const ase_byte_t* __match_occurrences (
|
|||||||
* lbound in the implementation below, though)
|
* lbound in the implementation below, though)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ASE_AWK_ASSERT (matcher->awk, ubound > lbound);
|
ASE_ASSERT (ubound > lbound);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1672,8 +1671,7 @@ static ase_bool_t __test_charset (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (matcher->awk,
|
ASE_ASSERT (!"should never happen - invalid charset code");
|
||||||
!"should never happen - invalid charset code");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
230
ase/awk/run.c
230
ase/awk/run.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.339 2007-03-04 06:26:45 bacon Exp $
|
* $Id: run.c,v 1.340 2007-03-06 14:51:53 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -198,7 +198,7 @@ static ase_awk_val_t* __eval_getline (ase_awk_run_t* run, ase_awk_nde_t* nde);
|
|||||||
static int __raw_push (ase_awk_run_t* run, void* val);
|
static int __raw_push (ase_awk_run_t* run, void* val);
|
||||||
#define __raw_pop(run) \
|
#define __raw_pop(run) \
|
||||||
do { \
|
do { \
|
||||||
ASE_AWK_ASSERT (run->awk, (run)->stack_top > (run)->stack_base); \
|
ASE_ASSERT ((run)->stack_top > (run)->stack_base); \
|
||||||
(run)->stack_top--; \
|
(run)->stack_top--; \
|
||||||
} while (0)
|
} while (0)
|
||||||
static void __raw_pop_times (ase_awk_run_t* run, ase_size_t times);
|
static void __raw_pop_times (ase_awk_run_t* run, ase_size_t times);
|
||||||
@ -317,7 +317,7 @@ static int __set_global (
|
|||||||
{
|
{
|
||||||
/* due to the expression evaluation rule, the
|
/* due to the expression evaluation rule, the
|
||||||
* regular expression can not be an assigned value */
|
* regular expression can not be an assigned value */
|
||||||
ASE_AWK_ASSERT (run->awk, val->type != ASE_AWK_VAL_REX);
|
ASE_ASSERT (val->type != ASE_AWK_VAL_REX);
|
||||||
|
|
||||||
fs_ptr = ase_awk_valtostr (
|
fs_ptr = ase_awk_valtostr (
|
||||||
run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &fs_len);
|
run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &fs_len);
|
||||||
@ -450,7 +450,7 @@ static int __set_global (
|
|||||||
{
|
{
|
||||||
/* due to the expression evaluation rule, the
|
/* due to the expression evaluation rule, the
|
||||||
* regular expression can not be an assigned value */
|
* regular expression can not be an assigned value */
|
||||||
ASE_AWK_ASSERT (run->awk, val->type != ASE_AWK_VAL_REX);
|
ASE_ASSERT (val->type != ASE_AWK_VAL_REX);
|
||||||
|
|
||||||
rs_ptr = ase_awk_valtostr (
|
rs_ptr = ase_awk_valtostr (
|
||||||
run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &rs_len);
|
run, val, ASE_AWK_VALTOSTR_CLEAR, ASE_NULL, &rs_len);
|
||||||
@ -814,7 +814,7 @@ static void __deinit_run (ase_awk_run_t* run)
|
|||||||
/* close all pending extio's */
|
/* close all pending extio's */
|
||||||
/* TODO: what if this operation fails? */
|
/* TODO: what if this operation fails? */
|
||||||
ase_awk_clearextio (run);
|
ase_awk_clearextio (run);
|
||||||
ASE_AWK_ASSERT (run->awk, run->extio.chain == ASE_NULL);
|
ASE_ASSERT (run->extio.chain == ASE_NULL);
|
||||||
|
|
||||||
if (run->global.rs != ASE_NULL)
|
if (run->global.rs != ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -889,7 +889,7 @@ static void __deinit_run (ase_awk_run_t* run)
|
|||||||
/* destroy run stack */
|
/* destroy run stack */
|
||||||
if (run->stack != ASE_NULL)
|
if (run->stack != ASE_NULL)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, run->stack_top == 0);
|
ASE_ASSERT (run->stack_top == 0);
|
||||||
|
|
||||||
ASE_AWK_FREE (run->awk, run->stack);
|
ASE_AWK_FREE (run->awk, run->stack);
|
||||||
run->stack = ASE_NULL;
|
run->stack = ASE_NULL;
|
||||||
@ -956,7 +956,7 @@ static int __build_runarg (
|
|||||||
|
|
||||||
key_len = ase_awk_longtostr (
|
key_len = ase_awk_longtostr (
|
||||||
argc, 10, ASE_NULL, key, ASE_COUNTOF(key));
|
argc, 10, ASE_NULL, key, ASE_COUNTOF(key));
|
||||||
ASE_AWK_ASSERT (run->awk, key_len != (ase_size_t)-1);
|
ASE_ASSERT (key_len != (ase_size_t)-1);
|
||||||
|
|
||||||
/* increment reference count of v_tmp in advance as if
|
/* increment reference count of v_tmp in advance as if
|
||||||
* it has successfully been assigned into ARGV. */
|
* it has successfully been assigned into ARGV. */
|
||||||
@ -991,7 +991,7 @@ static int __build_runarg (
|
|||||||
|
|
||||||
ase_awk_refupval (run, v_argc);
|
ase_awk_refupval (run, v_argc);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
STACK_GLOBAL(run,ASE_AWK_GLOBAL_ARGC) == ase_awk_val_nil);
|
STACK_GLOBAL(run,ASE_AWK_GLOBAL_ARGC) == ase_awk_val_nil);
|
||||||
|
|
||||||
if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_ARGC, v_argc) == -1)
|
if (ase_awk_setglobal (run, ASE_AWK_GLOBAL_ARGC, v_argc) == -1)
|
||||||
@ -1103,7 +1103,7 @@ static int __set_globals_to_default (ase_awk_run_t* run)
|
|||||||
|
|
||||||
ase_awk_refupval (run, tmp);
|
ase_awk_refupval (run, tmp);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
STACK_GLOBAL(run,gtab[i].idx) == ase_awk_val_nil);
|
STACK_GLOBAL(run,gtab[i].idx) == ase_awk_val_nil);
|
||||||
|
|
||||||
if (ase_awk_setglobal (run, gtab[i].idx, tmp) == -1)
|
if (ase_awk_setglobal (run, gtab[i].idx, tmp) == -1)
|
||||||
@ -1133,7 +1133,7 @@ static int run_main (
|
|||||||
ase_awk_val_t* v;
|
ase_awk_val_t* v;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, run->stack_base == 0 && run->stack_top == 0);
|
ASE_ASSERT (run->stack_base == 0 && run->stack_top == 0);
|
||||||
|
|
||||||
/* secure space for global variables */
|
/* secure space for global variables */
|
||||||
saved_stack_top = run->stack_top;
|
saved_stack_top = run->stack_top;
|
||||||
@ -1261,7 +1261,7 @@ static int run_main (
|
|||||||
nde.nargs++;
|
nde.nargs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nrunargs == nde.nargs);
|
ASE_ASSERT (nrunargs == nde.nargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
v = __eval_afn (run, (ase_awk_nde_t*)&nde);
|
v = __eval_afn (run, (ase_awk_nde_t*)&nde);
|
||||||
@ -1348,7 +1348,7 @@ static int run_main (
|
|||||||
ase_awk_nde_blk_t* blk;
|
ase_awk_nde_blk_t* blk;
|
||||||
|
|
||||||
blk = (ase_awk_nde_blk_t*)run->awk->tree.begin;
|
blk = (ase_awk_nde_blk_t*)run->awk->tree.begin;
|
||||||
ASE_AWK_ASSERT (run->awk, blk->type == ASE_AWK_NDE_BLK);
|
ASE_ASSERT (blk->type == ASE_AWK_NDE_BLK);
|
||||||
|
|
||||||
run->active_block = blk;
|
run->active_block = blk;
|
||||||
run->exit_level = EXIT_NONE;
|
run->exit_level = EXIT_NONE;
|
||||||
@ -1370,7 +1370,7 @@ static int run_main (
|
|||||||
ase_awk_nde_blk_t* blk;
|
ase_awk_nde_blk_t* blk;
|
||||||
|
|
||||||
blk = (ase_awk_nde_blk_t*)run->awk->tree.end;
|
blk = (ase_awk_nde_blk_t*)run->awk->tree.end;
|
||||||
ASE_AWK_ASSERT (run->awk, blk->type == ASE_AWK_NDE_BLK);
|
ASE_ASSERT (blk->type == ASE_AWK_NDE_BLK);
|
||||||
|
|
||||||
run->active_block = blk;
|
run->active_block = blk;
|
||||||
run->exit_level = EXIT_NONE;
|
run->exit_level = EXIT_NONE;
|
||||||
@ -1379,7 +1379,7 @@ static int run_main (
|
|||||||
|
|
||||||
/* restore stack */
|
/* restore stack */
|
||||||
nargs = (ase_size_t)STACK_NARGS(run);
|
nargs = (ase_size_t)STACK_NARGS(run);
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == 0);
|
ASE_ASSERT (nargs == 0);
|
||||||
for (i = 0; i < nargs; i++)
|
for (i = 0; i < nargs; i++)
|
||||||
{
|
{
|
||||||
ase_awk_refdownval (run, STACK_ARG(run,i));
|
ase_awk_refdownval (run, STACK_ARG(run,i));
|
||||||
@ -1533,8 +1533,8 @@ static int __run_pattern_block (
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* pattern, pattern { ... } */
|
/* pattern, pattern { ... } */
|
||||||
ASE_AWK_ASSERT (run->awk, ptn->next->next == ASE_NULL);
|
ASE_ASSERT (ptn->next->next == ASE_NULL);
|
||||||
ASE_AWK_ASSERT (run->awk, run->pattern_range_state != ASE_NULL);
|
ASE_ASSERT (run->pattern_range_state != ASE_NULL);
|
||||||
|
|
||||||
if (run->pattern_range_state[block_no] == 0)
|
if (run->pattern_range_state[block_no] == 0)
|
||||||
{
|
{
|
||||||
@ -1652,7 +1652,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nde->type == ASE_AWK_NDE_BLK);
|
ASE_ASSERT (nde->type == ASE_AWK_NDE_BLK);
|
||||||
|
|
||||||
p = nde->body;
|
p = nde->body;
|
||||||
nlocals = nde->nlocals;
|
nlocals = nde->nlocals;
|
||||||
@ -1847,7 +1847,7 @@ static int __run_if (ase_awk_run_t* run, ase_awk_nde_if_t* nde)
|
|||||||
/* the test expression for the if statement cannot have
|
/* the test expression for the if statement cannot have
|
||||||
* chained expressions. this should not be allowed by the
|
* chained expressions. this should not be allowed by the
|
||||||
* parser first of all */
|
* parser first of all */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->test->next == ASE_NULL);
|
ASE_ASSERT (nde->test->next == ASE_NULL);
|
||||||
|
|
||||||
test = __eval_expression (run, nde->test);
|
test = __eval_expression (run, nde->test);
|
||||||
if (test == ASE_NULL) return -1;
|
if (test == ASE_NULL) return -1;
|
||||||
@ -1874,7 +1874,7 @@ static int __run_while (ase_awk_run_t* run, ase_awk_nde_while_t* nde)
|
|||||||
{
|
{
|
||||||
/* no chained expressions are allowed for the test
|
/* no chained expressions are allowed for the test
|
||||||
* expression of the while statement */
|
* expression of the while statement */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->test->next == ASE_NULL);
|
ASE_ASSERT (nde->test->next == ASE_NULL);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -1915,7 +1915,7 @@ static int __run_while (ase_awk_run_t* run, ase_awk_nde_while_t* nde)
|
|||||||
{
|
{
|
||||||
/* no chained expressions are allowed for the test
|
/* no chained expressions are allowed for the test
|
||||||
* expression of the while statement */
|
* expression of the while statement */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->test->next == ASE_NULL);
|
ASE_ASSERT (nde->test->next == ASE_NULL);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1957,7 +1957,7 @@ static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde)
|
|||||||
|
|
||||||
if (nde->init != ASE_NULL)
|
if (nde->init != ASE_NULL)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, nde->init->next == ASE_NULL);
|
ASE_ASSERT (nde->init->next == ASE_NULL);
|
||||||
val = __eval_expression(run,nde->init);
|
val = __eval_expression(run,nde->init);
|
||||||
if (val == ASE_NULL) return -1;
|
if (val == ASE_NULL) return -1;
|
||||||
|
|
||||||
@ -1973,7 +1973,7 @@ static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde)
|
|||||||
|
|
||||||
/* no chained expressions for the test expression of
|
/* no chained expressions for the test expression of
|
||||||
* the for statement are allowed */
|
* the for statement are allowed */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->test->next == ASE_NULL);
|
ASE_ASSERT (nde->test->next == ASE_NULL);
|
||||||
|
|
||||||
test = __eval_expression (run, nde->test);
|
test = __eval_expression (run, nde->test);
|
||||||
if (test == ASE_NULL) return -1;
|
if (test == ASE_NULL) return -1;
|
||||||
@ -2013,7 +2013,7 @@ static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde)
|
|||||||
|
|
||||||
if (nde->incr != ASE_NULL)
|
if (nde->incr != ASE_NULL)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, nde->incr->next == ASE_NULL);
|
ASE_ASSERT (nde->incr->next == ASE_NULL);
|
||||||
val = __eval_expression(run,nde->incr);
|
val = __eval_expression(run,nde->incr);
|
||||||
if (val == ASE_NULL) return -1;
|
if (val == ASE_NULL) return -1;
|
||||||
|
|
||||||
@ -2072,13 +2072,13 @@ static int __run_foreach (ase_awk_run_t* run, ase_awk_nde_foreach_t* nde)
|
|||||||
struct __foreach_walker_t walker;
|
struct __foreach_walker_t walker;
|
||||||
|
|
||||||
test = (ase_awk_nde_exp_t*)nde->test;
|
test = (ase_awk_nde_exp_t*)nde->test;
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
test->type == ASE_AWK_NDE_EXP_BIN &&
|
test->type == ASE_AWK_NDE_EXP_BIN &&
|
||||||
test->opcode == ASE_AWK_BINOP_IN);
|
test->opcode == ASE_AWK_BINOP_IN);
|
||||||
|
|
||||||
/* chained expressions should not be allowed
|
/* chained expressions should not be allowed
|
||||||
* by the parser first of all */
|
* by the parser first of all */
|
||||||
ASE_AWK_ASSERT (run->awk, test->right->next == ASE_NULL);
|
ASE_ASSERT (test->right->next == ASE_NULL);
|
||||||
|
|
||||||
rv = __eval_expression (run, test->right);
|
rv = __eval_expression (run, test->right);
|
||||||
if (rv == ASE_NULL) return -1;
|
if (rv == ASE_NULL) return -1;
|
||||||
@ -2124,7 +2124,7 @@ static int __run_return (ase_awk_run_t* run, ase_awk_nde_return_t* nde)
|
|||||||
|
|
||||||
/* chained expressions should not be allowed
|
/* chained expressions should not be allowed
|
||||||
* by the parser first of all */
|
* by the parser first of all */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->val->next == ASE_NULL);
|
ASE_ASSERT (nde->val->next == ASE_NULL);
|
||||||
|
|
||||||
val = __eval_expression (run, nde->val);
|
val = __eval_expression (run, nde->val);
|
||||||
if (val == ASE_NULL) return -1;
|
if (val == ASE_NULL) return -1;
|
||||||
@ -2146,7 +2146,7 @@ static int __run_exit (ase_awk_run_t* run, ase_awk_nde_exit_t* nde)
|
|||||||
|
|
||||||
/* chained expressions should not be allowed
|
/* chained expressions should not be allowed
|
||||||
* by the parser first of all */
|
* by the parser first of all */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->val->next == ASE_NULL);
|
ASE_ASSERT (nde->val->next == ASE_NULL);
|
||||||
|
|
||||||
val = __eval_expression (run, nde->val);
|
val = __eval_expression (run, nde->val);
|
||||||
if (val == ASE_NULL) return -1;
|
if (val == ASE_NULL) return -1;
|
||||||
@ -2290,7 +2290,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
{
|
{
|
||||||
ase_awk_pair_t* pair;
|
ase_awk_pair_t* pair;
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk,
|
ASE_ASSERTX (
|
||||||
(var->type == ASE_AWK_NDE_NAMED && var->idx == ASE_NULL) ||
|
(var->type == ASE_AWK_NDE_NAMED && var->idx == ASE_NULL) ||
|
||||||
(var->type == ASE_AWK_NDE_NAMEDIDX && var->idx != ASE_NULL),
|
(var->type == ASE_AWK_NDE_NAMEDIDX && var->idx != ASE_NULL),
|
||||||
"if a named variable has an index part and a named indexed variable doesn't have an index part, the program is definitely wrong");
|
"if a named variable has an index part and a named indexed variable doesn't have an index part, the program is definitely wrong");
|
||||||
@ -2335,7 +2335,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
ase_awk_map_t* map;
|
ase_awk_map_t* map;
|
||||||
|
|
||||||
val = (ase_awk_val_t*)pair->val;
|
val = (ase_awk_val_t*)pair->val;
|
||||||
ASE_AWK_ASSERT (run->awk, val != ASE_NULL);
|
ASE_ASSERT (val != ASE_NULL);
|
||||||
|
|
||||||
if (val->type != ASE_AWK_VAL_MAP)
|
if (val->type != ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
@ -2356,7 +2356,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
ase_size_t key_len;
|
ase_size_t key_len;
|
||||||
ase_awk_val_t* idx;
|
ase_awk_val_t* idx;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, var->idx != ASE_NULL);
|
ASE_ASSERT (var->idx != ASE_NULL);
|
||||||
|
|
||||||
idx = __eval_expression (run, var->idx);
|
idx = __eval_expression (run, var->idx);
|
||||||
if (idx == ASE_NULL) return -1;
|
if (idx == ASE_NULL) return -1;
|
||||||
@ -2400,7 +2400,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
val = STACK_LOCAL (run,var->id.idxa);
|
val = STACK_LOCAL (run,var->id.idxa);
|
||||||
else val = STACK_ARG (run,var->id.idxa);
|
else val = STACK_ARG (run,var->id.idxa);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, val != ASE_NULL);
|
ASE_ASSERT (val != ASE_NULL);
|
||||||
|
|
||||||
if (val->type == ASE_AWK_VAL_NIL)
|
if (val->type == ASE_AWK_VAL_NIL)
|
||||||
{
|
{
|
||||||
@ -2470,7 +2470,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
ase_size_t key_len;
|
ase_size_t key_len;
|
||||||
ase_awk_val_t* idx;
|
ase_awk_val_t* idx;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, var->idx != ASE_NULL);
|
ASE_ASSERT (var->idx != ASE_NULL);
|
||||||
|
|
||||||
idx = __eval_expression (run, var->idx);
|
idx = __eval_expression (run, var->idx);
|
||||||
if (idx == ASE_NULL) return -1;
|
if (idx == ASE_NULL) return -1;
|
||||||
@ -2499,7 +2499,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERTX (run->awk,
|
ASE_ASSERTX (
|
||||||
!"should never happen - wrong target for delete",
|
!"should never happen - wrong target for delete",
|
||||||
"the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc");
|
"the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc");
|
||||||
ase_awk_setrunerror_old (
|
ase_awk_setrunerror_old (
|
||||||
@ -2518,7 +2518,7 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
|
|||||||
ase_awk_val_t* v;
|
ase_awk_val_t* v;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
(nde->out_type == ASE_AWK_OUT_PIPE && nde->out != ASE_NULL) ||
|
(nde->out_type == ASE_AWK_OUT_PIPE && nde->out != ASE_NULL) ||
|
||||||
(nde->out_type == ASE_AWK_OUT_COPROC && nde->out != ASE_NULL) ||
|
(nde->out_type == ASE_AWK_OUT_COPROC && nde->out != ASE_NULL) ||
|
||||||
(nde->out_type == ASE_AWK_OUT_FILE && nde->out != ASE_NULL) ||
|
(nde->out_type == ASE_AWK_OUT_FILE && nde->out != ASE_NULL) ||
|
||||||
@ -2601,7 +2601,7 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
|
|||||||
if (nde->args->type == ASE_AWK_NDE_GRP)
|
if (nde->args->type == ASE_AWK_NDE_GRP)
|
||||||
{
|
{
|
||||||
/* parenthesized print */
|
/* parenthesized print */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->args->next == ASE_NULL);
|
ASE_ASSERT (nde->args->next == ASE_NULL);
|
||||||
head = ((ase_awk_nde_grp_t*)nde->args)->body;
|
head = ((ase_awk_nde_grp_t*)nde->args)->body;
|
||||||
}
|
}
|
||||||
else head = nde->args;
|
else head = nde->args;
|
||||||
@ -2670,7 +2670,7 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
|
|||||||
ase_awk_nde_t* head;
|
ase_awk_nde_t* head;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
(nde->out_type == ASE_AWK_OUT_PIPE && nde->out != ASE_NULL) ||
|
(nde->out_type == ASE_AWK_OUT_PIPE && nde->out != ASE_NULL) ||
|
||||||
(nde->out_type == ASE_AWK_OUT_COPROC && nde->out != ASE_NULL) ||
|
(nde->out_type == ASE_AWK_OUT_COPROC && nde->out != ASE_NULL) ||
|
||||||
(nde->out_type == ASE_AWK_OUT_FILE && nde->out != ASE_NULL) ||
|
(nde->out_type == ASE_AWK_OUT_FILE && nde->out != ASE_NULL) ||
|
||||||
@ -2723,18 +2723,18 @@ static int __run_printf (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
|
|||||||
|
|
||||||
dst = (out == ASE_NULL)? ASE_T(""): out;
|
dst = (out == ASE_NULL)? ASE_T(""): out;
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk, nde->args != ASE_NULL,
|
ASE_ASSERTX (nde->args != ASE_NULL,
|
||||||
"a valid printf statement should have at least one argument. the parser must ensure this.");
|
"a valid printf statement should have at least one argument. the parser must ensure this.");
|
||||||
|
|
||||||
if (nde->args->type == ASE_AWK_NDE_GRP)
|
if (nde->args->type == ASE_AWK_NDE_GRP)
|
||||||
{
|
{
|
||||||
/* parenthesized print */
|
/* parenthesized print */
|
||||||
ASE_AWK_ASSERT (run->awk, nde->args->next == ASE_NULL);
|
ASE_ASSERT (nde->args->next == ASE_NULL);
|
||||||
head = ((ase_awk_nde_grp_t*)nde->args)->body;
|
head = ((ase_awk_nde_grp_t*)nde->args)->body;
|
||||||
}
|
}
|
||||||
else head = nde->args;
|
else head = nde->args;
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk, head != ASE_NULL,
|
ASE_ASSERTX (head != ASE_NULL,
|
||||||
"a valid printf statement should have at least one argument. the parser must ensure this.");
|
"a valid printf statement should have at least one argument. the parser must ensure this.");
|
||||||
|
|
||||||
v = __eval_expression (run, head);
|
v = __eval_expression (run, head);
|
||||||
@ -2822,7 +2822,7 @@ static ase_awk_val_t* __eval_expression (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERTX (run->awk,
|
ASE_ASSERTX (
|
||||||
run->inrec.d0->type == ASE_AWK_VAL_STR,
|
run->inrec.d0->type == ASE_AWK_VAL_STR,
|
||||||
"the internal value representing $0 should always be of the string type once it has been set/updated. it is nil initially.");
|
"the internal value representing $0 should always be of the string type once it has been set/updated. it is nil initially.");
|
||||||
|
|
||||||
@ -2893,7 +2893,7 @@ static ase_awk_val_t* __eval_expression0 (ase_awk_run_t* run, ase_awk_nde_t* nde
|
|||||||
__eval_getline
|
__eval_getline
|
||||||
};
|
};
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nde->type >= ASE_AWK_NDE_GRP &&
|
ASE_ASSERT (nde->type >= ASE_AWK_NDE_GRP &&
|
||||||
(nde->type - ASE_AWK_NDE_GRP) < ASE_COUNTOF(__eval_func));
|
(nde->type - ASE_AWK_NDE_GRP) < ASE_COUNTOF(__eval_func));
|
||||||
|
|
||||||
return __eval_func[nde->type-ASE_AWK_NDE_GRP] (run, nde);
|
return __eval_func[nde->type-ASE_AWK_NDE_GRP] (run, nde);
|
||||||
@ -2903,7 +2903,7 @@ static ase_awk_val_t* __eval_group (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
{
|
{
|
||||||
/* __eval_binop_in evaluates the ASE_AWK_NDE_GRP specially.
|
/* __eval_binop_in evaluates the ASE_AWK_NDE_GRP specially.
|
||||||
* so this function should never be reached. */
|
* so this function should never be reached. */
|
||||||
ASE_AWK_ASSERT (run->awk, !"should never happen - NDE_GRP only for in");
|
ASE_ASSERT (!"should never happen - NDE_GRP only for in");
|
||||||
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, nde->line, ASE_NULL);
|
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, nde->line, ASE_NULL);
|
||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
@ -2913,10 +2913,10 @@ static ase_awk_val_t* __eval_assignment (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
ase_awk_val_t* val, * ret;
|
ase_awk_val_t* val, * ret;
|
||||||
ase_awk_nde_ass_t* ass = (ase_awk_nde_ass_t*)nde;
|
ase_awk_nde_ass_t* ass = (ase_awk_nde_ass_t*)nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, ass->left != ASE_NULL);
|
ASE_ASSERT (ass->left != ASE_NULL);
|
||||||
ASE_AWK_ASSERT (run->awk, ass->right != ASE_NULL);
|
ASE_ASSERT (ass->right != ASE_NULL);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, ass->right->next == ASE_NULL);
|
ASE_ASSERT (ass->right->next == ASE_NULL);
|
||||||
val = __eval_expression (run, ass->right);
|
val = __eval_expression (run, ass->right);
|
||||||
if (val == ASE_NULL) return ASE_NULL;
|
if (val == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
@ -2937,7 +2937,7 @@ static ase_awk_val_t* __eval_assignment (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
__eval_binop_exp
|
__eval_binop_exp
|
||||||
};
|
};
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, ass->left->next == ASE_NULL);
|
ASE_ASSERT (ass->left->next == ASE_NULL);
|
||||||
val2 = __eval_expression (run, ass->left);
|
val2 = __eval_expression (run, ass->left);
|
||||||
if (val2 == ASE_NULL)
|
if (val2 == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -2947,9 +2947,9 @@ static ase_awk_val_t* __eval_assignment (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
|
|
||||||
ase_awk_refupval (run, val2);
|
ase_awk_refupval (run, val2);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, ass->opcode >= 0);
|
ASE_ASSERT (ass->opcode >= 0);
|
||||||
ASE_AWK_ASSERT (run->awk, ass->opcode < ASE_COUNTOF(__binop_func));
|
ASE_ASSERT (ass->opcode < ASE_COUNTOF(__binop_func));
|
||||||
ASE_AWK_ASSERT (run->awk, __binop_func[ass->opcode] != ASE_NULL);
|
ASE_ASSERT (__binop_func[ass->opcode] != ASE_NULL);
|
||||||
|
|
||||||
tmp = __binop_func[ass->opcode] (run, val2, val);
|
tmp = __binop_func[ass->opcode] (run, val2, val);
|
||||||
if (tmp == ASE_NULL)
|
if (tmp == ASE_NULL)
|
||||||
@ -3005,7 +3005,7 @@ static ase_awk_val_t* __do_assignment (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
!"should never happen - invalid variable type");
|
!"should never happen - invalid variable type");
|
||||||
ase_awk_setrunerror_old (
|
ase_awk_setrunerror_old (
|
||||||
run, ASE_AWK_EINTERN, var->line, ASE_NULL);
|
run, ASE_AWK_EINTERN, var->line, ASE_NULL);
|
||||||
@ -3018,13 +3018,13 @@ static ase_awk_val_t* __do_assignment (
|
|||||||
static ase_awk_val_t* __do_assignment_scalar (
|
static ase_awk_val_t* __do_assignment_scalar (
|
||||||
ase_awk_run_t* run, ase_awk_nde_var_t* var, ase_awk_val_t* val)
|
ase_awk_run_t* run, ase_awk_nde_var_t* var, ase_awk_val_t* val)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
(var->type == ASE_AWK_NDE_NAMED ||
|
(var->type == ASE_AWK_NDE_NAMED ||
|
||||||
var->type == ASE_AWK_NDE_GLOBAL ||
|
var->type == ASE_AWK_NDE_GLOBAL ||
|
||||||
var->type == ASE_AWK_NDE_LOCAL ||
|
var->type == ASE_AWK_NDE_LOCAL ||
|
||||||
var->type == ASE_AWK_NDE_ARG) && var->idx == ASE_NULL);
|
var->type == ASE_AWK_NDE_ARG) && var->idx == ASE_NULL);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, val->type != ASE_AWK_VAL_MAP);
|
ASE_ASSERT (val->type != ASE_AWK_VAL_MAP);
|
||||||
|
|
||||||
if (var->type == ASE_AWK_NDE_NAMED)
|
if (var->type == ASE_AWK_NDE_NAMED)
|
||||||
{
|
{
|
||||||
@ -3120,12 +3120,12 @@ static ase_awk_val_t* __do_assignment_map (
|
|||||||
ase_size_t len;
|
ase_size_t len;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
(var->type == ASE_AWK_NDE_NAMEDIDX ||
|
(var->type == ASE_AWK_NDE_NAMEDIDX ||
|
||||||
var->type == ASE_AWK_NDE_GLOBALIDX ||
|
var->type == ASE_AWK_NDE_GLOBALIDX ||
|
||||||
var->type == ASE_AWK_NDE_LOCALIDX ||
|
var->type == ASE_AWK_NDE_LOCALIDX ||
|
||||||
var->type == ASE_AWK_NDE_ARGIDX) && var->idx != ASE_NULL);
|
var->type == ASE_AWK_NDE_ARGIDX) && var->idx != ASE_NULL);
|
||||||
ASE_AWK_ASSERT (run->awk, val->type != ASE_AWK_VAL_MAP);
|
ASE_ASSERT (val->type != ASE_AWK_VAL_MAP);
|
||||||
|
|
||||||
if (var->type == ASE_AWK_NDE_NAMEDIDX)
|
if (var->type == ASE_AWK_NDE_NAMEDIDX)
|
||||||
{
|
{
|
||||||
@ -3327,7 +3327,7 @@ static ase_awk_val_t* __eval_binary (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
||||||
ase_awk_val_t* left, * right, * res;
|
ase_awk_val_t* left, * right, * res;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, exp->type == ASE_AWK_NDE_EXP_BIN);
|
ASE_ASSERT (exp->type == ASE_AWK_NDE_EXP_BIN);
|
||||||
|
|
||||||
if (exp->opcode == ASE_AWK_BINOP_LAND)
|
if (exp->opcode == ASE_AWK_BINOP_LAND)
|
||||||
{
|
{
|
||||||
@ -3352,13 +3352,13 @@ static ase_awk_val_t* __eval_binary (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, exp->left->next == ASE_NULL);
|
ASE_ASSERT (exp->left->next == ASE_NULL);
|
||||||
left = __eval_expression (run, exp->left);
|
left = __eval_expression (run, exp->left);
|
||||||
if (left == ASE_NULL) return ASE_NULL;
|
if (left == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
ase_awk_refupval (run, left);
|
ase_awk_refupval (run, left);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, exp->right->next == ASE_NULL);
|
ASE_ASSERT (exp->right->next == ASE_NULL);
|
||||||
right = __eval_expression (run, exp->right);
|
right = __eval_expression (run, exp->right);
|
||||||
if (right == ASE_NULL)
|
if (right == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -3368,9 +3368,9 @@ static ase_awk_val_t* __eval_binary (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
|
|
||||||
ase_awk_refupval (run, right);
|
ase_awk_refupval (run, right);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, exp->opcode >= 0 &&
|
ASE_ASSERT (exp->opcode >= 0 &&
|
||||||
exp->opcode < ASE_COUNTOF(__binop_func));
|
exp->opcode < ASE_COUNTOF(__binop_func));
|
||||||
ASE_AWK_ASSERT (run->awk, __binop_func[exp->opcode] != ASE_NULL);
|
ASE_ASSERT (__binop_func[exp->opcode] != ASE_NULL);
|
||||||
|
|
||||||
res = __binop_func[exp->opcode] (run, left, right);
|
res = __binop_func[exp->opcode] (run, left, right);
|
||||||
if (res == ASE_NULL)
|
if (res == ASE_NULL)
|
||||||
@ -3405,7 +3405,7 @@ static ase_awk_val_t* __eval_binop_lor (
|
|||||||
/* short-circuit evaluation required special treatment */
|
/* short-circuit evaluation required special treatment */
|
||||||
ase_awk_val_t* lv, * rv, * res;
|
ase_awk_val_t* lv, * rv, * res;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, left->next == ASE_NULL);
|
ASE_ASSERT (left->next == ASE_NULL);
|
||||||
lv = __eval_expression (run, left);
|
lv = __eval_expression (run, left);
|
||||||
if (lv == ASE_NULL) return ASE_NULL;
|
if (lv == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
@ -3416,7 +3416,7 @@ static ase_awk_val_t* __eval_binop_lor (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, right->next == ASE_NULL);
|
ASE_ASSERT (right->next == ASE_NULL);
|
||||||
rv = __eval_expression (run, right);
|
rv = __eval_expression (run, right);
|
||||||
if (rv == ASE_NULL)
|
if (rv == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -3454,7 +3454,7 @@ static ase_awk_val_t* __eval_binop_land (
|
|||||||
/* short-circuit evaluation required special treatment */
|
/* short-circuit evaluation required special treatment */
|
||||||
ase_awk_val_t* lv, * rv, * res;
|
ase_awk_val_t* lv, * rv, * res;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, left->next == ASE_NULL);
|
ASE_ASSERT (left->next == ASE_NULL);
|
||||||
lv = __eval_expression (run, left);
|
lv = __eval_expression (run, left);
|
||||||
if (lv == ASE_NULL) return ASE_NULL;
|
if (lv == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
@ -3465,7 +3465,7 @@ static ase_awk_val_t* __eval_binop_land (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, right->next == ASE_NULL);
|
ASE_ASSERT (right->next == ASE_NULL);
|
||||||
rv = __eval_expression (run, right);
|
rv = __eval_expression (run, right);
|
||||||
if (rv == ASE_NULL)
|
if (rv == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -3496,7 +3496,7 @@ static ase_awk_val_t* __eval_binop_in (
|
|||||||
right->type != ASE_AWK_NDE_NAMED)
|
right->type != ASE_AWK_NDE_NAMED)
|
||||||
{
|
{
|
||||||
/* the compiler should have handled this case */
|
/* the compiler should have handled this case */
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
!"should never happen - in needs a plain variable");
|
!"should never happen - in needs a plain variable");
|
||||||
|
|
||||||
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, right->line, ASE_NULL);
|
ase_awk_setrunerror_old (run, ASE_AWK_EINTERN, right->line, ASE_NULL);
|
||||||
@ -3510,7 +3510,7 @@ static ase_awk_val_t* __eval_binop_in (
|
|||||||
if (str == ASE_NULL) return ASE_NULL;
|
if (str == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
/* evaluate the right-hand side of the operator */
|
/* evaluate the right-hand side of the operator */
|
||||||
ASE_AWK_ASSERT (run->awk, right->next == ASE_NULL);
|
ASE_ASSERT (right->next == ASE_NULL);
|
||||||
rv = __eval_expression (run, right);
|
rv = __eval_expression (run, right);
|
||||||
if (rv == ASE_NULL)
|
if (rv == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -3568,7 +3568,7 @@ static ase_awk_val_t* __eval_binop_bor (
|
|||||||
}
|
}
|
||||||
|
|
||||||
n3 = n1 + (n2 << 1);
|
n3 = n1 + (n2 << 1);
|
||||||
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
|
ASE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||||
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)l2):
|
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)l2):
|
||||||
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1|(ase_long_t)l2):
|
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1|(ase_long_t)l2):
|
||||||
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)r2):
|
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1|(ase_long_t)r2):
|
||||||
@ -3600,7 +3600,7 @@ static ase_awk_val_t* __eval_binop_bxor (
|
|||||||
}
|
}
|
||||||
|
|
||||||
n3 = n1 + (n2 << 1);
|
n3 = n1 + (n2 << 1);
|
||||||
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
|
ASE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||||
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)l2):
|
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)l2):
|
||||||
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1^(ase_long_t)l2):
|
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1^(ase_long_t)l2):
|
||||||
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)r2):
|
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1^(ase_long_t)r2):
|
||||||
@ -3632,7 +3632,7 @@ static ase_awk_val_t* __eval_binop_band (
|
|||||||
}
|
}
|
||||||
|
|
||||||
n3 = n1 + (n2 << 1);
|
n3 = n1 + (n2 << 1);
|
||||||
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
|
ASE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||||
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)l2):
|
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)l2):
|
||||||
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1&(ase_long_t)l2):
|
(n3 == 1)? ase_awk_makeintval(run,(ase_long_t)r1&(ase_long_t)l2):
|
||||||
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)r2):
|
(n3 == 2)? ase_awk_makeintval(run,(ase_long_t)l1&(ase_long_t)r2):
|
||||||
@ -3897,10 +3897,10 @@ static int __cmp_val (
|
|||||||
return CMP_ERROR;
|
return CMP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
left->type >= ASE_AWK_VAL_NIL &&
|
left->type >= ASE_AWK_VAL_NIL &&
|
||||||
left->type <= ASE_AWK_VAL_STR);
|
left->type <= ASE_AWK_VAL_STR);
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
right->type >= ASE_AWK_VAL_NIL &&
|
right->type >= ASE_AWK_VAL_NIL &&
|
||||||
right->type <= ASE_AWK_VAL_STR);
|
right->type <= ASE_AWK_VAL_STR);
|
||||||
|
|
||||||
@ -4053,7 +4053,7 @@ static ase_awk_val_t* __eval_binop_plus (
|
|||||||
1 1 = 3
|
1 1 = 3
|
||||||
*/
|
*/
|
||||||
n3 = n1 + (n2 << 1);
|
n3 = n1 + (n2 << 1);
|
||||||
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
|
ASE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||||
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1+(ase_long_t)l2):
|
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1+(ase_long_t)l2):
|
||||||
(n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1+(ase_real_t)l2):
|
(n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1+(ase_real_t)l2):
|
||||||
(n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1+(ase_real_t)r2):
|
(n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1+(ase_real_t)r2):
|
||||||
@ -4085,7 +4085,7 @@ static ase_awk_val_t* __eval_binop_minus (
|
|||||||
}
|
}
|
||||||
|
|
||||||
n3 = n1 + (n2 << 1);
|
n3 = n1 + (n2 << 1);
|
||||||
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
|
ASE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||||
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1-(ase_long_t)l2):
|
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1-(ase_long_t)l2):
|
||||||
(n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1-(ase_real_t)l2):
|
(n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1-(ase_real_t)l2):
|
||||||
(n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1-(ase_real_t)r2):
|
(n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1-(ase_real_t)r2):
|
||||||
@ -4117,7 +4117,7 @@ static ase_awk_val_t* __eval_binop_mul (
|
|||||||
}
|
}
|
||||||
|
|
||||||
n3 = n1 + (n2 << 1);
|
n3 = n1 + (n2 << 1);
|
||||||
ASE_AWK_ASSERT (run->awk, n3 >= 0 && n3 <= 3);
|
ASE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||||
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1*(ase_long_t)l2):
|
res = (n3 == 0)? ase_awk_makeintval(run,(ase_long_t)l1*(ase_long_t)l2):
|
||||||
(n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1*(ase_real_t)l2):
|
(n3 == 1)? ase_awk_makerealval(run,(ase_real_t)r1*(ase_real_t)l2):
|
||||||
(n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1*(ase_real_t)r2):
|
(n3 == 2)? ase_awk_makerealval(run,(ase_real_t)l1*(ase_real_t)r2):
|
||||||
@ -4180,7 +4180,7 @@ static ase_awk_val_t* __eval_binop_div (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, n3 == 3);
|
ASE_ASSERT (n3 == 3);
|
||||||
res = ase_awk_makerealval (
|
res = ase_awk_makerealval (
|
||||||
run, (ase_real_t)r1 / (ase_real_t)r2);
|
run, (ase_real_t)r1 / (ase_real_t)r2);
|
||||||
}
|
}
|
||||||
@ -4233,7 +4233,7 @@ static ase_awk_val_t* __eval_binop_idiv (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, n3 == 3);
|
ASE_ASSERT (n3 == 3);
|
||||||
|
|
||||||
quo = (ase_real_t)r1 / (ase_real_t)r2;
|
quo = (ase_real_t)r1 / (ase_real_t)r2;
|
||||||
res = ase_awk_makeintval (run, (ase_long_t)quo);
|
res = ase_awk_makeintval (run, (ase_long_t)quo);
|
||||||
@ -4297,7 +4297,7 @@ static ase_awk_val_t* __eval_binop_exp (
|
|||||||
ase_real_t r1, r2;
|
ase_real_t r1, r2;
|
||||||
ase_awk_val_t* res;
|
ase_awk_val_t* res;
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk, run->awk->prmfns.misc.pow != ASE_NULL,
|
ASE_ASSERTX (run->awk->prmfns.misc.pow != ASE_NULL,
|
||||||
"the pow function should be provided when the awk object is created to make the exponentiation work properly.");
|
"the pow function should be provided when the awk object is created to make the exponentiation work properly.");
|
||||||
|
|
||||||
n1 = ase_awk_valtonum (run, left, &l1, &r1);
|
n1 = ase_awk_valtonum (run, left, &l1, &r1);
|
||||||
@ -4365,7 +4365,7 @@ static ase_awk_val_t* __eval_binop_exp (
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* left - real, right - real */
|
/* left - real, right - real */
|
||||||
ASE_AWK_ASSERT (run->awk, n3 == 3);
|
ASE_ASSERT (n3 == 3);
|
||||||
res = ase_awk_makerealval (run,
|
res = ase_awk_makerealval (run,
|
||||||
run->awk->prmfns.misc.pow(
|
run->awk->prmfns.misc.pow(
|
||||||
run->awk->prmfns.misc.custom_data,
|
run->awk->prmfns.misc.custom_data,
|
||||||
@ -4421,8 +4421,8 @@ static ase_awk_val_t* __eval_binop_ma (
|
|||||||
{
|
{
|
||||||
ase_awk_val_t* lv, * rv, * res;
|
ase_awk_val_t* lv, * rv, * res;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, left->next == ASE_NULL);
|
ASE_ASSERT (left->next == ASE_NULL);
|
||||||
ASE_AWK_ASSERT (run->awk, right->next == ASE_NULL);
|
ASE_ASSERT (right->next == ASE_NULL);
|
||||||
|
|
||||||
lv = __eval_expression (run, left);
|
lv = __eval_expression (run, left);
|
||||||
if (lv == ASE_NULL)
|
if (lv == ASE_NULL)
|
||||||
@ -4455,8 +4455,8 @@ static ase_awk_val_t* __eval_binop_nm (
|
|||||||
{
|
{
|
||||||
ase_awk_val_t* lv, * rv, * res;
|
ase_awk_val_t* lv, * rv, * res;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, left->next == ASE_NULL);
|
ASE_ASSERT (left->next == ASE_NULL);
|
||||||
ASE_AWK_ASSERT (run->awk, right->next == ASE_NULL);
|
ASE_ASSERT (right->next == ASE_NULL);
|
||||||
|
|
||||||
lv = __eval_expression (run, left);
|
lv = __eval_expression (run, left);
|
||||||
if (lv == ASE_NULL) return ASE_NULL;
|
if (lv == ASE_NULL) return ASE_NULL;
|
||||||
@ -4606,17 +4606,17 @@ static ase_awk_val_t* __eval_unary (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
ase_long_t l;
|
ase_long_t l;
|
||||||
ase_real_t r;
|
ase_real_t r;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
exp->type == ASE_AWK_NDE_EXP_UNR);
|
exp->type == ASE_AWK_NDE_EXP_UNR);
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
exp->opcode == ASE_AWK_UNROP_PLUS ||
|
exp->opcode == ASE_AWK_UNROP_PLUS ||
|
||||||
exp->opcode == ASE_AWK_UNROP_MINUS ||
|
exp->opcode == ASE_AWK_UNROP_MINUS ||
|
||||||
exp->opcode == ASE_AWK_UNROP_NOT ||
|
exp->opcode == ASE_AWK_UNROP_NOT ||
|
||||||
exp->opcode == ASE_AWK_UNROP_BNOT);
|
exp->opcode == ASE_AWK_UNROP_BNOT);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, exp->left->next == ASE_NULL);
|
ASE_ASSERT (exp->left->next == ASE_NULL);
|
||||||
left = __eval_expression (run, exp->left);
|
left = __eval_expression (run, exp->left);
|
||||||
if (left == ASE_NULL) return ASE_NULL;
|
if (left == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
@ -4697,9 +4697,9 @@ static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
ase_awk_val_t* left, * res;
|
ase_awk_val_t* left, * res;
|
||||||
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
exp->type == ASE_AWK_NDE_EXP_INCPRE);
|
exp->type == ASE_AWK_NDE_EXP_INCPRE);
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
||||||
|
|
||||||
/* this way of checking if the l-value is assignable is
|
/* this way of checking if the l-value is assignable is
|
||||||
@ -4713,7 +4713,7 @@ static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, exp->left->next == ASE_NULL);
|
ASE_ASSERT (exp->left->next == ASE_NULL);
|
||||||
left = __eval_expression (run, exp->left);
|
left = __eval_expression (run, exp->left);
|
||||||
if (left == ASE_NULL) return ASE_NULL;
|
if (left == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
@ -4766,7 +4766,7 @@ static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else /* if (n == 1) */
|
else /* if (n == 1) */
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, n == 1);
|
ASE_ASSERT (n == 1);
|
||||||
res = ase_awk_makerealval (run, v2 + 1.0);
|
res = ase_awk_makerealval (run, v2 + 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4826,7 +4826,7 @@ static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else /* if (n == 1) */
|
else /* if (n == 1) */
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, n == 1);
|
ASE_ASSERT (n == 1);
|
||||||
res = ase_awk_makerealval (run, v2 - 1.0);
|
res = ase_awk_makerealval (run, v2 - 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4841,7 +4841,7 @@ static ase_awk_val_t* __eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
!"should never happen - invalid opcode");
|
!"should never happen - invalid opcode");
|
||||||
ase_awk_refdownval (run, left);
|
ase_awk_refdownval (run, left);
|
||||||
|
|
||||||
@ -4865,9 +4865,9 @@ static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
ase_awk_val_t* left, * res, * res2;
|
ase_awk_val_t* left, * res, * res2;
|
||||||
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
exp->type == ASE_AWK_NDE_EXP_INCPST);
|
exp->type == ASE_AWK_NDE_EXP_INCPST);
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
||||||
|
|
||||||
/* this way of checking if the l-value is assignable is
|
/* this way of checking if the l-value is assignable is
|
||||||
@ -4881,7 +4881,7 @@ static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, exp->left->next == ASE_NULL);
|
ASE_ASSERT (exp->left->next == ASE_NULL);
|
||||||
left = __eval_expression (run, exp->left);
|
left = __eval_expression (run, exp->left);
|
||||||
if (left == ASE_NULL) return ASE_NULL;
|
if (left == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
@ -4971,7 +4971,7 @@ static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else /* if (n == 1) */
|
else /* if (n == 1) */
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, n == 1);
|
ASE_ASSERT (n == 1);
|
||||||
res = ase_awk_makerealval (run, v2);
|
res = ase_awk_makerealval (run, v2);
|
||||||
if (res == ASE_NULL)
|
if (res == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -5077,7 +5077,7 @@ static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else /* if (n == 1) */
|
else /* if (n == 1) */
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, n == 1);
|
ASE_ASSERT (n == 1);
|
||||||
res = ase_awk_makerealval (run, v2);
|
res = ase_awk_makerealval (run, v2);
|
||||||
if (res == ASE_NULL)
|
if (res == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -5102,7 +5102,7 @@ static ase_awk_val_t* __eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
!"should never happen - invalid opcode");
|
!"should never happen - invalid opcode");
|
||||||
ase_awk_refdownval (run, left);
|
ase_awk_refdownval (run, left);
|
||||||
|
|
||||||
@ -5126,14 +5126,14 @@ static ase_awk_val_t* __eval_cnd (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
ase_awk_val_t* tv, * v;
|
ase_awk_val_t* tv, * v;
|
||||||
ase_awk_nde_cnd_t* cnd = (ase_awk_nde_cnd_t*)nde;
|
ase_awk_nde_cnd_t* cnd = (ase_awk_nde_cnd_t*)nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, cnd->test->next == ASE_NULL);
|
ASE_ASSERT (cnd->test->next == ASE_NULL);
|
||||||
|
|
||||||
tv = __eval_expression (run, cnd->test);
|
tv = __eval_expression (run, cnd->test);
|
||||||
if (tv == ASE_NULL) return ASE_NULL;
|
if (tv == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
ase_awk_refupval (run, tv);
|
ase_awk_refupval (run, tv);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
cnd->left->next == ASE_NULL &&
|
cnd->left->next == ASE_NULL &&
|
||||||
cnd->right->next == ASE_NULL);
|
cnd->right->next == ASE_NULL);
|
||||||
v = (ase_awk_valtobool (run, tv))?
|
v = (ase_awk_valtobool (run, tv))?
|
||||||
@ -5187,7 +5187,7 @@ static ase_awk_val_t* __eval_afn (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
}
|
}
|
||||||
|
|
||||||
afn = (ase_awk_afn_t*)pair->val;
|
afn = (ase_awk_afn_t*)pair->val;
|
||||||
ASE_AWK_ASSERT (run->awk, afn != ASE_NULL);
|
ASE_ASSERT (afn != ASE_NULL);
|
||||||
|
|
||||||
if (call->nargs > afn->nargs)
|
if (call->nargs > afn->nargs)
|
||||||
{
|
{
|
||||||
@ -5272,9 +5272,9 @@ static ase_awk_val_t* __eval_call (
|
|||||||
* ---------------------
|
* ---------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
ASE_SIZEOF(void*) >= ASE_SIZEOF(run->stack_top));
|
ASE_SIZEOF(void*) >= ASE_SIZEOF(run->stack_top));
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
ASE_SIZEOF(void*) >= ASE_SIZEOF(run->stack_base));
|
ASE_SIZEOF(void*) >= ASE_SIZEOF(run->stack_base));
|
||||||
|
|
||||||
saved_stack_top = run->stack_top;
|
saved_stack_top = run->stack_top;
|
||||||
@ -5325,7 +5325,7 @@ static ase_awk_val_t* __eval_call (
|
|||||||
*/
|
*/
|
||||||
for (p = call->args, nargs = 0; p != ASE_NULL; p = p->next, nargs++)
|
for (p = call->args, nargs = 0; p != ASE_NULL; p = p->next, nargs++)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
bfn_arg_spec == ASE_NULL ||
|
bfn_arg_spec == ASE_NULL ||
|
||||||
(bfn_arg_spec != ASE_NULL &&
|
(bfn_arg_spec != ASE_NULL &&
|
||||||
ase_strlen(bfn_arg_spec) > nargs));
|
ase_strlen(bfn_arg_spec) > nargs));
|
||||||
@ -5383,7 +5383,7 @@ static ase_awk_val_t* __eval_call (
|
|||||||
/*nargs++; p = p->next;*/
|
/*nargs++; p = p->next;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nargs == call->nargs);
|
ASE_ASSERT (nargs == call->nargs);
|
||||||
|
|
||||||
if (afn != ASE_NULL)
|
if (afn != ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -5414,7 +5414,7 @@ static ase_awk_val_t* __eval_call (
|
|||||||
if (afn != ASE_NULL)
|
if (afn != ASE_NULL)
|
||||||
{
|
{
|
||||||
/* normal awk function */
|
/* normal awk function */
|
||||||
ASE_AWK_ASSERT (run->awk, afn->body->type == ASE_AWK_NDE_BLK);
|
ASE_ASSERT (afn->body->type == ASE_AWK_NDE_BLK);
|
||||||
n = __run_block(run,(ase_awk_nde_blk_t*)afn->body);
|
n = __run_block(run,(ase_awk_nde_blk_t*)afn->body);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -5422,7 +5422,7 @@ static ase_awk_val_t* __eval_call (
|
|||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
/* built-in function */
|
/* built-in function */
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
call->nargs >= call->what.bfn.arg.min &&
|
call->nargs >= call->what.bfn.arg.min &&
|
||||||
call->nargs <= call->what.bfn.arg.max);
|
call->nargs <= call->what.bfn.arg.max);
|
||||||
|
|
||||||
@ -5616,7 +5616,7 @@ static ase_awk_val_t** __get_reference_indexed (
|
|||||||
ase_char_t* str;
|
ase_char_t* str;
|
||||||
ase_size_t len;
|
ase_size_t len;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, val != ASE_NULL);
|
ASE_ASSERT (val != ASE_NULL);
|
||||||
|
|
||||||
if ((*val)->type == ASE_AWK_VAL_NIL)
|
if ((*val)->type == ASE_AWK_VAL_NIL)
|
||||||
{
|
{
|
||||||
@ -5641,7 +5641,7 @@ static ase_awk_val_t** __get_reference_indexed (
|
|||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nde->idx != ASE_NULL);
|
ASE_ASSERT (nde->idx != ASE_NULL);
|
||||||
|
|
||||||
str = __idxnde_to_str (run, nde->idx, &len);
|
str = __idxnde_to_str (run, nde->idx, &len);
|
||||||
if (str == ASE_NULL) return ASE_NULL;
|
if (str == ASE_NULL) return ASE_NULL;
|
||||||
@ -5767,7 +5767,7 @@ static ase_awk_val_t* __eval_indexed (
|
|||||||
ase_char_t* str;
|
ase_char_t* str;
|
||||||
ase_size_t len;
|
ase_size_t len;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, val != ASE_NULL);
|
ASE_ASSERT (val != ASE_NULL);
|
||||||
|
|
||||||
if ((*val)->type == ASE_AWK_VAL_NIL)
|
if ((*val)->type == ASE_AWK_VAL_NIL)
|
||||||
{
|
{
|
||||||
@ -5792,7 +5792,7 @@ static ase_awk_val_t* __eval_indexed (
|
|||||||
return ASE_NULL;
|
return ASE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nde->idx != ASE_NULL);
|
ASE_ASSERT (nde->idx != ASE_NULL);
|
||||||
|
|
||||||
str = __idxnde_to_str (run, nde->idx, &len);
|
str = __idxnde_to_str (run, nde->idx, &len);
|
||||||
if (str == ASE_NULL) return ASE_NULL;
|
if (str == ASE_NULL) return ASE_NULL;
|
||||||
@ -5891,7 +5891,7 @@ static ase_awk_val_t* __eval_getline (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
|||||||
|
|
||||||
p = (ase_awk_nde_getline_t*)nde;
|
p = (ase_awk_nde_getline_t*)nde;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk,
|
ASE_ASSERT (
|
||||||
(p->in_type == ASE_AWK_IN_PIPE && p->in != ASE_NULL) ||
|
(p->in_type == ASE_AWK_IN_PIPE && p->in != ASE_NULL) ||
|
||||||
(p->in_type == ASE_AWK_IN_COPROC && p->in != ASE_NULL) ||
|
(p->in_type == ASE_AWK_IN_COPROC && p->in != ASE_NULL) ||
|
||||||
(p->in_type == ASE_AWK_IN_FILE && p->in != ASE_NULL) ||
|
(p->in_type == ASE_AWK_IN_FILE && p->in != ASE_NULL) ||
|
||||||
@ -6095,7 +6095,7 @@ static int __read_record (ase_awk_run_t* run)
|
|||||||
#endif
|
#endif
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (run->awk, ASE_STR_LEN(&run->inrec.line) == 0);
|
ASE_ASSERT (ASE_STR_LEN(&run->inrec.line) == 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6113,7 +6113,7 @@ static int __shorten_record (ase_awk_run_t* run, ase_size_t nflds)
|
|||||||
ase_size_t ofs_len, i;
|
ase_size_t ofs_len, i;
|
||||||
ase_str_t tmp;
|
ase_str_t tmp;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nflds <= run->inrec.nflds);
|
ASE_ASSERT (nflds <= run->inrec.nflds);
|
||||||
|
|
||||||
if (nflds > 1)
|
if (nflds > 1)
|
||||||
{
|
{
|
||||||
@ -6209,7 +6209,7 @@ static ase_char_t* __idxnde_to_str (
|
|||||||
ase_char_t* str;
|
ase_char_t* str;
|
||||||
ase_awk_val_t* idx;
|
ase_awk_val_t* idx;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nde != ASE_NULL);
|
ASE_ASSERT (nde != ASE_NULL);
|
||||||
|
|
||||||
if (nde->next == ASE_NULL)
|
if (nde->next == ASE_NULL)
|
||||||
{
|
{
|
||||||
@ -6332,7 +6332,7 @@ ase_char_t* ase_awk_format (
|
|||||||
if ((buf)->ptr == ASE_NULL) (buf)->len = 0; \
|
if ((buf)->ptr == ASE_NULL) (buf)->len = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk, run->format.tmp.ptr != ASE_NULL,
|
ASE_ASSERTX (run->format.tmp.ptr != ASE_NULL,
|
||||||
"run->format.tmp.ptr should have been assigned a pointer to a block of memory before this function has been called");
|
"run->format.tmp.ptr should have been assigned a pointer to a block of memory before this function has been called");
|
||||||
|
|
||||||
if (nargs_on_stack == (ase_size_t)-1)
|
if (nargs_on_stack == (ase_size_t)-1)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: tab.c,v 1.31 2007-02-23 08:17:51 bacon Exp $
|
* $Id: tab.c,v 1.32 2007-03-06 14:51:53 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -55,7 +55,7 @@ ase_awk_tab_t* ase_awk_tab_setcapa (ase_awk_tab_t* tab, ase_size_t capa)
|
|||||||
if (tab->size > capa)
|
if (tab->size > capa)
|
||||||
{
|
{
|
||||||
ase_awk_tab_remove (tab, capa, tab->size - capa);
|
ase_awk_tab_remove (tab, capa, tab->size - capa);
|
||||||
ASE_AWK_ASSERT (tab->awk, tab->size <= capa);
|
ASE_ASSERT (tab->size <= capa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capa > 0)
|
if (capa > 0)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: tree.c,v 1.105 2007-03-04 06:26:45 bacon Exp $
|
* $Id: tree.c,v 1.106 2007-03-06 14:51:53 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -154,7 +154,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
PUT_SRCSTR (awk, ASE_T(" "));
|
PUT_SRCSTR (awk, ASE_T(" "));
|
||||||
PRINT_EXPRESSION (awk, px->right);
|
PRINT_EXPRESSION (awk, px->right);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, px->right->next == ASE_NULL);
|
ASE_ASSERT (px->right->next == ASE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
|
|
||||||
PUT_SRCSTR (awk, ASE_T("("));
|
PUT_SRCSTR (awk, ASE_T("("));
|
||||||
PRINT_EXPRESSION (awk, px->left);
|
PRINT_EXPRESSION (awk, px->left);
|
||||||
ASE_AWK_ASSERT (awk, px->left->next == ASE_NULL);
|
ASE_ASSERT (px->left->next == ASE_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, ASE_T(" "));
|
PUT_SRCSTR (awk, ASE_T(" "));
|
||||||
PUT_SRCSTR (awk, __binop_str[px->opcode]);
|
PUT_SRCSTR (awk, __binop_str[px->opcode]);
|
||||||
@ -175,7 +175,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
PRINT_EXPRESSION (awk, px->right);
|
PRINT_EXPRESSION (awk, px->right);
|
||||||
if (px->right->type == ASE_AWK_NDE_ASS)
|
if (px->right->type == ASE_AWK_NDE_ASS)
|
||||||
PUT_SRCSTR (awk, ASE_T(")"));
|
PUT_SRCSTR (awk, ASE_T(")"));
|
||||||
ASE_AWK_ASSERT (awk, px->right->next == ASE_NULL);
|
ASE_ASSERT (px->right->next == ASE_NULL);
|
||||||
PUT_SRCSTR (awk, ASE_T(")"));
|
PUT_SRCSTR (awk, ASE_T(")"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
case ASE_AWK_NDE_EXP_UNR:
|
case ASE_AWK_NDE_EXP_UNR:
|
||||||
{
|
{
|
||||||
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde;
|
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde;
|
||||||
ASE_AWK_ASSERT (awk, px->right == ASE_NULL);
|
ASE_ASSERT (px->right == ASE_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, ASE_T("("));
|
PUT_SRCSTR (awk, ASE_T("("));
|
||||||
PUT_SRCSTR (awk, __unrop_str[px->opcode]);
|
PUT_SRCSTR (awk, __unrop_str[px->opcode]);
|
||||||
@ -197,7 +197,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
case ASE_AWK_NDE_EXP_INCPRE:
|
case ASE_AWK_NDE_EXP_INCPRE:
|
||||||
{
|
{
|
||||||
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde;
|
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde;
|
||||||
ASE_AWK_ASSERT (awk, px->right == ASE_NULL);
|
ASE_ASSERT (px->right == ASE_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, __incop_str[px->opcode]);
|
PUT_SRCSTR (awk, __incop_str[px->opcode]);
|
||||||
PUT_SRCSTR (awk, ASE_T("("));
|
PUT_SRCSTR (awk, ASE_T("("));
|
||||||
@ -209,7 +209,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
case ASE_AWK_NDE_EXP_INCPST:
|
case ASE_AWK_NDE_EXP_INCPST:
|
||||||
{
|
{
|
||||||
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde;
|
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)nde;
|
||||||
ASE_AWK_ASSERT (awk, px->right == ASE_NULL);
|
ASE_ASSERT (px->right == ASE_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, ASE_T("("));
|
PUT_SRCSTR (awk, ASE_T("("));
|
||||||
PRINT_EXPRESSION (awk, px->left);
|
PRINT_EXPRESSION (awk, px->left);
|
||||||
@ -327,7 +327,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
ase_char_t tmp[ASE_SIZEOF(ase_long_t)*8+2];
|
ase_char_t tmp[ASE_SIZEOF(ase_long_t)*8+2];
|
||||||
ase_size_t n;
|
ase_size_t n;
|
||||||
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
||||||
ASE_AWK_ASSERT (awk, px->id.idxa != (ase_size_t)-1);
|
ASE_ASSERT (px->id.idxa != (ase_size_t)-1);
|
||||||
|
|
||||||
n = ase_awk_longtostr (
|
n = ase_awk_longtostr (
|
||||||
px->id.idxa, 10, ASE_NULL, tmp, ASE_COUNTOF(tmp));
|
px->id.idxa, 10, ASE_NULL, tmp, ASE_COUNTOF(tmp));
|
||||||
@ -335,7 +335,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
PUT_SRCSTR (awk, ASE_T("__param"));
|
PUT_SRCSTR (awk, ASE_T("__param"));
|
||||||
PUT_SRCSTRX (awk, tmp, n);
|
PUT_SRCSTRX (awk, tmp, n);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, px->idx == ASE_NULL);
|
ASE_ASSERT (px->idx == ASE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,8 +343,8 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
{
|
{
|
||||||
ase_size_t n;
|
ase_size_t n;
|
||||||
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
||||||
ASE_AWK_ASSERT (awk, px->id.idxa != (ase_size_t)-1);
|
ASE_ASSERT (px->id.idxa != (ase_size_t)-1);
|
||||||
ASE_AWK_ASSERT (awk, px->idx != ASE_NULL);
|
ASE_ASSERT (px->idx != ASE_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, ASE_T("__param"));
|
PUT_SRCSTR (awk, ASE_T("__param"));
|
||||||
n = ase_awk_longtostr (
|
n = ase_awk_longtostr (
|
||||||
@ -360,8 +360,8 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
case ASE_AWK_NDE_NAMED:
|
case ASE_AWK_NDE_NAMED:
|
||||||
{
|
{
|
||||||
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
||||||
ASE_AWK_ASSERT (awk, px->id.idxa == (ase_size_t)-1);
|
ASE_ASSERT (px->id.idxa == (ase_size_t)-1);
|
||||||
ASE_AWK_ASSERT (awk, px->idx == ASE_NULL);
|
ASE_ASSERT (px->idx == ASE_NULL);
|
||||||
|
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
break;
|
break;
|
||||||
@ -370,8 +370,8 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
case ASE_AWK_NDE_NAMEDIDX:
|
case ASE_AWK_NDE_NAMEDIDX:
|
||||||
{
|
{
|
||||||
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)nde;
|
||||||
ASE_AWK_ASSERT (awk, px->id.idxa == (ase_size_t)-1);
|
ASE_ASSERT (px->id.idxa == (ase_size_t)-1);
|
||||||
ASE_AWK_ASSERT (awk, px->idx != ASE_NULL);
|
ASE_ASSERT (px->idx != ASE_NULL);
|
||||||
|
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
PUT_SRCSTR (awk, ASE_T("["));
|
PUT_SRCSTR (awk, ASE_T("["));
|
||||||
@ -401,7 +401,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
{
|
{
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
}
|
}
|
||||||
ASE_AWK_ASSERT (awk, px->idx == ASE_NULL);
|
ASE_ASSERT (px->idx == ASE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
PUT_SRCSTR (awk, ASE_T("["));
|
PUT_SRCSTR (awk, ASE_T("["));
|
||||||
}
|
}
|
||||||
ASE_AWK_ASSERT (awk, px->idx != ASE_NULL);
|
ASE_ASSERT (px->idx != ASE_NULL);
|
||||||
PRINT_EXPRESSION_LIST (awk, px->idx);
|
PRINT_EXPRESSION_LIST (awk, px->idx);
|
||||||
PUT_SRCSTR (awk, ASE_T("]"));
|
PUT_SRCSTR (awk, ASE_T("]"));
|
||||||
break;
|
break;
|
||||||
@ -451,7 +451,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
{
|
{
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
}
|
}
|
||||||
ASE_AWK_ASSERT (awk, px->idx == ASE_NULL);
|
ASE_ASSERT (px->idx == ASE_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
|||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
PUT_SRCSTR (awk, ASE_T("["));
|
PUT_SRCSTR (awk, ASE_T("["));
|
||||||
}
|
}
|
||||||
ASE_AWK_ASSERT (awk, px->idx != ASE_NULL);
|
ASE_ASSERT (px->idx != ASE_NULL);
|
||||||
PRINT_EXPRESSION_LIST (awk, px->idx);
|
PRINT_EXPRESSION_LIST (awk, px->idx);
|
||||||
PUT_SRCSTR (awk, ASE_T("]"));
|
PUT_SRCSTR (awk, ASE_T("]"));
|
||||||
break;
|
break;
|
||||||
@ -631,7 +631,7 @@ static int __print_statements (ase_awk_t* awk, ase_awk_nde_t* tree, int depth)
|
|||||||
PUT_SRCSTR (awk, ASE_T(")"));
|
PUT_SRCSTR (awk, ASE_T(")"));
|
||||||
PUT_NEWLINE (awk);
|
PUT_NEWLINE (awk);
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk, px->then_part != ASE_NULL);
|
ASE_ASSERT (px->then_part != ASE_NULL);
|
||||||
if (px->then_part->type == ASE_AWK_NDE_BLK)
|
if (px->then_part->type == ASE_AWK_NDE_BLK)
|
||||||
PRINT_STATEMENTS (awk, px->then_part, depth);
|
PRINT_STATEMENTS (awk, px->then_part, depth);
|
||||||
else
|
else
|
||||||
@ -774,7 +774,7 @@ static int __print_statements (ase_awk_t* awk, ase_awk_nde_t* tree, int depth)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PUT_SRCSTR (awk, ASE_T("return "));
|
PUT_SRCSTR (awk, ASE_T("return "));
|
||||||
ASE_AWK_ASSERT (awk, ((ase_awk_nde_return_t*)p)->val->next == ASE_NULL);
|
ASE_ASSERT (((ase_awk_nde_return_t*)p)->val->next == ASE_NULL);
|
||||||
|
|
||||||
PRINT_EXPRESSION (awk, ((ase_awk_nde_return_t*)p)->val);
|
PRINT_EXPRESSION (awk, ((ase_awk_nde_return_t*)p)->val);
|
||||||
PUT_SRCSTR (awk, ASE_T(";"));
|
PUT_SRCSTR (awk, ASE_T(";"));
|
||||||
@ -796,7 +796,7 @@ static int __print_statements (ase_awk_t* awk, ase_awk_nde_t* tree, int depth)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PUT_SRCSTR (awk, ASE_T("exit "));
|
PUT_SRCSTR (awk, ASE_T("exit "));
|
||||||
ASE_AWK_ASSERT (awk, px->val->next == ASE_NULL);
|
ASE_ASSERT (px->val->next == ASE_NULL);
|
||||||
PRINT_EXPRESSION (awk, px->val);
|
PRINT_EXPRESSION (awk, px->val);
|
||||||
PUT_SRCSTR (awk, ASE_T(";"));
|
PUT_SRCSTR (awk, ASE_T(";"));
|
||||||
PUT_NEWLINE (awk);
|
PUT_NEWLINE (awk);
|
||||||
@ -1037,8 +1037,8 @@ void ase_awk_clrpt (ase_awk_t* awk, ase_awk_nde_t* tree)
|
|||||||
case ASE_AWK_NDE_EXP_BIN:
|
case ASE_AWK_NDE_EXP_BIN:
|
||||||
{
|
{
|
||||||
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)p;
|
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)p;
|
||||||
ASE_AWK_ASSERT (awk, px->left->next == ASE_NULL);
|
ASE_ASSERT (px->left->next == ASE_NULL);
|
||||||
ASE_AWK_ASSERT (awk, px->right->next == ASE_NULL);
|
ASE_ASSERT (px->right->next == ASE_NULL);
|
||||||
|
|
||||||
ase_awk_clrpt (awk, px->left);
|
ase_awk_clrpt (awk, px->left);
|
||||||
ase_awk_clrpt (awk, px->right);
|
ase_awk_clrpt (awk, px->right);
|
||||||
@ -1051,7 +1051,7 @@ void ase_awk_clrpt (ase_awk_t* awk, ase_awk_nde_t* tree)
|
|||||||
case ASE_AWK_NDE_EXP_INCPST:
|
case ASE_AWK_NDE_EXP_INCPST:
|
||||||
{
|
{
|
||||||
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)p;
|
ase_awk_nde_exp_t* px = (ase_awk_nde_exp_t*)p;
|
||||||
ASE_AWK_ASSERT (awk, px->right == ASE_NULL);
|
ASE_ASSERT (px->right == ASE_NULL);
|
||||||
ase_awk_clrpt (awk, px->left);
|
ase_awk_clrpt (awk, px->left);
|
||||||
ASE_AWK_FREE (awk, p);
|
ASE_AWK_FREE (awk, p);
|
||||||
break;
|
break;
|
||||||
@ -1103,7 +1103,7 @@ void ase_awk_clrpt (ase_awk_t* awk, ase_awk_nde_t* tree)
|
|||||||
case ASE_AWK_NDE_ARG:
|
case ASE_AWK_NDE_ARG:
|
||||||
{
|
{
|
||||||
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)p;
|
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)p;
|
||||||
ASE_AWK_ASSERT (awk, px->idx == ASE_NULL);
|
ASE_ASSERT (px->idx == ASE_NULL);
|
||||||
if (px->id.name != ASE_NULL)
|
if (px->id.name != ASE_NULL)
|
||||||
ASE_AWK_FREE (awk, px->id.name);
|
ASE_AWK_FREE (awk, px->id.name);
|
||||||
ASE_AWK_FREE (awk, p);
|
ASE_AWK_FREE (awk, p);
|
||||||
@ -1116,7 +1116,7 @@ void ase_awk_clrpt (ase_awk_t* awk, ase_awk_nde_t* tree)
|
|||||||
case ASE_AWK_NDE_ARGIDX:
|
case ASE_AWK_NDE_ARGIDX:
|
||||||
{
|
{
|
||||||
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)p;
|
ase_awk_nde_var_t* px = (ase_awk_nde_var_t*)p;
|
||||||
ASE_AWK_ASSERT (awk, px->idx != ASE_NULL);
|
ASE_ASSERT (px->idx != ASE_NULL);
|
||||||
ase_awk_clrpt (awk, px->idx);
|
ase_awk_clrpt (awk, px->idx);
|
||||||
if (px->id.name != ASE_NULL)
|
if (px->id.name != ASE_NULL)
|
||||||
ASE_AWK_FREE (awk, px->id.name);
|
ASE_AWK_FREE (awk, px->id.name);
|
||||||
@ -1163,7 +1163,7 @@ void ase_awk_clrpt (ase_awk_t* awk, ase_awk_nde_t* tree)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERT (awk, !"should never happen - invalid node type");
|
ASE_ASSERT (!"should never happen - invalid node type");
|
||||||
ASE_AWK_FREE (awk, p);
|
ASE_AWK_FREE (awk, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: val.c,v 1.113 2007-03-02 11:14:34 bacon Exp $
|
* $Id: val.c,v 1.114 2007-03-06 14:51:53 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -347,7 +347,7 @@ void ase_awk_freeval (ase_awk_run_t* run, ase_awk_val_t* val, ase_bool_t cache)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERTX (run->awk,
|
ASE_ASSERTX (
|
||||||
!"should never happen - invalid value type",
|
!"should never happen - invalid value type",
|
||||||
"the type of a value should be one of ASE_AWK_VAL_XXX's defined in val.h");
|
"the type of a value should be one of ASE_AWK_VAL_XXX's defined in val.h");
|
||||||
}
|
}
|
||||||
@ -376,7 +376,7 @@ void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val)
|
|||||||
ase_dprintf (ASE_T("\n"));
|
ase_dprintf (ASE_T("\n"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk, val->ref > 0,
|
ASE_ASSERTX (val->ref > 0,
|
||||||
"the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs");
|
"the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs");
|
||||||
|
|
||||||
val->ref--;
|
val->ref--;
|
||||||
@ -390,7 +390,7 @@ void ase_awk_refdownval_nofree (ase_awk_run_t* run, ase_awk_val_t* val)
|
|||||||
{
|
{
|
||||||
if (ase_awk_isbuiltinval(val)) return;
|
if (ase_awk_isbuiltinval(val)) return;
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk, val->ref > 0,
|
ASE_ASSERTX (val->ref > 0,
|
||||||
"the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs");
|
"the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs");
|
||||||
val->ref--;
|
val->ref--;
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ ase_bool_t ase_awk_valtobool (ase_awk_run_t* run, ase_awk_val_t* val)
|
|||||||
return ase_false; /* TODO: is this correct? */
|
return ase_false; /* TODO: is this correct? */
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERTX (run->awk,
|
ASE_ASSERTX (
|
||||||
!"should never happen - invalid value type",
|
!"should never happen - invalid value type",
|
||||||
"the type of a value should be one of ASE_AWK_VAL_XXX's defined in val.h");
|
"the type of a value should be one of ASE_AWK_VAL_XXX's defined in val.h");
|
||||||
return ase_false;
|
return ase_false;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: macros.h,v 1.2 2007-03-06 14:29:04 bacon Exp $
|
* $Id: macros.h,v 1.3 2007-03-06 14:54:49 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -97,8 +97,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define ASE_ASSERT(awk,expr) ((void)0)
|
#define ASE_ASSERT(expr) ((void)0)
|
||||||
#define ASE_ASSERTX(awk,expr,desc) ((void)0)
|
#define ASE_ASSERTX(expr,desc) ((void)0)
|
||||||
#else
|
#else
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -112,9 +112,9 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ASE_ASSERT(awk,expr) (void)((expr) || \
|
#define ASE_ASSERT(expr) (void)((expr) || \
|
||||||
(ase_assert_failed (ASE_T(#expr), ASE_NULL, ASE_T(__FILE__), __LINE__), 0))
|
(ase_assert_failed (ASE_T(#expr), ASE_NULL, ASE_T(__FILE__), __LINE__), 0))
|
||||||
#define ASE_ASSERTX(awk,expr,desc) (void)((expr) || \
|
#define ASE_ASSERTX(expr,desc) (void)((expr) || \
|
||||||
(ase_assert_failed (ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
|
(ase_assert_failed (ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.cpp,v 1.26 2007-02-24 14:32:44 bacon Exp $
|
* $Id: Awk.cpp,v 1.27 2007-03-06 14:54:49 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -92,6 +92,27 @@ CAwk::~CAwk ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
void ase_assert_dprintf (void)
|
||||||
|
{
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ase_assert_dprintf (const ase_char_t* fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
int n;
|
||||||
|
ase_char_t buf[1024];
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
|
||||||
|
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
|
||||||
|
|
||||||
|
MessageBox (NULL, buf, ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR);
|
||||||
|
va_end (ap);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void* custom_awk_malloc (void* custom, ase_size_t n)
|
static void* custom_awk_malloc (void* custom, ase_size_t n)
|
||||||
{
|
{
|
||||||
return malloc (n);
|
return malloc (n);
|
||||||
@ -177,11 +198,6 @@ static ase_real_t custom_awk_pow (void* custom, ase_real_t x, ase_real_t y)
|
|||||||
return pow (x, y);
|
return pow (x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void custom_awk_abort (void* custom)
|
|
||||||
{
|
|
||||||
abort ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int custom_awk_sprintf (
|
static int custom_awk_sprintf (
|
||||||
void* custom, ase_char_t* buf, ase_size_t size,
|
void* custom, ase_char_t* buf, ase_size_t size,
|
||||||
@ -197,20 +213,6 @@ static int custom_awk_sprintf (
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void custom_awk_aprintf (void* custom, const ase_char_t* fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int n;
|
|
||||||
ase_char_t buf[1024];
|
|
||||||
|
|
||||||
va_start (ap, fmt);
|
|
||||||
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
|
|
||||||
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
|
|
||||||
|
|
||||||
MessageBox (NULL, buf, ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR);
|
|
||||||
va_end (ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void custom_awk_dprintf (void* custom, const ase_char_t* fmt, ...)
|
static void custom_awk_dprintf (void* custom, const ase_char_t* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -261,8 +263,7 @@ static ase_ssize_t __read_source (
|
|||||||
awk->read_src_len = n;
|
awk->read_src_len = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk->handle,
|
ASE_ASSERT (awk->read_src_pos < awk->read_src_len);
|
||||||
awk->read_src_pos < awk->read_src_len);
|
|
||||||
|
|
||||||
BSTR str = tmp->str;
|
BSTR str = tmp->str;
|
||||||
INT left = awk->read_src_len - awk->read_src_pos;
|
INT left = awk->read_src_len - awk->read_src_pos;
|
||||||
@ -652,7 +653,7 @@ static ase_ssize_t __process_extio (
|
|||||||
extio = (IAwkExtio*)epa->handle;
|
extio = (IAwkExtio*)epa->handle;
|
||||||
extio2 = (CAwkExtio*)extio;
|
extio2 = (CAwkExtio*)extio;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
|
ASE_ASSERT (extio != NULL);
|
||||||
|
|
||||||
INT n = awk->Fire_CloseExtio (extio);
|
INT n = awk->Fire_CloseExtio (extio);
|
||||||
if (n >= 0)
|
if (n >= 0)
|
||||||
@ -672,7 +673,7 @@ static ase_ssize_t __process_extio (
|
|||||||
extio = (IAwkExtio*)epa->handle;
|
extio = (IAwkExtio*)epa->handle;
|
||||||
extio2 = (CAwkExtio*)extio;
|
extio2 = (CAwkExtio*)extio;
|
||||||
|
|
||||||
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
|
ASE_ASSERT (extio != NULL);
|
||||||
|
|
||||||
CBuffer* tmp = (CBuffer*)extio2->read_buf;
|
CBuffer* tmp = (CBuffer*)extio2->read_buf;
|
||||||
if (extio2->read_buf_pos >= extio2->read_buf_len)
|
if (extio2->read_buf_pos >= extio2->read_buf_len)
|
||||||
@ -685,8 +686,7 @@ static ase_ssize_t __process_extio (
|
|||||||
extio2->read_buf_len = n;
|
extio2->read_buf_len = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (awk->handle,
|
ASE_ASSERT (extio2->read_buf_pos < extio2->read_buf_len);
|
||||||
extio2->read_buf_pos < extio2->read_buf_len);
|
|
||||||
|
|
||||||
BSTR str = tmp->str;
|
BSTR str = tmp->str;
|
||||||
INT left = extio2->read_buf_len - extio2->read_buf_pos;
|
INT left = extio2->read_buf_len - extio2->read_buf_pos;
|
||||||
@ -712,7 +712,7 @@ static ase_ssize_t __process_extio (
|
|||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IAwkExtio* extio = (IAwkExtio*)epa->handle;
|
IAwkExtio* extio = (IAwkExtio*)epa->handle;
|
||||||
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
|
ASE_ASSERT (extio != NULL);
|
||||||
|
|
||||||
if (awk->write_extio_buf == NULL)
|
if (awk->write_extio_buf == NULL)
|
||||||
{
|
{
|
||||||
@ -736,13 +736,13 @@ static ase_ssize_t __process_extio (
|
|||||||
else if (cmd == ASE_AWK_IO_FLUSH)
|
else if (cmd == ASE_AWK_IO_FLUSH)
|
||||||
{
|
{
|
||||||
IAwkExtio* extio = (IAwkExtio*)epa->handle;
|
IAwkExtio* extio = (IAwkExtio*)epa->handle;
|
||||||
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
|
ASE_ASSERT (extio != NULL);
|
||||||
return awk->Fire_FlushExtio (extio);
|
return awk->Fire_FlushExtio (extio);
|
||||||
}
|
}
|
||||||
else if (cmd == ASE_AWK_IO_NEXT)
|
else if (cmd == ASE_AWK_IO_NEXT)
|
||||||
{
|
{
|
||||||
IAwkExtio* extio = (IAwkExtio*)epa->handle;
|
IAwkExtio* extio = (IAwkExtio*)epa->handle;
|
||||||
ASE_AWK_ASSERT (ase_awk_getrunawk(epa->run), extio != NULL);
|
ASE_ASSERT (extio != NULL);
|
||||||
return awk->Fire_NextExtio (extio);
|
return awk->Fire_NextExtio (extio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: env.c,v 1.16 2007-02-11 07:36:54 bacon Exp $
|
* $Id: env.c,v 1.17 2007-03-06 14:58:00 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -69,7 +69,7 @@ ase_lsp_assoc_t* ase_lsp_lookupinframe (
|
|||||||
{
|
{
|
||||||
ase_lsp_assoc_t* assoc;
|
ase_lsp_assoc_t* assoc;
|
||||||
|
|
||||||
ASE_LSP_ASSERT (lsp, ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM);
|
ASE_ASSERT (ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM);
|
||||||
|
|
||||||
assoc = frame->assoc;
|
assoc = frame->assoc;
|
||||||
while (assoc != ASE_NULL)
|
while (assoc != ASE_NULL)
|
||||||
@ -86,7 +86,7 @@ ase_lsp_assoc_t* ase_lsp_insvalueintoframe (
|
|||||||
{
|
{
|
||||||
ase_lsp_assoc_t* assoc;
|
ase_lsp_assoc_t* assoc;
|
||||||
|
|
||||||
ASE_LSP_ASSERT (lsp, ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM);
|
ASE_ASSERT (ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM);
|
||||||
|
|
||||||
assoc = __new_assoc (lsp, name, value, ASE_NULL);
|
assoc = __new_assoc (lsp, name, value, ASE_NULL);
|
||||||
if (assoc == ASE_NULL) return ASE_NULL;
|
if (assoc == ASE_NULL) return ASE_NULL;
|
||||||
@ -102,7 +102,7 @@ ase_lsp_assoc_t* ase_lsp_insfuncintoframe (
|
|||||||
{
|
{
|
||||||
ase_lsp_assoc_t* assoc;
|
ase_lsp_assoc_t* assoc;
|
||||||
|
|
||||||
ASE_LSP_ASSERT (lsp, ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM);
|
ASE_ASSERT (ASE_LSP_TYPE(name) == ASE_LSP_OBJ_SYM);
|
||||||
|
|
||||||
assoc = __new_assoc (lsp, name, ASE_NULL, func);
|
assoc = __new_assoc (lsp, name, ASE_NULL, func);
|
||||||
if (assoc == ASE_NULL) return ASE_NULL;
|
if (assoc == ASE_NULL) return ASE_NULL;
|
||||||
@ -136,7 +136,7 @@ void ase_lsp_poptmp (ase_lsp_t* lsp)
|
|||||||
{
|
{
|
||||||
ase_lsp_tlink_t* top;
|
ase_lsp_tlink_t* top;
|
||||||
|
|
||||||
ASE_LSP_ASSERT (lsp, lsp->mem->tlink != ASE_NULL);
|
ASE_ASSERT (lsp->mem->tlink != ASE_NULL);
|
||||||
|
|
||||||
top = lsp->mem->tlink;
|
top = lsp->mem->tlink;
|
||||||
lsp->mem->tlink = top->link;
|
lsp->mem->tlink = top->link;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: lsp.c,v 1.26 2007-02-24 14:32:11 bacon Exp $
|
* $Id: lsp.c,v 1.27 2007-03-06 14:58:00 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -40,9 +40,7 @@ ase_lsp_t* ase_lsp_open (
|
|||||||
prmfns->ccls.to_lower == ASE_NULL) return ASE_NULL;
|
prmfns->ccls.to_lower == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
if (prmfns->misc.sprintf == ASE_NULL ||
|
if (prmfns->misc.sprintf == ASE_NULL ||
|
||||||
prmfns->misc.aprintf == ASE_NULL ||
|
prmfns->misc.dprintf == ASE_NULL) return ASE_NULL;
|
||||||
prmfns->misc.dprintf == ASE_NULL ||
|
|
||||||
prmfns->misc.abort == ASE_NULL) return ASE_NULL;
|
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
||||||
lsp = (ase_lsp_t*) malloc (ASE_SIZEOF(ase_lsp_t));
|
lsp = (ase_lsp_t*) malloc (ASE_SIZEOF(ase_lsp_t));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: lsp.h,v 1.41 2007-03-06 14:16:53 bacon Exp $
|
* $Id: lsp.h,v 1.42 2007-03-06 14:58:00 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -22,9 +22,7 @@ typedef ase_real_t (*ase_lsp_pow_t) (
|
|||||||
typedef int (*ase_lsp_sprintf_t) (
|
typedef int (*ase_lsp_sprintf_t) (
|
||||||
void* custom, ase_char_t* buf, ase_size_t size,
|
void* custom, ase_char_t* buf, ase_size_t size,
|
||||||
const ase_char_t* fmt, ...);
|
const ase_char_t* fmt, ...);
|
||||||
typedef void (*ase_lsp_aprintf_t) (void* custom, const ase_char_t* fmt, ...);
|
|
||||||
typedef void (*ase_lsp_dprintf_t) (void* custom, const ase_char_t* fmt, ...);
|
typedef void (*ase_lsp_dprintf_t) (void* custom, const ase_char_t* fmt, ...);
|
||||||
typedef void (*ase_lsp_abort_t) (void* custom);
|
|
||||||
|
|
||||||
struct ase_lsp_prmfns_t
|
struct ase_lsp_prmfns_t
|
||||||
{
|
{
|
||||||
@ -35,9 +33,7 @@ struct ase_lsp_prmfns_t
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
ase_lsp_sprintf_t sprintf;
|
ase_lsp_sprintf_t sprintf;
|
||||||
ase_lsp_aprintf_t aprintf;
|
|
||||||
ase_lsp_dprintf_t dprintf;
|
ase_lsp_dprintf_t dprintf;
|
||||||
ase_lsp_abort_t abort;
|
|
||||||
void* custom_data;
|
void* custom_data;
|
||||||
} misc;
|
} misc;
|
||||||
};
|
};
|
||||||
@ -88,17 +84,6 @@ enum
|
|||||||
|
|
||||||
typedef ase_lsp_obj_t* (*ase_lsp_prim_t) (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
typedef ase_lsp_obj_t* (*ase_lsp_prim_t) (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
||||||
|
|
||||||
/* assertion statement */
|
|
||||||
#ifdef NDEBUG
|
|
||||||
#define ASE_LSP_ASSERT(lsp,expr) ((void)0)
|
|
||||||
#define ASE_LSP_ASSERTX(lsp,expr,desc) ((void)0)
|
|
||||||
#else
|
|
||||||
#define ASE_LSP_ASSERT(lsp,expr) (void)((expr) || \
|
|
||||||
(ase_lsp_assertfail (lsp, ASE_T(#expr), ASE_NULL, ASE_T(__FILE__), __LINE__), 0))
|
|
||||||
#define ASE_LSP_ASSERTX(lsp,expr,desc) (void)((expr) || \
|
|
||||||
(ase_lsp_assertfail (lsp, ASE_T(#expr), ASE_T(desc), ASE_T(__FILE__), __LINE__), 0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,7 +4,7 @@ OBJS = $(SRCS:.c=.o)
|
|||||||
CC = @CC@
|
CC = @CC@
|
||||||
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/..
|
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/..
|
||||||
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/cmn -L@abs_top_builddir@/awk -L@abs_top_builddir@/utl
|
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/cmn -L@abs_top_builddir@/awk -L@abs_top_builddir@/utl
|
||||||
LIBS = @LIBS@ -lasecmn -laseawk -lasecmn -laseutl -lm
|
LIBS = @LIBS@ -laseawk -lasecmn -laseutl -lm
|
||||||
|
|
||||||
all: aseawk
|
all: aseawk
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user