*** empty log message ***
This commit is contained in:
parent
03e914fa01
commit
e94b5729ef
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.78 2006-10-02 14:53:44 bacon Exp $
|
* $Id: awk.c,v 1.79 2006-10-12 04:17:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -29,6 +29,10 @@ xp_awk_t* xp_awk_open (xp_awk_syscas_t* syscas)
|
|||||||
syscas->to_upper == XP_NULL ||
|
syscas->to_upper == XP_NULL ||
|
||||||
syscas->to_lower == XP_NULL) return XP_NULL;
|
syscas->to_lower == XP_NULL) return XP_NULL;
|
||||||
|
|
||||||
|
if (syscas->sprintf == XP_NULL ||
|
||||||
|
syscas->dprintf == XP_NULL ||
|
||||||
|
syscas->abort == XP_NULL) return XP_NULL;
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_DEBUG)
|
#if defined(_WIN32) && defined(_DEBUG)
|
||||||
awk = (xp_awk_t*) malloc (xp_sizeof(xp_awk_t));
|
awk = (xp_awk_t*) malloc (xp_sizeof(xp_awk_t));
|
||||||
#else
|
#else
|
||||||
@ -120,7 +124,7 @@ int xp_awk_close (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
if (xp_awk_clear (awk) == -1) return -1;
|
if (xp_awk_clear (awk) == -1) return -1;
|
||||||
|
|
||||||
xp_assert (awk->run.count == 0 && awk->run.ptr == XP_NULL);
|
xp_awk_assert (awk, awk->run.count == 0 && awk->run.ptr == XP_NULL);
|
||||||
|
|
||||||
xp_awk_map_close (&awk->tree.afns);
|
xp_awk_map_close (&awk->tree.afns);
|
||||||
xp_awk_tab_close (&awk->parse.globals);
|
xp_awk_tab_close (&awk->parse.globals);
|
||||||
@ -171,14 +175,14 @@ int xp_awk_clear (xp_awk_t* awk)
|
|||||||
|
|
||||||
if (awk->tree.begin != XP_NULL)
|
if (awk->tree.begin != XP_NULL)
|
||||||
{
|
{
|
||||||
xp_assert (awk->tree.begin->next == XP_NULL);
|
xp_awk_assert (awk, awk->tree.begin->next == XP_NULL);
|
||||||
xp_awk_clrpt (awk, awk->tree.begin);
|
xp_awk_clrpt (awk, awk->tree.begin);
|
||||||
awk->tree.begin = XP_NULL;
|
awk->tree.begin = XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (awk->tree.end != XP_NULL)
|
if (awk->tree.end != XP_NULL)
|
||||||
{
|
{
|
||||||
xp_assert (awk->tree.end->next == XP_NULL);
|
xp_awk_assert (awk, awk->tree.end->next == XP_NULL);
|
||||||
xp_awk_clrpt (awk, awk->tree.end);
|
xp_awk_clrpt (awk, awk->tree.end);
|
||||||
awk->tree.end = XP_NULL;
|
awk->tree.end = XP_NULL;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.h,v 1.125 2006-10-10 14:08:55 bacon Exp $
|
* $Id: awk.h,v 1.126 2006-10-12 04:17:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_AWK_AWK_H_
|
#ifndef _XP_AWK_AWK_H_
|
||||||
@ -71,7 +71,10 @@ struct xp_awk_syscas_t
|
|||||||
/* utilities */
|
/* utilities */
|
||||||
void* (*memcpy) (void* dst, const void* src, xp_size_t n);
|
void* (*memcpy) (void* dst, const void* src, xp_size_t n);
|
||||||
void* (*memset) (void* dst, int val, xp_size_t n);
|
void* (*memset) (void* dst, int val, xp_size_t n);
|
||||||
|
|
||||||
int (*sprintf) (xp_char_t* buf, xp_size_t size, xp_char_t* fmt, ...);
|
int (*sprintf) (xp_char_t* buf, xp_size_t size, xp_char_t* fmt, ...);
|
||||||
|
int (*dprintf) (xp_char_t* fmt, ...);
|
||||||
|
void (*abort) (void);
|
||||||
|
|
||||||
void* custom_data;
|
void* custom_data;
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk_i.h,v 1.63 2006-10-11 15:01:54 bacon Exp $
|
* $Id: awk_i.h,v 1.64 2006-10-12 04:17:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_AWK_AWKI_H_
|
#ifndef _XP_AWK_AWKI_H_
|
||||||
@ -9,18 +9,6 @@ typedef struct xp_awk_chain_t xp_awk_chain_t;
|
|||||||
typedef struct xp_awk_tree_t xp_awk_tree_t;
|
typedef struct xp_awk_tree_t xp_awk_tree_t;
|
||||||
|
|
||||||
#include <xp/awk/awk.h>
|
#include <xp/awk/awk.h>
|
||||||
|
|
||||||
#ifdef XP_AWK_STAND_ALONE
|
|
||||||
#if !defined(XP_CHAR_IS_MCHAR) && !defined(XP_CHAR_IS_WCHAR)
|
|
||||||
#error Neither XP_CHAR_IS_MCHAR nor XP_CHAR_IS_WCHAR is defined.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#define xp_assert assert
|
|
||||||
#else
|
|
||||||
#include <xp/bas/assert.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <xp/awk/str.h>
|
#include <xp/awk/str.h>
|
||||||
#include <xp/awk/rex.h>
|
#include <xp/awk/rex.h>
|
||||||
#include <xp/awk/map.h>
|
#include <xp/awk/map.h>
|
||||||
@ -33,13 +21,15 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
|
|||||||
#include <xp/awk/extio.h>
|
#include <xp/awk/extio.h>
|
||||||
#include <xp/awk/misc.h>
|
#include <xp/awk/misc.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef NDEBUG
|
||||||
#pragma warning (disable: 4996)
|
#define xp_awk_assert(awk,expr) ((void)0)
|
||||||
|
#else
|
||||||
|
#define xp_awk_assert(awk,expr) (void)((expr) || \
|
||||||
|
(xp_awk_abort(awk, XP_TEXT(#expr), XP_TEXT(__FILE__), __LINE__), 0))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(XP_AWK_STAND_ALONE) && defined(_DEBUG)
|
#ifdef _MSC_VER
|
||||||
#define _CRTDBG_MAP_ALLOC
|
#pragma warning (disable: 4996)
|
||||||
#include <crtdbg.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define XP_AWK_MAX_GLOBALS 9999
|
#define XP_AWK_MAX_GLOBALS 9999
|
||||||
@ -47,6 +37,9 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
|
|||||||
#define XP_AWK_MAX_PARAMS 9999
|
#define XP_AWK_MAX_PARAMS 9999
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_DEBUG)
|
#if defined(_WIN32) && defined(_DEBUG)
|
||||||
|
#define _CRTDBG_MAP_ALLOC
|
||||||
|
#include <crtdbg.h>
|
||||||
|
|
||||||
#define XP_AWK_MALLOC(awk,size) malloc (size)
|
#define XP_AWK_MALLOC(awk,size) malloc (size)
|
||||||
#define XP_AWK_REALLOC(awk,ptr,size) realloc (ptr, size)
|
#define XP_AWK_REALLOC(awk,ptr,size) realloc (ptr, size)
|
||||||
#define XP_AWK_FREE(awk,ptr) free (ptr)
|
#define XP_AWK_FREE(awk,ptr) free (ptr)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: extio.c,v 1.51 2006-10-11 15:01:55 bacon Exp $
|
* $Id: extio.c,v 1.52 2006-10-12 04:17:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -84,9 +84,12 @@ int xp_awk_readextio (
|
|||||||
xp_size_t rs_len;
|
xp_size_t rs_len;
|
||||||
xp_size_t line_len = 0;
|
xp_size_t line_len = 0;
|
||||||
|
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_type_map));
|
xp_awk_assert (run->awk,
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_mode_map));
|
in_type >= 0 && in_type <= xp_countof(__in_type_map));
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_mask_map));
|
xp_awk_assert (run->awk,
|
||||||
|
in_type >= 0 && in_type <= xp_countof(__in_mode_map));
|
||||||
|
xp_awk_assert (run->awk,
|
||||||
|
in_type >= 0 && in_type <= xp_countof(__in_mask_map));
|
||||||
|
|
||||||
/* translate the in_type into the relevant extio type and mode */
|
/* translate the in_type into the relevant extio type and mode */
|
||||||
extio_type = __in_type_map[in_type];
|
extio_type = __in_type_map[in_type];
|
||||||
@ -280,7 +283,7 @@ int xp_awk_readextio (
|
|||||||
const xp_char_t* match_ptr;
|
const xp_char_t* match_ptr;
|
||||||
xp_size_t match_len;
|
xp_size_t match_len;
|
||||||
|
|
||||||
xp_assert (run->global.rs != XP_NULL);
|
xp_awk_assert (run->awk, run->global.rs != XP_NULL);
|
||||||
|
|
||||||
/* TODO: safematchrex */
|
/* TODO: safematchrex */
|
||||||
n = xp_awk_matchrex (
|
n = xp_awk_matchrex (
|
||||||
@ -298,7 +301,7 @@ int xp_awk_readextio (
|
|||||||
{
|
{
|
||||||
/* the match should be found at the end of
|
/* the match should be found at the end of
|
||||||
* the current buffer */
|
* the current buffer */
|
||||||
xp_assert (
|
xp_awk_assert (run->awk,
|
||||||
XP_AWK_STR_BUF(buf) + XP_AWK_STR_LEN(buf) ==
|
XP_AWK_STR_BUF(buf) + XP_AWK_STR_LEN(buf) ==
|
||||||
match_ptr + match_len);
|
match_ptr + match_len);
|
||||||
|
|
||||||
@ -373,7 +376,9 @@ int xp_awk_writeextio_val (
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
str = xp_awk_valtostr (
|
str = xp_awk_valtostr (
|
||||||
run, v, XP_AWK_VALTOSTR_CLEAR, XP_NULL, &len);
|
run, v,
|
||||||
|
XP_AWK_VALTOSTR_CLEAR | XP_AWK_VALTOSTR_PRINT,
|
||||||
|
XP_NULL, &len);
|
||||||
if (str == XP_NULL) return -1;
|
if (str == XP_NULL) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,9 +396,12 @@ int xp_awk_writeextio_str (
|
|||||||
xp_awk_io_t handler;
|
xp_awk_io_t handler;
|
||||||
int extio_type, extio_mode, extio_mask, n;
|
int extio_type, extio_mode, extio_mask, n;
|
||||||
|
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_type_map));
|
xp_awk_assert (run->awk,
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_mode_map));
|
out_type >= 0 && out_type <= xp_countof(__out_type_map));
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_mask_map));
|
xp_awk_assert (run->awk,
|
||||||
|
out_type >= 0 && out_type <= xp_countof(__out_mode_map));
|
||||||
|
xp_awk_assert (run->awk,
|
||||||
|
out_type >= 0 && out_type <= xp_countof(__out_mask_map));
|
||||||
|
|
||||||
/* translate the out_type into the relevant extio type and mode */
|
/* translate the out_type into the relevant extio type and mode */
|
||||||
extio_type = __out_type_map[out_type];
|
extio_type = __out_type_map[out_type];
|
||||||
@ -504,9 +512,12 @@ int xp_awk_flushextio (
|
|||||||
int extio_type, extio_mode, extio_mask, n;
|
int extio_type, extio_mode, extio_mask, n;
|
||||||
xp_bool_t ok = xp_false;
|
xp_bool_t ok = xp_false;
|
||||||
|
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_type_map));
|
xp_awk_assert (run->awk,
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_mode_map));
|
out_type >= 0 && out_type <= xp_countof(__out_type_map));
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_mask_map));
|
xp_awk_assert (run->awk,
|
||||||
|
out_type >= 0 && out_type <= xp_countof(__out_mode_map));
|
||||||
|
xp_awk_assert (run->awk,
|
||||||
|
out_type >= 0 && out_type <= xp_countof(__out_mask_map));
|
||||||
|
|
||||||
/* translate the out_type into the relevant extio type and mode */
|
/* translate the out_type into the relevant extio type and mode */
|
||||||
extio_type = __out_type_map[out_type];
|
extio_type = __out_type_map[out_type];
|
||||||
@ -564,9 +575,12 @@ int xp_awk_nextextio_read (
|
|||||||
xp_awk_io_t handler;
|
xp_awk_io_t handler;
|
||||||
int extio_type, extio_mode, extio_mask, n;
|
int extio_type, extio_mode, extio_mask, n;
|
||||||
|
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_type_map));
|
xp_awk_assert (run->awk,
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_mode_map));
|
in_type >= 0 && in_type <= xp_countof(__in_type_map));
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_mask_map));
|
xp_awk_assert (run->awk,
|
||||||
|
in_type >= 0 && in_type <= xp_countof(__in_mode_map));
|
||||||
|
xp_awk_assert (run->awk,
|
||||||
|
in_type >= 0 && in_type <= xp_countof(__in_mask_map));
|
||||||
|
|
||||||
/* translate the in_type into the relevant extio type and mode */
|
/* translate the in_type into the relevant extio type and mode */
|
||||||
extio_type = __in_type_map[in_type];
|
extio_type = __in_type_map[in_type];
|
||||||
@ -613,9 +627,12 @@ int xp_awk_closeextio_read (
|
|||||||
xp_awk_io_t handler;
|
xp_awk_io_t handler;
|
||||||
int extio_type, extio_mode, extio_mask;
|
int extio_type, extio_mode, extio_mask;
|
||||||
|
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_type_map));
|
xp_awk_assert (run->awk,
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_mode_map));
|
in_type >= 0 && in_type <= xp_countof(__in_type_map));
|
||||||
xp_assert (in_type >= 0 && in_type <= xp_countof(__in_mask_map));
|
xp_awk_assert (run->awk,
|
||||||
|
in_type >= 0 && in_type <= xp_countof(__in_mode_map));
|
||||||
|
xp_awk_assert (run->awk,
|
||||||
|
in_type >= 0 && in_type <= xp_countof(__in_mask_map));
|
||||||
|
|
||||||
/* translate the in_type into the relevant extio type and mode */
|
/* translate the in_type into the relevant extio type and mode */
|
||||||
extio_type = __in_type_map[in_type];
|
extio_type = __in_type_map[in_type];
|
||||||
@ -673,9 +690,12 @@ int xp_awk_closeextio_write (
|
|||||||
xp_awk_io_t handler;
|
xp_awk_io_t handler;
|
||||||
int extio_type, extio_mode, extio_mask;
|
int extio_type, extio_mode, extio_mask;
|
||||||
|
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_type_map));
|
xp_awk_assert (run->awk,
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_mode_map));
|
out_type >= 0 && out_type <= xp_countof(__out_type_map));
|
||||||
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_mask_map));
|
xp_awk_assert (run->awk,
|
||||||
|
out_type >= 0 && out_type <= xp_countof(__out_mode_map));
|
||||||
|
xp_awk_assert (run->awk,
|
||||||
|
out_type >= 0 && out_type <= xp_countof(__out_mask_map));
|
||||||
|
|
||||||
/* translate the out_type into the relevant extio type and mode */
|
/* translate the out_type into the relevant extio type and mode */
|
||||||
extio_type = __out_type_map[out_type];
|
extio_type = __out_type_map[out_type];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: func.c,v 1.61 2006-10-11 15:01:55 bacon Exp $
|
* $Id: func.c,v 1.62 2006-10-12 04:17:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -150,11 +150,11 @@ static int __bfn_close (xp_awk_run_t* run)
|
|||||||
xp_size_t len;
|
xp_size_t len;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs == 1);
|
xp_awk_assert (run->awk, nargs == 1);
|
||||||
/* TODO: support close (xxx, "to"/"from") like gawk */
|
/* TODO: support close (xxx, "to"/"from") like gawk */
|
||||||
|
|
||||||
a0 = xp_awk_getarg (run, 0);
|
a0 = xp_awk_getarg (run, 0);
|
||||||
xp_assert (a0 != XP_NULL);
|
xp_awk_assert (run->awk, a0 != XP_NULL);
|
||||||
|
|
||||||
if (a0->type == XP_AWK_VAL_STR)
|
if (a0->type == XP_AWK_VAL_STR)
|
||||||
{
|
{
|
||||||
@ -252,7 +252,7 @@ static int __bfn_fflush (xp_awk_run_t* run)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs >= 0 && nargs <= 1);
|
xp_awk_assert (run->awk, nargs >= 0 && nargs <= 1);
|
||||||
|
|
||||||
if (nargs == 0)
|
if (nargs == 0)
|
||||||
{
|
{
|
||||||
@ -347,7 +347,7 @@ static int __bfn_index (xp_awk_run_t* run)
|
|||||||
xp_long_t idx;
|
xp_long_t idx;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs == 2);
|
xp_awk_assert (run->awk, nargs == 2);
|
||||||
|
|
||||||
a0 = xp_awk_getarg (run, 0);
|
a0 = xp_awk_getarg (run, 0);
|
||||||
a1 = xp_awk_getarg (run, 1);
|
a1 = xp_awk_getarg (run, 1);
|
||||||
@ -408,7 +408,7 @@ static int __bfn_length (xp_awk_run_t* run)
|
|||||||
xp_size_t len;
|
xp_size_t len;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs == 1);
|
xp_awk_assert (run->awk, nargs == 1);
|
||||||
|
|
||||||
v = xp_awk_getarg (run, 0);
|
v = xp_awk_getarg (run, 0);
|
||||||
if (v->type == XP_AWK_VAL_STR)
|
if (v->type == XP_AWK_VAL_STR)
|
||||||
@ -445,7 +445,7 @@ static int __bfn_substr (xp_awk_run_t* run)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs >= 2 && nargs <= 3);
|
xp_awk_assert (run->awk, nargs >= 2 && nargs <= 3);
|
||||||
|
|
||||||
a0 = xp_awk_getarg (run, 0);
|
a0 = xp_awk_getarg (run, 0);
|
||||||
a1 = xp_awk_getarg (run, 1);
|
a1 = xp_awk_getarg (run, 1);
|
||||||
@ -520,13 +520,13 @@ static int __bfn_split (xp_awk_run_t* run)
|
|||||||
int errnum;
|
int errnum;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs >= 2 && nargs <= 3);
|
xp_awk_assert (run->awk, nargs >= 2 && nargs <= 3);
|
||||||
|
|
||||||
a0 = xp_awk_getarg (run, 0);
|
a0 = xp_awk_getarg (run, 0);
|
||||||
a1 = xp_awk_getarg (run, 1);
|
a1 = xp_awk_getarg (run, 1);
|
||||||
a2 = (nargs >= 3)? xp_awk_getarg (run, 2): XP_NULL;
|
a2 = (nargs >= 3)? xp_awk_getarg (run, 2): XP_NULL;
|
||||||
|
|
||||||
xp_assert (a1->type == XP_AWK_VAL_REF);
|
xp_awk_assert (run->awk, a1->type == XP_AWK_VAL_REF);
|
||||||
|
|
||||||
if (((xp_awk_val_ref_t*)a1)->id >= XP_AWK_VAL_REF_NAMEDIDX &&
|
if (((xp_awk_val_ref_t*)a1)->id >= XP_AWK_VAL_REF_NAMEDIDX &&
|
||||||
((xp_awk_val_ref_t*)a1)->id <= XP_AWK_VAL_REF_ARGIDX)
|
((xp_awk_val_ref_t*)a1)->id <= XP_AWK_VAL_REF_ARGIDX)
|
||||||
@ -687,7 +687,8 @@ static int __bfn_split (xp_awk_run_t* run)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert ((tok != XP_NULL && tok_len > 0) || tok_len == 0);
|
xp_awk_assert (run->awk,
|
||||||
|
(tok != XP_NULL && tok_len > 0) || tok_len == 0);
|
||||||
|
|
||||||
/* create the field string */
|
/* create the field string */
|
||||||
t2 = xp_awk_makestrval (run, tok, tok_len);
|
t2 = xp_awk_makestrval (run, tok, tok_len);
|
||||||
@ -706,7 +707,7 @@ static int __bfn_split (xp_awk_run_t* run)
|
|||||||
/* put it into the map */
|
/* put it into the map */
|
||||||
key_len = xp_awk_longtostr (
|
key_len = xp_awk_longtostr (
|
||||||
num, 10, XP_NULL, key, xp_countof(key));
|
num, 10, XP_NULL, key, xp_countof(key));
|
||||||
xp_assert (key_len != (xp_size_t)-1);
|
xp_awk_assert (run->awk, key_len != (xp_size_t)-1);
|
||||||
|
|
||||||
/* don't forget to update the reference count when you
|
/* don't forget to update the reference count when you
|
||||||
* handle the assignment-like situation. anyway, it is
|
* handle the assignment-like situation. anyway, it is
|
||||||
@ -757,7 +758,7 @@ static int __bfn_tolower (xp_awk_run_t* run)
|
|||||||
xp_awk_val_t* a0, * r;
|
xp_awk_val_t* a0, * r;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs == 1);
|
xp_awk_assert (run->awk, nargs == 1);
|
||||||
|
|
||||||
a0 = xp_awk_getarg (run, 0);
|
a0 = xp_awk_getarg (run, 0);
|
||||||
|
|
||||||
@ -796,7 +797,7 @@ static int __bfn_toupper (xp_awk_run_t* run)
|
|||||||
xp_awk_val_t* a0, * r;
|
xp_awk_val_t* a0, * r;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs == 1);
|
xp_awk_assert (run->awk, nargs == 1);
|
||||||
|
|
||||||
a0 = xp_awk_getarg (run, 0);
|
a0 = xp_awk_getarg (run, 0);
|
||||||
|
|
||||||
@ -844,13 +845,13 @@ static int __substitute (xp_awk_run_t* run, xp_long_t max_count)
|
|||||||
xp_long_t sub_count;
|
xp_long_t sub_count;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs >= 2 && nargs <= 3);
|
xp_awk_assert (run->awk, nargs >= 2 && nargs <= 3);
|
||||||
|
|
||||||
a0 = xp_awk_getarg (run, 0);
|
a0 = xp_awk_getarg (run, 0);
|
||||||
a1 = xp_awk_getarg (run, 1);
|
a1 = xp_awk_getarg (run, 1);
|
||||||
a2 = (nargs >= 3)? xp_awk_getarg (run, 2): XP_NULL;
|
a2 = (nargs >= 3)? xp_awk_getarg (run, 2): XP_NULL;
|
||||||
|
|
||||||
xp_assert (a2 == XP_NULL || a2->type == XP_AWK_VAL_REF);
|
xp_awk_assert (run->awk, a2 == XP_NULL || a2->type == XP_AWK_VAL_REF);
|
||||||
|
|
||||||
#define FREE_A_PTRS(awk) \
|
#define FREE_A_PTRS(awk) \
|
||||||
do { \
|
do { \
|
||||||
@ -947,8 +948,8 @@ static int __substitute (xp_awk_run_t* run, xp_long_t max_count)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
a2_ptr = xp_awk_valtostr (run, *a2_ref,
|
a2_ptr = xp_awk_valtostr (
|
||||||
XP_AWK_VALTOSTR_CLEAR, XP_NULL, &a2_len);
|
run, *a2_ref, XP_AWK_VALTOSTR_CLEAR, XP_NULL, &a2_len);
|
||||||
if (a2_ptr == XP_NULL)
|
if (a2_ptr == XP_NULL)
|
||||||
{
|
{
|
||||||
FREE_A_PTRS (run->awk);
|
FREE_A_PTRS (run->awk);
|
||||||
@ -1136,7 +1137,7 @@ static int __bfn_system (xp_awk_run_t* run)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs == 1);
|
xp_awk_assert (run->awk, nargs == 1);
|
||||||
|
|
||||||
cmd = xp_awk_valtostr (
|
cmd = xp_awk_valtostr (
|
||||||
run, xp_awk_getarg(run, 0),
|
run, xp_awk_getarg(run, 0),
|
||||||
@ -1174,7 +1175,7 @@ static int __bfn_sin (xp_awk_run_t* run)
|
|||||||
xp_real_t rv;
|
xp_real_t rv;
|
||||||
|
|
||||||
nargs = xp_awk_getnargs (run);
|
nargs = xp_awk_getnargs (run);
|
||||||
xp_assert (nargs == 1);
|
xp_awk_assert (run->awk, nargs == 1);
|
||||||
|
|
||||||
n = xp_awk_valtonum (run, xp_awk_getarg(run, 0), &lv, &rv);
|
n = xp_awk_valtonum (run, xp_awk_getarg(run, 0), &lv, &rv);
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: map.c,v 1.25 2006-09-22 14:04:25 bacon Exp $
|
* $Id: map.c,v 1.26 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -75,7 +75,7 @@ void xp_awk_map_clear (xp_awk_map_t* map)
|
|||||||
map->buck[i] = XP_NULL;
|
map->buck[i] = XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert (map->size == 0);
|
xp_awk_assert (map->awk, map->size == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_awk_pair_t* xp_awk_map_get (
|
xp_awk_pair_t* xp_awk_map_get (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: misc.c,v 1.26 2006-10-09 14:37:14 bacon Exp $
|
* $Id: misc.c,v 1.27 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -43,7 +43,7 @@ xp_long_t xp_awk_strxtolong (
|
|||||||
xp_size_t rem;
|
xp_size_t rem;
|
||||||
int digit, negative = 0;
|
int digit, negative = 0;
|
||||||
|
|
||||||
xp_assert (base < 37);
|
xp_awk_assert (awk, base < 37);
|
||||||
|
|
||||||
p = str;
|
p = str;
|
||||||
end = str + len;
|
end = str + len;
|
||||||
@ -995,7 +995,7 @@ xp_char_t* xp_awk_strxntokbyrex (
|
|||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert (n == 1);
|
xp_awk_assert (run->awk, n == 1);
|
||||||
|
|
||||||
if (match_len == 0)
|
if (match_len == 0)
|
||||||
{
|
{
|
||||||
@ -1060,4 +1060,12 @@ exit_loop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int xp_awk_abort (xp_awk_t* awk,
|
||||||
|
const xp_char_t* expr, const xp_char_t* file, int line)
|
||||||
|
{
|
||||||
|
awk->syscas->dprintf (
|
||||||
|
XP_T("ASSERTION FAILURE AT FILE %s, LINE %d\n%s\n"),
|
||||||
|
file, line, expr);
|
||||||
|
awk->syscas->abort ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: misc.h,v 1.2 2006-09-25 06:17:19 bacon Exp $
|
* $Id: misc.h,v 1.3 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_AWK_MISC_H_
|
#ifndef _XP_AWK_MISC_H_
|
||||||
@ -17,27 +17,30 @@ void* xp_awk_memcpy (void* dst, const void* src, xp_size_t n);
|
|||||||
void* xp_awk_memset (void* dst, int val, xp_size_t n);
|
void* xp_awk_memset (void* dst, int val, xp_size_t n);
|
||||||
|
|
||||||
xp_char_t* xp_awk_strtok (
|
xp_char_t* xp_awk_strtok (
|
||||||
xp_awk_run_t* awk, const xp_char_t* s,
|
xp_awk_run_t* run, const xp_char_t* s,
|
||||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
||||||
|
|
||||||
xp_char_t* xp_awk_strxtok (
|
xp_char_t* xp_awk_strxtok (
|
||||||
xp_awk_run_t* awk, const xp_char_t* s, xp_size_t len,
|
xp_awk_run_t* run, const xp_char_t* s, xp_size_t len,
|
||||||
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);
|
||||||
|
|
||||||
xp_char_t* xp_awk_strntok (
|
xp_char_t* xp_awk_strntok (
|
||||||
xp_awk_run_t* awk, const xp_char_t* s,
|
xp_awk_run_t* run, const xp_char_t* s,
|
||||||
const xp_char_t* delim, xp_size_t delim_len,
|
const xp_char_t* delim, xp_size_t delim_len,
|
||||||
xp_char_t** tok, xp_size_t* tok_len);
|
xp_char_t** tok, xp_size_t* tok_len);
|
||||||
|
|
||||||
xp_char_t* xp_awk_strxntok (
|
xp_char_t* xp_awk_strxntok (
|
||||||
xp_awk_run_t* awk, const xp_char_t* s, xp_size_t len,
|
xp_awk_run_t* run, const xp_char_t* s, xp_size_t len,
|
||||||
const xp_char_t* delim, xp_size_t delim_len,
|
const xp_char_t* delim, xp_size_t delim_len,
|
||||||
xp_char_t** tok, xp_size_t* tok_len);
|
xp_char_t** tok, xp_size_t* tok_len);
|
||||||
|
|
||||||
xp_char_t* xp_awk_strxntokbyrex (
|
xp_char_t* xp_awk_strxntokbyrex (
|
||||||
xp_awk_run_t* awk, const xp_char_t* s, xp_size_t len,
|
xp_awk_run_t* run, const xp_char_t* s, xp_size_t len,
|
||||||
void* rex, xp_char_t** tok, xp_size_t* tok_len, int* errnum);
|
void* rex, xp_char_t** tok, xp_size_t* tok_len, int* errnum);
|
||||||
|
|
||||||
|
int xp_awk_abort (xp_awk_t* awk,
|
||||||
|
const xp_char_t* expr, const xp_char_t* file, int line);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parse.c,v 1.187 2006-10-06 14:34:37 bacon Exp $
|
* $Id: parse.c,v 1.188 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -320,7 +320,7 @@ int xp_awk_parse (xp_awk_t* awk, xp_awk_srcios_t* srcios)
|
|||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
xp_assert (srcios != XP_NULL && srcios->in != XP_NULL);
|
xp_awk_assert (awk, srcios != XP_NULL && srcios->in != XP_NULL);
|
||||||
|
|
||||||
xp_awk_clear (awk);
|
xp_awk_clear (awk);
|
||||||
awk->src.ios = srcios;
|
awk->src.ios = srcios;
|
||||||
@ -399,7 +399,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
|||||||
function name (parameter-list) { statement }
|
function name (parameter-list) { statement }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xp_assert (awk->parse.depth.loop == 0);
|
xp_awk_assert (awk, awk->parse.depth.loop == 0);
|
||||||
|
|
||||||
if ((awk->option & XP_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
|
if ((awk->option & XP_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
|
||||||
{
|
{
|
||||||
@ -484,7 +484,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
|||||||
ptn = __parse_expression (awk);
|
ptn = __parse_expression (awk);
|
||||||
if (ptn == XP_NULL) return XP_NULL;
|
if (ptn == XP_NULL) return XP_NULL;
|
||||||
|
|
||||||
xp_assert (ptn->next == XP_NULL);
|
xp_awk_assert (awk, ptn->next == XP_NULL);
|
||||||
|
|
||||||
if (MATCH(awk,TOKEN_COMMA))
|
if (MATCH(awk,TOKEN_COMMA))
|
||||||
{
|
{
|
||||||
@ -559,7 +559,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
/* eat up the keyword 'function' and get the next token */
|
/* eat up the keyword 'function' and get the next token */
|
||||||
xp_assert (MATCH(awk,TOKEN_FUNCTION));
|
xp_awk_assert (awk, MATCH(awk,TOKEN_FUNCTION));
|
||||||
if (__get_token(awk) == -1) return XP_NULL;
|
if (__get_token(awk) == -1) return XP_NULL;
|
||||||
|
|
||||||
/* match a function name */
|
/* match a function name */
|
||||||
@ -614,7 +614,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* make sure that parameter table is empty */
|
/* make sure that parameter table is empty */
|
||||||
xp_assert (xp_awk_tab_getsize(&awk->parse.params) == 0);
|
xp_awk_assert (awk, xp_awk_tab_getsize(&awk->parse.params) == 0);
|
||||||
|
|
||||||
/* read parameter list */
|
/* read parameter list */
|
||||||
if (MATCH(awk,TOKEN_RPAREN))
|
if (MATCH(awk,TOKEN_RPAREN))
|
||||||
@ -773,7 +773,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* duplicate functions should have been detected previously */
|
/* duplicate functions should have been detected previously */
|
||||||
xp_assert (n != 0);
|
xp_awk_assert (awk, n != 0);
|
||||||
|
|
||||||
afn->name = pair->key; /* do some trick to save a string. */
|
afn->name = pair->key; /* do some trick to save a string. */
|
||||||
afn->name_len = pair->key_len;
|
afn->name_len = pair->key_len;
|
||||||
@ -786,7 +786,7 @@ static xp_awk_nde_t* __parse_begin (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
xp_awk_nde_t* nde;
|
xp_awk_nde_t* nde;
|
||||||
|
|
||||||
xp_assert (MATCH(awk,TOKEN_LBRACE));
|
xp_awk_assert (awk, MATCH(awk,TOKEN_LBRACE));
|
||||||
|
|
||||||
if (__get_token(awk) == -1) return XP_NULL;
|
if (__get_token(awk) == -1) return XP_NULL;
|
||||||
nde = __parse_block(awk, xp_true);
|
nde = __parse_block(awk, xp_true);
|
||||||
@ -800,7 +800,7 @@ static xp_awk_nde_t* __parse_end (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
xp_awk_nde_t* nde;
|
xp_awk_nde_t* nde;
|
||||||
|
|
||||||
xp_assert (MATCH(awk,TOKEN_LBRACE));
|
xp_awk_assert (awk, MATCH(awk,TOKEN_LBRACE));
|
||||||
|
|
||||||
if (__get_token(awk) == -1) return XP_NULL;
|
if (__get_token(awk) == -1) return XP_NULL;
|
||||||
nde = __parse_block(awk, xp_true);
|
nde = __parse_block(awk, xp_true);
|
||||||
@ -819,7 +819,7 @@ static xp_awk_chain_t* __parse_pattern_block (
|
|||||||
if (blockless) nde = XP_NULL;
|
if (blockless) nde = XP_NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xp_assert (MATCH(awk,TOKEN_LBRACE));
|
xp_awk_assert (awk, MATCH(awk,TOKEN_LBRACE));
|
||||||
if (__get_token(awk) == -1) return XP_NULL;
|
if (__get_token(awk) == -1) return XP_NULL;
|
||||||
nde = __parse_block(awk, xp_true);
|
nde = __parse_block(awk, xp_true);
|
||||||
if (nde == XP_NULL) return XP_NULL;
|
if (nde == XP_NULL) return XP_NULL;
|
||||||
@ -1281,7 +1281,7 @@ static xp_awk_nde_t* __parse_expression (xp_awk_t* awk)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert (x->next == XP_NULL);
|
xp_awk_assert (awk, x->next == XP_NULL);
|
||||||
if (!__is_var(x) && x->type != XP_AWK_NDE_POS)
|
if (!__is_var(x) && x->type != XP_AWK_NDE_POS)
|
||||||
{
|
{
|
||||||
xp_awk_clrpt (awk, x);
|
xp_awk_clrpt (awk, x);
|
||||||
@ -1965,7 +1965,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
|||||||
}
|
}
|
||||||
nde->len = XP_AWK_STR_LEN(&awk->token.name);
|
nde->len = XP_AWK_STR_LEN(&awk->token.name);
|
||||||
|
|
||||||
xp_assert (
|
xp_awk_assert (awk,
|
||||||
XP_AWK_STR_LEN(&awk->token.name) ==
|
XP_AWK_STR_LEN(&awk->token.name) ==
|
||||||
xp_awk_strlen(XP_AWK_STR_BUF(&awk->token.name)));
|
xp_awk_strlen(XP_AWK_STR_BUF(&awk->token.name)));
|
||||||
|
|
||||||
@ -2001,7 +2001,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
|||||||
}
|
}
|
||||||
nde->len = XP_AWK_STR_LEN(&awk->token.name);
|
nde->len = XP_AWK_STR_LEN(&awk->token.name);
|
||||||
|
|
||||||
xp_assert (
|
xp_awk_assert (awk,
|
||||||
XP_AWK_STR_LEN(&awk->token.name) ==
|
XP_AWK_STR_LEN(&awk->token.name) ==
|
||||||
xp_awk_strlen(XP_AWK_STR_BUF(&awk->token.name)));
|
xp_awk_strlen(XP_AWK_STR_BUF(&awk->token.name)));
|
||||||
|
|
||||||
@ -2052,7 +2052,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
|||||||
SET_TOKEN_TYPE (awk, TOKEN_REX);
|
SET_TOKEN_TYPE (awk, TOKEN_REX);
|
||||||
xp_awk_str_clear (&awk->token.name);
|
xp_awk_str_clear (&awk->token.name);
|
||||||
if (__get_rexstr (awk) == -1) return XP_NULL;
|
if (__get_rexstr (awk) == -1) return XP_NULL;
|
||||||
xp_assert (MATCH(awk,TOKEN_REX));
|
xp_awk_assert (awk, MATCH(awk,TOKEN_REX));
|
||||||
|
|
||||||
nde = (xp_awk_nde_rex_t*) XP_AWK_MALLOC (
|
nde = (xp_awk_nde_rex_t*) XP_AWK_MALLOC (
|
||||||
awk, xp_sizeof(xp_awk_nde_rex_t));
|
awk, xp_sizeof(xp_awk_nde_rex_t));
|
||||||
@ -2132,7 +2132,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
|||||||
|
|
||||||
/* parse subsequent expressions separated by a comma, if any */
|
/* parse subsequent expressions separated by a comma, if any */
|
||||||
last = nde;
|
last = nde;
|
||||||
xp_assert (last->next == XP_NULL);
|
xp_awk_assert (awk, last->next == XP_NULL);
|
||||||
|
|
||||||
while (MATCH(awk,TOKEN_COMMA))
|
while (MATCH(awk,TOKEN_COMMA))
|
||||||
{
|
{
|
||||||
@ -2151,7 +2151,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
|||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert (tmp->next == XP_NULL);
|
xp_awk_assert (awk, tmp->next == XP_NULL);
|
||||||
last->next = tmp;
|
last->next = tmp;
|
||||||
last = tmp;
|
last = tmp;
|
||||||
}
|
}
|
||||||
@ -2266,7 +2266,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
|||||||
xp_size_t name_len;
|
xp_size_t name_len;
|
||||||
xp_awk_bfn_t* bfn;
|
xp_awk_bfn_t* bfn;
|
||||||
|
|
||||||
xp_assert (MATCH(awk,TOKEN_IDENT));
|
xp_awk_assert (awk, MATCH(awk,TOKEN_IDENT));
|
||||||
|
|
||||||
name_dup = xp_awk_strxdup (
|
name_dup = xp_awk_strxdup (
|
||||||
awk,
|
awk,
|
||||||
@ -2423,7 +2423,7 @@ static xp_awk_nde_t* __parse_hashidx (
|
|||||||
|
|
||||||
if (idx == XP_NULL)
|
if (idx == XP_NULL)
|
||||||
{
|
{
|
||||||
xp_assert (last == XP_NULL);
|
xp_awk_assert (awk, last == XP_NULL);
|
||||||
idx = tmp; last = tmp;
|
idx = tmp; last = tmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2434,7 +2434,7 @@ static xp_awk_nde_t* __parse_hashidx (
|
|||||||
}
|
}
|
||||||
while (MATCH(awk,TOKEN_COMMA));
|
while (MATCH(awk,TOKEN_COMMA));
|
||||||
|
|
||||||
xp_assert (idx != XP_NULL);
|
xp_awk_assert (awk, idx != XP_NULL);
|
||||||
|
|
||||||
if (!MATCH(awk,TOKEN_RBRACK))
|
if (!MATCH(awk,TOKEN_RBRACK))
|
||||||
{
|
{
|
||||||
@ -3645,7 +3645,7 @@ static int __get_number (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
xp_cint_t c;
|
xp_cint_t c;
|
||||||
|
|
||||||
xp_assert (XP_AWK_STR_LEN(&awk->token.name) == 0);
|
xp_awk_assert (awk, XP_AWK_STR_LEN(&awk->token.name) == 0);
|
||||||
SET_TOKEN_TYPE (awk, TOKEN_INT);
|
SET_TOKEN_TYPE (awk, TOKEN_INT);
|
||||||
|
|
||||||
c = awk->src.lex.curc;
|
c = awk->src.lex.curc;
|
||||||
@ -4123,7 +4123,7 @@ static int __deparse (xp_awk_t* awk)
|
|||||||
struct __deparse_func_t df;
|
struct __deparse_func_t df;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
xp_assert (awk->src.ios->out != XP_NULL);
|
xp_awk_assert (awk, awk->src.ios->out != XP_NULL);
|
||||||
|
|
||||||
awk->src.shared.buf_len = 0;
|
awk->src.shared.buf_len = 0;
|
||||||
awk->src.shared.buf_pos = 0;
|
awk->src.shared.buf_pos = 0;
|
||||||
@ -4143,7 +4143,7 @@ static int __deparse (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
xp_size_t i, n;
|
xp_size_t i, n;
|
||||||
|
|
||||||
xp_assert (awk->tree.nglobals > 0);
|
xp_awk_assert (awk, awk->tree.nglobals > 0);
|
||||||
if (xp_awk_putsrcstr (awk, XP_T("global ")) == -1)
|
if (xp_awk_putsrcstr (awk, XP_T("global ")) == -1)
|
||||||
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
|
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
|
||||||
|
|
||||||
@ -4151,7 +4151,7 @@ static int __deparse (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
n = xp_awk_longtostr ((xp_long_t)i,
|
n = xp_awk_longtostr ((xp_long_t)i,
|
||||||
10, XP_T("__global"), tmp, xp_countof(tmp));
|
10, XP_T("__global"), tmp, xp_countof(tmp));
|
||||||
xp_assert (n != (xp_size_t)-1);
|
xp_awk_assert (awk, n != (xp_size_t)-1);
|
||||||
if (xp_awk_putsrcstrx (awk, tmp, n) == -1)
|
if (xp_awk_putsrcstrx (awk, tmp, n) == -1)
|
||||||
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
|
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
|
||||||
if (xp_awk_putsrcstr (awk, XP_T(", ")) == -1)
|
if (xp_awk_putsrcstr (awk, XP_T(", ")) == -1)
|
||||||
@ -4160,7 +4160,7 @@ static int __deparse (xp_awk_t* awk)
|
|||||||
|
|
||||||
n = xp_awk_longtostr ((xp_long_t)i,
|
n = xp_awk_longtostr ((xp_long_t)i,
|
||||||
10, XP_T("__global"), tmp, xp_countof(tmp));
|
10, XP_T("__global"), tmp, xp_countof(tmp));
|
||||||
xp_assert (n != (xp_size_t)-1);
|
xp_awk_assert (awk, n != (xp_size_t)-1);
|
||||||
if (xp_awk_putsrcstrx (awk, tmp, n) == -1)
|
if (xp_awk_putsrcstrx (awk, tmp, n) == -1)
|
||||||
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
|
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
|
||||||
if (xp_awk_putsrcstr (awk, XP_T(";\n\n")) == -1)
|
if (xp_awk_putsrcstr (awk, XP_T(";\n\n")) == -1)
|
||||||
@ -4245,7 +4245,7 @@ static int __deparse_func (xp_awk_pair_t* pair, void* arg)
|
|||||||
xp_awk_afn_t* afn = (xp_awk_afn_t*)pair->val;
|
xp_awk_afn_t* afn = (xp_awk_afn_t*)pair->val;
|
||||||
xp_size_t i, n;
|
xp_size_t i, n;
|
||||||
|
|
||||||
xp_assert (xp_awk_strxncmp (
|
xp_awk_assert (df->awk, xp_awk_strxncmp (
|
||||||
pair->key, pair->key_len, afn->name, afn->name_len) == 0);
|
pair->key, pair->key_len, afn->name, afn->name_len) == 0);
|
||||||
|
|
||||||
if (xp_awk_putsrcstr (df->awk, XP_T("function ")) == -1) return -1;
|
if (xp_awk_putsrcstr (df->awk, XP_T("function ")) == -1) return -1;
|
||||||
@ -4256,7 +4256,7 @@ static int __deparse_func (xp_awk_pair_t* pair, void* arg)
|
|||||||
{
|
{
|
||||||
n = xp_awk_longtostr (i++, 10,
|
n = xp_awk_longtostr (i++, 10,
|
||||||
XP_T("__param"), df->tmp, df->tmp_len);
|
XP_T("__param"), df->tmp, df->tmp_len);
|
||||||
xp_assert (n != (xp_size_t)-1);
|
xp_awk_assert (df->awk, n != (xp_size_t)-1);
|
||||||
if (xp_awk_putsrcstrx (df->awk, df->tmp, n) == -1) return -1;
|
if (xp_awk_putsrcstrx (df->awk, df->tmp, n) == -1) return -1;
|
||||||
if (i >= afn->nargs) break;
|
if (i >= afn->nargs) break;
|
||||||
if (xp_awk_putsrcstr (df->awk, XP_T(", ")) == -1) return -1;
|
if (xp_awk_putsrcstr (df->awk, XP_T(", ")) == -1) return -1;
|
||||||
@ -4284,7 +4284,7 @@ static int __flush (xp_awk_t* awk)
|
|||||||
{
|
{
|
||||||
xp_ssize_t n;
|
xp_ssize_t n;
|
||||||
|
|
||||||
xp_assert (awk->src.ios->out != XP_NULL);
|
xp_awk_assert (awk, awk->src.ios->out != XP_NULL);
|
||||||
|
|
||||||
while (awk->src.shared.buf_pos < awk->src.shared.buf_len)
|
while (awk->src.shared.buf_pos < awk->src.shared.buf_len)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: rec.c,v 1.1 2006-10-03 14:57:01 bacon Exp $
|
* $Id: rec.c,v 1.2 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -42,7 +42,7 @@ int xp_awk_setrec (
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert (run->inrec.d0->type == XP_AWK_VAL_NIL);
|
xp_awk_assert (run->awk, run->inrec.d0->type == XP_AWK_VAL_NIL);
|
||||||
/* d0 should be cleared before the next line is reached
|
/* d0 should be cleared before the next line is reached
|
||||||
* as it doesn't call xp_awk_refdownval on run->inrec.d0 */
|
* as it doesn't call xp_awk_refdownval on run->inrec.d0 */
|
||||||
run->inrec.d0 = v;
|
run->inrec.d0 = v;
|
||||||
@ -95,7 +95,7 @@ static int __split_record (xp_awk_run_t* run)
|
|||||||
int errnum;
|
int errnum;
|
||||||
|
|
||||||
/* inrec should be cleared before __split_record is called */
|
/* inrec should be cleared before __split_record is called */
|
||||||
xp_assert (run->inrec.nflds == 0);
|
xp_awk_assert (run->awk, run->inrec.nflds == 0);
|
||||||
|
|
||||||
/* get FS */
|
/* get FS */
|
||||||
fs = xp_awk_getglobal (run, XP_AWK_GLOBAL_FS);
|
fs = xp_awk_getglobal (run, XP_AWK_GLOBAL_FS);
|
||||||
@ -114,7 +114,7 @@ static int __split_record (xp_awk_run_t* run)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fs_ptr = xp_awk_valtostr (
|
fs_ptr = xp_awk_valtostr (
|
||||||
run, fs, xp_true, XP_NULL, &fs_len);
|
run, fs, XP_AWK_VALTOSTR_CLEAR, XP_NULL, &fs_len);
|
||||||
if (fs_ptr == XP_NULL) return -1;
|
if (fs_ptr == XP_NULL) return -1;
|
||||||
fs_free = fs_ptr;
|
fs_free = fs_ptr;
|
||||||
}
|
}
|
||||||
@ -152,7 +152,8 @@ static int __split_record (xp_awk_run_t* run)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert ((tok != XP_NULL && tok_len > 0) || tok_len == 0);
|
xp_awk_assert (run->awk,
|
||||||
|
(tok != XP_NULL && tok_len > 0) || tok_len == 0);
|
||||||
|
|
||||||
nflds++;
|
nflds++;
|
||||||
len = XP_AWK_STR_LEN(&run->inrec.line) -
|
len = XP_AWK_STR_LEN(&run->inrec.line) -
|
||||||
@ -201,7 +202,8 @@ static int __split_record (xp_awk_run_t* run)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert ((tok != XP_NULL && tok_len > 0) || tok_len == 0);
|
xp_awk_assert (run->awk,
|
||||||
|
(tok != XP_NULL && tok_len > 0) || tok_len == 0);
|
||||||
|
|
||||||
run->inrec.flds[run->inrec.nflds].ptr = tok;
|
run->inrec.flds[run->inrec.nflds].ptr = tok;
|
||||||
run->inrec.flds[run->inrec.nflds].len = tok_len;
|
run->inrec.flds[run->inrec.nflds].len = tok_len;
|
||||||
@ -234,7 +236,7 @@ static int __split_record (xp_awk_run_t* run)
|
|||||||
|
|
||||||
if (xp_awk_setglobal (run, XP_AWK_GLOBAL_NF, v) == -1) return -1;
|
if (xp_awk_setglobal (run, XP_AWK_GLOBAL_NF, v) == -1) return -1;
|
||||||
|
|
||||||
xp_assert (nflds == run->inrec.nflds);
|
xp_awk_assert (run->awk, nflds == run->inrec.nflds);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,11 +253,12 @@ int xp_awk_clrrec (xp_awk_run_t* run, xp_bool_t skip_inrec_line)
|
|||||||
|
|
||||||
if (run->inrec.nflds > 0)
|
if (run->inrec.nflds > 0)
|
||||||
{
|
{
|
||||||
xp_assert (run->inrec.flds != XP_NULL);
|
xp_awk_assert (run->awk, run->inrec.flds != XP_NULL);
|
||||||
|
|
||||||
for (i = 0; i < run->inrec.nflds; i++)
|
for (i = 0; i < run->inrec.nflds; i++)
|
||||||
{
|
{
|
||||||
xp_assert (run->inrec.flds[i].val != XP_NULL);
|
xp_awk_assert (run->awk,
|
||||||
|
run->inrec.flds[i].val != XP_NULL);
|
||||||
xp_awk_refdownval (run, run->inrec.flds[i].val);
|
xp_awk_refdownval (run, run->inrec.flds[i].val);
|
||||||
}
|
}
|
||||||
run->inrec.nflds = 0;
|
run->inrec.nflds = 0;
|
||||||
@ -270,7 +273,7 @@ int xp_awk_clrrec (xp_awk_run_t* run, xp_bool_t skip_inrec_line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert (run->inrec.nflds == 0);
|
xp_awk_assert (run->awk, run->inrec.nflds == 0);
|
||||||
if (!skip_inrec_line) xp_awk_str_clear (&run->inrec.line);
|
if (!skip_inrec_line) xp_awk_str_clear (&run->inrec.line);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
@ -286,7 +289,7 @@ static int __recomp_record_fields (
|
|||||||
/* recomposes the record and the fields when $N has been assigned
|
/* recomposes the record and the fields when $N has been assigned
|
||||||
* a new value and recomputes NF accordingly */
|
* a new value and recomputes NF accordingly */
|
||||||
|
|
||||||
xp_assert (lv > 0);
|
xp_awk_assert (run->awk, lv > 0);
|
||||||
max = (lv > run->inrec.nflds)? lv: run->inrec.nflds;
|
max = (lv > run->inrec.nflds)? lv: run->inrec.nflds;
|
||||||
|
|
||||||
nflds = run->inrec.nflds;
|
nflds = run->inrec.nflds;
|
||||||
@ -421,7 +424,7 @@ static int __recomp_record_fields (
|
|||||||
}
|
}
|
||||||
|
|
||||||
v = xp_awk_getglobal (run, XP_AWK_GLOBAL_NF);
|
v = xp_awk_getglobal (run, XP_AWK_GLOBAL_NF);
|
||||||
xp_assert (v->type == XP_AWK_VAL_INT);
|
xp_awk_assert (run->awk, v->type == XP_AWK_VAL_INT);
|
||||||
if (((xp_awk_val_int_t*)v)->val != max)
|
if (((xp_awk_val_int_t*)v)->val != max)
|
||||||
{
|
{
|
||||||
v = xp_awk_makeintval (run, (xp_long_t)max);
|
v = xp_awk_makeintval (run, (xp_long_t)max);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: rex.c,v 1.34 2006-10-08 05:46:41 bacon Exp $
|
* $Id: rex.c,v 1.35 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -384,16 +384,16 @@ int xp_awk_matchrex (
|
|||||||
|
|
||||||
void xp_awk_freerex (xp_awk_t* awk, void* code)
|
void xp_awk_freerex (xp_awk_t* awk, void* code)
|
||||||
{
|
{
|
||||||
xp_assert (code != XP_NULL);
|
xp_awk_assert (awk, code != XP_NULL);
|
||||||
XP_AWK_FREE (awk, code);
|
XP_AWK_FREE (awk, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_bool_t xp_awk_isemptyrex (void* code)
|
xp_bool_t xp_awk_isemptyrex (xp_awk_t* awk, void* code)
|
||||||
{
|
{
|
||||||
const xp_byte_t* p = code;
|
const xp_byte_t* p = code;
|
||||||
xp_size_t nb, el;
|
xp_size_t nb, el;
|
||||||
|
|
||||||
xp_assert (p != XP_NULL);
|
xp_awk_assert (awk, p != XP_NULL);
|
||||||
|
|
||||||
nb = *(xp_size_t*)p; p += xp_sizeof(nb);
|
nb = *(xp_size_t*)p; p += xp_sizeof(nb);
|
||||||
el = *(xp_size_t*)p; p += xp_sizeof(el);
|
el = *(xp_size_t*)p; p += xp_sizeof(el);
|
||||||
@ -598,7 +598,7 @@ static int __build_atom (__builder_t* builder)
|
|||||||
n = __build_charset (builder, cmd);
|
n = __build_charset (builder, cmd);
|
||||||
if (n == -1) return -1;
|
if (n == -1) return -1;
|
||||||
|
|
||||||
xp_assert (n != 0);
|
xp_awk_assert (builder->awk, n != 0);
|
||||||
|
|
||||||
if (builder->ptn.curc.type != CT_SPECIAL ||
|
if (builder->ptn.curc.type != CT_SPECIAL ||
|
||||||
builder->ptn.curc.value != XP_T(']'))
|
builder->ptn.curc.value != XP_T(']'))
|
||||||
@ -615,7 +615,7 @@ static int __build_atom (__builder_t* builder)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xp_assert (builder->ptn.curc.type == CT_NORMAL);
|
xp_awk_assert (builder->awk, builder->ptn.curc.type == CT_NORMAL);
|
||||||
|
|
||||||
tmp.cmd = CMD_ORD_CHAR;
|
tmp.cmd = CMD_ORD_CHAR;
|
||||||
tmp.negate = 0;
|
tmp.negate = 0;
|
||||||
@ -1145,8 +1145,9 @@ static const xp_byte_t* __match_atom (
|
|||||||
__match_group
|
__match_group
|
||||||
};
|
};
|
||||||
|
|
||||||
xp_assert (((struct __code_t*)base)->cmd >= 0 &&
|
xp_awk_assert (matcher->awk,
|
||||||
((struct __code_t*)base)->cmd < xp_countof(matchers));
|
((struct __code_t*)base)->cmd >= 0 &&
|
||||||
|
((struct __code_t*)base)->cmd < xp_countof(matchers));
|
||||||
|
|
||||||
return matchers[((struct __code_t*)base)->cmd] (matcher, base, mat);
|
return matchers[((struct __code_t*)base)->cmd] (matcher, base, mat);
|
||||||
}
|
}
|
||||||
@ -1158,7 +1159,7 @@ static const xp_byte_t* __match_bol (
|
|||||||
const struct __code_t* cp;
|
const struct __code_t* cp;
|
||||||
|
|
||||||
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
||||||
xp_assert (cp->cmd == CMD_BOL);
|
xp_awk_assert (matcher->awk, cp->cmd == CMD_BOL);
|
||||||
|
|
||||||
mat->matched = (mat->match_ptr == matcher->match.str.ptr ||
|
mat->matched = (mat->match_ptr == matcher->match.str.ptr ||
|
||||||
(cp->lbound == cp->ubound && cp->lbound == 0));
|
(cp->lbound == cp->ubound && cp->lbound == 0));
|
||||||
@ -1174,7 +1175,7 @@ static const xp_byte_t* __match_eol (
|
|||||||
const struct __code_t* cp;
|
const struct __code_t* cp;
|
||||||
|
|
||||||
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
||||||
xp_assert (cp->cmd == CMD_EOL);
|
xp_awk_assert (matcher->awk, cp->cmd == CMD_EOL);
|
||||||
|
|
||||||
mat->matched = (mat->match_ptr == matcher->match.str.end ||
|
mat->matched = (mat->match_ptr == matcher->match.str.end ||
|
||||||
(cp->lbound == cp->ubound && cp->lbound == 0));
|
(cp->lbound == cp->ubound && cp->lbound == 0));
|
||||||
@ -1191,7 +1192,7 @@ static const xp_byte_t* __match_any_char (
|
|||||||
xp_size_t si = 0, lbound, ubound;
|
xp_size_t si = 0, lbound, ubound;
|
||||||
|
|
||||||
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
||||||
xp_assert (cp->cmd == CMD_ANY_CHAR);
|
xp_awk_assert (matcher->awk, cp->cmd == CMD_ANY_CHAR);
|
||||||
|
|
||||||
lbound = cp->lbound;
|
lbound = cp->lbound;
|
||||||
ubound = cp->ubound;
|
ubound = cp->ubound;
|
||||||
@ -1241,7 +1242,7 @@ static const xp_byte_t* __match_ord_char (
|
|||||||
xp_char_t cc;
|
xp_char_t cc;
|
||||||
|
|
||||||
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
||||||
xp_assert (cp->cmd == CMD_ORD_CHAR);
|
xp_awk_assert (matcher->awk, cp->cmd == CMD_ORD_CHAR);
|
||||||
|
|
||||||
lbound = cp->lbound;
|
lbound = cp->lbound;
|
||||||
ubound = cp->ubound;
|
ubound = cp->ubound;
|
||||||
@ -1329,7 +1330,7 @@ static const xp_byte_t* __match_charset (
|
|||||||
xp_char_t c;
|
xp_char_t c;
|
||||||
|
|
||||||
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
||||||
xp_assert (cp->cmd == CMD_CHARSET);
|
xp_awk_assert (matcher->awk, cp->cmd == CMD_CHARSET);
|
||||||
|
|
||||||
lbound = cp->lbound;
|
lbound = cp->lbound;
|
||||||
ubound = cp->ubound;
|
ubound = cp->ubound;
|
||||||
@ -1373,7 +1374,7 @@ static const xp_byte_t* __match_group (
|
|||||||
xp_size_t si = 0, grp_len_static[16], * grp_len;
|
xp_size_t si = 0, grp_len_static[16], * grp_len;
|
||||||
|
|
||||||
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
cp = (const struct __code_t*)p; p += xp_sizeof(*cp);
|
||||||
xp_assert (cp->cmd == CMD_GROUP);
|
xp_awk_assert (matcher->awk, cp->cmd == CMD_GROUP);
|
||||||
|
|
||||||
mat->matched = xp_false;
|
mat->matched = xp_false;
|
||||||
mat->match_len = 0;
|
mat->match_len = 0;
|
||||||
@ -1454,7 +1455,7 @@ static const xp_byte_t* __match_group (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xp_assert (cp->ubound > cp->lbound);
|
xp_awk_assert (matcher->awk, cp->ubound > cp->lbound);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1499,7 +1500,7 @@ static const xp_byte_t* __match_occurrences (
|
|||||||
__matcher_t* matcher, xp_size_t si, const xp_byte_t* p,
|
__matcher_t* matcher, xp_size_t si, const xp_byte_t* p,
|
||||||
xp_size_t lbound, xp_size_t ubound, __match_t* mat)
|
xp_size_t lbound, xp_size_t ubound, __match_t* mat)
|
||||||
{
|
{
|
||||||
xp_assert (si >= lbound && si <= ubound);
|
xp_awk_assert (matcher->awk, si >= lbound && si <= ubound);
|
||||||
/* the match has been found */
|
/* the match has been found */
|
||||||
|
|
||||||
if (lbound == ubound || p >= mat->branch_end)
|
if (lbound == ubound || p >= mat->branch_end)
|
||||||
@ -1552,7 +1553,7 @@ static const xp_byte_t* __match_occurrences (
|
|||||||
* lbound in the implementation below, though)
|
* lbound in the implementation below, though)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xp_assert (ubound > lbound);
|
xp_awk_assert (matcher->awk, ubound > lbound);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -1624,7 +1625,8 @@ xp_bool_t __test_charset (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xp_assert (!"should never happen - invalid charset code");
|
xp_awk_assert (matcher->awk,
|
||||||
|
!"should never happen - invalid charset code");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1799,7 +1801,7 @@ static const xp_byte_t* __print_atom (const xp_byte_t* p)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xp_assert (!"should never happen - invalid charset code");
|
xp_printf ("should never happen - invalid charset code\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
p += xp_sizeof(c1);
|
p += xp_sizeof(c1);
|
||||||
@ -1816,7 +1818,7 @@ static const xp_byte_t* __print_atom (const xp_byte_t* p)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xp_assert (!"should never happen - invalid atom code");
|
xp_printf ("should never happen - invalid atom code\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cp->lbound == 0 && cp->ubound == BOUND_MAX)
|
if (cp->lbound == 0 && cp->ubound == BOUND_MAX)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: rex.h,v 1.17 2006-10-04 10:11:04 bacon Exp $
|
* $Id: rex.h,v 1.18 2006-10-12 04:17:31 bacon Exp $
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef _XP_AWK_REX_H_
|
#ifndef _XP_AWK_REX_H_
|
||||||
@ -62,7 +62,7 @@ int xp_awk_matchrex (
|
|||||||
|
|
||||||
void xp_awk_freerex (xp_awk_t* awk, void* code);
|
void xp_awk_freerex (xp_awk_t* awk, void* code);
|
||||||
|
|
||||||
xp_bool_t xp_awk_isemptyrex (void* code);
|
xp_bool_t xp_awk_isemptyrex (xp_awk_t* awk, void* code);
|
||||||
|
|
||||||
void xp_awk_printrex (void* code);
|
void xp_awk_printrex (void* code);
|
||||||
|
|
||||||
|
287
ase/awk/run.c
287
ase/awk/run.c
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: tab.c,v 1.19 2006-09-28 06:56:30 bacon Exp $
|
* $Id: tab.c,v 1.20 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -53,7 +53,7 @@ xp_awk_tab_t* xp_awk_tab_setcapa (xp_awk_tab_t* tab, xp_size_t capa)
|
|||||||
if (tab->size > capa)
|
if (tab->size > capa)
|
||||||
{
|
{
|
||||||
xp_awk_tab_remove (tab, capa, tab->size - capa);
|
xp_awk_tab_remove (tab, capa, tab->size - capa);
|
||||||
xp_assert (tab->size <= capa);
|
xp_awk_assert (tab->awk, tab->size <= capa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capa > 0)
|
if (capa > 0)
|
||||||
@ -96,8 +96,6 @@ void xp_awk_tab_clear (xp_awk_tab_t* tab)
|
|||||||
{
|
{
|
||||||
xp_size_t i;
|
xp_size_t i;
|
||||||
|
|
||||||
xp_assert (tab != XP_NULL);
|
|
||||||
|
|
||||||
for (i = 0; i < tab->size; i++)
|
for (i = 0; i < tab->size; i++)
|
||||||
{
|
{
|
||||||
XP_AWK_FREE (tab->awk, tab->buf[i].name);
|
XP_AWK_FREE (tab->awk, tab->buf[i].name);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: tree.c,v 1.78 2006-10-06 03:33:43 bacon Exp $
|
* $Id: tree.c,v 1.79 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -144,7 +144,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
PUT_SRCSTR (awk, XP_T(" "));
|
PUT_SRCSTR (awk, XP_T(" "));
|
||||||
PRINT_EXPRESSION (awk, px->right);
|
PRINT_EXPRESSION (awk, px->right);
|
||||||
|
|
||||||
xp_assert (px->right->next == XP_NULL);
|
xp_awk_assert (awk, px->right->next == XP_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
|
|
||||||
PUT_SRCSTR (awk, XP_T("("));
|
PUT_SRCSTR (awk, XP_T("("));
|
||||||
PRINT_EXPRESSION (awk, px->left);
|
PRINT_EXPRESSION (awk, px->left);
|
||||||
xp_assert (px->left->next == XP_NULL);
|
xp_awk_assert (awk, px->left->next == XP_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, XP_T(" "));
|
PUT_SRCSTR (awk, XP_T(" "));
|
||||||
PUT_SRCSTR (awk, __binop_str[px->opcode]);
|
PUT_SRCSTR (awk, __binop_str[px->opcode]);
|
||||||
@ -165,7 +165,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
PRINT_EXPRESSION (awk, px->right);
|
PRINT_EXPRESSION (awk, px->right);
|
||||||
if (px->right->type == XP_AWK_NDE_ASS)
|
if (px->right->type == XP_AWK_NDE_ASS)
|
||||||
PUT_SRCSTR (awk, XP_T(")"));
|
PUT_SRCSTR (awk, XP_T(")"));
|
||||||
xp_assert (px->right->next == XP_NULL);
|
xp_awk_assert (awk, px->right->next == XP_NULL);
|
||||||
PUT_SRCSTR (awk, XP_T(")"));
|
PUT_SRCSTR (awk, XP_T(")"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
case XP_AWK_NDE_EXP_UNR:
|
case XP_AWK_NDE_EXP_UNR:
|
||||||
{
|
{
|
||||||
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)nde;
|
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)nde;
|
||||||
xp_assert (px->right == XP_NULL);
|
xp_awk_assert (awk, px->right == XP_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, __unrop_str[px->opcode]);
|
PUT_SRCSTR (awk, __unrop_str[px->opcode]);
|
||||||
PUT_SRCSTR (awk, XP_T("("));
|
PUT_SRCSTR (awk, XP_T("("));
|
||||||
@ -185,7 +185,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
case XP_AWK_NDE_EXP_INCPRE:
|
case XP_AWK_NDE_EXP_INCPRE:
|
||||||
{
|
{
|
||||||
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)nde;
|
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)nde;
|
||||||
xp_assert (px->right == XP_NULL);
|
xp_awk_assert (awk, px->right == XP_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, __incop_str[px->opcode]);
|
PUT_SRCSTR (awk, __incop_str[px->opcode]);
|
||||||
PUT_SRCSTR (awk, XP_T("("));
|
PUT_SRCSTR (awk, XP_T("("));
|
||||||
@ -197,7 +197,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
case XP_AWK_NDE_EXP_INCPST:
|
case XP_AWK_NDE_EXP_INCPST:
|
||||||
{
|
{
|
||||||
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)nde;
|
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)nde;
|
||||||
xp_assert (px->right == XP_NULL);
|
xp_awk_assert (awk, px->right == XP_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, XP_T("("));
|
PUT_SRCSTR (awk, XP_T("("));
|
||||||
PRINT_EXPRESSION (awk, px->left);
|
PRINT_EXPRESSION (awk, px->left);
|
||||||
@ -296,7 +296,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
|
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
|
||||||
xp_size_t n;
|
xp_size_t n;
|
||||||
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
||||||
xp_assert (px->id.idxa != (xp_size_t)-1);
|
xp_awk_assert (awk, px->id.idxa != (xp_size_t)-1);
|
||||||
|
|
||||||
n = xp_awk_longtostr (
|
n = xp_awk_longtostr (
|
||||||
px->id.idxa, 10, XP_NULL, tmp, xp_countof(tmp));
|
px->id.idxa, 10, XP_NULL, tmp, xp_countof(tmp));
|
||||||
@ -304,7 +304,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
PUT_SRCSTR (awk, XP_T("__param"));
|
PUT_SRCSTR (awk, XP_T("__param"));
|
||||||
PUT_SRCSTRX (awk, tmp, n);
|
PUT_SRCSTRX (awk, tmp, n);
|
||||||
|
|
||||||
xp_assert (px->idx == XP_NULL);
|
xp_awk_assert (awk, px->idx == XP_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,8 +313,8 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
|
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
|
||||||
xp_size_t n;
|
xp_size_t n;
|
||||||
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
||||||
xp_assert (px->id.idxa != (xp_size_t)-1);
|
xp_awk_assert (awk, px->id.idxa != (xp_size_t)-1);
|
||||||
xp_assert (px->idx != XP_NULL);
|
xp_awk_assert (awk, px->idx != XP_NULL);
|
||||||
|
|
||||||
PUT_SRCSTR (awk, XP_T("__param"));
|
PUT_SRCSTR (awk, XP_T("__param"));
|
||||||
n = xp_awk_longtostr (
|
n = xp_awk_longtostr (
|
||||||
@ -329,8 +329,8 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
case XP_AWK_NDE_NAMED:
|
case XP_AWK_NDE_NAMED:
|
||||||
{
|
{
|
||||||
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
||||||
xp_assert (px->id.idxa == (xp_size_t)-1);
|
xp_awk_assert (awk, px->id.idxa == (xp_size_t)-1);
|
||||||
xp_assert (px->idx == XP_NULL);
|
xp_awk_assert (awk, px->idx == XP_NULL);
|
||||||
|
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
break;
|
break;
|
||||||
@ -339,8 +339,8 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
case XP_AWK_NDE_NAMEDIDX:
|
case XP_AWK_NDE_NAMEDIDX:
|
||||||
{
|
{
|
||||||
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
|
||||||
xp_assert (px->id.idxa == (xp_size_t)-1);
|
xp_awk_assert (awk, px->id.idxa == (xp_size_t)-1);
|
||||||
xp_assert (px->idx != XP_NULL);
|
xp_awk_assert (awk, px->idx != XP_NULL);
|
||||||
|
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
PUT_SRCSTR (awk, XP_T("["));
|
PUT_SRCSTR (awk, XP_T("["));
|
||||||
@ -367,7 +367,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
{
|
{
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
}
|
}
|
||||||
xp_assert (px->idx == XP_NULL);
|
xp_awk_assert (awk, px->idx == XP_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
PUT_SRCSTR (awk, XP_T("["));
|
PUT_SRCSTR (awk, XP_T("["));
|
||||||
}
|
}
|
||||||
xp_assert (px->idx != XP_NULL);
|
xp_awk_assert (awk, px->idx != XP_NULL);
|
||||||
PRINT_EXPRESSION_LIST (awk, px->idx);
|
PRINT_EXPRESSION_LIST (awk, px->idx);
|
||||||
PUT_SRCSTR (awk, XP_T("]"));
|
PUT_SRCSTR (awk, XP_T("]"));
|
||||||
break;
|
break;
|
||||||
@ -415,7 +415,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
{
|
{
|
||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
}
|
}
|
||||||
xp_assert (px->idx == XP_NULL);
|
xp_awk_assert (awk, px->idx == XP_NULL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
PUT_SRCSTRX (awk, px->id.name, px->id.name_len);
|
||||||
PUT_SRCSTR (awk, XP_T("["));
|
PUT_SRCSTR (awk, XP_T("["));
|
||||||
}
|
}
|
||||||
xp_assert (px->idx != XP_NULL);
|
xp_awk_assert (awk, px->idx != XP_NULL);
|
||||||
PRINT_EXPRESSION_LIST (awk, px->idx);
|
PRINT_EXPRESSION_LIST (awk, px->idx);
|
||||||
PUT_SRCSTR (awk, XP_T("]"));
|
PUT_SRCSTR (awk, XP_T("]"));
|
||||||
break;
|
break;
|
||||||
@ -591,7 +591,7 @@ static int __print_statements (xp_awk_t* awk, xp_awk_nde_t* tree, int depth)
|
|||||||
PRINT_EXPRESSION (awk, px->test);
|
PRINT_EXPRESSION (awk, px->test);
|
||||||
PUT_SRCSTR (awk, XP_T(")\n"));
|
PUT_SRCSTR (awk, XP_T(")\n"));
|
||||||
|
|
||||||
xp_assert (px->then_part != XP_NULL);
|
xp_awk_assert (awk, px->then_part != XP_NULL);
|
||||||
if (px->then_part->type == XP_AWK_NDE_BLK)
|
if (px->then_part->type == XP_AWK_NDE_BLK)
|
||||||
PRINT_STATEMENTS (awk, px->then_part, depth);
|
PRINT_STATEMENTS (awk, px->then_part, depth);
|
||||||
else
|
else
|
||||||
@ -726,7 +726,7 @@ static int __print_statements (xp_awk_t* awk, xp_awk_nde_t* tree, int depth)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PUT_SRCSTR (awk, XP_T("return "));
|
PUT_SRCSTR (awk, XP_T("return "));
|
||||||
xp_assert (((xp_awk_nde_return_t*)p)->val->next == XP_NULL);
|
xp_awk_assert (awk, ((xp_awk_nde_return_t*)p)->val->next == XP_NULL);
|
||||||
|
|
||||||
PRINT_EXPRESSION (awk, ((xp_awk_nde_return_t*)p)->val);
|
PRINT_EXPRESSION (awk, ((xp_awk_nde_return_t*)p)->val);
|
||||||
PUT_SRCSTR (awk, XP_T(";\n"));
|
PUT_SRCSTR (awk, XP_T(";\n"));
|
||||||
@ -746,7 +746,7 @@ static int __print_statements (xp_awk_t* awk, xp_awk_nde_t* tree, int depth)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
PUT_SRCSTR (awk, XP_T("exit "));
|
PUT_SRCSTR (awk, XP_T("exit "));
|
||||||
xp_assert (px->val->next == XP_NULL);
|
xp_awk_assert (awk, px->val->next == XP_NULL);
|
||||||
PRINT_EXPRESSION (awk, px->val);
|
PRINT_EXPRESSION (awk, px->val);
|
||||||
PUT_SRCSTR (awk, XP_T(";\n"));
|
PUT_SRCSTR (awk, XP_T(";\n"));
|
||||||
}
|
}
|
||||||
@ -978,8 +978,8 @@ void xp_awk_clrpt (xp_awk_t* awk, xp_awk_nde_t* tree)
|
|||||||
case XP_AWK_NDE_EXP_BIN:
|
case XP_AWK_NDE_EXP_BIN:
|
||||||
{
|
{
|
||||||
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)p;
|
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)p;
|
||||||
xp_assert (px->left->next == XP_NULL);
|
xp_awk_assert (awk, px->left->next == XP_NULL);
|
||||||
xp_assert (px->right->next == XP_NULL);
|
xp_awk_assert (awk, px->right->next == XP_NULL);
|
||||||
|
|
||||||
xp_awk_clrpt (awk, px->left);
|
xp_awk_clrpt (awk, px->left);
|
||||||
xp_awk_clrpt (awk, px->right);
|
xp_awk_clrpt (awk, px->right);
|
||||||
@ -992,7 +992,7 @@ void xp_awk_clrpt (xp_awk_t* awk, xp_awk_nde_t* tree)
|
|||||||
case XP_AWK_NDE_EXP_INCPST:
|
case XP_AWK_NDE_EXP_INCPST:
|
||||||
{
|
{
|
||||||
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)p;
|
xp_awk_nde_exp_t* px = (xp_awk_nde_exp_t*)p;
|
||||||
xp_assert (px->right == XP_NULL);
|
xp_awk_assert (awk, px->right == XP_NULL);
|
||||||
xp_awk_clrpt (awk, px->left);
|
xp_awk_clrpt (awk, px->left);
|
||||||
XP_AWK_FREE (awk, p);
|
XP_AWK_FREE (awk, p);
|
||||||
break;
|
break;
|
||||||
@ -1044,7 +1044,7 @@ void xp_awk_clrpt (xp_awk_t* awk, xp_awk_nde_t* tree)
|
|||||||
case XP_AWK_NDE_ARG:
|
case XP_AWK_NDE_ARG:
|
||||||
{
|
{
|
||||||
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)p;
|
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)p;
|
||||||
xp_assert (px->idx == XP_NULL);
|
xp_awk_assert (awk, px->idx == XP_NULL);
|
||||||
if (px->id.name != XP_NULL)
|
if (px->id.name != XP_NULL)
|
||||||
XP_AWK_FREE (awk, px->id.name);
|
XP_AWK_FREE (awk, px->id.name);
|
||||||
XP_AWK_FREE (awk, p);
|
XP_AWK_FREE (awk, p);
|
||||||
@ -1057,7 +1057,7 @@ void xp_awk_clrpt (xp_awk_t* awk, xp_awk_nde_t* tree)
|
|||||||
case XP_AWK_NDE_ARGIDX:
|
case XP_AWK_NDE_ARGIDX:
|
||||||
{
|
{
|
||||||
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)p;
|
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)p;
|
||||||
xp_assert (px->idx != XP_NULL);
|
xp_awk_assert (awk, px->idx != XP_NULL);
|
||||||
xp_awk_clrpt (awk, px->idx);
|
xp_awk_clrpt (awk, px->idx);
|
||||||
if (px->id.name != XP_NULL)
|
if (px->id.name != XP_NULL)
|
||||||
XP_AWK_FREE (awk, px->id.name);
|
XP_AWK_FREE (awk, px->id.name);
|
||||||
@ -1104,7 +1104,7 @@ void xp_awk_clrpt (xp_awk_t* awk, xp_awk_nde_t* tree)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
xp_assert (!"should never happen - invalid node type");
|
xp_awk_assert (awk, !"should never happen - invalid node type");
|
||||||
XP_AWK_FREE (awk, p);
|
XP_AWK_FREE (awk, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: val.c,v 1.71 2006-10-11 15:01:55 bacon Exp $
|
* $Id: val.c,v 1.72 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -298,7 +298,8 @@ xp_printf (XP_T("\n"));*/
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xp_assert (!"should never happen - invalid value type");
|
xp_awk_assert (run->awk,
|
||||||
|
!"should never happen - invalid value type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +325,7 @@ xp_awk_printval (val);
|
|||||||
xp_printf (XP_T("\n"));
|
xp_printf (XP_T("\n"));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
xp_assert (val->ref > 0);
|
xp_awk_assert (run->awk, val->ref > 0);
|
||||||
val->ref--;
|
val->ref--;
|
||||||
if (val->ref <= 0)
|
if (val->ref <= 0)
|
||||||
{
|
{
|
||||||
@ -341,11 +342,11 @@ void xp_awk_refdownval_nofree (xp_awk_run_t* run, xp_awk_val_t* val)
|
|||||||
{
|
{
|
||||||
if (xp_awk_isbuiltinval(val)) return;
|
if (xp_awk_isbuiltinval(val)) return;
|
||||||
|
|
||||||
xp_assert (val->ref > 0);
|
xp_awk_assert (run->awk, val->ref > 0);
|
||||||
val->ref--;
|
val->ref--;
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_bool_t xp_awk_valtobool (xp_awk_val_t* val)
|
xp_bool_t xp_awk_valtobool (xp_awk_run_t* run, xp_awk_val_t* val)
|
||||||
{
|
{
|
||||||
if (val == XP_NULL) return xp_false;
|
if (val == XP_NULL) return xp_false;
|
||||||
|
|
||||||
@ -367,7 +368,7 @@ xp_bool_t xp_awk_valtobool (xp_awk_val_t* val)
|
|||||||
return xp_false; /* TODO: is this correct? */
|
return xp_false; /* TODO: is this correct? */
|
||||||
}
|
}
|
||||||
|
|
||||||
xp_assert (!"should never happen - invalid value type");
|
xp_awk_assert (run->awk, !"should never happen - invalid value type");
|
||||||
return xp_false;
|
return xp_false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +707,6 @@ void xp_awk_printval (xp_awk_val_t* val)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
xp_assert (!"should never happen - invalid value type");
|
|
||||||
xp_printf (XP_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
|
xp_printf (XP_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: val.h,v 1.45 2006-10-11 15:01:55 bacon Exp $
|
* $Id: val.h,v 1.46 2006-10-12 04:17:31 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_AWK_VAL_H_
|
#ifndef _XP_AWK_VAL_H_
|
||||||
@ -164,10 +164,13 @@ void xp_awk_refupval (xp_awk_val_t* val);
|
|||||||
void xp_awk_refdownval (xp_awk_run_t* run, xp_awk_val_t* val);
|
void xp_awk_refdownval (xp_awk_run_t* run, xp_awk_val_t* val);
|
||||||
void xp_awk_refdownval_nofree (xp_awk_run_t* run, xp_awk_val_t* val);
|
void xp_awk_refdownval_nofree (xp_awk_run_t* run, xp_awk_val_t* val);
|
||||||
|
|
||||||
xp_bool_t xp_awk_valtobool (xp_awk_val_t* val);
|
xp_bool_t xp_awk_valtobool (
|
||||||
|
xp_awk_run_t* run, xp_awk_val_t* val);
|
||||||
|
|
||||||
xp_char_t* xp_awk_valtostr (
|
xp_char_t* xp_awk_valtostr (
|
||||||
xp_awk_run_t* run, xp_awk_val_t* val,
|
xp_awk_run_t* run, xp_awk_val_t* val,
|
||||||
int opt, xp_awk_str_t* buf, xp_size_t* len);
|
int opt, xp_awk_str_t* buf, xp_size_t* len);
|
||||||
|
|
||||||
int xp_awk_valtonum (
|
int xp_awk_valtonum (
|
||||||
xp_awk_run_t* run, xp_awk_val_t* v, xp_long_t* l, xp_real_t* r);
|
xp_awk_run_t* run, xp_awk_val_t* v, xp_long_t* l, xp_real_t* r);
|
||||||
|
|
||||||
|
@ -13,4 +13,6 @@ BEGIN {
|
|||||||
print "ARGV[" i "]", ARGV[i];
|
print "ARGV[" i "]", ARGV[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (ARGC >= 0) print "ARGC is positive";
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.94 2006-10-11 03:19:08 bacon Exp $
|
* $Id: awk.c,v 1.95 2006-10-12 04:17:58 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk.h>
|
#include <xp/awk/awk.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef XP_CHAR_IS_WCHAR
|
#ifdef XP_CHAR_IS_WCHAR
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
@ -21,6 +22,7 @@
|
|||||||
#include <xp/bas/assert.h>
|
#include <xp/bas/assert.h>
|
||||||
#include <xp/bas/locale.h>
|
#include <xp/bas/locale.h>
|
||||||
#else
|
#else
|
||||||
|
#include <xp/bas/stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
#define XP_PATH_MAX 4096
|
#define XP_PATH_MAX 4096
|
||||||
@ -86,6 +88,25 @@ static FILE* fopen_t (const xp_char_t* path, const xp_char_t* mode)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int __dprintf (const xp_char_t* fmt, ...)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
va_list ap;
|
||||||
|
#ifdef _WIN32
|
||||||
|
xp_char_t buf[1024];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_start (ap, fmt);
|
||||||
|
#ifdef _WIN32
|
||||||
|
n = xp_vsprintf (buf, xp_countof(buf), fmt, ap);
|
||||||
|
MessageBox (NULL, buf, XP_T("ASSERTION FAILURE"), MB_OK | MB_ICONERROR);
|
||||||
|
#else
|
||||||
|
n = xp_vprintf (fmt, ap);
|
||||||
|
#endif
|
||||||
|
va_end (ap);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode)
|
static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -679,6 +700,8 @@ static int __main (int argc, xp_char_t* argv[])
|
|||||||
syscas.memcpy = memcpy;
|
syscas.memcpy = memcpy;
|
||||||
syscas.memset = memset;
|
syscas.memset = memset;
|
||||||
syscas.sprintf = xp_sprintf;
|
syscas.sprintf = xp_sprintf;
|
||||||
|
syscas.dprintf = __dprintf;
|
||||||
|
syscas.abort = abort;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
syscas_data.heap = HeapCreate (0, 1000000, 1000000);
|
syscas_data.heap = HeapCreate (0, 1000000, 1000000);
|
||||||
|
@ -6,4 +6,3 @@ BEGIN {
|
|||||||
print "NF=" NF;
|
print "NF=" NF;
|
||||||
for (i = 0; i < NF; i++) print i " [" $(i+1) "]";
|
for (i = 0; i < NF; i++) print i " [" $(i+1) "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user