simplified assertion

This commit is contained in:
hyung-hwan 2019-12-21 16:59:00 +00:00
parent c23d902ad0
commit 476a800572
26 changed files with 604 additions and 447 deletions

View File

@ -1160,7 +1160,7 @@ static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
rtx = hawk_rtx_openstdwithbcstr(
awk, 0, "hawk",
(arg.call? HAWK_NULL: (const hawk_ooch_t**)arg.icf.ptr), /* console input */
(arg.call? HAWK_NULL: arg.icf.ptr), /* console input */
HAWK_NULL, /* console output */
arg.console_cmgr
);

View File

@ -117,6 +117,7 @@ libhawk_la_SOURCES = \
tree.c \
utf16.c \
utf8.c \
utl-ass.c \
utl-sort.c \
utl-str.c \
utl-sys.c \

View File

@ -171,7 +171,7 @@ am__libhawk_la_SOURCES_DIST = hawk.h hawk-chr.h hawk-cmn.h hawk-dir.h \
tre-compile.c tre-compile.h tre-match-bt.c tre-match-pa.c \
tre-match-ut.h tre-mem.c tre-mem.h tre-parse.c tre-parse.h \
tre-stack.c tre-stack.h tre.c tree-prv.h tree.c utf16.c utf8.c \
utl-sort.c utl-str.c utl-sys.c utl.c val-prv.h val.c \
utl-ass.c utl-sort.c utl-str.c utl-sys.c utl.c val-prv.h val.c \
hawk-cli.h hawk-fio.h hawk-mtx.h hawk-pio.h hawk-sio.h \
hawk-tio.h cli.c fio.c mtx.c pio.c sio.c syscall.h syserr.h \
tio.c std-prv.h std.c imap-imp.h mod-math.c mod-math.h \
@ -191,11 +191,12 @@ am_libhawk_la_OBJECTS = $(am__objects_1) libhawk_la-arr.lo \
libhawk_la-tre-match-pa.lo libhawk_la-tre-mem.lo \
libhawk_la-tre-parse.lo libhawk_la-tre-stack.lo \
libhawk_la-tre.lo libhawk_la-tree.lo libhawk_la-utf16.lo \
libhawk_la-utf8.lo libhawk_la-utl-sort.lo \
libhawk_la-utl-str.lo libhawk_la-utl-sys.lo libhawk_la-utl.lo \
libhawk_la-val.lo libhawk_la-cli.lo libhawk_la-fio.lo \
libhawk_la-mtx.lo libhawk_la-pio.lo libhawk_la-sio.lo \
libhawk_la-tio.lo libhawk_la-std.lo $(am__objects_2)
libhawk_la-utf8.lo libhawk_la-utl-ass.lo \
libhawk_la-utl-sort.lo libhawk_la-utl-str.lo \
libhawk_la-utl-sys.lo libhawk_la-utl.lo libhawk_la-val.lo \
libhawk_la-cli.lo libhawk_la-fio.lo libhawk_la-mtx.lo \
libhawk_la-pio.lo libhawk_la-sio.lo libhawk_la-tio.lo \
libhawk_la-std.lo $(am__objects_2)
libhawk_la_OBJECTS = $(am_libhawk_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -509,10 +510,10 @@ libhawk_la_SOURCES = $(pkginclude_HEADERS) arr.c chr.c dir.c ecs-imp.h \
tre-ast.c tre-ast.h tre-compile.c tre-compile.h tre-match-bt.c \
tre-match-pa.c tre-match-ut.h tre-mem.c tre-mem.h tre-parse.c \
tre-parse.h tre-stack.c tre-stack.h tre.c tree-prv.h tree.c \
utf16.c utf8.c utl-sort.c utl-str.c utl-sys.c utl.c val-prv.h \
val.c hawk-cli.h hawk-fio.h hawk-mtx.h hawk-pio.h hawk-sio.h \
hawk-tio.h cli.c fio.c mtx.c pio.c sio.c syscall.h syserr.h \
tio.c std-prv.h std.c $(am__append_6)
utf16.c utf8.c utl-ass.c utl-sort.c utl-str.c utl-sys.c utl.c \
val-prv.h val.c hawk-cli.h hawk-fio.h hawk-mtx.h hawk-pio.h \
hawk-sio.h hawk-tio.h cli.c fio.c mtx.c pio.c sio.c syscall.h \
syserr.h tio.c std-prv.h std.c $(am__append_6)
libhawk_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
libhawk_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
libhawk_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_7) \
@ -667,6 +668,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-tree.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utf16.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utf8.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-ass.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-sort.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-str.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-sys.Plo@am__quote@
@ -895,6 +897,13 @@ libhawk_la-utf8.lo: utf8.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhawk_la-utf8.lo `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c
libhawk_la-utl-ass.lo: utl-ass.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhawk_la-utl-ass.lo -MD -MP -MF $(DEPDIR)/libhawk_la-utl-ass.Tpo -c -o libhawk_la-utl-ass.lo `test -f 'utl-ass.c' || echo '$(srcdir)/'`utl-ass.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-utl-ass.Tpo $(DEPDIR)/libhawk_la-utl-ass.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utl-ass.c' object='libhawk_la-utl-ass.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhawk_la-utl-ass.lo `test -f 'utl-ass.c' || echo '$(srcdir)/'`utl-ass.c
libhawk_la-utl-sort.lo: utl-sort.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhawk_la-utl-sort.lo -MD -MP -MF $(DEPDIR)/libhawk_la-utl-sort.Tpo -c -o libhawk_la-utl-sort.lo `test -f 'utl-sort.c' || echo '$(srcdir)/'`utl-sort.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-utl-sort.Tpo $(DEPDIR)/libhawk_la-utl-sort.Plo

View File

@ -160,7 +160,7 @@ void hawk_arr_setscale (hawk_arr_t* arr, int scale)
{
/* The scale should be larger than 0 and less than or equal to the
* maximum value that the hawk_uint8_t type can hold */
/*HAWK_ASSERT (arr->gem, scale > 0 && scale <= HAWK_TYPE_MAX(hawk_uint8_t));*/
HAWK_ASSERT (scale > 0 && scale <= HAWK_TYPE_MAX(hawk_uint8_t));
if (scale <= 0) scale = 1;
if (scale > HAWK_TYPE_MAX(hawk_uint8_t)) scale = HAWK_TYPE_MAX(hawk_uint8_t);
@ -240,7 +240,7 @@ hawk_arr_t* hawk_arr_setcapa (hawk_arr_t* arr, hawk_oow_t capa)
{
/* to trigger freeers on the items truncated */
hawk_arr_delete (arr, capa, arr->size - capa);
/*HAWK_ASSERT (arr->gem, arr->size <= capa);*/
HAWK_ASSERT (arr->size <= capa);
}
if (capa > 0)
@ -331,7 +331,7 @@ hawk_oow_t hawk_arr_insert (hawk_arr_t* arr, hawk_oow_t pos, void* dptr, hawk_oo
{
if (arr->capa <= 0)
{
/*HAWK_ASSERT (arr->gem, arr->size <= 0);*/
HAWK_ASSERT (arr->size <= 0);
capa = HAWK_ALIGN_POW2(pos + 1, 64);
}
else
@ -567,7 +567,7 @@ hawk_oow_t hawk_arr_pushstack (hawk_arr_t* arr, void* dptr, hawk_oow_t dlen)
void hawk_arr_popstack (hawk_arr_t* arr)
{
/*HAWK_ASSERT (arr->gem, arr->size > 0);*/
HAWK_ASSERT (arr->size > 0);
hawk_arr_delete (arr, arr->size - 1, 1);
}
@ -681,7 +681,7 @@ hawk_oow_t hawk_arr_pushheap (hawk_arr_t* arr, void* dptr, hawk_oow_t dlen)
if (hawk_arr_insert(arr, index, dptr, dlen) == HAWK_ARR_NIL) return HAWK_ARR_NIL;
HEAP_UPDATE_POS (arr, index);
/*HAWK_ASSERT (arr->gem, arr->size == index + 1);*/
HAWK_ASSERT (arr->size == index + 1);
/* move the item upto the top if it's greater than the parent items */
sift_up (arr, index);
@ -690,7 +690,7 @@ hawk_oow_t hawk_arr_pushheap (hawk_arr_t* arr, void* dptr, hawk_oow_t dlen)
void hawk_arr_popheap (hawk_arr_t* arr)
{
/*HAWK_ASSERT (arr->gem, arr->size > 0);*/
HAWK_ASSERT (arr->size > 0);
hawk_arr_deleteheap (arr, 0);
}
@ -698,8 +698,8 @@ void hawk_arr_deleteheap (hawk_arr_t* arr, hawk_oow_t index)
{
slot_t* tmp;
/*HAWK_ASSERT (arr->gem, arr->size > 0);
HAWK_ASSERT (arr->gem, index < arr->size);*/
HAWK_ASSERT (arr->size > 0);
HAWK_ASSERT (index < arr->size);
/* remember the item to destroy */
tmp = arr->slot[index];
@ -736,7 +736,7 @@ hawk_oow_t hawk_arr_updateheap (hawk_arr_t* arr, hawk_oow_t index, void* dptr, h
int n;
tmp = arr->slot[index];
/*HAWK_ASSERT (arr->gem, tmp != HAWK_NULL);*/
HAWK_ASSERT (tmp != HAWK_NULL);
n = arr->comper(arr, dptr, dlen, DPTR(tmp), DLEN(tmp));
if (n)

View File

@ -152,7 +152,7 @@ void FN(clear) (str_t* str)
str->val.len = 0;
if (str->val.ptr)
{
HAWK_ASSERT (str->gem, str->capa >= 1);
HAWK_ASSERT (str->capa >= 1);
str->val.ptr[0] = '\0';
}
}
@ -251,8 +251,8 @@ static int FN(resize_for_ncat) (str_t* str, hawk_oow_t len)
}
else if (str->capa <= 0 && len <= 0)
{
HAWK_ASSERT (str->gem, str->val.ptr == HAWK_NULL);
HAWK_ASSERT (str->gem, str->val.len <= 0);
HAWK_ASSERT (str->val.ptr == HAWK_NULL);
HAWK_ASSERT (str->val.len <= 0);
if (FN(setcapa)(str, 1) == (hawk_oow_t)-1) return -1;
}

View File

@ -366,7 +366,7 @@ void hawk_seterror (hawk_t* hawk, hawk_errnum_t errnum, const hawk_oocs_t* errar
hawk->_gem.errnum = errnum;
errfmt = hawk_geterrstr(hawk)(hawk, errnum);
HAWK_ASSERT (awk, errfmt != HAWK_NULL);
HAWK_ASSERT (errfmt != HAWK_NULL);
/* TODO: this change is buggy... copying won't process arguments...
qse_strxfncpy (hawk->_gem.errmsg, HAWK_COUNTOF(hawk->_gem.errmsg), errfmt, errarg);
*/
@ -548,7 +548,7 @@ void hawk_rtx_seterror (hawk_rtx_t* rtx, hawk_errnum_t errnum, const hawk_oocs_t
rtx->_gem.errnum = errnum;
errfmt = hawk_geterrstr(hawk_rtx_gethawk(rtx))(hawk_rtx_gethawk(rtx), errnum);
HAWK_ASSERT (awk, errfmt != HAWK_NULL);
HAWK_ASSERT (errfmt != HAWK_NULL);
/* TODO: this change is buggy... copying won't process arguments...
qse_strxfncpy (rtx->_gem.errmsg, HAWK_COUNTOF(rtx->_gem.errmsg), errfmt, errarg);
*/

View File

@ -350,11 +350,11 @@ static int fnc_close (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_oow_t len, optlen = 0;
nargs = hawk_rtx_getnargs(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 1 || nargs == 2);
HAWK_ASSERT (nargs == 1 || nargs == 2);
a0 = hawk_rtx_getarg (rtx, 0);
if (nargs >= 2) a1 = hawk_rtx_getarg(rtx, 1);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a0 != HAWK_NULL);
HAWK_ASSERT (a0 != HAWK_NULL);
name = hawk_rtx_getvaloocstr(rtx, a0, &len);
if (name == HAWK_NULL) return -1;
@ -462,7 +462,7 @@ static int fnc_fflush (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
int n;
nargs = hawk_rtx_getnargs (rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 0 || nargs == 1);
HAWK_ASSERT (nargs == 0 || nargs == 1);
if (nargs == 0)
{
@ -692,7 +692,7 @@ int hawk_fnc_length (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_oow_t len;
nargs = hawk_rtx_getnargs (rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 0 && nargs <= 1);
HAWK_ASSERT (nargs >= 0 && nargs <= 1);
if (nargs == 0)
{
@ -743,7 +743,7 @@ int hawk_fnc_substr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
int n;
nargs = hawk_rtx_getnargs(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 3);
HAWK_ASSERT (nargs >= 2 && nargs <= 3);
a0 = hawk_rtx_getarg(rtx, 0);
a1 = hawk_rtx_getarg(rtx, 1);
@ -821,14 +821,14 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
str.len = 0;
nargs = hawk_rtx_getnargs(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 3);
HAWK_ASSERT (nargs >= 2 && nargs <= 3);
a0 = hawk_rtx_getarg(rtx, 0);
a1 = hawk_rtx_getarg(rtx, 1);
a2 = (nargs >= 3)? hawk_rtx_getarg (rtx, 2): HAWK_NULL;
a1_vtype = HAWK_RTX_GETVALTYPE (rtx, a1);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a1_vtype == HAWK_VAL_REF);
HAWK_ASSERT (a1_vtype == HAWK_VAL_REF);
str.ptr = hawk_rtx_getvaloocstr(rtx, a0, &str.len);
if (str.ptr == HAWK_NULL) goto oops;
@ -941,7 +941,7 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
break;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
HAWK_ASSERT ((tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
/* create the field string - however, the split function must
* create a numeric string if the string is a number */
@ -951,7 +951,7 @@ int hawk_fnc_split (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
/* put it into the map */
key_len = hawk_int_to_oocstr(++nflds, 10, HAWK_NULL, key_buf, HAWK_COUNTOF(key_buf));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), key_len != (hawk_oow_t)-1);
HAWK_ASSERT (key_len != (hawk_oow_t)-1);
if (hawk_rtx_setmapvalfld(rtx, t1, key_buf, key_len, t2) == HAWK_NULL)
{
@ -1094,14 +1094,14 @@ static int __substitute (hawk_rtx_t* rtx, hawk_int_t max_count)
s1.len = 0;
nargs = hawk_rtx_getnargs(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 3);
HAWK_ASSERT (nargs >= 2 && nargs <= 3);
a0 = hawk_rtx_getarg(rtx, 0);
a1 = hawk_rtx_getarg(rtx, 1);
a2 = (nargs >= 3)? hawk_rtx_getarg(rtx, 2): HAWK_NULL;
a0_vtype = HAWK_RTX_GETVALTYPE (rtx, a0);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a2 == HAWK_NULL || HAWK_RTX_GETVALTYPE(rtx, a2) == HAWK_VAL_REF);
HAWK_ASSERT (a2 == HAWK_NULL || HAWK_RTX_GETVALTYPE(rtx, a2) == HAWK_VAL_REF);
if (a0_vtype == HAWK_VAL_REX)
{
@ -1314,7 +1314,7 @@ int hawk_fnc_match (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_ooecs_t* tmpbuf = HAWK_NULL;
nargs = hawk_rtx_getnargs(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs >= 2 && nargs <= 4);
HAWK_ASSERT (nargs >= 2 && nargs <= 4);
a0 = hawk_rtx_getarg(rtx, 0);
a1 = hawk_rtx_getarg(rtx, 1);
@ -1456,7 +1456,7 @@ int hawk_fnc_sprintf (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_val_t* a0;
nargs = hawk_rtx_getnargs(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs > 0);
HAWK_ASSERT (nargs > 0);
a0 = hawk_rtx_getarg(rtx, 0);
if (HAWK_RTX_GETVALTYPE(rtx, a0) == HAWK_VAL_MBS)
@ -1636,7 +1636,7 @@ static HAWK_INLINE int __fnc_asort (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi,
a0 = hawk_rtx_getarg(rtx, 0);
a0_type = HAWK_RTX_GETVALTYPE(rtx, a0);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), a0_type == HAWK_VAL_REF);
HAWK_ASSERT (a0_type == HAWK_VAL_REF);
v_type = hawk_rtx_getrefvaltype(rtx, (hawk_val_ref_t*)a0);
if (v_type != HAWK_VAL_MAP)
@ -1652,7 +1652,7 @@ static HAWK_INLINE int __fnc_asort (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi,
}
a0_val = hawk_rtx_getrefval(rtx, (hawk_val_ref_t*)a0);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, a0_val) == HAWK_VAL_MAP);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE(rtx, a0_val) == HAWK_VAL_MAP);
if (nargs >= 2)
{
@ -1684,7 +1684,7 @@ static HAWK_INLINE int __fnc_asort (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi,
if (!hawk_rtx_getfirstmapvalitr(rtx, a0_val, &itr)) goto done; /* map empty */
msz = hawk_htb_getsize(((hawk_val_map_t*)a0_val)->map);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), msz > 0);
HAWK_ASSERT (msz > 0);
va = (hawk_val_t**)hawk_rtx_allocmem(rtx, msz * HAWK_SIZEOF(*va));
if (!va) return -1;

View File

@ -927,6 +927,13 @@ struct hawk_loc_t
};
typedef struct hawk_loc_t hawk_loc_t;
typedef void (*hawk_assertfail_t) (
hawk_gem_t* gem,
const hawk_bch_t* expr,
const hawk_bch_t* file,
hawk_oow_t line
);
struct hawk_gem_t
{
hawk_mmgr_t* mmgr;
@ -934,6 +941,9 @@ struct hawk_gem_t
hawk_errnum_t errnum;
hawk_ooch_t errmsg[HAWK_ERRMSG_CAPA];
hawk_loc_t errloc;
#if defined(HAWK_BUILD_DEBUG)
hawk_assertfail_t assertfail;
#endif
};
enum hawk_log_mask_t
@ -1233,6 +1243,16 @@ typedef enum hawk_log_mask_t hawk_log_mask_t;
#define HAWK_STATIC_ASSERT_EXPR(expr) ((void)HAWK_SIZEOF(char[(expr)? 1: -1]))
/* =========================================================================
* ASSERTION
* =========================================================================*/
#if defined(HAWK_BUILD_RELEASE)
# define HAWK_ASSERT(expr) ((void)0)
#else
# define HAWK_ASSERT(expr) ((void)((expr) || (hawk_assert_fail(#expr, __FILE__, __LINE__), 0)))
#endif
/* =========================================================================
* CHARACTER/STRING LITERALS
@ -1302,8 +1322,4 @@ typedef enum hawk_log_mask_t hawk_log_mask_t;
# error Unsupported platform
#endif
/**** TODO ****/
#define HAWK_ASSERT(hawk, x)
#endif

View File

@ -1541,6 +1541,16 @@ HAWK_EXPORT void hawk_sub_time (
hawk_ntime_t* z
);
/* =========================================================================
* ASSERTION
* ========================================================================= */
HAWK_EXPORT void hawk_assert_fail (
const hawk_bch_t* expr,
const hawk_bch_t* file,
hawk_oow_t line
);
#if defined(__cplusplus)
}
#endif

View File

@ -158,9 +158,9 @@ int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm
awk->haltall = 0;
/* progagate the primitive functions */
HAWK_ASSERT (awk, prm != HAWK_NULL);
HAWK_ASSERT (awk, prm->math.pow != HAWK_NULL);
HAWK_ASSERT (awk, prm->math.mod != HAWK_NULL);
HAWK_ASSERT (prm != HAWK_NULL);
HAWK_ASSERT (prm->math.pow != HAWK_NULL);
HAWK_ASSERT (prm->math.mod != HAWK_NULL);
if (prm == HAWK_NULL ||
prm->math.pow == HAWK_NULL ||
prm->math.mod == HAWK_NULL)
@ -363,7 +363,7 @@ void hawk_clear (hawk_t* awk)
hawk_rbt_walk (awk->modtab, unload_module, awk);
hawk_rbt_clear (awk->modtab);
HAWK_ASSERT (awk, HAWK_ARR_SIZE(awk->parse.gbls) == awk->tree.ngbls);
HAWK_ASSERT (HAWK_ARR_SIZE(awk->parse.gbls) == awk->tree.ngbls);
/* delete all non-builtin global variables */
hawk_arr_delete (
awk->parse.gbls, awk->tree.ngbls_base,
@ -395,7 +395,6 @@ void hawk_clear (hawk_t* awk)
if (awk->tree.begin)
{
/*HAWK_ASSERT (awk, awk->tree.begin->next == HAWK_NULL);*/
hawk_clrpt (awk, awk->tree.begin);
awk->tree.begin = HAWK_NULL;
awk->tree.begin_tail = HAWK_NULL;
@ -403,7 +402,6 @@ void hawk_clear (hawk_t* awk)
if (awk->tree.end)
{
/*HAWK_ASSERT (awk, awk->tree.end->next == HAWK_NULL);*/
hawk_clrpt (awk, awk->tree.end);
awk->tree.end = HAWK_NULL;
awk->tree.end_tail = HAWK_NULL;

View File

@ -282,14 +282,14 @@ int hawk_htb_init (hawk_htb_t* htb, hawk_gem_t* gem, hawk_oow_t capa, int factor
{
/* The initial capacity should be greater than 0.
* Otherwise, it is adjusted to 1 in the release mode */
HAWK_ASSERT (hawk, capa > 0);
HAWK_ASSERT (capa > 0);
/* The load factor should be between 0 and 100 inclusive.
* In the release mode, a value out of the range is adjusted to 100 */
HAWK_ASSERT (hawk, factor >= 0 && factor <= 100);
HAWK_ASSERT (factor >= 0 && factor <= 100);
HAWK_ASSERT (hawk, kscale >= 0 && kscale <= HAWK_TYPE_MAX(hawk_uint8_t));
HAWK_ASSERT (hawk, vscale >= 0 && vscale <= HAWK_TYPE_MAX(hawk_uint8_t));
HAWK_ASSERT (kscale >= 0 && kscale <= HAWK_TYPE_MAX(hawk_uint8_t));
HAWK_ASSERT (vscale >= 0 && vscale <= HAWK_TYPE_MAX(hawk_uint8_t));
/* some initial adjustment */
if (capa <= 0) capa = 1;
@ -331,7 +331,7 @@ const style_t* hawk_htb_getstyle (const hawk_htb_t* htb)
void hawk_htb_setstyle (hawk_htb_t* htb, const style_t* style)
{
HAWK_ASSERT (htb->gem, style != HAWK_NULL);
HAWK_ASSERT (style != HAWK_NULL);
htb->style = style;
}
@ -500,7 +500,7 @@ static HAWK_INLINE pair_t* insert (hawk_htb_t* htb, void* kptr, hawk_oow_t klen,
}
}
HAWK_ASSERT (htb->gem, pair == HAWK_NULL);
HAWK_ASSERT (pair == HAWK_NULL);
pair = hawk_htb_allocpair (htb, kptr, klen, vptr, vlen);
if (pair == HAWK_NULL) return HAWK_NULL; /* error */
@ -581,7 +581,7 @@ pair_t* hawk_htb_cbsert (hawk_htb_t* htb, void* kptr, hawk_oow_t klen, cbserter_
}
}
HAWK_ASSERT (htb->gem, pair == HAWK_NULL);
HAWK_ASSERT (pair == HAWK_NULL);
pair = cbserter(htb, HAWK_NULL, kptr, klen, ctx);
if (pair == HAWK_NULL) return HAWK_NULL; /* error */

View File

@ -95,7 +95,7 @@ static __IMAP_NODE_T* __MAKE_IMAP_NODE (hawk_rtx_t* rtx, __IMAP_LIST_T* list)
list->map.high++;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), list->map.tab[node->id] == HAWK_NULL);
HAWK_ASSERT (list->map.tab[node->id] == HAWK_NULL);
list->map.tab[node->id] = node;
/* append it to the tail */

View File

@ -273,7 +273,7 @@ hawk_ooch_t* hawk_rtx_strxntokbyrex (
return HAWK_NULL;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), n == 1);
HAWK_ASSERT (n == 1);
if (match.len == 0)
{
@ -496,7 +496,7 @@ static int matchtre (hawk_tre_t* tre, int opt, const hawk_oocs_t* str, hawk_oocs
return -1;
}
/* HAWK_ASSERT (awk, match[0].rm_so != -1); <--- add back with gem*/
HAWK_ASSERT (match[0].rm_so != -1);
if (mat)
{
mat->ptr = &str->ptr[match[0].rm_so];

View File

@ -78,7 +78,7 @@ static int fnc_math_1 (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, hawk_math1_t
int n;
nargs = hawk_rtx_getnargs (rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 1);
HAWK_ASSERT (nargs == 1);
a0 = hawk_rtx_getarg(rtx, 0);
@ -101,7 +101,7 @@ static int fnc_math_2 (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi, hawk_math2_t
int n;
nargs = hawk_rtx_getnargs (rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 2);
HAWK_ASSERT (nargs == 2);
a0 = hawk_rtx_getarg(rtx, 0);
a1 = hawk_rtx_getarg(rtx, 1);
@ -564,7 +564,7 @@ static int fnc_srand (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
modctx = (modctx_t*)fi->mod->ctx;
nargs = hawk_rtx_getnargs(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 0 || nargs == 1);
HAWK_ASSERT (nargs == 0 || nargs == 1);
prev = modctx->seed;

View File

@ -89,19 +89,17 @@ struct mod_ctx_t
{
hawk_rbt_t* rtxtab;
/*
struct
{
syslog_type_t type;
char* ident;
hawk_skad_t skad;
// hawk_skad_t skad;
int syslog_opened; // has openlog() been called?
int opt;
int fac;
int sck;
hawk_becs_t* dmsgbuf;
} log;
*/
};
typedef struct mod_ctx_t mod_ctx_t;
@ -292,7 +290,7 @@ static HAWK_INLINE sys_list_t* rtx_to_sys_list (hawk_rtx_t* rtx, const hawk_fnc_
hawk_rbt_pair_t* pair;
pair = hawk_rbt_search(mctx->rtxtab, &rtx, HAWK_SIZEOF(rtx));
HAWK_ASSERT (hawk_rtx_getawk(rtx), pair != HAWK_NULL);
HAWK_ASSERT (pair != HAWK_NULL);
return (sys_list_t*)HAWK_RBT_VPTR(pair);
}
@ -430,7 +428,7 @@ static int fnc_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
set_errmsg_on_sys_list_with_syserr (rtx, sys_list);
}
/*HAWK_ASSERT (HAWK_IN_QUICKINT_RANGE(rx));*/
HAWK_ASSERT (HAWK_IN_QUICKINT_RANGE(rx));
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
return 0;
}
@ -1675,19 +1673,6 @@ static int fnc_strftime (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_oow_t sl;
#if 0
HAWK_MEMSET (&tm, 0, HAWK_SIZEOF(tm));
tm.tm_year = bt.year;
tm.tm_mon = bt.mon;
tm.tm_mday = bt.mday;
tm.tm_hour = bt.hour;
tm.tm_min = bt.min;
tm.tm_sec = bt.sec;
tm.tm_isdst = bt.isdst;
#if defined(HAVE_STRUCT_TM_TM_GMTOFF)
tm.tm_gmtoff = bt.gmtoff;
#elif defined(HAVE_STRUCT_TM___TM_GMTOFF)
tm.__tm_gmtoff = bt.gmtoff;
#endif
if (flags & STRFTIME_UTC)
{
#if defined(HAVE_STRUCT_TM_TM_ZONE)
@ -1881,7 +1866,7 @@ static int fnc_getnwifcfg (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
md[5].vptr = (cfg.flags & HAWK_NWIFCFG_LINKUP)? HAWK_T("up"): HAWK_T("down");
}
tmp = hawk_rtx_makemapvalwithdata (rtx, md);
tmp = hawk_rtx_makemapvalwithdata(rtx, md);
if (tmp)
{
int x;
@ -2115,8 +2100,7 @@ static void open_remote_log_socket (hawk_rtx_t* rtx, mod_ctx_t* mctx)
int domain = hawk_skadfamily(&mctx->log.skad);
int type = SOCK_DGRAM;
HAWK_ASSERT (mctx->log.sck <= -1);
//HAWK_ASSERT (mctx->log.sck <= -1);
#if defined(SOCK_NONBLOCK) && defined(SOCK_CLOEXEC)
type |= SOCK_NONBLOCK;
@ -2170,7 +2154,6 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
hawk_nwad_t nwad;
syslog_type_t log_type = SYSLOG_LOCAL;
ident = hawk_rtx_getvaloocstr(rtx, hawk_rtx_getarg(rtx, 0), &ident_len);
if (!ident) goto done;
@ -2181,7 +2164,7 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
if (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 1), &opt) <= -1) goto done;
if (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 2), &fac) <= -1) goto done;
if (hawk_comp_bcstr_limited(ident, HAWK_T("remote://"), 9))
if (hawk_comp_oocstr_limited(ident, HAWK_T("remote://"), 9, 0))
{
hawk_ooch_t* slash;
/* "udp://remote-addr:remote-port/syslog-identifier" */
@ -2193,7 +2176,7 @@ static int fnc_openlog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
if (hawk_strntonwad(actual_ident, slash - actual_ident, &nwad) <= -1) goto done;
actual_ident = slash + 1;
}
else if (hawk_strbeg(ident, HAWK_T("local://")))
else if (hawk_comp_oocstr_limited(ident, HAWK_T("local://"), 8, 0))
{
/* "local://syslog-identifier" */
actual_ident = ident + 8;
@ -2359,18 +2342,8 @@ static int fnc_writelog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
static const hawk_bch_t* __syslog_month_names[] =
{
HAWK_BT("Jan"),
HAWK_BT("Feb"),
HAWK_BT("Mar"),
HAWK_BT("Apr"),
HAWK_BT("May"),
HAWK_BT("Jun"),
HAWK_BT("Jul"),
HAWK_BT("Aug"),
HAWK_BT("Sep"),
HAWK_BT("Oct"),
HAWK_BT("Nov"),
HAWK_BT("Dec"),
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
};
if (mctx->log.sck <= -1) open_remote_log_socket (rtx, mctx);
@ -2382,7 +2355,7 @@ static int fnc_writelog (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
if (hawk_get_time(&now) || hawk_localtime(&now, &cnow) <= -1) goto done;
if (hawk_becs_fmt (
if (hawk_becs_fmt(
mctx->log.dmsgbuf, HAWK_BT("<%d>%s %02d %02d:%02d:%02d "),
(int)(mctx->log.fac | pri),
__syslog_month_names[cnow.mon], cnow.mday,
@ -2427,7 +2400,6 @@ done:
hawk_rtx_setretval (rtx, retv);
return 0;
}
#endif
/* ------------------------------------------------------------ */
@ -2787,7 +2759,7 @@ static void unload (hawk_mod_t* mod, hawk_t* awk)
{
mod_ctx_t* mctx = (mod_ctx_t*)mod->ctx;
HAWK_ASSERT (awk, HAWK_RBT_SIZE(mctx->rtxtab) == 0);
HAWK_ASSERT (HAWK_RBT_SIZE(mctx->rtxtab) == 0);
hawk_rbt_close (mctx->rtxtab);
hawk_freemem (awk, mctx);

View File

@ -518,13 +518,13 @@ static int get_char (hawk_t* awk)
static void unget_char (hawk_t* awk, const hawk_sio_lxc_t* c)
{
/* Make sure that the unget buffer is large enough */
HAWK_ASSERT (awk, awk->sio.nungots < HAWK_COUNTOF(awk->sio.ungot));
HAWK_ASSERT (awk->sio.nungots < HAWK_COUNTOF(awk->sio.ungot));
awk->sio.ungot[awk->sio.nungots++] = *c;
}
const hawk_ooch_t* hawk_getgblname (hawk_t* awk, hawk_oow_t idx, hawk_oow_t* len)
{
HAWK_ASSERT (awk, idx < HAWK_ARR_SIZE(awk->parse.gbls));
HAWK_ASSERT (idx < HAWK_ARR_SIZE(awk->parse.gbls));
*len = HAWK_ARR_DLEN(awk->parse.gbls,idx);
return HAWK_ARR_DPTR(awk->parse.gbls,idx);
@ -540,7 +540,7 @@ static int parse (hawk_t* awk)
int ret = -1;
hawk_ooi_t op;
HAWK_ASSERT (awk, awk->sio.inf != HAWK_NULL);
HAWK_ASSERT (awk->sio.inf != HAWK_NULL);
CLRERR (awk);
op = awk->sio.inf(awk, HAWK_SIO_CMD_OPEN, awk->sio.inp, HAWK_NULL, 0);
@ -597,7 +597,7 @@ static int parse (hawk_t* awk)
}
}
HAWK_ASSERT (awk, awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls));
HAWK_ASSERT (awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls));
ret = 0;
oops:
@ -617,7 +617,7 @@ oops:
prev = awk->sio.inp->prev;
HAWK_ASSERT (awk, awk->sio.inp->name != HAWK_NULL);
HAWK_ASSERT (awk->sio.inp->name != HAWK_NULL);
hawk_freemem (awk, awk->sio.inp);
awk->sio.inp = prev;
@ -626,7 +626,7 @@ oops:
else if (ret == 0)
{
/* no error occurred so far */
HAWK_ASSERT (awk, awk->sio.inp == &awk->sio.arg);
HAWK_ASSERT (awk->sio.inp == &awk->sio.arg);
CLRERR (awk);
}
@ -667,10 +667,10 @@ int hawk_parse (hawk_t* awk, hawk_sio_cbs_t* sio)
int n;
/* the source code istream must be provided */
HAWK_ASSERT (awk, sio != HAWK_NULL);
HAWK_ASSERT (sio != HAWK_NULL);
/* the source code input stream must be provided at least */
HAWK_ASSERT (awk, sio->in != HAWK_NULL);
HAWK_ASSERT (sio->in != HAWK_NULL);
if (!sio || !sio->in)
{
@ -678,8 +678,8 @@ int hawk_parse (hawk_t* awk, hawk_sio_cbs_t* sio)
return -1;
}
HAWK_ASSERT (awk, awk->parse.depth.loop == 0);
HAWK_ASSERT (awk, awk->parse.depth.expr == 0);
HAWK_ASSERT (awk->parse.depth.loop == 0);
HAWK_ASSERT (awk->parse.depth.expr == 0);
hawk_clear (awk);
hawk_clearsionames (awk);
@ -696,8 +696,8 @@ int hawk_parse (hawk_t* awk, hawk_sio_cbs_t* sio)
n = parse(awk);
if (n == 0 && awk->sio.outf != HAWK_NULL) n = deparse (awk);
HAWK_ASSERT (awk, awk->parse.depth.loop == 0);
HAWK_ASSERT (awk, awk->parse.depth.expr == 0);
HAWK_ASSERT (awk->parse.depth.loop == 0);
HAWK_ASSERT (awk->parse.depth.expr == 0);
return n;
}
@ -724,7 +724,7 @@ static int end_include (hawk_t* awk)
cur = awk->sio.inp;
awk->sio.inp = awk->sio.inp->prev;
HAWK_ASSERT (awk, cur->name != HAWK_NULL);
HAWK_ASSERT (cur->name != HAWK_NULL);
/* restore the pragma values */
awk->parse.pragma.trait = cur->pragma_trait;
hawk_freemem (awk, cur);
@ -889,7 +889,7 @@ static int parse_progunit (hawk_t* awk)
function name (parameter-list) { statement }
*/
HAWK_ASSERT (awk, awk->parse.depth.loop == 0);
HAWK_ASSERT (awk->parse.depth.loop == 0);
if (MATCH(awk, TOK_XGLOBAL))
{
@ -899,7 +899,7 @@ static int parse_progunit (hawk_t* awk)
if (get_token(awk) <= -1) return -1;
HAWK_ASSERT (awk, awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls));
HAWK_ASSERT (awk->tree.ngbls == HAWK_ARR_SIZE(awk->parse.gbls));
ngbls = awk->tree.ngbls;
if (collect_globals(awk) == HAWK_NULL)
{
@ -1112,7 +1112,7 @@ static int parse_progunit (hawk_t* awk)
ptn = parse_expr_withdc (awk, &eloc);
if (ptn == HAWK_NULL) return -1;
HAWK_ASSERT (awk, ptn->next == HAWK_NULL);
HAWK_ASSERT (ptn->next == HAWK_NULL);
if (MATCH(awk,TOK_COMMA))
{
@ -1208,7 +1208,7 @@ static hawk_nde_t* parse_function (hawk_t* awk)
int rederr;
/* eat up the keyword 'function' and get the next token */
HAWK_ASSERT (awk, MATCH(awk,TOK_FUNCTION));
HAWK_ASSERT (MATCH(awk,TOK_FUNCTION));
if (get_token(awk) <= -1) return HAWK_NULL;
/* check if an identifier is in place */
@ -1260,7 +1260,7 @@ static hawk_nde_t* parse_function (hawk_t* awk)
if (get_token(awk) <= -1) goto oops;
/* make sure that parameter table is empty */
HAWK_ASSERT (awk, HAWK_ARR_SIZE(awk->parse.params) == 0);
HAWK_ASSERT (HAWK_ARR_SIZE(awk->parse.params) == 0);
/* read parameter list */
if (MATCH(awk,TOK_RPAREN))
@ -1437,7 +1437,7 @@ static hawk_nde_t* parse_begin (hawk_t* awk)
hawk_loc_t xloc;
xloc = awk->tok.loc;
HAWK_ASSERT (awk, MATCH(awk,TOK_LBRACE));
HAWK_ASSERT (MATCH(awk,TOK_LBRACE));
if (get_token(awk) <= -1) return HAWK_NULL;
nde = parse_block_dc (awk, &xloc, 1);
@ -1463,7 +1463,7 @@ static hawk_nde_t* parse_end (hawk_t* awk)
hawk_loc_t xloc;
xloc = awk->tok.loc;
HAWK_ASSERT (awk, MATCH(awk,TOK_LBRACE));
HAWK_ASSERT (MATCH(awk,TOK_LBRACE));
if (get_token(awk) <= -1) return HAWK_NULL;
nde = parse_block_dc (awk, &xloc, 1);
@ -1493,7 +1493,7 @@ static hawk_chain_t* parse_action_block (
if (blockless) nde = HAWK_NULL;
else
{
HAWK_ASSERT (awk, MATCH(awk,TOK_LBRACE));
HAWK_ASSERT (MATCH(awk,TOK_LBRACE));
if (get_token(awk) <= -1) return HAWK_NULL;
nde = parse_block_dc(awk, &xloc, 1);
if (nde == HAWK_NULL) return HAWK_NULL;
@ -1748,7 +1748,7 @@ int hawk_initgbls (hawk_t* awk)
/* hawk_initgbls is not generic-purpose. call this from
* hawk_open only. */
HAWK_ASSERT (awk, awk->tree.ngbls_base == 0 && awk->tree.ngbls == 0);
HAWK_ASSERT (awk->tree.ngbls_base == 0 && awk->tree.ngbls == 0);
awk->tree.ngbls_base = 0;
awk->tree.ngbls = 0;
@ -1760,13 +1760,13 @@ int hawk_initgbls (hawk_t* awk)
g = hawk_arr_insert(awk->parse.gbls, HAWK_ARR_SIZE(awk->parse.gbls), (hawk_ooch_t*)gtab[id].name, gtab[id].namelen);
if (g == HAWK_ARR_NIL) return -1;
HAWK_ASSERT (awk, (int)g == id);
HAWK_ASSERT ((int)g == id);
awk->tree.ngbls_base++;
awk->tree.ngbls++;
}
HAWK_ASSERT (awk, awk->tree.ngbls_base == HAWK_MAX_GBL_ID-HAWK_MIN_GBL_ID+1);
HAWK_ASSERT (awk->tree.ngbls_base == HAWK_MAX_GBL_ID-HAWK_MIN_GBL_ID+1);
return 0;
}
@ -1774,7 +1774,7 @@ static void adjust_static_globals (hawk_t* awk)
{
int id;
HAWK_ASSERT (awk, awk->tree.ngbls_base >= HAWK_MAX_GBL_ID - HAWK_MAX_GBL_ID + 1);
HAWK_ASSERT (awk->tree.ngbls_base >= HAWK_MAX_GBL_ID - HAWK_MAX_GBL_ID + 1);
for (id = HAWK_MIN_GBL_ID; id <= HAWK_MAX_GBL_ID; id++)
{
@ -1883,14 +1883,14 @@ static int add_global (hawk_t* awk, const hawk_oocs_t* name, hawk_loc_t* xloc, i
return -1;
}
HAWK_ASSERT (awk, ngbls == HAWK_ARR_SIZE(awk->parse.gbls) - 1);
HAWK_ASSERT (ngbls == HAWK_ARR_SIZE(awk->parse.gbls) - 1);
/* the disabled item is inserted normally but
* the name length is reset to zero. */
if (disabled) HAWK_ARR_DLEN(awk->parse.gbls,ngbls) = 0;
awk->tree.ngbls = HAWK_ARR_SIZE (awk->parse.gbls);
HAWK_ASSERT (awk, ngbls == awk->tree.ngbls-1);
HAWK_ASSERT (ngbls == awk->tree.ngbls-1);
/* return the id which is the index to the gbl table. */
return (int)ngbls;
@ -2023,7 +2023,7 @@ int hawk_delgblwithbcstr (hawk_t* hawk, const hawk_bch_t* name)
hawk->parse.gbls.buf[n].name.len = 0;
*/
n = hawk_arr_uplete(hawk->parse.gbls, n, 1);
HAWK_ASSERT (hawk, n == 1);
HAWK_ASSERT (n == 1);
return 0;
}
@ -2074,7 +2074,7 @@ int hawk_delgblwithucstr (hawk_t* hawk, const hawk_uch_t* name)
hawk->parse.gbls.buf[n].name.len = 0;
*/
n = hawk_arr_uplete(hawk->parse.gbls, n, 1);
HAWK_ASSERT (awk, n == 1);
HAWK_ASSERT (n == 1);
return 0;
}
@ -2590,7 +2590,7 @@ static hawk_nde_t* parse_dowhile (hawk_t* awk, const hawk_loc_t* xloc)
hawk_nde_while_t* nde;
hawk_loc_t ploc;
HAWK_ASSERT (awk, awk->ptok.type == TOK_DO);
HAWK_ASSERT (awk->ptok.type == TOK_DO);
ploc = awk->tok.loc;
body = parse_statement (awk, &ploc);
@ -2646,7 +2646,7 @@ static hawk_nde_t* parse_dowhile (hawk_t* awk, const hawk_loc_t* xloc)
oops:
if (body) hawk_clrpt (awk, body);
if (test) hawk_clrpt (awk, test);
HAWK_ASSERT (awk, nde == HAWK_NULL);
HAWK_ASSERT (nde == HAWK_NULL);
return HAWK_NULL;
}
@ -2654,7 +2654,7 @@ static hawk_nde_t* parse_break (hawk_t* awk, const hawk_loc_t* xloc)
{
hawk_nde_break_t* nde;
HAWK_ASSERT (awk, awk->ptok.type == TOK_BREAK);
HAWK_ASSERT (awk->ptok.type == TOK_BREAK);
if (awk->parse.depth.loop <= 0)
{
SETERR_LOC (awk, HAWK_EBREAK, xloc);
@ -2678,7 +2678,7 @@ static hawk_nde_t* parse_continue (hawk_t* awk, const hawk_loc_t* xloc)
{
hawk_nde_continue_t* nde;
HAWK_ASSERT (awk, awk->ptok.type == TOK_CONTINUE);
HAWK_ASSERT (awk->ptok.type == TOK_CONTINUE);
if (awk->parse.depth.loop <= 0)
{
SETERR_LOC (awk, HAWK_ECONTINUE, xloc);
@ -2703,7 +2703,7 @@ static hawk_nde_t* parse_return (hawk_t* awk, const hawk_loc_t* xloc)
hawk_nde_return_t* nde;
hawk_nde_t* val;
HAWK_ASSERT (awk, awk->ptok.type == TOK_RETURN);
HAWK_ASSERT (awk->ptok.type == TOK_RETURN);
nde = (hawk_nde_return_t*) hawk_callocmem ( awk, HAWK_SIZEOF(*nde));
if (nde == HAWK_NULL)
@ -2742,7 +2742,7 @@ static hawk_nde_t* parse_exit (hawk_t* awk, const hawk_loc_t* xloc)
hawk_nde_exit_t* nde;
hawk_nde_t* val;
HAWK_ASSERT (awk, awk->ptok.type == TOK_EXIT || awk->ptok.type == TOK_XABORT);
HAWK_ASSERT (awk->ptok.type == TOK_EXIT || awk->ptok.type == TOK_XABORT);
nde = (hawk_nde_exit_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde));
if (nde == HAWK_NULL)
@ -2781,7 +2781,7 @@ static hawk_nde_t* parse_next (hawk_t* awk, const hawk_loc_t* xloc)
{
hawk_nde_next_t* nde;
HAWK_ASSERT (awk, awk->ptok.type == TOK_NEXT);
HAWK_ASSERT (awk->ptok.type == TOK_NEXT);
if (awk->parse.id.block == PARSE_BEGIN_BLOCK)
{
@ -2844,7 +2844,7 @@ static hawk_nde_t* parse_delete (hawk_t* awk, const hawk_loc_t* xloc)
hawk_nde_type_t type;
int inparen = 0;
HAWK_ASSERT (awk, awk->ptok.type == TOK_DELETE ||
HAWK_ASSERT (awk->ptok.type == TOK_DELETE ||
awk->ptok.type == TOK_XRESET);
type = (awk->ptok.type == TOK_DELETE)?
@ -2911,7 +2911,7 @@ static hawk_nde_t* parse_print (hawk_t* awk, const hawk_loc_t* xloc)
hawk_nde_type_t type;
hawk_loc_t eloc;
HAWK_ASSERT (awk, awk->ptok.type == TOK_PRINT ||
HAWK_ASSERT (awk->ptok.type == TOK_PRINT ||
awk->ptok.type == TOK_PRINTF);
type = (awk->ptok.type == TOK_PRINT)?
@ -3437,7 +3437,7 @@ static hawk_nde_t* parse_expr (hawk_t* awk, const hawk_loc_t* xloc)
return x;
}
HAWK_ASSERT (awk, x->next == HAWK_NULL);
HAWK_ASSERT (x->next == HAWK_NULL);
if (!is_var(x) && x->type != HAWK_NDE_POS)
{
hawk_clrpt (awk, x);
@ -4248,7 +4248,7 @@ static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc)
}
else
{
HAWK_ASSERT (awk, left->type == HAWK_NDE_FLT);
HAWK_ASSERT (left->type == HAWK_NDE_FLT);
hawk_clrpt (awk, left);
return new_int_node (awk, folded.l, xloc);
}
@ -4261,7 +4261,7 @@ static hawk_nde_t* parse_unary (hawk_t* awk, const hawk_loc_t* xloc)
}
else
{
HAWK_ASSERT (awk, left->type == HAWK_NDE_INT);
HAWK_ASSERT (left->type == HAWK_NDE_INT);
hawk_clrpt (awk, left);
return new_flt_node (awk, folded.r, xloc);
}
@ -4398,7 +4398,7 @@ static hawk_nde_t* parse_increment (hawk_t* awk, const hawk_loc_t* xloc)
}
else /*if (opcode2 != -1)*/
{
HAWK_ASSERT (awk, opcode2 != -1);
HAWK_ASSERT (opcode2 != -1);
/* postfix increment operator */
type = HAWK_NDE_EXP_INCPST;
@ -4482,7 +4482,7 @@ static HAWK_INLINE int isfunname (hawk_t* awk, const hawk_oocs_t* name, hawk_fun
if (fun)
{
*fun = (hawk_fun_t*)HAWK_HTB_VPTR(pair);
HAWK_ASSERT (awk, *fun != HAWK_NULL);
HAWK_ASSERT (*fun != HAWK_NULL);
}
return FNTYPE_FUN;
}
@ -4520,7 +4520,7 @@ static hawk_nde_t* parse_primary_int (hawk_t* hawk, const hawk_loc_t* xloc)
);
if (nde == HAWK_NULL) return HAWK_NULL;
HAWK_ASSERT (hawk, HAWK_OOECS_LEN(hawk->tok.name) == hawk_count_oocstr(HAWK_OOECS_PTR(hawk->tok.name)));
HAWK_ASSERT (HAWK_OOECS_LEN(hawk->tok.name) == hawk_count_oocstr(HAWK_OOECS_PTR(hawk->tok.name)));
/* remember the literal in the original form */
nde->len = HAWK_OOECS_LEN(hawk->tok.name);
@ -4530,7 +4530,7 @@ static hawk_nde_t* parse_primary_int (hawk_t* hawk, const hawk_loc_t* xloc)
return (hawk_nde_t*)nde;
oops:
HAWK_ASSERT (hawk, nde != HAWK_NULL);
HAWK_ASSERT (nde != HAWK_NULL);
if (nde->str) hawk_freemem (hawk, nde->str);
hawk_freemem (hawk, nde);
return HAWK_NULL;
@ -4548,7 +4548,7 @@ static hawk_nde_t* parse_primary_flt (hawk_t* hawk, const hawk_loc_t* xloc)
);
if (nde == HAWK_NULL) return HAWK_NULL;
HAWK_ASSERT (hawk,
HAWK_ASSERT (
HAWK_OOECS_LEN(hawk->tok.name) ==
hawk_count_oocstr(HAWK_OOECS_PTR(hawk->tok.name)));
@ -4560,7 +4560,7 @@ static hawk_nde_t* parse_primary_flt (hawk_t* hawk, const hawk_loc_t* xloc)
return (hawk_nde_t*)nde;
oops:
HAWK_ASSERT (hawk, nde != HAWK_NULL);
HAWK_ASSERT (nde != HAWK_NULL);
if (nde->str) hawk_freemem (hawk, nde->str);
hawk_freemem (hawk, nde);
return HAWK_NULL;
@ -4586,7 +4586,7 @@ static hawk_nde_t* parse_primary_str (hawk_t* awk, const hawk_loc_t* xloc)
return (hawk_nde_t*)nde;
oops:
HAWK_ASSERT (awk, nde != HAWK_NULL);
HAWK_ASSERT (nde != HAWK_NULL);
if (nde->ptr) hawk_freemem (awk, nde->ptr);
hawk_freemem (awk, nde);
return HAWK_NULL;
@ -4632,7 +4632,7 @@ static hawk_nde_t* parse_primary_mbs (hawk_t* awk, const hawk_loc_t* xloc)
return (hawk_nde_t*)nde;
oops:
HAWK_ASSERT (awk, nde != HAWK_NULL);
HAWK_ASSERT (nde != HAWK_NULL);
if (nde->ptr) hawk_freemem (awk, nde->ptr);
hawk_freemem (awk, nde);
return HAWK_NULL;
@ -4659,7 +4659,7 @@ static hawk_nde_t* parse_primary_rex (hawk_t* awk, const hawk_loc_t* xloc)
SET_TOKEN_TYPE (awk, &awk->tok, TOK_REX);
if (get_rexstr (awk, &awk->tok) <= -1) return HAWK_NULL;
HAWK_ASSERT (awk, MATCH(awk,TOK_REX));
HAWK_ASSERT (MATCH(awk,TOK_REX));
nde = (hawk_nde_rex_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde));
if (nde == HAWK_NULL)
@ -4685,7 +4685,7 @@ static hawk_nde_t* parse_primary_rex (hawk_t* awk, const hawk_loc_t* xloc)
return (hawk_nde_t*)nde;
oops:
HAWK_ASSERT (awk, nde != HAWK_NULL);
HAWK_ASSERT (nde != HAWK_NULL);
if (nde->code[0]) hawk_freerex (awk, nde->code[0], nde->code[1]);
if (nde->str.ptr) hawk_freemem (awk, nde->str.ptr);
hawk_freemem (awk, nde);
@ -4743,7 +4743,7 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc)
/* parse subsequent expressions separated by a comma, if any */
last = nde;
HAWK_ASSERT (awk, last->next == HAWK_NULL);
HAWK_ASSERT (last->next == HAWK_NULL);
while (MATCH(awk,TOK_COMMA))
{
@ -4759,7 +4759,7 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc)
tmp = parse_expr_withdc(awk, &eloc);
if (!tmp) goto oops;
HAWK_ASSERT (awk, tmp->next == HAWK_NULL);
HAWK_ASSERT (tmp->next == HAWK_NULL);
last->next = tmp;
last = tmp;
}
@ -5133,7 +5133,7 @@ static int dup_ident_and_get_next (hawk_t* awk, const hawk_loc_t* xloc, hawk_ooc
{
int nsegs = 0;
HAWK_ASSERT (awk, MATCH(awk,TOK_IDENT));
HAWK_ASSERT (MATCH(awk,TOK_IDENT));
do
{
@ -5227,7 +5227,7 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo
*/
hawk_oocs_t segs[2];
HAWK_ASSERT (awk, fnc->spec.arg.spec != HAWK_NULL);
HAWK_ASSERT (fnc->spec.arg.spec != HAWK_NULL);
segs[0].ptr = (hawk_ooch_t*)fnc->spec.arg.spec;
segs[0].len = hawk_count_oocstr(fnc->spec.arg.spec);
@ -5275,12 +5275,12 @@ static hawk_nde_t* parse_primary_ident_noseg (hawk_t* awk, const hawk_loc_t* xlo
if (fntype)
{
HAWK_ASSERT (awk, fntype == FNTYPE_FUN);
HAWK_ASSERT (fntype == FNTYPE_FUN);
if (MATCH(awk,TOK_LPAREN))
{
/* must be a function name */
HAWK_ASSERT (awk, hawk_htb_search(awk->parse.named, name->ptr, name->len) == HAWK_NULL);
HAWK_ASSERT (hawk_htb_search(awk->parse.named, name->ptr, name->len) == HAWK_NULL);
nde = parse_fncall(awk, name, HAWK_NULL, xloc, 0);
}
else
@ -5455,7 +5455,7 @@ static hawk_nde_t* parse_primary_ident (hawk_t* awk, const hawk_loc_t* xloc)
hawk_oocs_t name[2]; /* TODO: support more than 2 segments??? */
int nsegs;
HAWK_ASSERT (awk, MATCH(awk,TOK_IDENT));
HAWK_ASSERT (MATCH(awk,TOK_IDENT));
nsegs = dup_ident_and_get_next(awk, xloc, name, HAWK_COUNTOF(name));
if (nsegs <= -1) return HAWK_NULL;
@ -5536,7 +5536,7 @@ static hawk_nde_t* parse_hashidx (hawk_t* awk, const hawk_oocs_t* name, const ha
if (idx == HAWK_NULL)
{
HAWK_ASSERT (awk, last == HAWK_NULL);
HAWK_ASSERT (last == HAWK_NULL);
idx = tmp; last = tmp;
}
else
@ -5547,7 +5547,7 @@ static hawk_nde_t* parse_hashidx (hawk_t* awk, const hawk_oocs_t* name, const ha
}
while (MATCH(awk,TOK_COMMA));
HAWK_ASSERT (awk, idx != HAWK_NULL);
HAWK_ASSERT (idx != HAWK_NULL);
if (!MATCH(awk,TOK_RBRACK))
{
@ -5630,7 +5630,7 @@ static hawk_nde_t* parse_hashidx (hawk_t* awk, const hawk_oocs_t* name, const ha
goto exit_func;
}
HAWK_ASSERT (awk, fnname == 0);
HAWK_ASSERT (fnname == 0);
nde->type = HAWK_NDE_NAMEDIDX;
nde->loc = *xloc;
@ -5776,7 +5776,7 @@ static int get_number (hawk_t* awk, hawk_tok_t* tok)
{
hawk_ooci_t c;
HAWK_ASSERT (awk, HAWK_OOECS_LEN(tok->name) == 0);
HAWK_ASSERT (HAWK_OOECS_LEN(tok->name) == 0);
SET_TOKEN_TYPE (awk, tok, TOK_INT);
c = awk->sio.last.c;
@ -6694,7 +6694,7 @@ static int deparse (hawk_t* awk)
hawk_ooi_t op;
hawk_oocs_t kw;
HAWK_ASSERT (awk, awk->sio.outf != HAWK_NULL);
HAWK_ASSERT (awk->sio.outf != HAWK_NULL);
HAWK_MEMSET (&awk->sio.arg, 0, HAWK_SIZEOF(awk->sio.arg));
@ -6722,7 +6722,7 @@ static int deparse (hawk_t* awk)
{
hawk_oow_t i, len;
HAWK_ASSERT (awk, awk->tree.ngbls > 0);
HAWK_ASSERT (awk->tree.ngbls > 0);
hawk_getkwname (awk, HAWK_KWID_XGLOBAL, &kw);
if (hawk_putsroocsn(awk, kw.ptr, kw.len) <= -1 || hawk_putsroocs (awk, HAWK_T(" ")) <= -1) EXIT_DEPARSE ();
@ -6737,7 +6737,7 @@ static int deparse (hawk_t* awk)
else
{
len = hawk_int_to_oocstr((hawk_int_t)i, 10, HAWK_T("__g"), tmp, HAWK_COUNTOF(tmp));
HAWK_ASSERT (awk, len != (hawk_oow_t)-1);
HAWK_ASSERT (len != (hawk_oow_t)-1);
if (hawk_putsroocsn (awk, tmp, len) <= -1) EXIT_DEPARSE ();
}
@ -6752,7 +6752,7 @@ static int deparse (hawk_t* awk)
else
{
len = hawk_int_to_oocstr((hawk_int_t)i, 10, HAWK_T("__g"), tmp, HAWK_COUNTOF(tmp));
HAWK_ASSERT (awk, len != (hawk_oow_t)-1);
HAWK_ASSERT (len != (hawk_oow_t)-1);
if (hawk_putsroocsn (awk, tmp, len) <= -1) EXIT_DEPARSE ();
}
@ -6872,7 +6872,7 @@ static hawk_htb_walk_t deparse_func (hawk_htb_t* map, hawk_htb_pair_t* pair, voi
hawk_oow_t i, n;
hawk_oocs_t kw;
HAWK_ASSERT (awk, hawk_comp_oochars(HAWK_HTB_KPTR(pair), HAWK_HTB_KLEN(pair), fun->name.ptr, fun->name.len) == 0);
HAWK_ASSERT (hawk_comp_oochars(HAWK_HTB_KPTR(pair), HAWK_HTB_KLEN(pair), fun->name.ptr, fun->name.len, 0) == 0);
#define PUT_C(x,c) \
if (put_char(x->awk,c)==-1) { \
@ -6900,7 +6900,7 @@ static hawk_htb_walk_t deparse_func (hawk_htb_t* map, hawk_htb_pair_t* pair, voi
{
if (fun->argspec && fun->argspec[i] == 'r') PUT_S (df, HAWK_T("&"));
n = hawk_int_to_oocstr (i++, 10, HAWK_T("__p"), df->tmp, df->tmp_len);
HAWK_ASSERT (awk, n != (hawk_oow_t)-1);
HAWK_ASSERT (n != (hawk_oow_t)-1);
PUT_SX (df, df->tmp, n);
if (i >= fun->nargs) break;
@ -7051,7 +7051,7 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg
hawk_oocs_t ea;
int n;
HAWK_ASSERT (awk, nsegs == 2);
HAWK_ASSERT (nsegs == 2);
pair = hawk_rbt_search (awk->modtab, segs[0].ptr, segs[0].len);
if (pair)

View File

@ -344,7 +344,7 @@ static int make_param (hawk_pio_t* pio, const hawk_ooch_t* cmd, int flags, param
if (flags & HAWK_PIO_SHELL)
{
/*HAWK_ASSERT (pio->hawk, wcmd == HAWK_NULL);*/
/*HAWK_ASSERT (wcmd == HAWK_NULL);*/
/* hawk_wcstombs() should succeed as
* it was successful above */
hawk_conv_ucstr_to_bcstr_with_cmgr (cmd, &wl, mcmd, &mn, pio->gem->cmgr);
@ -352,7 +352,7 @@ static int make_param (hawk_pio_t* pio, const hawk_ooch_t* cmd, int flags, param
}
else
{
HAWK_ASSERT (pio->hawk, wcmd != HAWK_NULL);
HAWK_ASSERT (wcmd != HAWK_NULL);
/* hawk_wcsntombsn() should succeed as
* it was was successful above */
hawk_conv_uchars_to_bchars_with_cmgr (wcmd, &wl, mcmd, &mn, pio->gem->cmgr);
@ -1788,7 +1788,7 @@ create_process:
if (flags & HAWK_PIO_IGNOREECERR) topt |= HAWK_TIO_IGNOREECERR;
if (flags & HAWK_PIO_NOAUTOFLUSH) topt |= HAWK_TIO_NOAUTOFLUSH;
HAWK_ASSERT (pio->hawk, HAWK_COUNTOF(tio) == HAWK_COUNTOF(pio->pin));
HAWK_ASSERT (HAWK_COUNTOF(tio) == HAWK_COUNTOF(pio->pin));
for (i = 0; i < HAWK_COUNTOF(tio); i++)
{
int r;
@ -2150,7 +2150,7 @@ int hawk_pio_wait (hawk_pio_t* pio)
return -1;
}
HAWK_ASSERT (pio->hawk, w == WAIT_OBJECT_0);
HAWK_ASSERT (w == WAIT_OBJECT_0);
if (GetExitCodeProcess(pio->child, &ecode) == FALSE)
{
@ -2258,7 +2258,7 @@ int hawk_pio_wait (hawk_pio_t* pio)
if (n == 0)
{
/* when WNOHANG is not specified, 0 can't be returned */
/*HAWK_ASSERT (pio->hawk, pio->flags & HAWK_PIO_WAITNOBLOCK);*/
/*HAWK_ASSERT (pio->flags & HAWK_PIO_WAITNOBLOCK);*/
ret = 255 + 1;
/* the child process is still alive */
@ -2350,8 +2350,8 @@ static hawk_ooi_t pio_input (hawk_tio_t* tio, hawk_tio_cmd_t cmd, void* buf, haw
if (cmd == HAWK_TIO_DATA)
{
hawk_pio_pin_t* pin = *(hawk_pio_pin_t**)hawk_tio_getxtn(tio);
/*HAWK_ASSERT (pio->hawk, pin != HAWK_NULL);
HAWK_ASSERT (pio->hawk, pin->self != HAWK_NULL);*/
HAWK_ASSERT (pin != HAWK_NULL);
HAWK_ASSERT (pin->self != HAWK_NULL);
return pio_read(pin->self, buf, size, pin->handle);
}
@ -2365,8 +2365,8 @@ static hawk_ooi_t pio_output (hawk_tio_t* tio, hawk_tio_cmd_t cmd, void* buf, ha
if (cmd == HAWK_TIO_DATA)
{
hawk_pio_pin_t* pin = *(hawk_pio_pin_t**)hawk_tio_getxtn(tio);
/*HAWK_ASSERT (pio->hawk, pin != HAWK_NULL);
HAWK_ASSERT (pio->hawk, pin->self != HAWK_NULL);*/
HAWK_ASSERT (pin != HAWK_NULL);
HAWK_ASSERT (pin->self != HAWK_NULL);
return pio_write(pin->self, buf, size, pin->handle);
}

View File

@ -250,7 +250,7 @@ const hawk_rbt_style_t* hawk_rbt_getstyle (const hawk_rbt_t* rbt)
void hawk_rbt_setstyle (hawk_rbt_t* rbt, const hawk_rbt_style_t* style)
{
HAWK_ASSERT (rbt->hawk, style != HAWK_NULL);
HAWK_ASSERT (style != HAWK_NULL);
rbt->style = style;
}
@ -315,7 +315,7 @@ static void rotate (hawk_rbt_t* rbt, hawk_rbt_pair_t* pivot, int leftwise)
hawk_rbt_pair_t* parent, * z, * c;
int cid1, cid2;
HAWK_ASSERT (rbt->hawk, pivot != HAWK_NULL);
HAWK_ASSERT (pivot != HAWK_NULL);
if (leftwise)
{
@ -343,13 +343,13 @@ static void rotate (hawk_rbt_t* rbt, hawk_rbt_pair_t* pivot, int leftwise)
}
else
{
HAWK_ASSERT (rbt->hawk, parent->right == pivot);
HAWK_ASSERT (parent->right == pivot);
parent->right = z;
}
}
else
{
HAWK_ASSERT (rbt->hawk, rbt->root == pivot);
HAWK_ASSERT (rbt->root == pivot);
rbt->root = z;
}
@ -370,7 +370,7 @@ static void adjust (hawk_rbt_t* rbt, hawk_rbt_pair_t* pair)
x_par = pair->parent;
if (x_par->color == HAWK_RBT_BLACK) break;
HAWK_ASSERT (rbt->hawk, x_par->parent != HAWK_NULL);
HAWK_ASSERT (x_par->parent != HAWK_NULL);
if (x_par == x_par->parent->child[LEFT])
{
@ -458,7 +458,7 @@ static hawk_rbt_pair_t* change_pair_val (
}
else
{
HAWK_ASSERT (rbt->hawk, pair->parent->right == pair);
HAWK_ASSERT (pair->parent->right == pair);
pair->parent->right = p;
}
}
@ -535,7 +535,7 @@ static hawk_rbt_pair_t* insert (hawk_rbt_t* rbt, void* kptr, hawk_oow_t klen, vo
if (x_par == HAWK_NULL)
{
/* the tree contains no pair */
HAWK_ASSERT (rbt->hawk, rbt->root == &rbt->xnil);
HAWK_ASSERT (rbt->root == &rbt->xnil);
rbt->root = x_new;
}
else
@ -544,12 +544,12 @@ static hawk_rbt_pair_t* insert (hawk_rbt_t* rbt, void* kptr, hawk_oow_t klen, vo
int n = rbt->style->comper(rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
if (n > 0)
{
HAWK_ASSERT (rbt->hawk, x_par->right == &rbt->xnil);
HAWK_ASSERT (x_par->right == &rbt->xnil);
x_par->right = x_new;
}
else
{
HAWK_ASSERT (rbt->hawk, x_par->left == &rbt->xnil);
HAWK_ASSERT (x_par->left == &rbt->xnil);
x_par->left = x_new;
}
@ -627,7 +627,7 @@ hawk_rbt_pair_t* hawk_rbt_cbsert (hawk_rbt_t* rbt, void* kptr, hawk_oow_t klen,
}
else
{
HAWK_ASSERT (rbt->hawk, tmp.parent->right == x_cur);
HAWK_ASSERT (tmp.parent->right == x_cur);
tmp.parent->right = x_new;
}
}
@ -652,7 +652,7 @@ hawk_rbt_pair_t* hawk_rbt_cbsert (hawk_rbt_t* rbt, void* kptr, hawk_oow_t klen,
if (x_par == HAWK_NULL)
{
/* the tree contains no pair */
HAWK_ASSERT (rbt->hawk, rbt->root == &rbt->xnil);
HAWK_ASSERT (rbt->root == &rbt->xnil);
rbt->root = x_new;
}
else
@ -661,12 +661,12 @@ hawk_rbt_pair_t* hawk_rbt_cbsert (hawk_rbt_t* rbt, void* kptr, hawk_oow_t klen,
int n = rbt->style->comper(rbt, kptr, klen, KPTR(x_par), KLEN(x_par));
if (n > 0)
{
HAWK_ASSERT (rbt->hawk, x_par->right == &rbt->xnil);
HAWK_ASSERT (x_par->right == &rbt->xnil);
x_par->right = x_new;
}
else
{
HAWK_ASSERT (rbt->hawk, x_par->left == &rbt->xnil);
HAWK_ASSERT (x_par->left == &rbt->xnil);
x_par->left = x_new;
}
@ -726,7 +726,7 @@ static void adjust_for_delete (hawk_rbt_t* rbt, hawk_rbt_pair_t* pair, hawk_rbt_
}
else
{
HAWK_ASSERT (rbt->hawk, pair == par->right);
HAWK_ASSERT (pair == par->right);
tmp = par->left;
if (tmp->color == HAWK_RBT_RED)
{
@ -771,7 +771,7 @@ static void delete_pair (hawk_rbt_t* rbt, hawk_rbt_pair_t* pair)
{
hawk_rbt_pair_t* x, * y, * par;
HAWK_ASSERT (rbt->hawk, pair && !IS_NIL(rbt,pair));
HAWK_ASSERT (pair && !IS_NIL(rbt,pair));
if (IS_NIL(rbt,pair->left) || IS_NIL(rbt,pair->right))
{
@ -949,7 +949,7 @@ static HAWK_INLINE void walk (hawk_rbt_t* rbt, walker_t walker, void* ctx, int l
else
{
/* both the left child and the right child have been traversed */
HAWK_ASSERT (rbt->hawk, prev == x_cur->child[r]);
HAWK_ASSERT (prev == x_cur->child[r]);
/* just move up to the parent */
prev = x_cur;
x_cur = x_cur->parent;

View File

@ -59,7 +59,7 @@ int hawk_rtx_setrec (hawk_rtx_t* rtx, hawk_oow_t idx, const hawk_oocs_t* str)
return -1;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, rtx->inrec.d0) == HAWK_VAL_NIL);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, rtx->inrec.d0) == HAWK_VAL_NIL);
/* d0 should be cleared before the next line is reached
* as it doesn't call hawk_rtx_refdownval on rtx->inrec.d0 */
rtx->inrec.d0 = v;
@ -109,7 +109,7 @@ static int split_record (hawk_rtx_t* rtx)
/* inrec should be cleared before split_record is called */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->inrec.nflds == 0);
HAWK_ASSERT (rtx->inrec.nflds == 0);
/* get FS */
fs = hawk_rtx_getgbl (rtx, HAWK_GBL_FS);
@ -195,7 +195,7 @@ static int split_record (hawk_rtx_t* rtx)
return 0;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
HAWK_ASSERT ((tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
nflds++;
len = HAWK_OOECS_LEN(&rtx->inrec.line) - (p - HAWK_OOECS_PTR(&rtx->inrec.line));
@ -282,7 +282,7 @@ static int split_record (hawk_rtx_t* rtx)
}
#endif
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
HAWK_ASSERT ((tok.ptr != HAWK_NULL && tok.len > 0) || tok.len == 0);
#if 1
if (rtx->inrec.nflds >= rtx->inrec.maxflds)
@ -355,11 +355,11 @@ int hawk_rtx_clrrec (hawk_rtx_t* run, int skip_inrec_line)
if (run->inrec.nflds > 0)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->inrec.flds != HAWK_NULL);
HAWK_ASSERT (run->inrec.flds != HAWK_NULL);
for (i = 0; i < run->inrec.nflds; i++)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->inrec.flds[i].val != HAWK_NULL);
HAWK_ASSERT (run->inrec.flds[i].val != HAWK_NULL);
hawk_rtx_refdownval (run, run->inrec.flds[i].val);
}
run->inrec.nflds = 0;
@ -374,7 +374,7 @@ int hawk_rtx_clrrec (hawk_rtx_t* run, int skip_inrec_line)
}
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run->inrec.nflds == 0);
HAWK_ASSERT (run->inrec.nflds == 0);
if (!skip_inrec_line) hawk_ooecs_clear (&run->inrec.line);
return n;
@ -388,7 +388,7 @@ static int recomp_record_fields (hawk_rtx_t* rtx, hawk_oow_t lv, const hawk_oocs
/* recomposes the record and the fields when $N has been assigned
* a new value and recomputes NF accordingly */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), lv > 0);
HAWK_ASSERT (lv > 0);
max = (lv > rtx->inrec.nflds)? lv: rtx->inrec.nflds;
nflds = rtx->inrec.nflds;
@ -482,7 +482,7 @@ static int recomp_record_fields (hawk_rtx_t* rtx, hawk_oow_t lv, const hawk_oocs
}
v = hawk_rtx_getgbl (rtx, HAWK_GBL_NF);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, v) == HAWK_VAL_INT);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, v) == HAWK_VAL_INT);
if (HAWK_RTX_GETINTFROMVAL (rtx, v)!= max)
{

View File

@ -101,9 +101,9 @@ static int find_rio_in (
hawk_rio_impl_t handler;
int io_type, io_mode, io_mask;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
/* translate the in_type into the relevant io type and mode */
io_type = in_type_map[in_type];
@ -225,8 +225,8 @@ static HAWK_INLINE int match_long_rs (hawk_rtx_t* rtx, hawk_ooecs_t* buf, hawk_r
hawk_errnum_t errnum;
int ret;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->gbl.rs[0] != HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->gbl.rs[1] != HAWK_NULL);
HAWK_ASSERT (rtx->gbl.rs[0] != HAWK_NULL);
HAWK_ASSERT (rtx->gbl.rs[1] != HAWK_NULL);
ret = hawk_rtx_matchrex(
rtx, rtx->gbl.rs[rtx->gbl.ignorecase],
@ -242,7 +242,7 @@ static HAWK_INLINE int match_long_rs (hawk_rtx_t* rtx, hawk_ooecs_t* buf, hawk_r
* as the previous call to this function.
* A match in this case must end at the end of
* the current record buffer */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_PTR(buf) + HAWK_OOECS_LEN(buf) == match.ptr + match.len);
HAWK_ASSERT (HAWK_OOECS_PTR(buf) + HAWK_OOECS_LEN(buf) == match.ptr + match.len);
/* drop the RS part. no extra character after RS to drop
* because we're at EOF and the EOF condition didn't
@ -428,9 +428,9 @@ int hawk_rtx_readio (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name, hawk
/* CR must have come from the previous
* read. drop CR that must be found at
* the end of the record buffer. */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), end_pos == start_pos);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LEN(buf) > 0);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LASTCHAR(buf) == HAWK_T('\r'));
HAWK_ASSERT (end_pos == start_pos);
HAWK_ASSERT (HAWK_OOECS_LEN(buf) > 0);
HAWK_ASSERT (HAWK_OOECS_LASTCHAR(buf) == HAWK_T('\r'));
HAWK_OOECS_LEN(buf)--;
}
}
@ -466,7 +466,7 @@ int hawk_rtx_readio (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name, hawk
{
/* shrink the line length and the record
* by dropping of CR before NL */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), line_len > 0);
HAWK_ASSERT (line_len > 0);
line_len--;
/* we don't drop CR from the record buffer
@ -642,9 +642,9 @@ static int prepare_for_write_io_data (hawk_rtx_t* rtx, int out_type, const hawk_
hawk_rio_impl_t handler;
int io_type, io_mode, io_mask, n;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
/* translate the out_type into the relevant io type and mode */
io_type = out_type_map[out_type];
@ -803,9 +803,9 @@ int hawk_rtx_flushio (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* name)
hawk_ooi_t n;
int ok = 0;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
/* translate the out_type into the relevant I/O type and mode */
io_type = out_type_map[out_type];
@ -859,9 +859,9 @@ int hawk_rtx_nextio_read (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name)
int io_type, /*io_mode,*/ io_mask;
hawk_ooi_t n;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
/* translate the in_type into the relevant I/O type and mode */
io_type = in_type_map[in_type];
@ -885,7 +885,7 @@ int hawk_rtx_nextio_read (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name)
if (!p)
{
/* something is totally wrong */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - cannot find the relevant rio entry");
HAWK_ASSERT (!"should never happen - cannot find the relevant rio entry");
hawk_rtx_seterrnum (rtx, HAWK_EINTERN, HAWK_NULL);
return -1;
}
@ -934,9 +934,9 @@ int hawk_rtx_nextio_write (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* nam
int io_type, /*io_mode,*/ io_mask;
hawk_ooi_t n;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
/* translate the out_type into the relevant I/O type and mode */
io_type = out_type_map[out_type];
@ -960,7 +960,7 @@ int hawk_rtx_nextio_write (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* nam
if (!p)
{
/* something is totally wrong */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - cannot find the relevant rio entry");
HAWK_ASSERT (!"should never happen - cannot find the relevant rio entry");
hawk_rtx_seterrnum (rtx, HAWK_EINTERN, HAWK_NULL);
return -1;
@ -1004,9 +1004,9 @@ int hawk_rtx_closio_read (hawk_rtx_t* rtx, int in_type, const hawk_ooch_t* name)
hawk_rio_impl_t handler;
int io_type, /*io_mode,*/ io_mask;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_type_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_mode_map));
HAWK_ASSERT (in_type >= 0 && in_type <= HAWK_COUNTOF(in_mask_map));
/* translate the in_type into the relevant I/O type and mode */
io_type = in_type_map[in_type];
@ -1061,9 +1061,9 @@ int hawk_rtx_closio_write (hawk_rtx_t* rtx, int out_type, const hawk_ooch_t* nam
hawk_rio_impl_t handler;
int io_type, /*io_mode,*/ io_mask;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_type_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mode_map));
HAWK_ASSERT (out_type >= 0 && out_type <= HAWK_COUNTOF(out_mask_map));
/* translate the out_type into the relevant io type and mode */
io_type = out_type_map[out_type];
@ -1143,7 +1143,7 @@ int hawk_rtx_closeio (hawk_rtx_t* rtx, const hawk_ooch_t* name, const hawk_ooch_
}
else
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), opt[0] == HAWK_T('w'));
HAWK_ASSERT (opt[0] == HAWK_T('w'));
if (p->type & IO_MASK_RDWR)
{
if (p->rwcstate != HAWK_RIO_CMD_CLOSE_READ)

View File

@ -223,7 +223,7 @@ static hawk_val_t* eval_printf (hawk_rtx_t* rtx, hawk_nde_t* nde);
static int __raw_push (hawk_rtx_t* rtx, void* val);
#define __raw_pop(rtx) \
do { \
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (rtx)->stack_top > (rtx)->stack_base); \
HAWK_ASSERT ((rtx)->stack_top > (rtx)->stack_base); \
(rtx)->stack_top--; \
} while (0)
@ -248,7 +248,7 @@ HAWK_INLINE hawk_val_t* hawk_rtx_getarg (hawk_rtx_t* rtx, hawk_oow_t idx)
HAWK_INLINE hawk_val_t* hawk_rtx_getgbl (hawk_rtx_t* rtx, int id)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls));
HAWK_ASSERT (id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls));
return RTX_STACK_GBL(rtx, id);
}
@ -416,7 +416,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t
/* due to the expression evaluation rule, the
* regular expression can not be an assigned value */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), vtype != HAWK_VAL_REX);
HAWK_ASSERT (vtype != HAWK_VAL_REX);
out.type = HAWK_RTX_VALTOSTR_CPLDUP;
if (hawk_rtx_valtostr (rtx, val, &out) <= -1) return -1;
@ -565,7 +565,7 @@ static int set_global (hawk_rtx_t* rtx, int idx, hawk_nde_var_t* var, hawk_val_t
/* due to the expression evaluation rule, the
* regular expression can not be an assigned
* value */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), vtype != HAWK_VAL_REX);
HAWK_ASSERT (vtype != HAWK_VAL_REX);
out.type = HAWK_RTX_VALTOSTR_CPLDUP;
if (hawk_rtx_valtostr(rtx, val, &out) <= -1) return -1;
@ -655,7 +655,7 @@ HAWK_INLINE void hawk_rtx_setretval (hawk_rtx_t* rtx, hawk_val_t* val)
HAWK_INLINE int hawk_rtx_setgbl (hawk_rtx_t* rtx, int id, hawk_val_t* val)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls));
HAWK_ASSERT (id >= 0 && id < (int)HAWK_ARR_SIZE(rtx->awk->parse.gbls));
return set_global (rtx, id, HAWK_NULL, val, 0);
}
@ -1010,7 +1010,7 @@ static void fini_rtx (hawk_rtx_t* rtx, int fini_globals)
/* close all pending io's */
/* TODO: what if this operation fails? */
hawk_rtx_cleario (rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->rio.chain == HAWK_NULL);
HAWK_ASSERT (rtx->rio.chain == HAWK_NULL);
if (rtx->gbl.rs[0])
{
@ -1097,7 +1097,7 @@ static void fini_rtx (hawk_rtx_t* rtx, int fini_globals)
/* destroy the stack if necessary */
if (rtx->stack)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->stack_top == 0);
HAWK_ASSERT (rtx->stack_top == 0);
hawk_rtx_freemem (rtx, rtx->stack);
rtx->stack = HAWK_NULL;
@ -1257,7 +1257,7 @@ static int defaultify_globals (hawk_rtx_t* rtx)
hawk_rtx_refupval (rtx, tmp);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), RTX_STACK_GBL(rtx,gtab[i].idx) == hawk_val_nil);
HAWK_ASSERT (RTX_STACK_GBL(rtx,gtab[i].idx) == hawk_val_nil);
if (hawk_rtx_setgbl(rtx, gtab[i].idx, tmp) == -1)
{
@ -1293,8 +1293,8 @@ static void refdown_globals (hawk_rtx_t* run, int pop)
static int init_globals (hawk_rtx_t* rtx)
{
/* the stack must be clean when this function is invoked */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->stack_base == 0);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->stack_top == 0);
HAWK_ASSERT (rtx->stack_base == 0);
HAWK_ASSERT (rtx->stack_top == 0);
if (prepare_globals (rtx) == -1) return -1;
if (update_fnr (rtx, 0, 0) == -1) goto oops;
@ -1357,7 +1357,7 @@ static void exit_stack_frame (hawk_rtx_t* run)
{
/* At this point, the current stack frame should have
* the 4 entries pushed in enter_stack_frame(). */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), (run->stack_top-run->stack_base) == 4);
HAWK_ASSERT ((run->stack_top-run->stack_base) == 4);
run->stack_top = (hawk_oow_t)run->stack[run->stack_base + 1];
run->stack_base = (hawk_oow_t)run->stack[run->stack_base + 0];
@ -1382,7 +1382,7 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx)
hawk_nde_blk_t* blk;
blk = (hawk_nde_blk_t*)nde;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), blk->type == HAWK_NDE_BLK);
HAWK_ASSERT (blk->type == HAWK_NDE_BLK);
rtx->active_block = blk;
rtx->exit_level = EXIT_NONE;
@ -1427,7 +1427,7 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx)
hawk_nde_blk_t* blk;
blk = (hawk_nde_blk_t*)nde;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), blk->type == HAWK_NDE_BLK);
HAWK_ASSERT (blk->type == HAWK_NDE_BLK);
rtx->active_block = blk;
rtx->exit_level = EXIT_NONE;
@ -1454,7 +1454,7 @@ static hawk_val_t* run_bpae_loop (hawk_rtx_t* rtx)
* pushed to the stack as asserted below. we didn't push any arguments
* for BEGIN/pattern action/END block execution.*/
nargs = (hawk_oow_t)RTX_STACK_NARGS(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == 0);
HAWK_ASSERT (nargs == 0);
for (i = 0; i < nargs; i++)
hawk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i));
@ -1548,7 +1548,7 @@ hawk_val_t* hawk_rtx_callfun (hawk_rtx_t* rtx, hawk_fun_t* fun, hawk_val_t* args
struct pafv_t pafv/*= { args, nargs }*/;
hawk_nde_fncall_t call;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun != HAWK_NULL);
HAWK_ASSERT (fun != HAWK_NULL);
pafv.args = args;
pafv.nargs = nargs;
@ -1806,8 +1806,8 @@ static int run_pblock (hawk_rtx_t* rtx, hawk_chain_t* cha, hawk_oow_t bno)
else
{
/* pattern, pattern { ... } */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), ptn->next->next == HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->pattern_range_state != HAWK_NULL);
HAWK_ASSERT (ptn->next->next == HAWK_NULL);
HAWK_ASSERT (rtx->pattern_range_state != HAWK_NULL);
if (rtx->pattern_range_state[bno] == 0)
{
@ -1888,7 +1888,7 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde)
return 0;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->type == HAWK_NDE_BLK);
HAWK_ASSERT (nde->type == HAWK_NDE_BLK);
p = nde->body;
nlcls = nde->nlcls;
@ -2071,7 +2071,7 @@ static int run_if (hawk_rtx_t* rtx, hawk_nde_if_t* nde)
/* the test expression for the if statement cannot have
* chained expressions. this should not be allowed by the
* parser first of all */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL);
HAWK_ASSERT (nde->test->next == HAWK_NULL);
test = eval_expression (rtx, nde->test);
if (test == HAWK_NULL) return -1;
@ -2098,7 +2098,7 @@ static int run_while (hawk_rtx_t* rtx, hawk_nde_while_t* nde)
{
/* no chained expressions are allowed for the test
* expression of the while statement */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL);
HAWK_ASSERT (nde->test->next == HAWK_NULL);
while (1)
{
@ -2142,7 +2142,7 @@ static int run_while (hawk_rtx_t* rtx, hawk_nde_while_t* nde)
{
/* no chained expressions are allowed for the test
* expression of the while statement */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL);
HAWK_ASSERT (nde->test->next == HAWK_NULL);
do
{
@ -2186,7 +2186,7 @@ static int run_for (hawk_rtx_t* rtx, hawk_nde_for_t* nde)
if (nde->init != HAWK_NULL)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->init->next == HAWK_NULL);
HAWK_ASSERT (nde->init->next == HAWK_NULL);
ON_STATEMENT (rtx, nde->init);
val = eval_expression(rtx,nde->init);
@ -2204,7 +2204,7 @@ static int run_for (hawk_rtx_t* rtx, hawk_nde_for_t* nde)
/* no chained expressions for the test expression of
* the for statement are allowed */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->test->next == HAWK_NULL);
HAWK_ASSERT (nde->test->next == HAWK_NULL);
ON_STATEMENT (rtx, nde->test);
test = eval_expression (rtx, nde->test);
@ -2245,7 +2245,7 @@ static int run_for (hawk_rtx_t* rtx, hawk_nde_for_t* nde)
if (nde->incr != HAWK_NULL)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->incr->next == HAWK_NULL);
HAWK_ASSERT (nde->incr->next == HAWK_NULL);
ON_STATEMENT (rtx, nde->incr);
val = eval_expression (rtx, nde->incr);
@ -2323,11 +2323,11 @@ static int run_foreach (hawk_rtx_t* rtx, hawk_nde_foreach_t* nde)
hawk_val_type_t rvtype;
test = (hawk_nde_exp_t*)nde->test;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), test->type == HAWK_NDE_EXP_BIN && test->opcode == HAWK_BINOP_IN);
HAWK_ASSERT (test->type == HAWK_NDE_EXP_BIN && test->opcode == HAWK_BINOP_IN);
/* chained expressions should not be allowed
* by the parser first of all */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), test->right->next == HAWK_NULL);
HAWK_ASSERT (test->right->next == HAWK_NULL);
rv = eval_expression(rtx, test->right);
if (rv == HAWK_NULL) return -1;
@ -2378,7 +2378,7 @@ static int run_return (hawk_rtx_t* rtx, hawk_nde_return_t* nde)
/* chained expressions should not be allowed
* by the parser first of all */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->val->next == HAWK_NULL);
HAWK_ASSERT (nde->val->next == HAWK_NULL);
val = eval_expression (rtx, nde->val);
if (val == HAWK_NULL) return -1;
@ -2414,7 +2414,7 @@ static int run_exit (hawk_rtx_t* rtx, hawk_nde_exit_t* nde)
/* chained expressions should not be allowed
* by the parser first of all */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->val->next == HAWK_NULL);
HAWK_ASSERT (nde->val->next == HAWK_NULL);
val = eval_expression (rtx, nde->val);
if (val == HAWK_NULL) return -1;
@ -2529,7 +2529,7 @@ static int delete_indexed (
{
hawk_val_t* idx;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), var->idx != HAWK_NULL);
HAWK_ASSERT (var->idx != HAWK_NULL);
idx = eval_expression (rtx, var->idx);
if (idx == HAWK_NULL) return -1;
@ -2588,7 +2588,7 @@ static int run_delete_named (hawk_rtx_t* rtx, hawk_nde_var_t* var)
/* if a named variable has an index part and a named indexed variable
* doesn't have an index part, the program is definitely wrong */
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
(var->type == HAWK_NDE_NAMED && var->idx == HAWK_NULL) ||
(var->type == HAWK_NDE_NAMEDIDX && var->idx != HAWK_NULL));
@ -2627,7 +2627,7 @@ static int run_delete_named (hawk_rtx_t* rtx, hawk_nde_var_t* var)
hawk_htb_t* map;
val = (hawk_val_t*)HAWK_HTB_VPTR(pair);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL);
HAWK_ASSERT (val != HAWK_NULL);
if (HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_MAP)
{
@ -2671,7 +2671,7 @@ static int run_delete_unnamed (hawk_rtx_t* rtx, hawk_nde_var_t* var)
break;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL);
HAWK_ASSERT (val != HAWK_NULL);
vtype = HAWK_RTX_GETVALTYPE(rtx, val);
if (vtype == HAWK_VAL_NIL)
@ -2770,7 +2770,7 @@ static int run_delete (hawk_rtx_t* rtx, hawk_nde_delete_t* nde)
default:
/* the delete statement cannot be called with other nodes than
* the variables such as a named variable, a named indexed variable, etc */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - wrong target for delete");
HAWK_ASSERT (!"should never happen - wrong target for delete");
SETERR_LOC (rtx, HAWK_EBADARG, &var->loc);
return -1;
}
@ -2783,7 +2783,7 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var)
{
case HAWK_NDE_NAMED:
/* if a named variable has an index part, something is definitely wrong */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), var->type == HAWK_NDE_NAMED && var->idx == HAWK_NULL);
HAWK_ASSERT (var->type == HAWK_NDE_NAMED && var->idx == HAWK_NULL);
/* a named variable can be reset if removed from a internal map
to manage it */
@ -2811,7 +2811,7 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var)
break;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL);
HAWK_ASSERT (val != HAWK_NULL);
if (HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_NIL)
{
@ -2836,7 +2836,7 @@ static int reset_variable (hawk_rtx_t* rtx, hawk_nde_var_t* var)
default:
/* the reset statement can only be called with plain variables */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - wrong target for reset");
HAWK_ASSERT (!"should never happen - wrong target for reset");
SETERR_LOC (rtx, HAWK_EBADARG, &var->loc);
return -1;
}
@ -2854,7 +2854,7 @@ static int run_print (hawk_rtx_t* rtx, hawk_nde_print_t* nde)
const hawk_ooch_t* dst;
int n, xret = 0;
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
(nde->out_type == HAWK_OUT_PIPE && nde->out != HAWK_NULL) ||
(nde->out_type == HAWK_OUT_RWPIPE && nde->out != HAWK_NULL) ||
(nde->out_type == HAWK_OUT_FILE && nde->out != HAWK_NULL) ||
@ -2932,7 +2932,7 @@ static int run_print (hawk_rtx_t* rtx, hawk_nde_print_t* nde)
if (nde->args->type == HAWK_NDE_GRP)
{
/* parenthesized print */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->args->next == HAWK_NULL);
HAWK_ASSERT (nde->args->next == HAWK_NULL);
head = ((hawk_nde_grp_t*)nde->args)->body;
}
else head = nde->args;
@ -3023,7 +3023,7 @@ static int run_printf (hawk_rtx_t* rtx, hawk_nde_print_t* nde)
hawk_nde_t* head;
int n, xret = 0;
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
(nde->out_type == HAWK_OUT_PIPE && nde->out != HAWK_NULL) ||
(nde->out_type == HAWK_OUT_RWPIPE && nde->out != HAWK_NULL) ||
(nde->out_type == HAWK_OUT_FILE && nde->out != HAWK_NULL) ||
@ -3068,18 +3068,18 @@ static int run_printf (hawk_rtx_t* rtx, hawk_nde_print_t* nde)
dst = (out == HAWK_NULL)? HAWK_T(""): out;
/*( valid printf statement should have at least one argument. the parser must ensure this. */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->args != HAWK_NULL);
HAWK_ASSERT (nde->args != HAWK_NULL);
if (nde->args->type == HAWK_NDE_GRP)
{
/* parenthesized print */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->args->next == HAWK_NULL);
HAWK_ASSERT (nde->args->next == HAWK_NULL);
head = ((hawk_nde_grp_t*)nde->args)->body;
}
else head = nde->args;
/* valid printf statement should have at least one argument. the parser must ensure this */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), head != HAWK_NULL);
HAWK_ASSERT (head != HAWK_NULL);
v = eval_expression(rtx, head);
if (v == HAWK_NULL) goto oops_1;
@ -3233,7 +3233,7 @@ static hawk_val_t* eval_expression (hawk_rtx_t* rtx, hawk_nde_t* nde)
else
{
/* the internal value representing $0 should always be of the string type once it has been set/updated. it is nil initially. */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, rtx->inrec.d0) == HAWK_VAL_STR);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE(rtx, rtx->inrec.d0) == HAWK_VAL_STR);
vs.ptr = ((hawk_val_str_t*)rtx->inrec.d0)->val.ptr;
vs.len = ((hawk_val_str_t*)rtx->inrec.d0)->val.len;
}
@ -3297,7 +3297,7 @@ static hawk_val_t* eval_expression0 (hawk_rtx_t* rtx, hawk_nde_t* nde)
hawk_val_t* v;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->type >= HAWK_NDE_GRP && (nde->type - HAWK_NDE_GRP) < HAWK_COUNTOF(__evaluator));
HAWK_ASSERT (nde->type >= HAWK_NDE_GRP && (nde->type - HAWK_NDE_GRP) < HAWK_COUNTOF(__evaluator));
v = __evaluator[nde->type-HAWK_NDE_GRP](rtx, nde);
@ -3322,7 +3322,7 @@ static hawk_val_t* eval_group (hawk_rtx_t* rtx, hawk_nde_t* nde)
#if 0
/* eval_binop_in evaluates the HAWK_NDE_GRP specially.
* so this function should never be reached. */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - NDE_GRP only for in");
HAWK_ASSERT (!"should never happen - NDE_GRP only for in");
SETERR_LOC (rtx, HAWK_EINTERN, &nde->loc);
return HAWK_NULL;
#endif
@ -3342,7 +3342,7 @@ static hawk_val_t* eval_group (hawk_rtx_t* rtx, hawk_nde_t* nde)
np = ((hawk_nde_grp_t*)nde)->body;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), np != HAWK_NULL);
HAWK_ASSERT (np != HAWK_NULL);
loop:
val = eval_expression (rtx, np);
@ -3364,10 +3364,10 @@ static hawk_val_t* eval_assignment (hawk_rtx_t* rtx, hawk_nde_t* nde)
hawk_val_t* val, * ret;
hawk_nde_ass_t* ass = (hawk_nde_ass_t*)nde;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->left != HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->right != HAWK_NULL);
HAWK_ASSERT (ass->left != HAWK_NULL);
HAWK_ASSERT (ass->right != HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->right->next == HAWK_NULL);
HAWK_ASSERT (ass->right->next == HAWK_NULL);
val = eval_expression (rtx, ass->right);
if (val == HAWK_NULL) return HAWK_NULL;
@ -3395,7 +3395,7 @@ static hawk_val_t* eval_assignment (hawk_rtx_t* rtx, hawk_nde_t* nde)
eval_binop_bor
};
HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->left->next == HAWK_NULL);
HAWK_ASSERT (ass->left->next == HAWK_NULL);
val2 = eval_expression(rtx, ass->left);
if (val2 == HAWK_NULL)
{
@ -3405,9 +3405,9 @@ static hawk_val_t* eval_assignment (hawk_rtx_t* rtx, hawk_nde_t* nde)
hawk_rtx_refupval (rtx, val2);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->opcode >= 0);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), ass->opcode < HAWK_COUNTOF(binop_func));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), binop_func[ass->opcode] != HAWK_NULL);
HAWK_ASSERT (ass->opcode >= 0);
HAWK_ASSERT (ass->opcode < HAWK_COUNTOF(binop_func));
HAWK_ASSERT (binop_func[ass->opcode] != HAWK_NULL);
tmp = binop_func[ass->opcode](rtx, val2, val);
if (tmp == HAWK_NULL)
@ -3470,7 +3470,7 @@ static hawk_val_t* do_assignment (hawk_rtx_t* rtx, hawk_nde_t* var, hawk_val_t*
break;
default:
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid variable type");
HAWK_ASSERT (!"should never happen - invalid variable type");
errnum = HAWK_EINTERN;
goto exit_on_error;
}
@ -3486,14 +3486,14 @@ static hawk_val_t* do_assignment_nonidx (hawk_rtx_t* run, hawk_nde_var_t* var, h
{
hawk_val_type_t vtype;
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
var->type == HAWK_NDE_NAMED ||
var->type == HAWK_NDE_GBL ||
var->type == HAWK_NDE_LCL ||
var->type == HAWK_NDE_ARG
);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), var->idx == HAWK_NULL);
HAWK_ASSERT (var->idx == HAWK_NULL);
vtype = HAWK_RTX_GETVALTYPE (rtx, val);
switch (var->type)
@ -3614,12 +3614,12 @@ static hawk_val_t* do_assignment_idx (hawk_rtx_t* rtx, hawk_nde_var_t* var, hawk
hawk_oow_t len;
hawk_ooch_t idxbuf[IDXBUFSIZE];
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
(var->type == HAWK_NDE_NAMEDIDX ||
var->type == HAWK_NDE_GBLIDX ||
var->type == HAWK_NDE_LCLIDX ||
var->type == HAWK_NDE_ARGIDX) && var->idx != HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_MAP);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, val) != HAWK_VAL_MAP);
retry:
switch (var->type)
@ -3858,7 +3858,7 @@ static hawk_val_t* eval_binary (hawk_rtx_t* run, hawk_nde_t* nde)
hawk_nde_exp_t* exp = (hawk_nde_exp_t*)nde;
hawk_val_t* left, * right, * res;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->type == HAWK_NDE_EXP_BIN);
HAWK_ASSERT (exp->type == HAWK_NDE_EXP_BIN);
if (exp->opcode == HAWK_BINOP_LAND)
{
@ -3883,13 +3883,13 @@ static hawk_val_t* eval_binary (hawk_rtx_t* run, hawk_nde_t* nde)
}
else
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL);
HAWK_ASSERT (exp->left->next == HAWK_NULL);
left = eval_expression (run, exp->left);
if (left == HAWK_NULL) return HAWK_NULL;
hawk_rtx_refupval (run, left);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->right->next == HAWK_NULL);
HAWK_ASSERT (exp->right->next == HAWK_NULL);
right = eval_expression (run, exp->right);
if (right == HAWK_NULL)
{
@ -3899,9 +3899,9 @@ static hawk_val_t* eval_binary (hawk_rtx_t* run, hawk_nde_t* nde)
hawk_rtx_refupval (run, right);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->opcode >= 0 &&
HAWK_ASSERT (exp->opcode >= 0 &&
exp->opcode < HAWK_COUNTOF(binop_func));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), binop_func[exp->opcode] != HAWK_NULL);
HAWK_ASSERT (binop_func[exp->opcode] != HAWK_NULL);
res = binop_func[exp->opcode] (run, left, right);
if (res == HAWK_NULL) ADJERR_LOC (run, &nde->loc);
@ -3936,7 +3936,7 @@ static hawk_val_t* eval_binop_lor (
/* short-circuit evaluation required special treatment */
hawk_val_t* lv, * rv, * res;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL);
HAWK_ASSERT (left->next == HAWK_NULL);
lv = eval_expression (run, left);
if (lv == HAWK_NULL) return HAWK_NULL;
@ -3947,7 +3947,7 @@ static hawk_val_t* eval_binop_lor (
}
else
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL);
HAWK_ASSERT (right->next == HAWK_NULL);
rv = eval_expression (run, right);
if (rv == HAWK_NULL)
{
@ -3988,7 +3988,7 @@ static hawk_val_t* eval_binop_land (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_
/* short-circuit evaluation required special treatment */
hawk_val_t* lv, * rv, * res;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL);
HAWK_ASSERT (left->next == HAWK_NULL);
lv = eval_expression (run, left);
if (lv == HAWK_NULL) return HAWK_NULL;
@ -3999,7 +3999,7 @@ static hawk_val_t* eval_binop_land (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_
}
else
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL);
HAWK_ASSERT (right->next == HAWK_NULL);
rv = eval_expression (run, right);
if (rv == HAWK_NULL)
{
@ -4031,7 +4031,7 @@ static hawk_val_t* eval_binop_in (hawk_rtx_t* rtx, hawk_nde_t* left, hawk_nde_t*
right->type != HAWK_NDE_NAMED)
{
/* the compiler should have handled this case */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - it needs a plain variable");
HAWK_ASSERT (!"should never happen - it needs a plain variable");
SETERR_LOC (rtx, HAWK_EINTERN, &right->loc);
return HAWK_NULL;
}
@ -4044,7 +4044,7 @@ static hawk_val_t* eval_binop_in (hawk_rtx_t* rtx, hawk_nde_t* left, hawk_nde_t*
if (str == HAWK_NULL) return HAWK_NULL;
/* evaluate the right-hand side of the operator */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL);
HAWK_ASSERT (right->next == HAWK_NULL);
rv = eval_expression (rtx, right);
if (rv == HAWK_NULL)
{
@ -4499,7 +4499,7 @@ static HAWK_INLINE int __cmp_str_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va
{
hawk_flt_t rr;
HAWK_ASSERT (hawk, rs->nstr == 2);
HAWK_ASSERT (rs->nstr == 2);
rr = hawk_oochars_to_flt(rs->val.ptr, rs->val.len, HAWK_NULL, (hawk->opt.trait & HAWK_STRIPSTRSPC));
@ -4511,7 +4511,7 @@ static HAWK_INLINE int __cmp_str_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va
{
hawk_flt_t ll;
HAWK_ASSERT (hawk, ls->nstr == 2);
HAWK_ASSERT (ls->nstr == 2);
ll = hawk_oochars_to_flt(ls->val.ptr, ls->val.len, HAWK_NULL, (hawk->opt.trait & HAWK_STRIPSTRSPC));
@ -4528,7 +4528,7 @@ static HAWK_INLINE int __cmp_str_str (hawk_rtx_t* rtx, hawk_val_t* left, hawk_va
{
hawk_flt_t rr;
HAWK_ASSERT (hawk, rs->nstr == 2);
HAWK_ASSERT (rs->nstr == 2);
rr = hawk_oochars_to_flt(rs->val.ptr, rs->val.len, HAWK_NULL, (hawk->opt.trait & HAWK_STRIPSTRSPC));
@ -4739,8 +4739,8 @@ static HAWK_INLINE int __cmp_val (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t*
return -1;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), lvtype >= HAWK_VAL_NIL && lvtype <= HAWK_VAL_MAP);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rvtype >= HAWK_VAL_NIL && rvtype <= HAWK_VAL_MAP);
HAWK_ASSERT (lvtype >= HAWK_VAL_NIL && lvtype <= HAWK_VAL_MAP);
HAWK_ASSERT (rvtype >= HAWK_VAL_NIL && rvtype <= HAWK_VAL_MAP);
/* mapping fomula and table layout assume:
* HAWK_VAL_NIL = 0
@ -4934,7 +4934,7 @@ static hawk_val_t* eval_binop_plus (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_
1 1 = 3
*/
n3 = n1 + (n2 << 1);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), n3 >= 0 && n3 <= 3);
HAWK_ASSERT (n3 >= 0 && n3 <= 3);
return (n3 == 0)? hawk_rtx_makeintval(rtx,(hawk_int_t)l1+(hawk_int_t)l2):
(n3 == 1)? hawk_rtx_makefltval(rtx,(hawk_flt_t)r1+(hawk_flt_t)l2):
@ -4958,7 +4958,7 @@ static hawk_val_t* eval_binop_minus (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val
}
n3 = n1 + (n2 << 1);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), n3 >= 0 && n3 <= 3);
HAWK_ASSERT (n3 >= 0 && n3 <= 3);
return (n3 == 0)? hawk_rtx_makeintval(rtx,(hawk_int_t)l1-(hawk_int_t)l2):
(n3 == 1)? hawk_rtx_makefltval(rtx,(hawk_flt_t)r1-(hawk_flt_t)l2):
(n3 == 2)? hawk_rtx_makefltval(rtx,(hawk_flt_t)l1-(hawk_flt_t)r2):
@ -4981,7 +4981,7 @@ static hawk_val_t* eval_binop_mul (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t
}
n3 = n1 + (n2 << 1);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), n3 >= 0 && n3 <= 3);
HAWK_ASSERT (n3 >= 0 && n3 <= 3);
return (n3 == 0)? hawk_rtx_makeintval(rtx,(hawk_int_t)l1*(hawk_int_t)l2):
(n3 == 1)? hawk_rtx_makefltval(rtx,(hawk_flt_t)r1*(hawk_flt_t)l2):
(n3 == 2)? hawk_rtx_makefltval(rtx,(hawk_flt_t)l1*(hawk_flt_t)r2):
@ -5101,7 +5101,7 @@ static hawk_val_t* eval_binop_mod (hawk_rtx_t* rtx, hawk_val_t* left, hawk_val_t
hawk_val_t* res;
/* the mod function must be provided when the awk object is created to be able to calculate floating-pointer remainder */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->awk->prm.math.mod != HAWK_NULL);
HAWK_ASSERT (rtx->awk->prm.math.mod != HAWK_NULL);
n1 = hawk_rtx_valtonum(rtx, left, &l1, &r1);
n2 = hawk_rtx_valtonum(rtx, right, &l2, &r2);
@ -5284,8 +5284,8 @@ static hawk_val_t* eval_binop_ma (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_t*
{
hawk_val_t* lv, * rv, * res;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL);
HAWK_ASSERT (left->next == HAWK_NULL);
HAWK_ASSERT (right->next == HAWK_NULL);
lv = eval_expression (run, left);
if (lv == HAWK_NULL) return HAWK_NULL;
@ -5313,8 +5313,8 @@ static hawk_val_t* eval_binop_nm (hawk_rtx_t* run, hawk_nde_t* left, hawk_nde_t*
{
hawk_val_t* lv, * rv, * res;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), left->next == HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), right->next == HAWK_NULL);
HAWK_ASSERT (left->next == HAWK_NULL);
HAWK_ASSERT (right->next == HAWK_NULL);
lv = eval_expression (run, left);
if (lv == HAWK_NULL) return HAWK_NULL;
@ -5346,17 +5346,17 @@ static hawk_val_t* eval_unary (hawk_rtx_t* rtx, hawk_nde_t* nde)
hawk_int_t l;
hawk_flt_t r;
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
exp->type == HAWK_NDE_EXP_UNR);
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
exp->left != HAWK_NULL && exp->right == HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
exp->opcode == HAWK_UNROP_PLUS ||
exp->opcode == HAWK_UNROP_MINUS ||
exp->opcode == HAWK_UNROP_LNOT ||
exp->opcode == HAWK_UNROP_BNOT);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL);
HAWK_ASSERT (exp->left->next == HAWK_NULL);
left = eval_expression (rtx, exp->left);
if (left == HAWK_NULL) return HAWK_NULL;
@ -5420,8 +5420,8 @@ static hawk_val_t* eval_incpre (hawk_rtx_t* rtx, hawk_nde_t* nde)
hawk_flt_t inc_val_flt;
hawk_nde_exp_t* exp = (hawk_nde_exp_t*)nde;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->type == HAWK_NDE_EXP_INCPRE);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left != HAWK_NULL && exp->right == HAWK_NULL);
HAWK_ASSERT (exp->type == HAWK_NDE_EXP_INCPRE);
HAWK_ASSERT (exp->left != HAWK_NULL && exp->right == HAWK_NULL);
/* this way of checking if the l-value is assignable is
* ugly as it is dependent on the node types defined in hawk.h
@ -5446,12 +5446,12 @@ static hawk_val_t* eval_incpre (hawk_rtx_t* rtx, hawk_nde_t* nde)
}
else
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid opcode");
HAWK_ASSERT (!"should never happen - invalid opcode");
SETERR_LOC (rtx, HAWK_EINTERN, &nde->loc);
return HAWK_NULL;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL);
HAWK_ASSERT (exp->left->next == HAWK_NULL);
left = eval_expression (rtx, exp->left);
if (left == HAWK_NULL) return HAWK_NULL;
@ -5506,7 +5506,7 @@ static hawk_val_t* eval_incpre (hawk_rtx_t* rtx, hawk_nde_t* nde)
}
else /* if (n == 1) */
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), n == 1);
HAWK_ASSERT (n == 1);
res = hawk_rtx_makefltval (rtx, v2 + inc_val_flt);
}
@ -5539,8 +5539,8 @@ static hawk_val_t* eval_incpst (hawk_rtx_t* rtx, hawk_nde_t* nde)
hawk_flt_t inc_val_flt;
hawk_nde_exp_t* exp = (hawk_nde_exp_t*)nde;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->type == HAWK_NDE_EXP_INCPST);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left != HAWK_NULL && exp->right == HAWK_NULL);
HAWK_ASSERT (exp->type == HAWK_NDE_EXP_INCPST);
HAWK_ASSERT (exp->left != HAWK_NULL && exp->right == HAWK_NULL);
/* this way of checking if the l-value is assignable is
* ugly as it is dependent on the node types defined in hawk.h.
@ -5565,12 +5565,12 @@ static hawk_val_t* eval_incpst (hawk_rtx_t* rtx, hawk_nde_t* nde)
}
else
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid opcode");
HAWK_ASSERT (!"should never happen - invalid opcode");
SETERR_LOC (rtx, HAWK_EINTERN, &nde->loc);
return HAWK_NULL;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), exp->left->next == HAWK_NULL);
HAWK_ASSERT (exp->left->next == HAWK_NULL);
left = eval_expression (rtx, exp->left);
if (left == HAWK_NULL) return HAWK_NULL;
@ -5661,7 +5661,7 @@ static hawk_val_t* eval_incpst (hawk_rtx_t* rtx, hawk_nde_t* nde)
}
else /* if (n == 1) */
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), n == 1);
HAWK_ASSERT (n == 1);
res = hawk_rtx_makefltval (rtx, v2);
if (res == HAWK_NULL)
{
@ -5699,14 +5699,14 @@ static hawk_val_t* eval_cnd (hawk_rtx_t* run, hawk_nde_t* nde)
hawk_val_t* tv, * v;
hawk_nde_cnd_t* cnd = (hawk_nde_cnd_t*)nde;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), cnd->test->next == HAWK_NULL);
HAWK_ASSERT (cnd->test->next == HAWK_NULL);
tv = eval_expression (run, cnd->test);
if (tv == HAWK_NULL) return HAWK_NULL;
hawk_rtx_refupval (run, tv);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), cnd->left->next == HAWK_NULL && cnd->right->next == HAWK_NULL);
HAWK_ASSERT (cnd->left->next == HAWK_NULL && cnd->right->next == HAWK_NULL);
v = (hawk_rtx_valtobool(run, tv))? eval_expression(run, cnd->left): eval_expression(run, cnd->right);
hawk_rtx_refdownval (run, tv);
@ -5718,7 +5718,7 @@ static hawk_val_t* eval_fncall_fnc (hawk_rtx_t* rtx, hawk_nde_t* nde)
/* intrinsic function */
hawk_nde_fncall_t* call = (hawk_nde_fncall_t*)nde;
/* the parser must make sure that the number of arguments is proper */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max);
HAWK_ASSERT (call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max);
return __eval_call(rtx, nde, HAWK_NULL, push_arg_from_nde, (void*)call->u.fnc.spec.arg.spec, HAWK_NULL, HAWK_NULL);
}
@ -5744,7 +5744,7 @@ static HAWK_INLINE hawk_val_t* eval_fncall_fun_ex (hawk_rtx_t* rtx, hawk_nde_t*
}
fun = (hawk_fun_t*)HAWK_HTB_VPTR(pair);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun != HAWK_NULL);
HAWK_ASSERT (fun != HAWK_NULL);
/* cache the search result */
call->u.fun.fun = fun;
@ -5873,8 +5873,8 @@ static hawk_val_t* __eval_call (
* ---------------------
*/
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_top));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_base));
HAWK_ASSERT (HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_top));
HAWK_ASSERT (HAWK_SIZEOF(void*) >= HAWK_SIZEOF(rtx->stack_base));
saved_stack_top = rtx->stack_top;
@ -5922,7 +5922,7 @@ static hawk_val_t* __eval_call (
return HAWK_NULL;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nargs == call->nargs);
HAWK_ASSERT (nargs == call->nargs);
if (fun)
{
@ -5974,7 +5974,7 @@ static hawk_val_t* __eval_call (
if (fun)
{
/* normal awk function */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun->body->type == HAWK_NDE_BLK);
HAWK_ASSERT (fun->body->type == HAWK_NDE_BLK);
n = run_block(rtx,(hawk_nde_blk_t*)fun->body);
}
else
@ -5982,7 +5982,7 @@ static hawk_val_t* __eval_call (
n = 0;
/* intrinsic function */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max);
HAWK_ASSERT (call->nargs >= call->u.fnc.spec.arg.min && call->nargs <= call->u.fnc.spec.arg.max);
if (call->u.fnc.spec.impl)
{
@ -6249,7 +6249,7 @@ static hawk_oow_t push_arg_from_nde (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, v
hawk_rtx_refupval (rtx, v);
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), call->nargs == nargs);
HAWK_ASSERT (call->nargs == nargs);
return nargs;
}
@ -6380,7 +6380,7 @@ static hawk_val_t** get_reference_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde,
hawk_ooch_t idxbuf[IDXBUFSIZE];
hawk_val_type_t vtype;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL);
HAWK_ASSERT (val != HAWK_NULL);
vtype = HAWK_RTX_GETVALTYPE(rtx, *val);
if (vtype == HAWK_VAL_NIL)
@ -6404,7 +6404,7 @@ static hawk_val_t** get_reference_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde,
return HAWK_NULL;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->idx != HAWK_NULL);
HAWK_ASSERT (nde->idx != HAWK_NULL);
len = HAWK_COUNTOF(idxbuf);
str = idxnde_to_str (rtx, nde->idx, idxbuf, &len);
@ -6474,7 +6474,6 @@ static hawk_val_t* eval_fun (hawk_rtx_t* rtx, hawk_nde_t* nde)
{
hawk_val_t* val;
hawk_fun_t* fun;
fun = ((hawk_nde_fun_t*)nde)->funptr;
if (!fun)
@ -6490,7 +6489,7 @@ static hawk_val_t* eval_fun (hawk_rtx_t* rtx, hawk_nde_t* nde)
}
fun = (hawk_fun_t*)HAWK_HTB_VPTR(pair);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), fun != HAWK_NULL);
HAWK_ASSERT (fun != HAWK_NULL);
}
val = hawk_rtx_makefunval(rtx, fun);
@ -6528,7 +6527,7 @@ static hawk_val_t* eval_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde, hawk_val_
hawk_ooch_t idxbuf[IDXBUFSIZE];
hawk_val_type_t vtype;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val != HAWK_NULL);
HAWK_ASSERT (val != HAWK_NULL);
vtype = HAWK_RTX_GETVALTYPE(rtx, *val);
if (vtype == HAWK_VAL_NIL)
@ -6552,7 +6551,7 @@ static hawk_val_t* eval_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* nde, hawk_val_
return HAWK_NULL;
}
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde->idx != HAWK_NULL);
HAWK_ASSERT (nde->idx != HAWK_NULL);
len = HAWK_COUNTOF(idxbuf);
str = idxnde_to_str(rtx, nde->idx, idxbuf, &len);
@ -6643,7 +6642,7 @@ static hawk_val_t* eval_getline (hawk_rtx_t* rtx, hawk_nde_t* nde)
p = (hawk_nde_getline_t*)nde;
HAWK_ASSERT (hawk_rtx_gethawk(rtx),
HAWK_ASSERT (
(p->in_type == HAWK_IN_PIPE && p->in != HAWK_NULL) ||
(p->in_type == HAWK_IN_RWPIPE && p->in != HAWK_NULL) ||
(p->in_type == HAWK_IN_FILE && p->in != HAWK_NULL) ||
@ -6713,7 +6712,7 @@ read_console_again:
{
if (p->in_type == HAWK_IN_CONSOLE)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), p->in == HAWK_NULL);
HAWK_ASSERT (p->in == HAWK_NULL);
if (rtx->nrflt.limit > 0)
{
/* record filter based on record number(NR) */
@ -6825,7 +6824,7 @@ read_again:
#endif
if (n == 0)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LEN(buf) == 0);
HAWK_ASSERT (HAWK_OOECS_LEN(buf) == 0);
return 0;
}
@ -6852,7 +6851,7 @@ static int shorten_record (hawk_rtx_t* rtx, hawk_oow_t nflds)
hawk_ooecs_t tmp;
hawk_val_type_t vtype;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nflds <= rtx->inrec.nflds);
HAWK_ASSERT (nflds <= rtx->inrec.nflds);
if (nflds > 1)
{
@ -6941,7 +6940,7 @@ static hawk_ooch_t* idxnde_to_str (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_ooch_t
hawk_ooch_t* str;
hawk_val_t* idx;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), nde != HAWK_NULL);
HAWK_ASSERT (nde != HAWK_NULL);
if (!nde->next)
{
@ -6966,7 +6965,7 @@ static hawk_ooch_t* idxnde_to_str (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_ooch_t
{
str = out.u.cplcpy.ptr;
*len = out.u.cplcpy.len;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), str == buf);
HAWK_ASSERT (str == buf);
}
}
@ -7094,7 +7093,7 @@ hawk_ooch_t* hawk_rtx_format (
} while(0)
/* run->format.tmp.ptr should have been assigned a pointer to a block of memory before this function has been called */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rtx->format.tmp.ptr != HAWK_NULL);
HAWK_ASSERT (rtx->format.tmp.ptr != HAWK_NULL);
if (nargs_on_stack == (hawk_oow_t)-1)
{
@ -7330,7 +7329,7 @@ wp_mod_main:
if (wp[WP_WIDTH] != -1)
{
/* Width must be greater than 0 if specified */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), wp[WP_WIDTH] > 0);
HAWK_ASSERT (wp[WP_WIDTH] > 0);
/* justification when width is specified. */
if (flags & FLAG_ZERO)
@ -7909,7 +7908,7 @@ hawk_bch_t* hawk_rtx_formatmbs (
} while(0)
/* run->format.tmp.ptr should have been assigned a pointer to a block of memory before this function has been called */
HAWK_ASSERT (hawk_rtx_gethawk(awk), rtx->formatmbs.tmp.ptr != HAWK_NULL)
HAWK_ASSERT (rtx->formatmbs.tmp.ptr != HAWK_NULL);
if (nargs_on_stack == (hawk_oow_t)-1)
{
@ -8145,7 +8144,7 @@ wp_mod_main:
if (wp[WP_WIDTH] != -1)
{
/* Width must be greater than 0 if specified */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), wp[WP_WIDTH] > 0);
HAWK_ASSERT (wp[WP_WIDTH] > 0);
/* justification when width is specified. */
if (flags & FLAG_ZERO)

View File

@ -361,7 +361,7 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec)
hawk_freemem (awk, modpath);
HAWK_ASSERT (awk, HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*));
HAWK_ASSERT (HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*));
return h;
#elif defined(__OS2__)
@ -393,7 +393,7 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec)
hawk_freemem (awk, modpath);
HAWK_ASSERT (awk, HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*));
HAWK_ASSERT (HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*));
return h;
#elif defined(__DOS__) && defined(HAWK_ENABLE_DOS_DYNAMIC_MODULE)
@ -423,7 +423,7 @@ void* hawk_stdmodopen (hawk_t* awk, const hawk_mod_spec_t* spec)
hawk_freemem (awk, modpath);
HAWK_ASSERT (awk, HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*));
HAWK_ASSERT (HAWK_SIZEOF(h) <= HAWK_SIZEOF(void*));
return h;
#elif defined(USE_DLFCN)
@ -773,7 +773,7 @@ static void log_write (hawk_t* hawk, hawk_bitmask_t mask, const hawk_ooch_t* msg
* buffer not sufficient. not all got converted yet.
* write what have been converted this round. */
HAWK_ASSERT (hawk, ucslen > 0); /* if this fails, the buffer size must be increased */
HAWK_ASSERT (ucslen > 0); /* if this fails, the buffer size must be increased */
/* attempt to write all converted characters */
if (write_log(hawk, logfd, buf, bcslen) <= -1) break;
@ -968,8 +968,8 @@ static int open_parsestd (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow
/* normal source files */
#if defined(HAWK_OOCH_IS_BCH)
case HAWK_PARSESTD_FILE:
HAWK_ASSERT (moo, &psin->u.fileb.path == &psin->u.file.path);
HAWK_ASSERT (moo, &psin->u.fileb.cmgr == &psin->u.file.cmgr);
HAWK_ASSERT (&psin->u.fileb.path == &psin->u.file.path);
HAWK_ASSERT (&psin->u.fileb.cmgr == &psin->u.file.cmgr);
#endif
case HAWK_PARSESTD_FILEB:
{
@ -1002,8 +1002,8 @@ static int open_parsestd (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn, hawk_oow
#if defined(HAWK_OOCH_IS_UCH)
case HAWK_PARSESTD_FILE:
HAWK_ASSERT (moo, &psin->u.fileu.path == &psin->u.file.path);
HAWK_ASSERT (moo, &psin->u.fileu.cmgr == &psin->u.file.cmgr);
HAWK_ASSERT (&psin->u.fileu.path == &psin->u.file.path);
HAWK_ASSERT (&psin->u.fileu.cmgr == &psin->u.file.cmgr);
#endif
case HAWK_PARSESTD_FILEU:
{
@ -1110,7 +1110,7 @@ static hawk_ooi_t sf_in_open (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn)
hawk_ooi_t x;
HAWK_ASSERT (awk, arg == &awk->sio.arg);
HAWK_ASSERT (arg == &awk->sio.arg);
x = open_parsestd(awk, arg, xtn, 0);
if (x >= 0)
@ -1134,7 +1134,7 @@ static hawk_ooi_t sf_in_open (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn)
hawk_ooch_t fbuf[64];
hawk_ooch_t* dbuf = HAWK_NULL;
HAWK_ASSERT (awk, arg->name != HAWK_NULL);
HAWK_ASSERT (arg->name != HAWK_NULL);
path = arg->name;
if (arg->prev->handle)
@ -1194,7 +1194,7 @@ static hawk_ooi_t sf_in_close (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn)
case HAWK_PARSESTD_FILE:
case HAWK_PARSESTD_FILEB:
case HAWK_PARSESTD_FILEU:
HAWK_ASSERT (awk, arg->handle != HAWK_NULL);
HAWK_ASSERT (arg->handle != HAWK_NULL);
hawk_sio_close (arg->handle);
break;
@ -1212,7 +1212,7 @@ static hawk_ooi_t sf_in_close (hawk_t* awk, hawk_sio_arg_t* arg, xtn_t* xtn)
else
{
/* handle the included source file - @include */
HAWK_ASSERT (awk, arg->handle != HAWK_NULL);
HAWK_ASSERT (arg->handle != HAWK_NULL);
hawk_sio_close (arg->handle);
}
@ -1225,7 +1225,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
{
hawk_ooi_t n;
HAWK_ASSERT (awk, arg == &awk->sio.arg);
HAWK_ASSERT (arg == &awk->sio.arg);
again:
switch (xtn->s.in.x[xtn->s.in.xindex].type)
@ -1234,7 +1234,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
case HAWK_PARSESTD_FILE:
#endif
case HAWK_PARSESTD_FILEU:
HAWK_ASSERT (awk, arg->handle != HAWK_NULL);
HAWK_ASSERT (arg->handle != HAWK_NULL);
n = hawk_sio_getoochars(arg->handle, data, size);
if (n <= -1)
{
@ -1252,7 +1252,7 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
case HAWK_PARSESTD_FILE:
#endif
case HAWK_PARSESTD_FILEB:
HAWK_ASSERT (awk, arg->handle != HAWK_NULL);
HAWK_ASSERT (arg->handle != HAWK_NULL);
n = hawk_sio_getoochars(arg->handle, data, size);
if (n <= -1)
{
@ -1368,8 +1368,8 @@ static hawk_ooi_t sf_in_read (hawk_t* awk, hawk_sio_arg_t* arg, hawk_ooch_t* dat
/* handle the included source file - @include */
hawk_ooi_t n;
HAWK_ASSERT (awk, arg->name != HAWK_NULL);
HAWK_ASSERT (awk, arg->handle != HAWK_NULL);
HAWK_ASSERT (arg->name != HAWK_NULL);
HAWK_ASSERT (arg->handle != HAWK_NULL);
n = hawk_sio_getoochars(arg->handle, data, size);
if (n <= -1)
@ -1416,8 +1416,8 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
{
#if defined(HAWK_OOCH_IS_BCH)
case HAWK_PARSESTD_FILE:
HAWK_ASSERT (moo, &xtn->s.out.x->u.fileb.path == &xtn->s.out.x->u.file.path);
HAWK_ASSERT (moo, &xtn->s.out.x->u.fileb.cmgr == &xtn->s.out.x->u.file.cmgr);
HAWK_ASSERT (&xtn->s.out.x->u.fileb.path == &xtn->s.out.x->u.file.path);
HAWK_ASSERT (&xtn->s.out.x->u.fileb.cmgr == &xtn->s.out.x->u.file.cmgr);
#endif
case HAWK_PARSESTD_FILEB:
if (xtn->s.out.x->u.fileb.path == HAWK_NULL || (xtn->s.out.x->u.fileb.path[0] == '-' && xtn->s.out.x->u.fileb.path[1] == '\0'))
@ -1445,8 +1445,8 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
#if defined(HAWK_OOCH_IS_UCH)
case HAWK_PARSESTD_FILE:
HAWK_ASSERT (moo, &xtn->s.out.x->u.fileu.path == &xtn->s.out.x->u.file.path);
HAWK_ASSERT (moo, &xtn->s.out.x->u.fileu.cmgr == &xtn->s.out.x->u.file.cmgr);
HAWK_ASSERT (&xtn->s.out.x->u.fileu.path == &xtn->s.out.x->u.file.path);
HAWK_ASSERT (&xtn->s.out.x->u.fileu.cmgr == &xtn->s.out.x->u.file.cmgr);
#endif
case HAWK_PARSESTD_FILEU:
if (xtn->s.out.x->u.fileu.path == HAWK_NULL || (xtn->s.out.x->u.fileu.path[0] == '-' && xtn->s.out.x->u.fileu.path[1] == '\0'))
@ -1522,7 +1522,7 @@ static hawk_ooi_t sf_out (hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg,
case HAWK_PARSESTD_FILEU:
{
hawk_ooi_t n;
HAWK_ASSERT (awk, xtn->s.out.u.file.sio != HAWK_NULL);
HAWK_ASSERT (xtn->s.out.u.file.sio != HAWK_NULL);
n = hawk_sio_putoochars(xtn->s.out.u.file.sio, data, size);
if (n <= -1)
{
@ -1660,7 +1660,7 @@ int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out)
case HAWK_PARSESTD_OOCS:
if (n >= 0)
{
HAWK_ASSERT (awk, xtn->s.out.u.oocs.buf != HAWK_NULL);
HAWK_ASSERT (xtn->s.out.u.oocs.buf != HAWK_NULL);
hawk_ooecs_yield (xtn->s.out.u.oocs.buf, &out->u.oocs, 0);
}
if (xtn->s.out.u.oocs.buf) hawk_ooecs_close (xtn->s.out.u.oocs.buf);
@ -1669,7 +1669,7 @@ int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out)
case HAWK_PARSESTD_BCS:
if (n >= 0)
{
HAWK_ASSERT (awk, xtn->s.out.u.bcs.buf != HAWK_NULL);
HAWK_ASSERT (xtn->s.out.u.bcs.buf != HAWK_NULL);
hawk_becs_yield (xtn->s.out.u.bcs.buf, &out->u.bcs, 0);
}
if (xtn->s.out.u.bcs.buf) hawk_becs_close (xtn->s.out.u.bcs.buf);
@ -1678,7 +1678,7 @@ int hawk_parsestd (hawk_t* awk, hawk_parsestd_t in[], hawk_parsestd_t* out)
case HAWK_PARSESTD_UCS:
if (n >= 0)
{
HAWK_ASSERT (awk, xtn->s.out.u.ucs.buf != HAWK_NULL);
HAWK_ASSERT (xtn->s.out.u.ucs.buf != HAWK_NULL);
hawk_uecs_yield (xtn->s.out.u.ucs.buf, &out->u.ucs, 0);
}
if (xtn->s.out.u.ucs.buf) hawk_uecs_close (xtn->s.out.u.ucs.buf);
@ -2013,7 +2013,7 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
{
/* if no input files is specified,
* open the standard input */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->c.in.index == 0);
HAWK_ASSERT (rxtn->c.in.index == 0);
if (rxtn->c.in.count == 0)
{
@ -2082,19 +2082,19 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
* { print $0; }' file1 file2
*/
argv = hawk_rtx_getgbl(rtx, xtn->gbl_argv);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), argv != HAWK_NULL);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, argv) == HAWK_VAL_MAP);
HAWK_ASSERT (argv != HAWK_NULL);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, argv) == HAWK_VAL_MAP);
map = ((hawk_val_map_t*)argv)->map;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), map != HAWK_NULL);
HAWK_ASSERT (map != HAWK_NULL);
ibuflen = hawk_int_to_oocstr (rxtn->c.in.index + 1, 10, HAWK_NULL, ibuf, HAWK_COUNTOF(ibuf));
pair = hawk_htb_search(map, ibuf, ibuflen);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), pair != HAWK_NULL);
HAWK_ASSERT (pair != HAWK_NULL);
v = HAWK_HTB_VPTR(pair);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), v != HAWK_NULL);
HAWK_ASSERT (v != HAWK_NULL);
as.ptr = hawk_rtx_getvaloocstr(rtx, v, &as.len);
if (as.ptr == HAWK_NULL) return -1;
@ -2158,7 +2158,7 @@ static int open_rio_console (hawk_rtx_t* rtx, hawk_rio_arg_t* riod)
{
if (rxtn->c.out.files == HAWK_NULL)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->c.out.index == 0);
HAWK_ASSERT (rxtn->c.out.index == 0);
if (rxtn->c.out.count == 0)
{
@ -2355,7 +2355,7 @@ static int build_argcv (
}
key_len = hawk_int_to_oocstr (argc, 10, HAWK_NULL, key, HAWK_COUNTOF(key));
HAWK_ASSERT (hawk_rtx_gethawk(rtx), key_len != (hawk_oow_t)-1);
HAWK_ASSERT (key_len != (hawk_oow_t)-1);
hawk_rtx_refupval (rtx, v_tmp);
@ -2818,7 +2818,7 @@ static int fnc_setioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
int tmout;
rxtn = GET_RXTN(rtx);
HAWK_ASSERT (hawk, rxtn->cmgrtab_inited == 1);
HAWK_ASSERT (rxtn->cmgrtab_inited == 1);
for (i = 0; i < 3; i++)
{
@ -2940,7 +2940,7 @@ static int fnc_getioattr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
ioattr_t ioattr_buf;
rxtn = GET_RXTN(rtx);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->cmgrtab_inited == 1);
HAWK_ASSERT (rxtn->cmgrtab_inited == 1);
for (i = 0; i < 2; i++)
{
@ -3024,7 +3024,7 @@ hawk_cmgr_t* hawk_rtx_getiocmgrstd (hawk_rtx_t* rtx, const hawk_ooch_t* ioname)
rxtn_t* rxtn = GET_RXTN(rtx);
ioattr_t* ioattr;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), rxtn->cmgrtab_inited == 1);
HAWK_ASSERT (rxtn->cmgrtab_inited == 1);
ioattr = get_ioattr(&rxtn->cmgrtab, ioname, hawk_count_oocstr(ioname));
if (ioattr) return ioattr->cmgr;

View File

@ -117,7 +117,7 @@ int hawk_tio_attachin (
if (hawk_tio_detachin(tio) <= -1) return -1;
HAWK_ASSERT (tio->hawk, tio->in.fun == HAWK_NULL);
HAWK_ASSERT (tio->in.fun == HAWK_NULL);
xbufptr = bufptr;
if (xbufptr == HAWK_NULL)
@ -200,7 +200,7 @@ int hawk_tio_attachout (
if (hawk_tio_detachout(tio) == -1) return -1;
/*HAWK_ASSERT (tio->hawk, tio->out.fun == HAWK_NULL);*/
HAWK_ASSERT (tio->out.fun == HAWK_NULL);
xbufptr = bufptr;
if (xbufptr == HAWK_NULL)
@ -322,7 +322,7 @@ hawk_ooi_t hawk_tio_readbchars (hawk_tio_t* tio, hawk_bch_t* buf, hawk_oow_t siz
hawk_oow_t nread;
hawk_ooi_t n;
/*HAWK_ASSERT (tio->hawk, tio->in.fun != HAWK_NULL);*/
/*HAWK_ASSERT (tio->in.fun != HAWK_NULL);*/
if (tio->in.fun == HAWK_NULL)
{
/* no input function */
@ -423,7 +423,7 @@ static HAWK_INLINE hawk_ooi_t tio_read_uchars (
{
/* not even a single character was handled.
* shift bytes in the buffer to the head. */
HAWK_ASSERT (tio->hawk, mlen <= 0);
HAWK_ASSERT (mlen <= 0);
tio->inbuf_len = tio->inbuf_len - tio->inbuf_cur;
HAWK_MEMCPY (&tio->in.buf.ptr[0],
&tio->in.buf.ptr[tio->inbuf_cur],
@ -437,7 +437,7 @@ static HAWK_INLINE hawk_ooi_t tio_read_uchars (
else if (x == -2)
{
/* buffer not large enough */
HAWK_ASSERT (tio->hawk, wlen > 0);
HAWK_ASSERT (wlen > 0);
/* the wide-character buffer is not just large enough to
* hold the entire conversion result. lets's go on so long as
@ -476,7 +476,7 @@ hawk_ooi_t hawk_tio_readuchars (hawk_tio_t* tio, hawk_uch_t* buf, hawk_oow_t siz
hawk_oow_t nread = 0;
hawk_ooi_t n;
/*HAWK_ASSERT (tio->hawk, tio->in.fun != HAWK_NULL);*/
/*HAWK_ASSERT (tio->in.fun != HAWK_NULL);*/
if (tio->in.fun == HAWK_NULL)
{
/* no input handler function */
@ -658,7 +658,7 @@ hawk_ooi_t hawk_tio_writeuchars (hawk_tio_t* tio, const hawk_uch_t* wptr, hawk_o
{
/* insert a question mark for an illegal
* character. */
HAWK_ASSERT (tio->hawk, tio->outbuf_len < tio->out.buf.capa);
HAWK_ASSERT (tio->outbuf_len < tio->out.buf.capa);
tio->out.buf.ptr[tio->outbuf_len++] = '?';
wcnt++; /* skip this illegal character */
/* don't need to increment mcnt since

View File

@ -221,7 +221,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
PUT_SRCSTR (awk, HAWK_T(" "));
PRINT_EXPR (awk, px->right);
HAWK_ASSERT (awk, px->right->next == HAWK_NULL);
HAWK_ASSERT (px->right->next == HAWK_NULL);
break;
}
@ -231,7 +231,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
PUT_SRCSTR (awk, HAWK_T("("));
PRINT_EXPR (awk, px->left);
HAWK_ASSERT (awk, px->left->next == HAWK_NULL);
HAWK_ASSERT (px->left->next == HAWK_NULL);
PUT_SRCSTR (awk, HAWK_T(" "));
PUT_SRCSTR (awk, binop_str[px->opcode][(awk->opt.trait & HAWK_BLANKCONCAT)? 0: 1]);
@ -242,7 +242,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
PRINT_EXPR (awk, px->right);
if (px->right->type == HAWK_NDE_ASS)
PUT_SRCSTR (awk, HAWK_T(")"));
HAWK_ASSERT (awk, px->right->next == HAWK_NULL);
HAWK_ASSERT (px->right->next == HAWK_NULL);
PUT_SRCSTR (awk, HAWK_T(")"));
break;
}
@ -250,7 +250,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
case HAWK_NDE_EXP_UNR:
{
hawk_nde_exp_t* px = (hawk_nde_exp_t*)nde;
HAWK_ASSERT (awk, px->right == HAWK_NULL);
HAWK_ASSERT (px->right == HAWK_NULL);
PUT_SRCSTR (awk, HAWK_T("("));
PUT_SRCSTR (awk, unrop_str[px->opcode]);
@ -264,7 +264,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
case HAWK_NDE_EXP_INCPRE:
{
hawk_nde_exp_t* px = (hawk_nde_exp_t*)nde;
HAWK_ASSERT (awk, px->right == HAWK_NULL);
HAWK_ASSERT (px->right == HAWK_NULL);
PUT_SRCSTR (awk, incop_str[px->opcode]);
PUT_SRCSTR (awk, HAWK_T("("));
@ -276,7 +276,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
case HAWK_NDE_EXP_INCPST:
{
hawk_nde_exp_t* px = (hawk_nde_exp_t*)nde;
HAWK_ASSERT (awk, px->right == HAWK_NULL);
HAWK_ASSERT (px->right == HAWK_NULL);
PUT_SRCSTR (awk, HAWK_T("("));
PRINT_EXPR (awk, px->left);
@ -507,14 +507,14 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
hawk_ooch_t tmp[HAWK_SIZEOF(hawk_int_t)*8+2];
hawk_oow_t n;
hawk_nde_var_t* px = (hawk_nde_var_t*)nde;
HAWK_ASSERT (awk, px->id.idxa != (hawk_oow_t)-1);
HAWK_ASSERT (px->id.idxa != (hawk_oow_t)-1);
n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, tmp, HAWK_COUNTOF(tmp));
PUT_SRCSTR (awk, HAWK_T("__p"));
PUT_SRCSTRN (awk, tmp, n);
HAWK_ASSERT (awk, px->idx == HAWK_NULL);
HAWK_ASSERT (px->idx == HAWK_NULL);
break;
}
@ -522,8 +522,8 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
{
hawk_oow_t n;
hawk_nde_var_t* px = (hawk_nde_var_t*)nde;
HAWK_ASSERT (awk, px->id.idxa != (hawk_oow_t)-1);
HAWK_ASSERT (awk, px->idx != HAWK_NULL);
HAWK_ASSERT (px->id.idxa != (hawk_oow_t)-1);
HAWK_ASSERT (px->idx != HAWK_NULL);
PUT_SRCSTR (awk, HAWK_T("__p"));
n = hawk_int_to_oocstr(px->id.idxa, 10, HAWK_NULL, awk->tmp.fmt, HAWK_COUNTOF(awk->tmp.fmt));
@ -537,8 +537,8 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
case HAWK_NDE_NAMED:
{
hawk_nde_var_t* px = (hawk_nde_var_t*)nde;
HAWK_ASSERT (awk, px->id.idxa == (hawk_oow_t)-1);
HAWK_ASSERT (awk, px->idx == HAWK_NULL);
HAWK_ASSERT (px->id.idxa == (hawk_oow_t)-1);
HAWK_ASSERT (px->idx == HAWK_NULL);
PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len);
break;
@ -547,8 +547,8 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
case HAWK_NDE_NAMEDIDX:
{
hawk_nde_var_t* px = (hawk_nde_var_t*)nde;
HAWK_ASSERT (awk, px->id.idxa == (hawk_oow_t)-1);
HAWK_ASSERT (awk, px->idx != HAWK_NULL);
HAWK_ASSERT (px->id.idxa == (hawk_oow_t)-1);
HAWK_ASSERT (px->idx != HAWK_NULL);
PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len);
PUT_SRCSTR (awk, HAWK_T("["));
@ -590,7 +590,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
{
PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len);
}
HAWK_ASSERT (awk, px->idx == HAWK_NULL);
HAWK_ASSERT (px->idx == HAWK_NULL);
break;
}
@ -629,7 +629,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len);
PUT_SRCSTR (awk, HAWK_T("["));
}
HAWK_ASSERT (awk, px->idx != HAWK_NULL);
HAWK_ASSERT (px->idx != HAWK_NULL);
PRINT_EXPR_LIST (awk, px->idx);
PUT_SRCSTR (awk, HAWK_T("]"));
break;
@ -650,7 +650,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
{
PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len);
}
HAWK_ASSERT (awk, px->idx == HAWK_NULL);
HAWK_ASSERT (px->idx == HAWK_NULL);
break;
}
@ -671,7 +671,7 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
PUT_SRCSTRN (awk, px->id.name.ptr, px->id.name.len);
PUT_SRCSTR (awk, HAWK_T("["));
}
HAWK_ASSERT (awk, px->idx != HAWK_NULL);
HAWK_ASSERT (px->idx != HAWK_NULL);
PRINT_EXPR_LIST (awk, px->idx);
PUT_SRCSTR (awk, HAWK_T("]"));
break;
@ -850,7 +850,7 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth)
PUT_SRCSTR (awk, HAWK_T(")"));
PUT_NL (awk);
HAWK_ASSERT (awk, px->then_part != HAWK_NULL);
HAWK_ASSERT (px->then_part != HAWK_NULL);
if (px->then_part->type == HAWK_NDE_BLK)
PRINT_STMTS (awk, px->then_part, depth);
else
@ -1011,7 +1011,7 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth)
hawk_getkwname (awk, HAWK_KWID_RETURN, &kw);
PUT_SRCSTRN (awk, kw.ptr, kw.len);
PUT_SRCSTR (awk, HAWK_T(" "));
HAWK_ASSERT (awk, ((hawk_nde_return_t*)p)->val->next == HAWK_NULL);
HAWK_ASSERT (((hawk_nde_return_t*)p)->val->next == HAWK_NULL);
PRINT_EXPR (awk, ((hawk_nde_return_t*)p)->val);
PUT_SRCSTR (awk, HAWK_T(";"));
@ -1037,7 +1037,7 @@ static int print_stmt (hawk_t* awk, hawk_nde_t* p, int depth)
hawk_getkwname (awk, (px->abort? HAWK_KWID_XABORT: HAWK_KWID_EXIT), &kw);
PUT_SRCSTRN (awk, kw.ptr, kw.len);
PUT_SRCSTR (awk, HAWK_T(" "));
HAWK_ASSERT (awk, px->val->next == HAWK_NULL);
HAWK_ASSERT (px->val->next == HAWK_NULL);
PRINT_EXPR (awk, px->val);
PUT_SRCSTR (awk, HAWK_T(";"));
PUT_NL (awk);
@ -1294,8 +1294,8 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree)
case HAWK_NDE_EXP_BIN:
{
hawk_nde_exp_t* px = (hawk_nde_exp_t*)p;
HAWK_ASSERT (awk, px->left->next == HAWK_NULL);
HAWK_ASSERT (awk, px->right->next == HAWK_NULL);
HAWK_ASSERT (px->left->next == HAWK_NULL);
HAWK_ASSERT (px->right->next == HAWK_NULL);
hawk_clrpt (awk, px->left);
hawk_clrpt (awk, px->right);
@ -1308,7 +1308,7 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree)
case HAWK_NDE_EXP_INCPST:
{
hawk_nde_exp_t* px = (hawk_nde_exp_t*)p;
HAWK_ASSERT (awk, px->right == HAWK_NULL);
HAWK_ASSERT (px->right == HAWK_NULL);
hawk_clrpt (awk, px->left);
hawk_freemem (awk, p);
break;
@ -1375,7 +1375,7 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree)
case HAWK_NDE_ARG:
{
hawk_nde_var_t* px = (hawk_nde_var_t*)p;
HAWK_ASSERT (awk, px->idx == HAWK_NULL);
HAWK_ASSERT (px->idx == HAWK_NULL);
if (px->id.name.ptr) hawk_freemem (awk, px->id.name.ptr);
hawk_freemem (awk, p);
break;
@ -1387,7 +1387,7 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree)
case HAWK_NDE_ARGIDX:
{
hawk_nde_var_t* px = (hawk_nde_var_t*)p;
HAWK_ASSERT (awk, px->idx != HAWK_NULL);
HAWK_ASSERT (px->idx != HAWK_NULL);
hawk_clrpt (awk, px->idx);
if (px->id.name.ptr) hawk_freemem (awk, px->id.name.ptr);
hawk_freemem (awk, p);
@ -1440,7 +1440,7 @@ void hawk_clrpt (hawk_t* awk, hawk_nde_t* tree)
default:
{
HAWK_ASSERT (awk, !"should never happen - invalid node type");
HAWK_ASSERT (!"should never happen - invalid node type");
hawk_freemem (awk, p);
break;
}

152
hawk/lib/utl-ass.c Normal file
View File

@ -0,0 +1,152 @@
/*
* $Id$
*
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <hawk-cmn.h>
#if defined(HAWK_BUILD_RELEASE)
void hawk_assert_fail (const hawk_bch_t* expr, const hawk_bch_t* file, hawk_oow_t line)
{
/* do nothing */
}
#else /* defined(HAWK_BUILD_RELEASE) */
#include <stdio.h>
#include <stdlib.h>
#if defined(_WIN32)
# include <windows.h>
#elif defined(__OS2__)
# define INCL_DOSPROCESS
# define INCL_DOSFILEMGR
# include <os2.h>
#elif defined(__DOS__)
# include <dos.h>
# include <dosfunc.h>
#elif defined(vms) || defined(__vms)
# define __NEW_STARLET 1
# include <starlet.h> /* (SYS$...) */
# include <ssdef.h> /* (SS$...) */
# include <lib$routines.h> /* (lib$...) */
#elif defined(macintosh)
# include <Process.h>
# include <Dialogs.h>
# include <TextUtils.h>
#else
# include "syscall.h"
#endif
#if defined(HAWK_ENABLE_LIBUNWIND)
#include <libunwind.h>
static void backtrace_stack_frames (void)
{
unw_cursor_t cursor;
unw_context_t context;
int n;
unw_getcontext(&context);
unw_init_local(&cursor, &context);
printf ("[BACKTRACE]\n");
for (n = 0; unw_step(&cursor) > 0; n++)
{
unw_word_t ip, sp, off;
char symbol[256];
unw_get_reg (&cursor, UNW_REG_IP, &ip);
unw_get_reg (&cursor, UNW_REG_SP, &sp);
if (unw_get_proc_name(&cursor, symbol, HAWK_COUNTOF(symbol), &off))
{
hawk_copy_bcstr (symbol, HAWK_COUNTOF(symbol), "<unknown>");
}
printf (
"#%02d ip=0x%*p sp=0x%*p %s+0x%lu\n",
n, HAWK_SIZEOF(void*) * 2, (void*)ip, HAWK_SIZEOF(void*) * 2, (void*)sp, symbol, (unsigned long int)off);
}
}
#elif defined(HAVE_BACKTRACE)
#include <execinfo.h>
static void backtrace_stack_frames (void)
{
void* btarray[128];
hawk_oow_t btsize;
char** btsyms;
btsize = backtrace(btarray, HAWK_COUNTOF(btarray));
btsyms = backtrace_symbols(btarray, btsize);
if (btsyms)
{
hawk_oow_t i;
printf ("[BACKTRACE]\n");
for (i = 0; i < btsize; i++)
{
printf (" %s\n", btsyms[i]);
}
free (btsyms);
}
}
#else
static void backtrace_stack_frames (void)
{
/* do nothing. not supported */
}
#endif /* defined(HAWK_ENABLE_LIBUNWIND) */
void hawk_assert_fail (const hawk_bch_t* expr, const hawk_bch_t* file, hawk_oow_t line)
{
printf ("ASSERTION FAILURE: %s at %s:%lu\n", expr, file, (unsigned long int)line);
backtrace_stack_frames ();
#if defined(_WIN32)
ExitProcess (249);
#elif defined(__OS2__)
DosExit (EXIT_PROCESS, 249);
#elif defined(__DOS__)
{
union REGS regs;
regs.h.ah = DOS_EXIT;
regs.h.al = 249;
intdos (&regs, &regs);
}
#elif defined(vms) || defined(__vms)
lib$stop (SS$_ABORT); /* use SS$_OPCCUS instead? */
/* this won't be reached since lib$stop() terminates the process */
sys$exit (SS$_ABORT); /* this condition code can be shown with
* 'show symbol $status' from the command-line. */
#elif defined(macintosh)
ExitToShell ();
#else
kill (getpid(), SIGABRT);
_exit (1);
#endif
}
#endif /* defined(HAWK_BUILD_RELEASE) */

View File

@ -317,7 +317,7 @@ hawk_val_t* hawk_rtx_makenstrvalwithuchars (hawk_rtx_t* rtx, const hawk_uch_t* p
{
/* set the numeric string flag if a string
* can be converted to a number */
HAWK_ASSERT (hawk, x == 0 || x == 1);
HAWK_ASSERT (x == 0 || x == 1);
v->nstr = x + 1; /* long -> 1, real -> 2 */
}
@ -342,7 +342,7 @@ hawk_val_t* hawk_rtx_makenstrvalwithbchars (hawk_rtx_t* rtx, const hawk_bch_t* p
{
/* set the numeric string flag if a string
* can be converted to a number */
HAWK_ASSERT (hawk, x == 0 || x == 1);
HAWK_ASSERT (x == 0 || x == 1);
v->nstr = x + 1; /* long -> 1, real -> 2 */
}
@ -582,7 +582,7 @@ hawk_val_t* hawk_rtx_setmapvalfld (
hawk_rtx_t* rtx, hawk_val_t* map,
const hawk_ooch_t* kptr, hawk_oow_t klen, hawk_val_t* v)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
if (hawk_htb_upsert (((hawk_val_map_t*)map)->map, (hawk_ooch_t*)kptr, klen, v, 0) == HAWK_NULL) return HAWK_NULL;
@ -599,7 +599,7 @@ hawk_val_t* hawk_rtx_getmapvalfld (hawk_rtx_t* rtx, hawk_val_t* map, const hawk_
{
hawk_htb_pair_t* pair;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, map) == HAWK_VAL_MAP);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE(rtx, map) == HAWK_VAL_MAP);
pair = hawk_htb_search(((hawk_val_map_t*)map)->map, kptr, klen);
if (pair == HAWK_NULL)
@ -619,7 +619,7 @@ hawk_val_t* hawk_rtx_getmapvalfld (hawk_rtx_t* rtx, hawk_val_t* map, const hawk_
hawk_val_map_itr_t* hawk_rtx_getfirstmapvalitr (
hawk_rtx_t* rtx, hawk_val_t* map, hawk_val_map_itr_t* itr)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
itr->pair = hawk_htb_getfirstpair (((hawk_val_map_t*)map)->map, &itr->buckno);
return itr->pair? itr: HAWK_NULL;
}
@ -627,7 +627,7 @@ hawk_val_map_itr_t* hawk_rtx_getfirstmapvalitr (
hawk_val_map_itr_t* hawk_rtx_getnextmapvalitr (
hawk_rtx_t* rtx, hawk_val_t* map, hawk_val_map_itr_t* itr)
{
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, map) == HAWK_VAL_MAP);
itr->pair = hawk_htb_getnextpair (((hawk_val_map_t*)map)->map, itr->pair, &itr->buckno);
return itr->pair? itr: HAWK_NULL;
}
@ -829,7 +829,7 @@ void hawk_rtx_refdownval (hawk_rtx_t* rtx, hawk_val_t* val)
#endif
/* the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val->ref > 0);
HAWK_ASSERT (val->ref > 0);
val->ref--;
@ -847,7 +847,7 @@ void hawk_rtx_refdownval_nofree (hawk_rtx_t* rtx, hawk_val_t* val)
if (IS_STATICVAL(val)) return;
/* the reference count of a value should be greater than zero for it to be decremented. check the source code for any bugs */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), val->ref > 0);
HAWK_ASSERT (val->ref > 0);
val->ref--;
}
@ -901,7 +901,7 @@ static int val_ref_to_bool (hawk_rtx_t* rtx, const hawk_val_ref_t* ref)
/* A reference value is not able to point to another
* refernce value for the way values are represented
* in HAWKAWK */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
/* make a recursive call back to the caller */
return hawk_rtx_valtobool(rtx, *xref);
@ -941,7 +941,7 @@ int hawk_rtx_valtobool (hawk_rtx_t* rtx, const hawk_val_t* val)
}
/* the type of a value should be one of HAWK_VAL_XXX enumerators defined in hawk-prv.h */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), !"should never happen - invalid value type");
HAWK_ASSERT (!"should never happen - invalid value type");
return 0;
}
@ -1111,7 +1111,7 @@ static int val_int_to_str (hawk_rtx_t* rtx, const hawk_val_int_t* v, hawk_rtx_va
* and cpl are the same type. the following
* assertion at least ensure that they have
* the same size. */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
HAWK_ASSERT (HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
case HAWK_RTX_VALTOSTR_CPLCPY:
if (rlen >= out->u.cplcpy.len)
@ -1141,7 +1141,7 @@ static int val_int_to_str (hawk_rtx_t* rtx, const hawk_val_int_t* v, hawk_rtx_va
hawk_oow_t n;
hawk_ooecs_clear (out->u.strp);
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_OOECS_LEN(out->u.strp) == 0);
HAWK_ASSERT (HAWK_OOECS_LEN(out->u.strp) == 0);
/* point to the beginning of the buffer */
tmp = HAWK_OOECS_PTR(out->u.strp);
@ -1239,7 +1239,7 @@ static int val_flt_to_str (hawk_rtx_t* rtx, const hawk_val_flt_t* v, hawk_rtx_va
* and cpl are the same type. the following
* assertion at least ensure that they have
* the same size. */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
HAWK_ASSERT (HAWK_SIZEOF(out->u.cpl) == HAWK_SIZEOF(out->u.cplcpy));
case HAWK_RTX_VALTOSTR_CPLCPY:
if (out->u.cplcpy.len <= tmp_len)
@ -1356,7 +1356,7 @@ static int val_ref_to_str (hawk_rtx_t* rtx, const hawk_val_ref_t* ref, hawk_rtx_
/* A reference value is not able to point to another
* refernce value for the way values are represented
* in HAWKAWK */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref) != HAWK_VAL_REF);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, *xref) != HAWK_VAL_REF);
/* make a recursive call back to the caller */
return hawk_rtx_valtostr (rtx, *xref, out);
@ -1637,7 +1637,7 @@ static int val_ref_to_num (hawk_rtx_t* rtx, const hawk_val_ref_t* ref, hawk_int_
/* A reference value is not able to point to another
* refernce value for the way values are represented
* in HAWKAWK */
HAWK_ASSERT (hawk, HAWK_RTX_GETVALTYPE(rtx, *xref) != HAWK_VAL_REF);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE(rtx, *xref) != HAWK_VAL_REF);
/* make a recursive call back to the caller */
return hawk_rtx_valtonum(rtx, *xref, l, r);
@ -1823,7 +1823,7 @@ hawk_val_type_t hawk_rtx_getrefvaltype (hawk_rtx_t* rtx, hawk_val_ref_t* ref)
* refernce value for the way values are represented
* in HAWKAWK */
v = *xref;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE(rtx, v) != HAWK_VAL_REF);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE(rtx, v) != HAWK_VAL_REF);
return HAWK_RTX_GETVALTYPE(rtx, v);
}
}
@ -1853,7 +1853,7 @@ hawk_val_t* hawk_rtx_getrefval (hawk_rtx_t* rtx, hawk_val_ref_t* ref)
/* A reference value is not able to point to another
* refernce value for the way values are represented
* in HAWKAWK */
HAWK_ASSERT (hawk_rtx_gethawk(rtx), HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
HAWK_ASSERT (HAWK_RTX_GETVALTYPE (rtx, *xref)!= HAWK_VAL_REF);
return *xref;
}
}
@ -1997,7 +1997,7 @@ static hawk_htb_walk_t print_pair (hawk_htb_t* map, hawk_htb_pair_t* pair, void*
{
hawk_rtx_t* run = (hawk_rtx_t*)arg;
HAWK_ASSERT (hawk_rtx_gethawk(rtx), run == *(hawk_rtx_t**)hawk_htb_getxtn(map));
HAWK_ASSERT (run == *(hawk_rtx_t**)hawk_htb_getxtn(map));
hawk_errputstrf (HAWK_T(" %.*s=>"), HAWK_HTB_KLEN(pair), HAWK_HTB_KPTR(pair));
hawk_dprintval ((hawk_rtx_t*)arg, HAWK_HTB_VPTR(pair));