*** empty log message ***
This commit is contained in:
parent
160edf1c46
commit
4cf885ab9a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: extio.c,v 1.24 2006-08-02 11:26:10 bacon Exp $
|
||||
* $Id: extio.c,v 1.25 2006-08-03 05:05:46 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -255,7 +255,8 @@ int xp_awk_writeextio (
|
||||
}
|
||||
|
||||
/* convert the value to string representation first */
|
||||
if (xp_awk_valtostr(v, errnum, &buf, XP_NULL) == XP_NULL)
|
||||
if (xp_awk_valtostr (
|
||||
v, errnum, xp_true, &buf, XP_NULL) == XP_NULL)
|
||||
{
|
||||
xp_str_close (&buf);
|
||||
return -1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: func.c,v 1.15 2006-08-02 11:26:11 bacon Exp $
|
||||
* $Id: func.c,v 1.16 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -27,12 +27,12 @@ static xp_awk_bfn_t __sys_bfn[] =
|
||||
{
|
||||
/* ensure that this matches XP_AWK_BNF_XXX in func.h */
|
||||
|
||||
{ XP_T("close"), XP_AWK_EXTIO, 1, 1, __bfn_close },
|
||||
{ XP_T("system"), 0, 1, 1, __bfn_system },
|
||||
{ XP_T("close"), 5, XP_AWK_EXTIO, 1, 1, __bfn_close },
|
||||
{ XP_T("system"), 6, 0, 1, 1, __bfn_system },
|
||||
|
||||
{ XP_T("sin"), 0, 1, 1, __bfn_sin },
|
||||
{ XP_T("sin"), 3, 0, 1, 1, __bfn_sin },
|
||||
|
||||
{ XP_NULL, 0, 0, 0, XP_NULL }
|
||||
{ XP_NULL, 0, 0, 0, 0, XP_NULL }
|
||||
};
|
||||
|
||||
xp_awk_bfn_t* xp_awk_addbfn (
|
||||
@ -150,7 +150,8 @@ static int __bfn_close (void* run)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xp_awk_valtostr (a0, &errnum, &buf, XP_NULL) == XP_NULL)
|
||||
if (xp_awk_valtostr (
|
||||
a0, &errnum, xp_true, &buf, XP_NULL) == XP_NULL)
|
||||
{
|
||||
xp_str_close (&buf);
|
||||
xp_awk_seterrnum (run, errnum);
|
||||
@ -223,7 +224,7 @@ static int __bfn_system (void* run)
|
||||
xp_assert (nargs == 1);
|
||||
|
||||
cmd = xp_awk_valtostr (
|
||||
xp_awk_getarg(run, 0), &errnum, XP_NULL, XP_NULL);
|
||||
xp_awk_getarg(run, 0), &errnum, xp_true, XP_NULL, XP_NULL);
|
||||
if (cmd == XP_NULL)
|
||||
{
|
||||
xp_awk_seterrnum (run, XP_AWK_ENOMEM);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: func.h,v 1.7 2006-07-17 04:17:40 bacon Exp $
|
||||
* $Id: func.h,v 1.8 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_FUNC_H_
|
||||
@ -14,6 +14,7 @@ typedef struct xp_awk_bfn_t xp_awk_bfn_t;
|
||||
struct xp_awk_bfn_t
|
||||
{
|
||||
const xp_char_t* name;
|
||||
xp_size_t name_len;
|
||||
int valid; /* the entry is valid when this option is set */
|
||||
|
||||
xp_size_t min_args;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: map.c,v 1.20 2006-07-10 14:28:45 bacon Exp $
|
||||
* $Id: map.c,v 1.21 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -13,7 +13,7 @@
|
||||
/* TODO: improve the entire map routines.
|
||||
support automatic bucket resizing and remaping, etc. */
|
||||
|
||||
static xp_size_t __hash (const xp_char_t* key);
|
||||
static xp_size_t __hash (const xp_char_t* key, xp_size_t key_len);
|
||||
|
||||
#define FREE_PAIR(map,pair) \
|
||||
do { \
|
||||
@ -81,45 +81,52 @@ void xp_awk_map_clear (xp_awk_map_t* map)
|
||||
xp_assert (map->size == 0);
|
||||
}
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_get (xp_awk_map_t* map, const xp_char_t* key)
|
||||
xp_awk_pair_t* xp_awk_map_get (
|
||||
xp_awk_map_t* map, const xp_char_t* key, xp_size_t key_len)
|
||||
{
|
||||
xp_awk_pair_t* pair;
|
||||
xp_size_t hc;
|
||||
|
||||
hc = __hash(key) % map->capa;
|
||||
hc = __hash(key,key_len) % map->capa;
|
||||
pair = map->buck[hc];
|
||||
|
||||
while (pair != XP_NULL)
|
||||
{
|
||||
if (xp_strcmp(pair->key,key) == 0) return pair;
|
||||
|
||||
if (xp_strxncmp (
|
||||
pair->key, pair->key_len,
|
||||
key, key_len) == 0) return pair;
|
||||
|
||||
pair = pair->next;
|
||||
}
|
||||
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_put (xp_awk_map_t* map, xp_char_t* key, void* val)
|
||||
xp_awk_pair_t* xp_awk_map_put (
|
||||
xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len, void* val)
|
||||
{
|
||||
int n;
|
||||
xp_awk_pair_t* px;
|
||||
|
||||
n = xp_awk_map_putx (map, key, val, &px);
|
||||
n = xp_awk_map_putx (map, key, key_len, val, &px);
|
||||
if (n < 0) return XP_NULL;
|
||||
return px;
|
||||
}
|
||||
|
||||
int xp_awk_map_putx (
|
||||
xp_awk_map_t* map, xp_char_t* key, void* val, xp_awk_pair_t** px)
|
||||
xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len,
|
||||
void* val, xp_awk_pair_t** px)
|
||||
{
|
||||
xp_awk_pair_t* pair;
|
||||
xp_size_t hc;
|
||||
|
||||
hc = __hash(key) % map->capa;
|
||||
hc = __hash(key,key_len) % map->capa;
|
||||
pair = map->buck[hc];
|
||||
|
||||
while (pair != XP_NULL)
|
||||
{
|
||||
if (xp_strcmp(pair->key,key) == 0)
|
||||
if (xp_strxncmp (pair->key, pair->key_len, key, key_len) == 0)
|
||||
{
|
||||
if (px != XP_NULL)
|
||||
*px = xp_awk_map_setpair (map, pair, val);
|
||||
@ -134,13 +141,17 @@ int xp_awk_map_putx (
|
||||
pair = (xp_awk_pair_t*) xp_malloc (xp_sizeof(xp_awk_pair_t));
|
||||
if (pair == XP_NULL) return -1; /* error */
|
||||
|
||||
/*pair->key = key;*/
|
||||
pair->key = xp_strdup (key); /* duplicate the key if it is new */
|
||||
/*pair->key = key;*/
|
||||
|
||||
/* duplicate the key if it is new */
|
||||
pair->key = xp_strxdup (key, key_len);
|
||||
if (pair->key == XP_NULL)
|
||||
{
|
||||
xp_free (pair);
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
pair->key_len = key_len;
|
||||
pair->val = val;
|
||||
pair->next = map->buck[hc];
|
||||
map->buck[hc] = pair;
|
||||
@ -150,17 +161,18 @@ int xp_awk_map_putx (
|
||||
return 1; /* new key added */
|
||||
}
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_set (xp_awk_map_t* map, xp_char_t* key, void* val)
|
||||
xp_awk_pair_t* xp_awk_map_set (
|
||||
xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len, void* val)
|
||||
{
|
||||
xp_awk_pair_t* pair;
|
||||
xp_size_t hc;
|
||||
|
||||
hc = __hash(key) % map->capa;
|
||||
hc = __hash(key,key_len) % map->capa;
|
||||
pair = map->buck[hc];
|
||||
|
||||
while (pair != XP_NULL)
|
||||
{
|
||||
if (xp_strcmp(pair->key,key) == 0)
|
||||
if (xp_strxncmp (pair->key, pair->key_len, key, key_len) == 0)
|
||||
{
|
||||
return xp_awk_map_setpair (map, pair, val);
|
||||
}
|
||||
@ -171,11 +183,11 @@ xp_awk_pair_t* xp_awk_map_set (xp_awk_map_t* map, xp_char_t* key, void* val)
|
||||
}
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_getpair (
|
||||
xp_awk_map_t* map, const xp_char_t* key, void** val)
|
||||
xp_awk_map_t* map, const xp_char_t* key, xp_size_t key_len, void** val)
|
||||
{
|
||||
xp_awk_pair_t* pair;
|
||||
|
||||
pair = xp_awk_map_get (map, key);
|
||||
pair = xp_awk_map_get (map, key, key_len);
|
||||
if (pair == XP_NULL) return XP_NULL;
|
||||
*val = pair->val;
|
||||
|
||||
@ -198,18 +210,18 @@ xp_awk_pair_t* xp_awk_map_setpair (
|
||||
return pair;
|
||||
}
|
||||
|
||||
int xp_awk_map_remove (xp_awk_map_t* map, xp_char_t* key)
|
||||
int xp_awk_map_remove (xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len)
|
||||
{
|
||||
xp_awk_pair_t* pair, * prev;
|
||||
xp_size_t hc;
|
||||
|
||||
hc = __hash(key) % map->capa;
|
||||
hc = __hash(key,key_len) % map->capa;
|
||||
pair = map->buck[hc];
|
||||
prev = XP_NULL;
|
||||
|
||||
while (pair != XP_NULL)
|
||||
{
|
||||
if (xp_strcmp(pair->key,key) == 0)
|
||||
if (xp_strxncmp (pair->key, pair->key_len, key, key_len) == 0)
|
||||
{
|
||||
if (prev == XP_NULL)
|
||||
map->buck[hc] = pair->next;
|
||||
@ -249,11 +261,12 @@ int xp_awk_map_walk (xp_awk_map_t* map,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static xp_size_t __hash (const xp_char_t* key)
|
||||
static xp_size_t __hash (const xp_char_t* key, xp_size_t key_len)
|
||||
{
|
||||
xp_size_t n = 0, i;
|
||||
const xp_char_t* end = key + key_len;
|
||||
|
||||
while (*key != XP_T('\0'))
|
||||
while (key < end)
|
||||
{
|
||||
xp_byte_t* bp = (xp_byte_t*)key;
|
||||
for (i = 0; i < xp_sizeof(*key); i++) n = n * 31 + *bp++;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: map.h,v 1.13 2006-07-10 14:28:45 bacon Exp $
|
||||
* $Id: map.h,v 1.14 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_MAP_H_
|
||||
@ -15,6 +15,7 @@ typedef struct xp_awk_pair_t xp_awk_pair_t;
|
||||
struct xp_awk_pair_t
|
||||
{
|
||||
xp_char_t* key;
|
||||
xp_size_t key_len;
|
||||
void* val;
|
||||
xp_awk_pair_t* next;
|
||||
};
|
||||
@ -35,21 +36,32 @@ extern "C" {
|
||||
|
||||
xp_awk_map_t* xp_awk_map_open (xp_awk_map_t* map,
|
||||
void* owner, xp_size_t capa, void(*freeval)(void*,void*));
|
||||
|
||||
void xp_awk_map_close (xp_awk_map_t* map);
|
||||
|
||||
void xp_awk_map_clear (xp_awk_map_t* map);
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_get (xp_awk_map_t* map, const xp_char_t* key);
|
||||
xp_awk_pair_t* xp_awk_map_put (xp_awk_map_t* map, xp_char_t* key, void* val);
|
||||
int xp_awk_map_putx (xp_awk_map_t* map, xp_char_t* key, void* val, xp_awk_pair_t** px);
|
||||
xp_awk_pair_t* xp_awk_map_set (xp_awk_map_t* map, xp_char_t* key, void* val);
|
||||
xp_awk_pair_t* xp_awk_map_get (
|
||||
xp_awk_map_t* map, const xp_char_t* key, xp_size_t key_len);
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_put (
|
||||
xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len, void* val);
|
||||
|
||||
int xp_awk_map_putx (
|
||||
xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len,
|
||||
void* val, xp_awk_pair_t** px);
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_set (
|
||||
xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len, void* val);
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_getpair (
|
||||
xp_awk_map_t* map, const xp_char_t* key, void** val);
|
||||
xp_awk_map_t* map, const xp_char_t* key, xp_size_t key_len, void** val);
|
||||
|
||||
xp_awk_pair_t* xp_awk_map_setpair (
|
||||
xp_awk_map_t* map, xp_awk_pair_t* pair, void* val);
|
||||
|
||||
int xp_awk_map_remove (xp_awk_map_t* map, xp_char_t* key);
|
||||
int xp_awk_map_remove (xp_awk_map_t* map, xp_char_t* key, xp_size_t key_len);
|
||||
|
||||
int xp_awk_map_walk (xp_awk_map_t* map,
|
||||
int (*walker)(xp_awk_pair_t*,void*), void* arg);
|
||||
|
||||
|
127
ase/awk/parse.c
127
ase/awk/parse.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.150 2006-08-02 14:36:23 bacon Exp $
|
||||
* $Id: parse.c,v 1.151 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -125,13 +125,14 @@ struct __binmap_t
|
||||
static xp_awk_t* __parse_progunit (xp_awk_t* awk);
|
||||
static xp_awk_t* __collect_globals (xp_awk_t* awk);
|
||||
static xp_awk_t* __add_builtin_globals (xp_awk_t* awk);
|
||||
static xp_awk_t* __add_global (xp_awk_t* awk, const xp_char_t* name);
|
||||
static xp_awk_t* __add_global (
|
||||
xp_awk_t* awk, const xp_char_t* name, xp_size_t name_len);
|
||||
static xp_awk_t* __collect_locals (xp_awk_t* awk, xp_size_t nlocals);
|
||||
|
||||
static xp_awk_nde_t* __parse_function (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_begin (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_end (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_ptnblock (xp_awk_t* awk, xp_awk_nde_t* ptn);
|
||||
static xp_awk_nde_t* __parse_pattern_block (xp_awk_t* awk, xp_awk_nde_t* ptn);
|
||||
|
||||
static xp_awk_nde_t* __parse_action (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_block (xp_awk_t* awk, xp_bool_t is_top);
|
||||
@ -165,9 +166,10 @@ static xp_awk_nde_t* __parse_increment (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_primary (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk);
|
||||
|
||||
static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name);
|
||||
static xp_awk_nde_t* __parse_hashidx (
|
||||
xp_awk_t* awk, xp_char_t* name, xp_size_t name_len);
|
||||
static xp_awk_nde_t* __parse_fncall (
|
||||
xp_awk_t* awk, xp_char_t* name, xp_awk_bfn_t* bfn);
|
||||
xp_awk_t* awk, xp_char_t* name, xp_size_t name_len, xp_awk_bfn_t* bfn);
|
||||
static xp_awk_nde_t* __parse_if (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_while (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_for (xp_awk_t* awk);
|
||||
@ -245,33 +247,34 @@ static struct __kwent __kwtab[] =
|
||||
struct __bvent
|
||||
{
|
||||
const xp_char_t* name;
|
||||
xp_size_t name_len;
|
||||
int valid;
|
||||
};
|
||||
|
||||
static struct __bvent __bvtab[] =
|
||||
{
|
||||
{ XP_T("ARGC"), 0 },
|
||||
{ XP_T("ARGIND"), 0 },
|
||||
{ XP_T("ARGV"), 0 },
|
||||
{ XP_T("CONVFMT"), 0 },
|
||||
{ XP_T("FIELDWIDTHS"), 0 },
|
||||
{ XP_T("ENVIRON"), 0 },
|
||||
{ XP_T("ERRNO"), 0 },
|
||||
{ XP_T("FILENAME"), 0 },
|
||||
{ XP_T("FNR"), 0 },
|
||||
{ XP_T("FS"), 0 },
|
||||
{ XP_T("IGNORECASE"), 0 },
|
||||
{ XP_T("NF"), 0 },
|
||||
{ XP_T("NR"), 0 },
|
||||
{ XP_T("OFMT"), 0 },
|
||||
{ XP_T("OFS"), 0 },
|
||||
{ XP_T("ORS"), 0 },
|
||||
{ XP_T("RS"), 0 },
|
||||
{ XP_T("RT"), 0 },
|
||||
{ XP_T("RSTART"), 0 },
|
||||
{ XP_T("RLENGTH"), 0 },
|
||||
{ XP_T("SUBSEP"), 0 },
|
||||
{ XP_NULL, 0 }
|
||||
{ XP_T("ARGC"), 4, 0 },
|
||||
{ XP_T("ARGIND"), 6, 0 },
|
||||
{ XP_T("ARGV"), 4, 0 },
|
||||
{ XP_T("CONVFMT"), 7, 0 },
|
||||
{ XP_T("FIELDWIDTHS"), 11, 0 },
|
||||
{ XP_T("ENVIRON"), 7, 0 },
|
||||
{ XP_T("ERRNO"), 5, 0 },
|
||||
{ XP_T("FILENAME"), 8, 0 },
|
||||
{ XP_T("FNR"), 3, 0 },
|
||||
{ XP_T("FS"), 2, 0 },
|
||||
{ XP_T("IGNORECASE"), 10, 0 },
|
||||
{ XP_T("NF"), 2, 0 },
|
||||
{ XP_T("NR"), 2, 0 },
|
||||
{ XP_T("OFMT"), 4, 0 },
|
||||
{ XP_T("OFS"), 3, 0 },
|
||||
{ XP_T("ORS"), 3, 0 },
|
||||
{ XP_T("RS"), 2, 0 },
|
||||
{ XP_T("RT"), 2, 0 },
|
||||
{ XP_T("RSTART"), 6, 0 },
|
||||
{ XP_T("RLENGTH"), 7, 0 },
|
||||
{ XP_T("SUBSEP"), 6, 0 },
|
||||
{ XP_NULL, 0, 0 }
|
||||
};
|
||||
|
||||
#define GET_CHAR(awk) \
|
||||
@ -470,7 +473,8 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
||||
{
|
||||
/* pattern less block */
|
||||
awk->parse.id.block = PARSE_BLOCK_PATTERN;
|
||||
if (__parse_ptnblock(awk,XP_NULL) == XP_NULL) return XP_NULL;
|
||||
if (__parse_pattern_block (
|
||||
awk, XP_NULL) == XP_NULL) return XP_NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -510,7 +514,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk)
|
||||
|
||||
if (MATCH(awk,TOKEN_LBRACE))
|
||||
{
|
||||
if (__parse_ptnblock (awk,ptn) == XP_NULL)
|
||||
if (__parse_pattern_block (awk,ptn) == XP_NULL)
|
||||
{
|
||||
xp_awk_clrpt (ptn);
|
||||
return XP_NULL;
|
||||
@ -533,6 +537,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
{
|
||||
xp_char_t* name;
|
||||
xp_char_t* name_dup;
|
||||
xp_size_t name_len;
|
||||
xp_awk_nde_t* body;
|
||||
xp_awk_afn_t* afn;
|
||||
xp_size_t nargs;
|
||||
@ -550,7 +555,8 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
}
|
||||
|
||||
name = XP_STR_BUF(&awk->token.name);
|
||||
if (xp_awk_map_get(&awk->tree.afns, name) != XP_NULL)
|
||||
name_len = XP_STR_LEN(&awk->token.name);
|
||||
if (xp_awk_map_get(&awk->tree.afns, name, name_len) != XP_NULL)
|
||||
{
|
||||
/* the function is defined previously */
|
||||
PANIC (awk, XP_AWK_EDUPFUNC);
|
||||
@ -566,7 +572,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
}
|
||||
|
||||
/* clone the function name before it is overwritten */
|
||||
name_dup = xp_strdup (name);
|
||||
name_dup = xp_strxdup (name, name_len);
|
||||
if (name_dup == XP_NULL) PANIC (awk, XP_AWK_ENOMEM);
|
||||
|
||||
/* get the next token */
|
||||
@ -609,6 +615,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
while (1)
|
||||
{
|
||||
xp_char_t* param;
|
||||
xp_size_t param_len;
|
||||
|
||||
if (!MATCH(awk,TOKEN_IDENT))
|
||||
{
|
||||
@ -618,12 +625,13 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
}
|
||||
|
||||
param = XP_STR_BUF(&awk->token.name);
|
||||
param_len = XP_STR_LEN(&awk->token.name);
|
||||
|
||||
if (awk->opt.parse & XP_AWK_UNIQUE)
|
||||
{
|
||||
/* check if a parameter conflicts with a function */
|
||||
if (xp_strcmp(name_dup, param) == 0 ||
|
||||
xp_awk_map_get(&awk->tree.afns, param) != XP_NULL)
|
||||
if (xp_strxncmp(name_dup, name_len, param, param_len) == 0 ||
|
||||
xp_awk_map_get(&awk->tree.afns, param, param_len) != XP_NULL)
|
||||
{
|
||||
xp_free (name_dup);
|
||||
xp_awk_tab_clear (&awk->parse.params);
|
||||
@ -726,7 +734,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
|
||||
afn->nargs = nargs;
|
||||
afn->body = body;
|
||||
|
||||
n = xp_awk_map_putx (&awk->tree.afns, name_dup, afn, &pair);
|
||||
n = xp_awk_map_putx (&awk->tree.afns, name_dup, name_len, afn, &pair);
|
||||
if (n < 0)
|
||||
{
|
||||
xp_free (name_dup);
|
||||
@ -772,7 +780,7 @@ static xp_awk_nde_t* __parse_end (xp_awk_t* awk)
|
||||
return nde;
|
||||
}
|
||||
|
||||
static xp_awk_nde_t* __parse_ptnblock (xp_awk_t* awk, xp_awk_nde_t* ptn)
|
||||
static xp_awk_nde_t* __parse_pattern_block (xp_awk_t* awk, xp_awk_nde_t* ptn)
|
||||
{
|
||||
xp_awk_nde_t* nde;
|
||||
xp_awk_chain_t* chain;
|
||||
@ -942,19 +950,21 @@ static xp_awk_t* __add_builtin_globals (xp_awk_t* awk)
|
||||
|
||||
while (p->name != XP_NULL)
|
||||
{
|
||||
if (__add_global (awk, p->name) == XP_NULL) return XP_NULL;
|
||||
if (__add_global (awk,
|
||||
p->name, p->name_len) == XP_NULL) return XP_NULL;
|
||||
p++;
|
||||
}
|
||||
|
||||
return awk;
|
||||
}
|
||||
|
||||
static xp_awk_t* __add_global (xp_awk_t* awk, const xp_char_t* name)
|
||||
static xp_awk_t* __add_global (
|
||||
xp_awk_t* awk, const xp_char_t* name, xp_size_t len)
|
||||
{
|
||||
if (awk->opt.parse & XP_AWK_UNIQUE)
|
||||
{
|
||||
/* check if it conflict with a function name */
|
||||
if (xp_awk_map_get(&awk->tree.afns, name) != XP_NULL)
|
||||
if (xp_awk_map_get(&awk->tree.afns, name, len) != XP_NULL)
|
||||
{
|
||||
PANIC (awk, XP_AWK_EDUPNAME);
|
||||
}
|
||||
@ -976,8 +986,6 @@ static xp_awk_t* __add_global (xp_awk_t* awk, const xp_char_t* name)
|
||||
|
||||
static xp_awk_t* __collect_globals (xp_awk_t* awk)
|
||||
{
|
||||
xp_char_t* global;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (!MATCH(awk,TOKEN_IDENT))
|
||||
@ -985,9 +993,9 @@ static xp_awk_t* __collect_globals (xp_awk_t* awk)
|
||||
PANIC (awk, XP_AWK_EIDENT);
|
||||
}
|
||||
|
||||
global = XP_STR_BUF(&awk->token.name);
|
||||
|
||||
if (__add_global (awk, global) == XP_NULL) return XP_NULL;
|
||||
if (__add_global (awk,
|
||||
XP_STR_BUF(&awk->token.name),
|
||||
XP_STR_LEN(&awk->token.name)) == XP_NULL) return XP_NULL;
|
||||
|
||||
if (__get_token(awk) == -1) return XP_NULL;
|
||||
|
||||
@ -1010,6 +1018,7 @@ static xp_awk_t* __collect_globals (xp_awk_t* awk)
|
||||
static xp_awk_t* __collect_locals (xp_awk_t* awk, xp_size_t nlocals)
|
||||
{
|
||||
xp_char_t* local;
|
||||
xp_size_t local_len;
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -1019,13 +1028,15 @@ static xp_awk_t* __collect_locals (xp_awk_t* awk, xp_size_t nlocals)
|
||||
}
|
||||
|
||||
local = XP_STR_BUF(&awk->token.name);
|
||||
local_len = XP_STR_LEN(&awk->token.name);
|
||||
|
||||
/* NOTE: it is not checked againt globals names */
|
||||
|
||||
if (awk->opt.parse & XP_AWK_UNIQUE)
|
||||
{
|
||||
/* check if it conflict with a function name */
|
||||
if (xp_awk_map_get(&awk->tree.afns, local) != XP_NULL)
|
||||
if (xp_awk_map_get (
|
||||
&awk->tree.afns, local, local_len) != XP_NULL)
|
||||
{
|
||||
PANIC (awk, XP_AWK_EDUPNAME);
|
||||
}
|
||||
@ -2166,12 +2177,15 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
|
||||
static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
{
|
||||
xp_char_t* name_dup;
|
||||
xp_size_t name_len;
|
||||
xp_awk_bfn_t* bfn;
|
||||
|
||||
xp_assert (MATCH(awk,TOKEN_IDENT));
|
||||
|
||||
name_dup = (xp_char_t*)xp_strdup(XP_STR_BUF(&awk->token.name));
|
||||
name_dup = xp_strxdup (
|
||||
XP_STR_BUF(&awk->token.name), XP_STR_LEN(&awk->token.name));
|
||||
if (name_dup == XP_NULL) PANIC (awk, XP_AWK_ENOMEM);
|
||||
name_len = XP_STR_LEN(&awk->token.name);
|
||||
|
||||
if (__get_token(awk) == -1)
|
||||
{
|
||||
@ -2193,7 +2207,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
PANIC (awk, XP_AWK_ELPAREN);
|
||||
}
|
||||
|
||||
nde = __parse_fncall (awk, XP_NULL, bfn);
|
||||
nde = __parse_fncall (awk, XP_NULL, 0, bfn);
|
||||
return (xp_awk_nde_t*)nde;
|
||||
}
|
||||
|
||||
@ -2201,7 +2215,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
if (MATCH(awk,TOKEN_LBRACK))
|
||||
{
|
||||
xp_awk_nde_t* nde;
|
||||
nde = __parse_hashidx (awk, name_dup);
|
||||
nde = __parse_hashidx (awk, name_dup, name_len);
|
||||
if (nde == XP_NULL) xp_free (name_dup);
|
||||
return (xp_awk_nde_t*)nde;
|
||||
}
|
||||
@ -2209,7 +2223,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
{
|
||||
/* function call */
|
||||
xp_awk_nde_t* nde;
|
||||
nde = __parse_fncall (awk, name_dup, XP_NULL);
|
||||
nde = __parse_fncall (awk, name_dup, name_len, XP_NULL);
|
||||
if (nde == XP_NULL) xp_free (name_dup);
|
||||
return (xp_awk_nde_t*)nde;
|
||||
}
|
||||
@ -2235,6 +2249,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
nde->next = XP_NULL;
|
||||
/*nde->id.name = XP_NULL;*/
|
||||
nde->id.name = name_dup;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = idxa;
|
||||
nde->idx = XP_NULL;
|
||||
|
||||
@ -2249,6 +2264,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
nde->next = XP_NULL;
|
||||
/*nde->id.name = XP_NULL;*/
|
||||
nde->id.name = name_dup;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = idxa;
|
||||
nde->idx = XP_NULL;
|
||||
|
||||
@ -2263,6 +2279,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
nde->next = XP_NULL;
|
||||
/*nde->id.name = XP_NULL;*/
|
||||
nde->id.name = name_dup;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = idxa;
|
||||
nde->idx = XP_NULL;
|
||||
|
||||
@ -2274,6 +2291,7 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
nde->type = XP_AWK_NDE_NAMED;
|
||||
nde->next = XP_NULL;
|
||||
nde->id.name = name_dup;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = (xp_size_t)-1;
|
||||
nde->idx = XP_NULL;
|
||||
|
||||
@ -2287,7 +2305,8 @@ static xp_awk_nde_t* __parse_primary_ident (xp_awk_t* awk)
|
||||
}
|
||||
}
|
||||
|
||||
static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
|
||||
static xp_awk_nde_t* __parse_hashidx (
|
||||
xp_awk_t* awk, xp_char_t* name, xp_size_t name_len)
|
||||
{
|
||||
xp_awk_nde_t* idx, * tmp, * last;
|
||||
xp_awk_nde_var_t* nde;
|
||||
@ -2353,6 +2372,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
|
||||
nde->next = XP_NULL;
|
||||
/*nde->id.name = XP_NULL; */
|
||||
nde->id.name = name;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = idxa;
|
||||
nde->idx = idx;
|
||||
|
||||
@ -2367,6 +2387,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
|
||||
nde->next = XP_NULL;
|
||||
/*nde->id.name = XP_NULL; */
|
||||
nde->id.name = name;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = idxa;
|
||||
nde->idx = idx;
|
||||
|
||||
@ -2381,6 +2402,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
|
||||
nde->next = XP_NULL;
|
||||
/*nde->id.name = XP_NULL;*/
|
||||
nde->id.name = name;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = idxa;
|
||||
nde->idx = idx;
|
||||
|
||||
@ -2392,6 +2414,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
|
||||
nde->type = XP_AWK_NDE_NAMEDIDX;
|
||||
nde->next = XP_NULL;
|
||||
nde->id.name = name;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = (xp_size_t)-1;
|
||||
nde->idx = idx;
|
||||
|
||||
@ -2405,7 +2428,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
|
||||
}
|
||||
|
||||
static xp_awk_nde_t* __parse_fncall (
|
||||
xp_awk_t* awk, xp_char_t* name, xp_awk_bfn_t* bfn)
|
||||
xp_awk_t* awk, xp_char_t* name, xp_size_t name_len, xp_awk_bfn_t* bfn)
|
||||
{
|
||||
xp_awk_nde_t* head, * curr, * nde;
|
||||
xp_awk_nde_call_t* call;
|
||||
@ -2477,6 +2500,7 @@ static xp_awk_nde_t* __parse_fncall (
|
||||
|
||||
/*call->what.bfn = bfn; */
|
||||
call->what.bfn.name = bfn->name;
|
||||
call->what.bfn.name_len = bfn->name_len;
|
||||
call->what.bfn.min_args = bfn->min_args;
|
||||
call->what.bfn.max_args = bfn->max_args;
|
||||
call->what.bfn.handler = bfn->handler;
|
||||
@ -2488,7 +2512,8 @@ static xp_awk_nde_t* __parse_fncall (
|
||||
{
|
||||
call->type = XP_AWK_NDE_AFN;
|
||||
call->next = XP_NULL;
|
||||
call->what.name = name;
|
||||
call->what.afn.name = name;
|
||||
call->what.afn.name_len = name_len;
|
||||
call->args = head;
|
||||
call->nargs = nargs;
|
||||
}
|
||||
|
152
ase/awk/run.c
152
ase/awk/run.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.156 2006-08-02 14:36:23 bacon Exp $
|
||||
* $Id: run.c,v 1.157 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -173,7 +173,8 @@ static void __clear_record (xp_awk_run_t* run, xp_bool_t noline);
|
||||
static int __recomp_record_fields (xp_awk_run_t* run,
|
||||
xp_size_t lv, xp_char_t* str, xp_size_t len, int* errnum);
|
||||
|
||||
static xp_char_t* __idxnde_to_str (xp_awk_run_t* run, xp_awk_nde_t* nde);
|
||||
static xp_char_t* __idxnde_to_str (
|
||||
xp_awk_run_t* run, xp_awk_nde_t* nde, xp_size_t* len);
|
||||
|
||||
typedef xp_awk_val_t* (*binop_func_t) (
|
||||
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right);
|
||||
@ -384,24 +385,17 @@ static int __run_main (xp_awk_run_t* run)
|
||||
if (run->opt & XP_AWK_RUNMAIN)
|
||||
{
|
||||
/* TODO: should the main function be user-specifiable? */
|
||||
static xp_char_t m_a_i_n[] =
|
||||
{
|
||||
XP_T('m'),
|
||||
XP_T('a'),
|
||||
XP_T('i'),
|
||||
XP_T('n'),
|
||||
XP_T('\0')
|
||||
};
|
||||
static xp_awk_nde_call_t nde =
|
||||
{
|
||||
XP_AWK_NDE_AFN, /* type */
|
||||
XP_NULL, /* next */
|
||||
m_a_i_n, /* name */
|
||||
XP_NULL /* args */
|
||||
};
|
||||
xp_awk_nde_call_t nde;
|
||||
|
||||
run->exit_level = EXIT_NONE;
|
||||
|
||||
nde.type = XP_AWK_NDE_AFN;
|
||||
nde.next = XP_NULL;
|
||||
nde.what.afn.name = XP_T("main");
|
||||
nde.what.afn.name_len = 4;
|
||||
nde.args = XP_NULL;
|
||||
nde.nargs = 0;
|
||||
|
||||
v = __eval_afn (run, (xp_awk_nde_t*)&nde);
|
||||
if (v == XP_NULL) n = -1;
|
||||
else
|
||||
@ -1247,7 +1241,8 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
|
||||
(var->type == XP_AWK_NDE_NAMEDIDX &&
|
||||
var->idx != XP_NULL));
|
||||
|
||||
pair = xp_awk_map_get (&run->named, var->id.name);
|
||||
pair = xp_awk_map_get (
|
||||
&run->named, var->id.name, var->id.name_len);
|
||||
if (pair == XP_NULL)
|
||||
{
|
||||
xp_awk_val_t* tmp;
|
||||
@ -1258,7 +1253,8 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
|
||||
tmp = xp_awk_makemapval (run);
|
||||
if (tmp == XP_NULL) PANIC_I (run, XP_AWK_ENOMEM);
|
||||
|
||||
if (xp_awk_map_put (&run->named, var->id.name, tmp) == XP_NULL)
|
||||
if (xp_awk_map_put (&run->named,
|
||||
var->id.name, var->id.name_len, tmp) == XP_NULL)
|
||||
{
|
||||
xp_awk_refupval (tmp);
|
||||
xp_awk_refdownval (run, tmp);
|
||||
@ -1282,6 +1278,7 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
|
||||
if (var->type == XP_AWK_NDE_NAMEDIDX)
|
||||
{
|
||||
xp_char_t* key;
|
||||
xp_size_t key_len;
|
||||
xp_awk_val_t* idx;
|
||||
int errnum;
|
||||
|
||||
@ -1291,13 +1288,13 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
|
||||
if (idx == XP_NULL) return -1;
|
||||
|
||||
xp_awk_refupval (idx);
|
||||
key = xp_awk_valtostr (
|
||||
idx, &errnum, XP_NULL, XP_NULL);
|
||||
key = xp_awk_valtostr (idx,
|
||||
&errnum, xp_true, XP_NULL, &key_len);
|
||||
xp_awk_refdownval (run, idx);
|
||||
|
||||
if (key == XP_NULL) PANIC_I (run, errnum);
|
||||
|
||||
xp_awk_map_remove (map, key);
|
||||
xp_awk_map_remove (map, key, key_len);
|
||||
xp_free (key);
|
||||
}
|
||||
else
|
||||
@ -1360,6 +1357,7 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
|
||||
var->type == XP_AWK_NDE_ARGIDX)
|
||||
{
|
||||
xp_char_t* key;
|
||||
xp_size_t key_len;
|
||||
xp_awk_val_t* idx;
|
||||
int errnum;
|
||||
|
||||
@ -1369,13 +1367,13 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
|
||||
if (idx == XP_NULL) return -1;
|
||||
|
||||
xp_awk_refupval (idx);
|
||||
key = xp_awk_valtostr (
|
||||
idx, &errnum, XP_NULL, XP_NULL);
|
||||
key = xp_awk_valtostr (idx,
|
||||
&errnum, xp_true, XP_NULL, &key_len);
|
||||
xp_awk_refdownval (run, idx);
|
||||
|
||||
if (key == XP_NULL) PANIC_I (run, errnum);
|
||||
|
||||
xp_awk_map_remove (map, key);
|
||||
xp_awk_map_remove (map, key, key_len);
|
||||
xp_free (key);
|
||||
}
|
||||
else
|
||||
@ -1417,7 +1415,7 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
|
||||
if (v == XP_NULL) return -1;
|
||||
|
||||
xp_awk_refupval (v);
|
||||
out = xp_awk_valtostr (v, &errnum, XP_NULL, &len);
|
||||
out = xp_awk_valtostr (v, &errnum, xp_true, XP_NULL, &len);
|
||||
if (out == XP_NULL)
|
||||
{
|
||||
xp_awk_refdownval (run, v);
|
||||
@ -1733,7 +1731,8 @@ static xp_awk_val_t* __do_assignment_scalar (
|
||||
xp_awk_pair_t* pair;
|
||||
int n;
|
||||
|
||||
pair = xp_awk_map_get (&run->named, var->id.name);
|
||||
pair = xp_awk_map_get (
|
||||
&run->named, var->id.name, var->id.name_len);
|
||||
if (pair != XP_NULL &&
|
||||
((xp_awk_val_t*)pair->val)->type == XP_AWK_VAL_MAP)
|
||||
{
|
||||
@ -1742,8 +1741,8 @@ static xp_awk_val_t* __do_assignment_scalar (
|
||||
PANIC (run, XP_AWK_ENOTSCALARIZABLE);
|
||||
}
|
||||
|
||||
n = xp_awk_map_putx (
|
||||
&run->named, var->id.name, val, XP_NULL);
|
||||
n = xp_awk_map_putx (&run->named,
|
||||
var->id.name, var->id.name_len, val, XP_NULL);
|
||||
if (n < 0) PANIC (run, XP_AWK_ENOMEM);
|
||||
|
||||
xp_awk_refupval (val);
|
||||
@ -1800,6 +1799,7 @@ static xp_awk_val_t* __do_assignment_map (
|
||||
{
|
||||
xp_awk_val_map_t* map;
|
||||
xp_char_t* str;
|
||||
xp_size_t len;
|
||||
int n;
|
||||
|
||||
xp_assert (
|
||||
@ -1812,7 +1812,8 @@ static xp_awk_val_t* __do_assignment_map (
|
||||
if (var->type == XP_AWK_NDE_NAMEDIDX)
|
||||
{
|
||||
xp_awk_pair_t* pair;
|
||||
pair = xp_awk_map_get (&run->named, var->id.name);
|
||||
pair = xp_awk_map_get (
|
||||
&run->named, var->id.name, var->id.name_len);
|
||||
map = (pair == XP_NULL)?
|
||||
(xp_awk_val_map_t*)xp_awk_val_nil:
|
||||
(xp_awk_val_map_t*)pair->val;
|
||||
@ -1839,8 +1840,8 @@ static xp_awk_val_t* __do_assignment_map (
|
||||
/* doesn't have to decrease the reference count
|
||||
* of the previous value here as it is done by
|
||||
* xp_awk_map_put */
|
||||
if (xp_awk_map_put (
|
||||
&run->named, var->id.name, tmp) == XP_NULL)
|
||||
if (xp_awk_map_put (&run->named,
|
||||
var->id.name, var->id.name_len, tmp) == XP_NULL)
|
||||
{
|
||||
xp_awk_refupval (tmp);
|
||||
xp_awk_refdownval (run, tmp);
|
||||
@ -1874,13 +1875,13 @@ static xp_awk_val_t* __do_assignment_map (
|
||||
PANIC (run, XP_AWK_ENOTINDEXABLE);
|
||||
}
|
||||
|
||||
str = __idxnde_to_str (run, var->idx);
|
||||
str = __idxnde_to_str (run, var->idx, &len);
|
||||
if (str == XP_NULL) return XP_NULL;
|
||||
|
||||
/*
|
||||
xp_printf (XP_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, map->ref, map->type);
|
||||
*/
|
||||
n = xp_awk_map_putx (map->map, str, val, XP_NULL);
|
||||
n = xp_awk_map_putx (map->map, str, len, val, XP_NULL);
|
||||
if (n < 0)
|
||||
{
|
||||
xp_free (str);
|
||||
@ -1915,7 +1916,7 @@ static xp_awk_val_t* __do_assignment_pos (
|
||||
if (lv < 0) PANIC (run, XP_AWK_EPOSIDX);
|
||||
|
||||
/* convert the value to the string */
|
||||
str = xp_awk_valtostr (val, &errnum, XP_NULL, &len);
|
||||
str = xp_awk_valtostr (val, &errnum, xp_true, XP_NULL, &len);
|
||||
if (str == XP_NULL) PANIC (run, errnum);
|
||||
|
||||
if (lv == 0)
|
||||
@ -2181,6 +2182,7 @@ static xp_awk_val_t* __eval_binop_in (
|
||||
{
|
||||
xp_awk_val_t* rv, * res;
|
||||
xp_char_t* str;
|
||||
xp_size_t len;
|
||||
|
||||
if (right->type != XP_AWK_NDE_GLOBAL &&
|
||||
right->type != XP_AWK_NDE_LOCAL &&
|
||||
@ -2195,8 +2197,8 @@ static xp_awk_val_t* __eval_binop_in (
|
||||
|
||||
/* evaluate the left-hand side of the operator */
|
||||
str = (left->type == XP_AWK_NDE_GRP)?
|
||||
__idxnde_to_str (run, ((xp_awk_nde_grp_t*)left)->body):
|
||||
__idxnde_to_str (run, left);
|
||||
__idxnde_to_str (run, ((xp_awk_nde_grp_t*)left)->body, &len):
|
||||
__idxnde_to_str (run, left, &len);
|
||||
if (str == XP_NULL) return XP_NULL;
|
||||
|
||||
/* evaluate the right-hand side of the operator */
|
||||
@ -2228,7 +2230,7 @@ static xp_awk_val_t* __eval_binop_in (
|
||||
{
|
||||
xp_long_t r;
|
||||
|
||||
r = xp_awk_map_get(((xp_awk_val_map_t*)rv)->map,str) != XP_NULL;
|
||||
r = (xp_long_t)(xp_awk_map_get(((xp_awk_val_map_t*)rv)->map,str,len) != XP_NULL);
|
||||
|
||||
res = xp_awk_makeintval (run, r);
|
||||
if (res == XP_NULL)
|
||||
@ -2244,7 +2246,8 @@ static xp_awk_val_t* __eval_binop_in (
|
||||
}
|
||||
|
||||
/* need an array */
|
||||
PANIC (run, XP_AWK_EOPERAND);
|
||||
/* TODO: change the error code to make it clearer */
|
||||
PANIC (run, XP_AWK_EOPERAND);
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
@ -2856,47 +2859,31 @@ static xp_awk_val_t* __eval_binop_exp (
|
||||
static xp_awk_val_t* __eval_binop_concat (
|
||||
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
|
||||
{
|
||||
xp_str_t lv, rv;
|
||||
xp_char_t* strl, * strr;
|
||||
xp_size_t strl_len, strr_len;
|
||||
xp_awk_val_t* res;
|
||||
int errnum;
|
||||
|
||||
if (xp_str_open (&lv, DEF_BUF_CAPA) == XP_NULL)
|
||||
{
|
||||
PANIC (run, XP_AWK_ENOMEM);
|
||||
}
|
||||
strl = xp_awk_valtostr (left, &errnum, xp_true, XP_NULL, &strl_len);
|
||||
if (strl == XP_NULL) PANIC (run, errnum);
|
||||
|
||||
if (xp_str_open (&rv, DEF_BUF_CAPA) == XP_NULL)
|
||||
strr = xp_awk_valtostr (right, &errnum, xp_true, XP_NULL, &strr_len);
|
||||
if (strr == XP_NULL)
|
||||
{
|
||||
xp_str_close (&lv);
|
||||
PANIC (run, XP_AWK_ENOMEM);
|
||||
}
|
||||
|
||||
if (xp_awk_valtostr (left, &errnum, &lv, XP_NULL) == XP_NULL)
|
||||
{
|
||||
xp_str_close (&lv);
|
||||
xp_str_close (&rv);
|
||||
xp_free (strl);
|
||||
PANIC (run, errnum);
|
||||
}
|
||||
|
||||
if (xp_awk_valtostr (right, &errnum, &rv, XP_NULL) == XP_NULL)
|
||||
{
|
||||
xp_str_close (&lv);
|
||||
xp_str_close (&rv);
|
||||
PANIC (run, errnum);
|
||||
}
|
||||
|
||||
res = xp_awk_makestrval2 (
|
||||
XP_STR_BUF(&lv), XP_STR_LEN(&lv),
|
||||
XP_STR_BUF(&rv), XP_STR_LEN(&rv));
|
||||
res = xp_awk_makestrval2 (strl, strl_len, strr, strr_len);
|
||||
if (res == XP_NULL)
|
||||
{
|
||||
xp_str_close (&lv);
|
||||
xp_str_close (&rv);
|
||||
xp_free (strl);
|
||||
xp_free (strr);
|
||||
PANIC (run, XP_AWK_ENOMEM);
|
||||
}
|
||||
|
||||
xp_str_close (&lv);
|
||||
xp_str_close (&rv);
|
||||
xp_free (strl);
|
||||
xp_free (strr);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -2984,7 +2971,7 @@ static xp_awk_val_t* __eval_binop_match0 (
|
||||
}
|
||||
else
|
||||
{
|
||||
str = xp_awk_valtostr (right, &errnum, XP_NULL, &len);
|
||||
str = xp_awk_valtostr (right, &errnum, xp_true, XP_NULL, &len);
|
||||
if (str == XP_NULL) PANIC (run, errnum);
|
||||
|
||||
rex_code = xp_awk_buildrex (str, len, &errnum);
|
||||
@ -3019,7 +3006,7 @@ static xp_awk_val_t* __eval_binop_match0 (
|
||||
}
|
||||
else
|
||||
{
|
||||
str = xp_awk_valtostr (right, &errnum, XP_NULL, &len);
|
||||
str = xp_awk_valtostr (right, &errnum, xp_true, XP_NULL, &len);
|
||||
if (str == XP_NULL)
|
||||
{
|
||||
if (right->type != XP_AWK_VAL_REX) xp_free (rex_code);
|
||||
@ -3547,7 +3534,8 @@ static xp_awk_val_t* __eval_afn (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
xp_awk_afn_t* afn;
|
||||
xp_awk_pair_t* pair;
|
||||
|
||||
pair = xp_awk_map_get (&run->awk->tree.afns, call->what.name);
|
||||
pair = xp_awk_map_get (&run->awk->tree.afns,
|
||||
call->what.afn.name, call->what.afn.name_len);
|
||||
if (pair == XP_NULL) PANIC (run, XP_AWK_ENOSUCHFUNC);
|
||||
|
||||
afn = (xp_awk_afn_t*)pair->val;
|
||||
@ -3827,7 +3815,7 @@ static xp_awk_val_t* __eval_named (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
xp_awk_pair_t* pair;
|
||||
xp_awk_nde_var_t* tgt = (xp_awk_nde_var_t*)nde;
|
||||
|
||||
pair = xp_awk_map_get(&run->named,tgt->id.name);
|
||||
pair = xp_awk_map_get (&run->named, tgt->id.name, tgt->id.name_len);
|
||||
return (pair == XP_NULL)? xp_awk_val_nil: pair->val;
|
||||
}
|
||||
|
||||
@ -3855,6 +3843,7 @@ static xp_awk_val_t* __eval_indexed (
|
||||
xp_awk_val_t* res;
|
||||
xp_awk_pair_t* pair;
|
||||
xp_char_t* str;
|
||||
xp_size_t len;
|
||||
|
||||
/* TODO: should it be an error? should it return nil? */
|
||||
if (map->type != XP_AWK_VAL_MAP)
|
||||
@ -3864,11 +3853,11 @@ static xp_awk_val_t* __eval_indexed (
|
||||
|
||||
xp_assert (nde->idx != XP_NULL);
|
||||
|
||||
str = __idxnde_to_str (run, nde->idx);
|
||||
str = __idxnde_to_str (run, nde->idx, &len);
|
||||
if (str == XP_NULL) return XP_NULL;
|
||||
|
||||
/* TODO: check this out........ */
|
||||
pair = xp_awk_map_get (((xp_awk_val_map_t*)map)->map, str);
|
||||
pair = xp_awk_map_get (((xp_awk_val_map_t*)map)->map, str, len);
|
||||
res = (pair == XP_NULL)? xp_awk_val_nil: (xp_awk_val_t*)pair->val;
|
||||
|
||||
xp_free (str);
|
||||
@ -3880,7 +3869,7 @@ static xp_awk_val_t* __eval_namedidx (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
xp_awk_nde_var_t* tgt = (xp_awk_nde_var_t*)nde;
|
||||
xp_awk_pair_t* pair;
|
||||
|
||||
pair = xp_awk_map_get (&run->named, tgt->id.name);
|
||||
pair = xp_awk_map_get (&run->named, tgt->id.name, tgt->id.name_len);
|
||||
return __eval_indexed (run, tgt,
|
||||
(pair == XP_NULL)? xp_awk_val_nil: pair->val);
|
||||
}
|
||||
@ -3959,7 +3948,7 @@ static xp_awk_val_t* __eval_getline (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
* v->type == XP_AWK_VAL_STR, xp_awk_refdownval(v)
|
||||
* should not be called immediately below */
|
||||
xp_awk_refupval (v);
|
||||
in = xp_awk_valtostr (v, &errnum, XP_NULL, &len);
|
||||
in = xp_awk_valtostr (v, &errnum, xp_true, XP_NULL, &len);
|
||||
if (in == XP_NULL)
|
||||
{
|
||||
xp_awk_refdownval (run, v);
|
||||
@ -4292,7 +4281,8 @@ static int __recomp_record_fields (xp_awk_run_t* run,
|
||||
v = STACK_GLOBAL(run, XP_AWK_GLOBAL_OFS);
|
||||
if (v != xp_awk_val_nil)
|
||||
{
|
||||
ofsp = xp_awk_valtostr (v, errnum, XP_NULL, &ofs_len);
|
||||
ofsp = xp_awk_valtostr (
|
||||
v, errnum, xp_true, XP_NULL, &ofs_len);
|
||||
if (ofsp == XP_NULL) return -1;
|
||||
|
||||
ofs = ofsp;
|
||||
@ -4414,7 +4404,8 @@ static int __recomp_record_fields (xp_awk_run_t* run,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static xp_char_t* __idxnde_to_str (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
static xp_char_t* __idxnde_to_str (
|
||||
xp_awk_run_t* run, xp_awk_nde_t* nde, xp_size_t* len)
|
||||
{
|
||||
xp_char_t* str;
|
||||
xp_awk_val_t* idx;
|
||||
@ -4430,7 +4421,7 @@ static xp_char_t* __idxnde_to_str (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
|
||||
xp_awk_refupval (idx);
|
||||
|
||||
str = xp_awk_valtostr (idx, &errnum, XP_NULL, XP_NULL);
|
||||
str = xp_awk_valtostr (idx, &errnum, xp_true, XP_NULL, len);
|
||||
if (str == XP_NULL)
|
||||
{
|
||||
xp_awk_refdownval (run, idx);
|
||||
@ -4469,8 +4460,8 @@ static xp_char_t* __idxnde_to_str (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
PANIC (run, XP_AWK_ENOMEM);
|
||||
}
|
||||
|
||||
if (xp_awk_valtostr (idx,
|
||||
&errnum, &idxstr, XP_NULL) == XP_NULL)
|
||||
if (xp_awk_valtostr (idx, &errnum,
|
||||
xp_false, &idxstr, XP_NULL) == XP_NULL)
|
||||
{
|
||||
xp_awk_refdownval (run, idx);
|
||||
xp_str_close (&idxstr);
|
||||
@ -4482,6 +4473,7 @@ static xp_char_t* __idxnde_to_str (xp_awk_run_t* run, xp_awk_nde_t* nde)
|
||||
}
|
||||
|
||||
str = XP_STR_BUF(&idxstr);
|
||||
*len = XP_STR_LEN(&idxstr);
|
||||
xp_str_forfeit (&idxstr);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tab.c,v 1.8 2006-04-16 04:31:38 bacon Exp $
|
||||
* $Id: tab.c,v 1.9 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -95,13 +95,13 @@ void xp_awk_tab_clear (xp_awk_tab_t* tab)
|
||||
|
||||
|
||||
xp_size_t xp_awk_tab_insert (
|
||||
xp_awk_tab_t* tab, xp_size_t index, const xp_char_t* value)
|
||||
xp_awk_tab_t* tab, xp_size_t index, const xp_char_t* str)
|
||||
{
|
||||
xp_size_t i;
|
||||
xp_char_t* value_dup;
|
||||
xp_char_t* str_dup;
|
||||
|
||||
value_dup = xp_strdup(value);
|
||||
if (value_dup == XP_NULL) return (xp_size_t)-1;
|
||||
str_dup = xp_strdup(str);
|
||||
if (str_dup == XP_NULL) return (xp_size_t)-1;
|
||||
|
||||
if (index >= tab->capa)
|
||||
{
|
||||
@ -115,13 +115,13 @@ xp_size_t xp_awk_tab_insert (
|
||||
|
||||
if (xp_awk_tab_setcapa(tab,capa) == XP_NULL)
|
||||
{
|
||||
xp_free (value_dup);
|
||||
xp_free (str_dup);
|
||||
return (xp_size_t)-1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = tab->size; i > index; i--) tab->buf[i] = tab->buf[i-1];
|
||||
tab->buf[index] = value_dup;
|
||||
tab->buf[index] = str_dup;
|
||||
|
||||
if (index > tab->size) tab->size = index + 1;
|
||||
else tab->size++;
|
||||
@ -161,47 +161,50 @@ xp_size_t xp_awk_tab_remove (
|
||||
return count;
|
||||
}
|
||||
|
||||
xp_size_t xp_awk_tab_add (xp_awk_tab_t* tab, const xp_char_t* value)
|
||||
xp_size_t xp_awk_tab_add (xp_awk_tab_t* tab, const xp_char_t* str)
|
||||
{
|
||||
return xp_awk_tab_insert (tab, tab->size, value);
|
||||
return xp_awk_tab_insert (tab, tab->size, str);
|
||||
}
|
||||
|
||||
|
||||
xp_size_t xp_awk_tab_find (
|
||||
xp_awk_tab_t* tab, const xp_char_t* value, xp_size_t index)
|
||||
xp_awk_tab_t* tab, const xp_char_t* str, xp_size_t index)
|
||||
{
|
||||
xp_size_t i;
|
||||
|
||||
for (i = index; i < tab->size; i++) {
|
||||
if (xp_strcmp(tab->buf[i], value) == 0) return i;
|
||||
for (i = index; i < tab->size; i++)
|
||||
{
|
||||
if (xp_strcmp(tab->buf[i], str) == 0) return i;
|
||||
}
|
||||
|
||||
return (xp_size_t)-1;
|
||||
}
|
||||
|
||||
xp_size_t xp_awk_tab_rfind (
|
||||
xp_awk_tab_t* tab, const xp_char_t* value, xp_size_t index)
|
||||
xp_awk_tab_t* tab, const xp_char_t* str, xp_size_t index)
|
||||
{
|
||||
xp_size_t i;
|
||||
|
||||
if (index >= tab->size) return (xp_size_t)-1;
|
||||
|
||||
for (i = index + 1; i-- > 0; ) {
|
||||
if (xp_strcmp(tab->buf[i], value) == 0) return i;
|
||||
for (i = index + 1; i-- > 0; )
|
||||
{
|
||||
if (xp_strcmp(tab->buf[i], str) == 0) return i;
|
||||
}
|
||||
|
||||
return (xp_size_t)-1;
|
||||
}
|
||||
|
||||
xp_size_t xp_awk_tab_rrfind (
|
||||
xp_awk_tab_t* tab, const xp_char_t* value, xp_size_t index)
|
||||
xp_awk_tab_t* tab, const xp_char_t* str, xp_size_t index)
|
||||
{
|
||||
xp_size_t i;
|
||||
|
||||
if (index >= tab->size) return (xp_size_t)-1;
|
||||
|
||||
for (i = tab->size - index; i-- > 0; ) {
|
||||
if (xp_strcmp(tab->buf[i], value) == 0) return i;
|
||||
for (i = tab->size - index; i-- > 0; )
|
||||
{
|
||||
if (xp_strcmp(tab->buf[i], str) == 0) return i;
|
||||
}
|
||||
|
||||
return (xp_size_t)-1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tree.c,v 1.68 2006-07-26 15:00:00 bacon Exp $
|
||||
* $Id: tree.c,v 1.69 2006-08-03 05:05:47 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -358,8 +358,9 @@ static int __print_expression (xp_awk_nde_t* nde)
|
||||
|
||||
case XP_AWK_NDE_AFN:
|
||||
{
|
||||
/* TODO: use px->what.afn.name_len */
|
||||
xp_awk_nde_call_t* px = (xp_awk_nde_call_t*)nde;
|
||||
xp_printf (XP_T("%s ("), px->what.name);
|
||||
xp_printf (XP_T("%s ("), px->what.afn.name);
|
||||
if (__print_expression_list (px->args) == -1) return -1;
|
||||
xp_printf (XP_T(")"));
|
||||
break;
|
||||
@ -966,7 +967,7 @@ void xp_awk_clrpt (xp_awk_nde_t* tree)
|
||||
case XP_AWK_NDE_AFN:
|
||||
{
|
||||
xp_awk_nde_call_t* px = (xp_awk_nde_call_t*)p;
|
||||
xp_free (px->what.name);
|
||||
xp_free (px->what.afn.name);
|
||||
xp_awk_clrpt (px->args);
|
||||
xp_free (p);
|
||||
break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tree.h,v 1.64 2006-07-31 04:25:17 bacon Exp $
|
||||
* $Id: tree.h,v 1.65 2006-08-03 05:05:48 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_TREE_H_
|
||||
@ -222,9 +222,10 @@ struct xp_awk_nde_rex_t
|
||||
struct xp_awk_nde_var_t
|
||||
{
|
||||
XP_AWK_NDE_HDR;
|
||||
struct /* could it be union? */
|
||||
struct
|
||||
{
|
||||
xp_char_t* name;
|
||||
xp_size_t name_len;
|
||||
xp_size_t idxa;
|
||||
} id;
|
||||
xp_awk_nde_t* idx; /* XP_NULL for non-XXXXIDX */
|
||||
@ -236,13 +237,18 @@ struct xp_awk_nde_call_t
|
||||
XP_AWK_NDE_HDR;
|
||||
union
|
||||
{
|
||||
xp_char_t* name;
|
||||
struct
|
||||
{
|
||||
xp_char_t* name;
|
||||
xp_size_t name_len;
|
||||
} afn;
|
||||
|
||||
/* minimum information of a built-in function
|
||||
* needed during run-time. */
|
||||
struct
|
||||
{
|
||||
const xp_char_t* name;
|
||||
xp_size_t name_len;
|
||||
xp_size_t min_args;
|
||||
xp_size_t max_args;
|
||||
int (*handler) (void* run);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: val.c,v 1.48 2006-07-26 16:43:35 bacon Exp $
|
||||
* $Id: val.c,v 1.49 2006-08-03 05:05:48 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -325,7 +325,8 @@ xp_bool_t xp_awk_valtobool (xp_awk_val_t* val)
|
||||
}
|
||||
|
||||
xp_char_t* xp_awk_valtostr (
|
||||
xp_awk_val_t* v, int* errnum, xp_str_t* buf, xp_size_t* len)
|
||||
xp_awk_val_t* v, int* errnum,
|
||||
xp_bool_t clear_buf, xp_str_t* buf, xp_size_t* len)
|
||||
{
|
||||
if (v->type == XP_AWK_VAL_NIL)
|
||||
{
|
||||
@ -344,7 +345,8 @@ xp_char_t* xp_awk_valtostr (
|
||||
}
|
||||
else
|
||||
{
|
||||
xp_str_clear (buf);
|
||||
if (clear_buf) xp_str_clear (buf);
|
||||
|
||||
if (len != XP_NULL) *len = XP_STR_LEN(buf);
|
||||
return XP_STR_BUF(buf);
|
||||
}
|
||||
@ -376,7 +378,7 @@ xp_char_t* xp_awk_valtostr (
|
||||
}
|
||||
else
|
||||
{
|
||||
xp_str_clear (buf);
|
||||
if (clear_buf) xp_str_clear (buf);
|
||||
if (xp_str_cat (buf, XP_T("0")) == (xp_size_t)-1)
|
||||
{
|
||||
*errnum = XP_AWK_ENOMEM;
|
||||
@ -402,13 +404,14 @@ xp_char_t* xp_awk_valtostr (
|
||||
}
|
||||
|
||||
tmp[l] = XP_T('\0');
|
||||
if (len != XP_NULL) *len = l;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* clear the buffer */
|
||||
xp_str_clear (buf);
|
||||
if (clear_buf) xp_str_clear (buf);
|
||||
|
||||
tmp = XP_STR_BUF(buf);
|
||||
tmp = XP_STR_BUF(buf) + XP_STR_LEN(buf);
|
||||
|
||||
/* extend the buffer */
|
||||
if (xp_str_nccat (
|
||||
@ -419,8 +422,6 @@ xp_char_t* xp_awk_valtostr (
|
||||
}
|
||||
}
|
||||
|
||||
if (len != XP_NULL) *len = l;
|
||||
|
||||
t = ((xp_awk_val_int_t*)v)->val;
|
||||
if (t < 0) t = -t;
|
||||
|
||||
@ -432,13 +433,18 @@ xp_char_t* xp_awk_valtostr (
|
||||
|
||||
if (((xp_awk_val_int_t*)v)->val < 0) tmp[--l] = XP_T('-');
|
||||
|
||||
if (buf != XP_NULL)
|
||||
{
|
||||
tmp = XP_STR_BUF(buf);
|
||||
if (len != XP_NULL) *len = XP_STR_LEN(buf);
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
if (v->type == XP_AWK_VAL_REAL)
|
||||
{
|
||||
/* TODO: change the code */
|
||||
|
||||
/* TODO: change the code */
|
||||
xp_char_t tbuf[256], * tmp;
|
||||
|
||||
#if (XP_SIZEOF_LONG_DOUBLE != 0)
|
||||
@ -466,7 +472,8 @@ xp_char_t* xp_awk_valtostr (
|
||||
}
|
||||
else
|
||||
{
|
||||
xp_str_clear (buf);
|
||||
if (clear_buf) xp_str_clear (buf);
|
||||
|
||||
if (xp_str_cat (buf, tbuf) == (xp_size_t)-1)
|
||||
{
|
||||
*errnum = XP_AWK_ENOMEM;
|
||||
@ -489,24 +496,30 @@ xp_char_t* xp_awk_valtostr (
|
||||
tmp = xp_strxdup (
|
||||
((xp_awk_val_str_t*)v)->buf,
|
||||
((xp_awk_val_str_t*)v)->len);
|
||||
if (tmp == XP_NULL)
|
||||
{
|
||||
*errnum = XP_AWK_ENOMEM;
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
if (tmp == XP_NULL) *errnum = XP_AWK_ENOMEM;
|
||||
if (len != XP_NULL) *len = ((xp_awk_val_str_t*)v)->len;
|
||||
}
|
||||
else
|
||||
{
|
||||
xp_str_clear (buf);
|
||||
tmp = XP_STR_BUF(buf);
|
||||
if (clear_buf) xp_str_clear (buf);
|
||||
|
||||
if (xp_str_ncat (buf,
|
||||
((xp_awk_val_str_t*)v)->buf,
|
||||
((xp_awk_val_str_t*)v)->len) == (xp_size_t)-1)
|
||||
{
|
||||
*errnum = XP_AWK_ENOMEM;
|
||||
tmp = XP_NULL;
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
tmp = XP_STR_BUF(buf);
|
||||
if (len != XP_NULL) *len = XP_STR_LEN(buf);
|
||||
}
|
||||
|
||||
if (len != XP_NULL) *len = ((xp_awk_val_str_t*)v)->len;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: val.h,v 1.34 2006-07-26 15:00:00 bacon Exp $
|
||||
* $Id: val.h,v 1.35 2006-08-03 05:05:48 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_VAL_H_
|
||||
@ -118,7 +118,8 @@ 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_char_t* xp_awk_valtostr (
|
||||
xp_awk_val_t* val, int* errnum, xp_str_t* buf, xp_size_t* len);
|
||||
xp_awk_val_t* val, int* errnum,
|
||||
xp_bool_t clear_buf, xp_str_t* buf, xp_size_t* len);
|
||||
int xp_awk_valtonum (xp_awk_val_t* v, xp_long_t* l, xp_real_t* r);
|
||||
|
||||
void xp_awk_printval (xp_awk_val_t* val);
|
||||
|
Loading…
Reference in New Issue
Block a user