fixing code to utilize ase_map_setscale
This commit is contained in:
parent
8480da56d1
commit
ca18186e94
@ -3,22 +3,21 @@ items:
|
||||
SYNOPSIS
|
||||
DESCRIPTION
|
||||
RETURN
|
||||
SEE ALSO
|
||||
BUGS
|
||||
EXAMPLES
|
||||
SOURCE
|
||||
NOTES
|
||||
BUGS
|
||||
SEE ALSO
|
||||
source items:
|
||||
SYNOPSIS
|
||||
SOURCE
|
||||
item order:
|
||||
NAME
|
||||
SYNOPSIS
|
||||
DESCRIPTION
|
||||
RETURN
|
||||
SEE ALSO
|
||||
BUGS
|
||||
EXAMPLES
|
||||
SOURCE
|
||||
NOTES
|
||||
BUGS
|
||||
SEE ALSO
|
||||
remark begin markers:
|
||||
/*
|
||||
remark end markers:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: map.h 388 2008-09-26 07:26:20Z baconevi $
|
||||
* $Id: map.h 389 2008-09-26 08:01:24Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -10,7 +10,7 @@
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/****o* ase.cmn.map/map.h
|
||||
/****o* ase.cmn.map/hash map
|
||||
* DESCRIPTION
|
||||
* A hash map maintains buckets for key/value pairs with the same key hash
|
||||
* chained under the same bucket.
|
||||
@ -291,14 +291,17 @@ int ase_map_getscale (
|
||||
);
|
||||
|
||||
/****f* ase.cmn.map/ase_map_setscale
|
||||
* NAME
|
||||
* ase_map_setscale - set the scale factor
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The ase_map_setscale() function sets the scale factor of the length
|
||||
* of a key and a value. A map is created with a scale factor of 1.
|
||||
* of a key and a value. A scale factor determines the actual length of
|
||||
* a key and a value in bytes. A map is created with a scale factor of 1.
|
||||
* The scale factor should be larger than 0 and less than 256.
|
||||
*
|
||||
* RETURN
|
||||
* ASE_NULL on failure
|
||||
* NOTES
|
||||
* It is a bad idea to change the scale factor when a map is not empty.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
@ -309,6 +312,10 @@ void ase_map_setscale (
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_map_copier_t ase_map_getcopier (
|
||||
ase_map_t* map /* a map */,
|
||||
int id /* ASE_MAP_KEY or ASE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.map/ase_map_setcopier
|
||||
* NAME
|
||||
@ -321,36 +328,39 @@ void ase_map_setscale (
|
||||
*
|
||||
* You may set the copier to ASE_NULL to perform no special operation
|
||||
* when the data pointer is rememebered.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_map_setcopier (
|
||||
ase_map_t* map /* a map */,
|
||||
int id /* ASE_MAP_KEY or ASE_MAP_VAL */,
|
||||
ase_map_copier_t copier /* a element copier */
|
||||
ase_map_t* map /* a map */,
|
||||
int id /* ASE_MAP_KEY or ASE_MAP_VAL */,
|
||||
ase_map_copier_t copier /* an element copier */
|
||||
);
|
||||
/******/
|
||||
|
||||
ase_map_copier_t ase_map_getcopier (
|
||||
ase_map_t* map /* a map */,
|
||||
int id /* ASE_MAP_KEY or ASE_MAP_VAL */
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: specifies how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*/
|
||||
void ase_map_setfreeer (
|
||||
ase_map_t* map /* a map */,
|
||||
int id /* ASE_MAP_KEY or ASE_MAP_VAL */,
|
||||
ase_map_freeer_t freeer /* a element freeer */
|
||||
);
|
||||
|
||||
ase_map_freeer_t ase_map_getfreeer (
|
||||
ase_map_t* map /* a map */,
|
||||
int id /* ASE_MAP_KEY or ASE_MAP_VAL */
|
||||
);
|
||||
|
||||
/****f* ase.cmn.map/ase_map_setfreeer
|
||||
* NAME
|
||||
* ase_map_setfreeer - specify how to destroy an element
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The freeer is called when a node containing the element is destroyed.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
void ase_map_setfreeer (
|
||||
ase_map_t* map /* a map */,
|
||||
int id /* ASE_MAP_KEY or ASE_MAP_VAL */,
|
||||
ase_map_freeer_t freeer /* an element freeer */
|
||||
);
|
||||
/******/
|
||||
|
||||
|
||||
ase_map_hasher_t ase_map_gethasher (
|
||||
ase_map_t* map
|
||||
);
|
||||
@ -419,36 +429,43 @@ int ase_map_put (
|
||||
ase_map_pair_t** px
|
||||
);
|
||||
|
||||
/*
|
||||
* NAME: find a pair with a matching key
|
||||
/****f* ase.cmn.map/ase_map_search
|
||||
* NAME
|
||||
* ase_map_search - find a pair with a matching key
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_map_search() functions searches a map to find a pair with a
|
||||
* DESCRIPTION
|
||||
* The ase_map_search() function searches a map to find a pair with a
|
||||
* matching key. It returns the pointer to the pair found. If it fails
|
||||
* to find one, it returns ASE_NULL.
|
||||
*
|
||||
* RETURNS:
|
||||
* The pointer to the pair with a maching key.
|
||||
* ASE_NULL if no match is found.
|
||||
* RETURN
|
||||
* The ase_map_search() function returns the pointer to the pair with a
|
||||
* maching key, and ASE_NULL if no match is found.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_map_pair_t* ase_map_search (
|
||||
ase_map_t* map /* a map */,
|
||||
const void* kptr /* the pointer to a key */,
|
||||
ase_size_t klen /* the size of the key in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/*
|
||||
* NAME: update an existing pair with a matching or inesrt a new pair
|
||||
/****f* ase.cmn.map/ase_map_upsert
|
||||
* NAME
|
||||
* ase_map_upsert - update an existing pair or inesrt a new pair
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* The ase_map_upsert() function searches a map for the pair with a matching
|
||||
* key. If one is found, it updates the pair. Otherwise, it inserts a new
|
||||
* pair with a key and a value. It returns the pointer to the pair updated
|
||||
* or inserted.
|
||||
* DESCRIPTION
|
||||
* The ase_map_upsert() function searches a map for the pair with a matching
|
||||
* key. If one is found, it updates the pair. Otherwise, it inserts a new
|
||||
* pair with a key and a value. It returns the pointer to the pair updated
|
||||
* or inserted.
|
||||
*
|
||||
* RETURNS:
|
||||
* a pointer to the updated or inserted pair.
|
||||
* ASE_NULL on failure.
|
||||
* RETURN
|
||||
* The ase_map_upsert() function returns a pointer to the updated or inserted
|
||||
* pair on success, and ASE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_map_pair_t* ase_map_upsert (
|
||||
ase_map_t* map /* a map */,
|
||||
@ -457,18 +474,22 @@ ase_map_pair_t* ase_map_upsert (
|
||||
void* vptr /* the pointer to a value */,
|
||||
ase_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/*
|
||||
* NAME: insert a new pair with a key and a value
|
||||
/****f* ase.cmn.map/ase_map_insert
|
||||
* NAME
|
||||
* ase_map_insert - insert a new pair with a key and a value
|
||||
*
|
||||
* DESCRIPTION:
|
||||
* DESCRIPTION
|
||||
* The ase_map_insert() function inserts a new pair with the key and the value
|
||||
* given. If there exists a pair with the key given, the function returns
|
||||
* ASE_NULL without channging the value.
|
||||
*
|
||||
* RETURNS:
|
||||
* a pointer to the pair successfully created on success.
|
||||
* ASE_NULL on failure.
|
||||
* RETURN
|
||||
* The ase_map_insert() function returns a pointer to the pair created on
|
||||
* success, and ASE_NULL on failure.
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
ase_map_pair_t* ase_map_insert (
|
||||
ase_map_t* map /* a map */,
|
||||
@ -477,6 +498,7 @@ ase_map_pair_t* ase_map_insert (
|
||||
void* vptr /* the pointer to a value */,
|
||||
ase_size_t vlen /* the length of the value in bytes */
|
||||
);
|
||||
/******/
|
||||
|
||||
/* update the value of a existing pair with a matching key */
|
||||
ase_map_pair_t* ase_map_update (
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str.h 388 2008-09-26 07:26:20Z baconevi $
|
||||
* $Id: str.h 389 2008-09-26 08:01:24Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -10,11 +10,14 @@
|
||||
#include <ase/types.h>
|
||||
#include <ase/macros.h>
|
||||
|
||||
/****o* ase.cmn.str/str.h
|
||||
/****o* ase.cmn.str/string
|
||||
* DESCRIPTION
|
||||
* <ase/cmn/str.h> defines various functions, types, macros to manipulate
|
||||
* strings.
|
||||
*
|
||||
* The ase_cstr_t type and the ase_xstr_t defined in ase/types.h helps you
|
||||
* dealing with a string pointer and length.
|
||||
*
|
||||
* #include <ase/cmn/str.h>
|
||||
*
|
||||
* EXAMPLES
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: types.h 375 2008-09-23 14:47:23Z baconevi $
|
||||
* $Id: types.h 389 2008-09-26 08:01:24Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -332,17 +332,31 @@ typedef void (*ase_free_t) (void* data, void* ptr);
|
||||
typedef ase_bool_t (*ase_isccls_t) (void* data, ase_cint_t c);
|
||||
typedef ase_cint_t (*ase_toccls_t) (void* data, ase_cint_t c);
|
||||
|
||||
/****t* ase/ase_xstr_t
|
||||
* NAME
|
||||
* ase_xstr_t - combile a pointer and length
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_xstr_t
|
||||
{
|
||||
ase_char_t* ptr; /* this is not a const pointer */
|
||||
ase_size_t len;
|
||||
};
|
||||
/******/
|
||||
|
||||
/****t* ase/ase_cstr_t
|
||||
* NAME
|
||||
* ase_cstr_t - combine a constant pointer and length
|
||||
*
|
||||
* SYNOPSIS
|
||||
*/
|
||||
struct ase_cstr_t
|
||||
{
|
||||
const ase_char_t* ptr; /* this is a const pointer */
|
||||
ase_size_t len;
|
||||
};
|
||||
/******/
|
||||
|
||||
struct ase_mmgr_t
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.c 385 2008-09-25 11:06:33Z baconevi $
|
||||
* $Id: awk.c 389 2008-09-26 08:01:24Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -77,6 +77,8 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext)
|
||||
*(ase_awk_t**)ASE_MAP_EXTENSION(awk->wtab) = awk;
|
||||
ase_map_setcopier (awk->wtab, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setcopier (awk->wtab, ASE_MAP_VAL, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setscale (awk->wtab, ASE_MAP_KEY, ASE_SIZEOF(ase_char_t));
|
||||
ase_map_setscale (awk->wtab, ASE_MAP_VAL, ASE_SIZEOF(ase_char_t));
|
||||
|
||||
awk->rwtab = ase_map_open (mmgr, ASE_SIZEOF(awk), 512, 70);
|
||||
if (awk->rwtab == ASE_NULL)
|
||||
@ -89,9 +91,10 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext)
|
||||
*(ase_awk_t**)ASE_MAP_EXTENSION(awk->rwtab) = awk;
|
||||
ase_map_setcopier (awk->rwtab, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setcopier (awk->rwtab, ASE_MAP_VAL, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setscale (awk->rwtab, ASE_MAP_KEY, ASE_SIZEOF(ase_char_t));
|
||||
ase_map_setscale (awk->rwtab, ASE_MAP_VAL, ASE_SIZEOF(ase_char_t));
|
||||
|
||||
/* TODO: initial map size?? */
|
||||
/*awk->tree.afns = ase_map_open (awk, 512, 70, free_afn, ASE_NULL, mmgr);*/
|
||||
awk->tree.afns = ase_map_open (mmgr, ASE_SIZEOF(awk), 512, 70);
|
||||
if (awk->tree.afns == ASE_NULL)
|
||||
{
|
||||
@ -102,9 +105,10 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext)
|
||||
return ASE_NULL;
|
||||
}
|
||||
*(ase_awk_t**)ASE_MAP_EXTENSION(awk->tree.afns) = awk;
|
||||
ase_map_setcopier (awk->tree.afns, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setfreeer (awk->tree.afns, ASE_MAP_VAL, free_afn);
|
||||
ase_map_setcale (awk->tree.afns, ASE_MAP_KEY, ASE_SIZEOF(ase_char_t));
|
||||
|
||||
/*awk->parse.afns = ase_map_open (awk, 256, 70, ASE_NULL, ASE_NULL, mmgr);*/
|
||||
awk->parse.afns = ase_map_open (mmgr, ASE_SIZEOF(awk), 256, 70);
|
||||
if (awk->parse.afns == ASE_NULL)
|
||||
{
|
||||
@ -116,9 +120,10 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext)
|
||||
return ASE_NULL;
|
||||
}
|
||||
*(ase_awk_t**)ASE_MAP_EXTENSION(awk->parse.afns) = awk;
|
||||
ase_map_setcopier (awk->parse.afns, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setcopier (awk->parse.afns, ASE_MAP_VAL, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setscale (awk->parse.afns, ASE_MAP_KEY, ASE_SIZEOF(ase_char_t));
|
||||
|
||||
/*awk->parse.named = ase_map_open (awk, 256, 70, ASE_NULL, ASE_NULL, mmgr);*/
|
||||
awk->parse.named = ase_map_open (mmgr, ASE_SIZEOF(awk), 256, 70);
|
||||
if (awk->parse.named == ASE_NULL)
|
||||
{
|
||||
@ -131,7 +136,9 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext)
|
||||
return ASE_NULL;
|
||||
}
|
||||
*(ase_awk_t**)ASE_MAP_EXTENSION(awk->parse.named) = awk;
|
||||
ase_map_setcopier (awk->parse.named, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setcopier (awk->parse.named, ASE_MAP_VAL, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setscale (awk->parse.named, ASE_MAP_KEY, ASE_SIZEOF(ase_char_t));
|
||||
|
||||
if (ase_awk_tab_open (&awk->parse.globals, awk) == ASE_NULL)
|
||||
{
|
||||
@ -205,7 +212,6 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext)
|
||||
|
||||
awk->bfn.sys = ASE_NULL;
|
||||
/*awk->bfn.user = ASE_NULL;*/
|
||||
/*awk->bfn.user = ase_map_open (awk, 512, 70, free_bfn, ASE_NULL, mmgr);*/
|
||||
awk->bfn.user = ase_map_open (mmgr, ASE_SIZEOF(awk), 512, 70);
|
||||
if (awk->bfn.user == ASE_NULL)
|
||||
{
|
||||
@ -224,6 +230,7 @@ ase_awk_t* ase_awk_open (ase_mmgr_t* mmgr, ase_size_t ext)
|
||||
*(ase_awk_t**)ASE_MAP_EXTENSION(awk->bfn.user) = awk;
|
||||
ase_map_setcopier (awk->bfn.user, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setfreeer (awk->bfn.user, ASE_MAP_VAL, free_bfn);
|
||||
ase_map_setscale (awk->bfn.user, ASE_MAP_KEY, ASE_SIZEOF(ase_char_t));
|
||||
|
||||
awk->parse.depth.cur.block = 0;
|
||||
awk->parse.depth.cur.loop = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: func.c 382 2008-09-24 11:36:45Z baconevi $
|
||||
* $Id: func.c 389 2008-09-26 08:01:24Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -99,7 +99,7 @@ void* ase_awk_addfunc (
|
||||
bfn->handler = handler;
|
||||
|
||||
if (ase_map_insert (awk->bfn.user,
|
||||
(ase_char_t*)name, ASE_NCTONB(name_len), bfn, 0) == ASE_NULL)
|
||||
(ase_char_t*)name, name_len, bfn, 0) == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, bfn);
|
||||
ase_awk_seterrnum (awk, ASE_AWK_ENOMEM);
|
||||
@ -112,7 +112,7 @@ void* ase_awk_addfunc (
|
||||
int ase_awk_delfunc (
|
||||
ase_awk_t* awk, const ase_char_t* name, ase_size_t name_len)
|
||||
{
|
||||
if (ase_map_remove (awk->bfn.user, name, ASE_NCTONB(name_len)) == -1)
|
||||
if (ase_map_remove (awk->bfn.user, name, name_len) == -1)
|
||||
{
|
||||
ase_cstr_t errarg;
|
||||
|
||||
@ -146,12 +146,12 @@ ase_awk_bfn_t* ase_awk_getbfn (
|
||||
(awk->option & bfn->valid) != bfn->valid) continue;
|
||||
|
||||
pair = ase_map_search (
|
||||
awk->wtab, bfn->name.ptr, ASE_NCTONB(bfn->name.len));
|
||||
awk->wtab, bfn->name.ptr, bfn->name.len);
|
||||
if (pair != ASE_NULL)
|
||||
{
|
||||
/* found in the customized word table */
|
||||
k = ASE_MAP_VPTR(pair);
|
||||
l = ASE_MAP_VCLEN(pair);
|
||||
l = ASE_MAP_VLEN(pair);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -166,21 +166,21 @@ ase_awk_bfn_t* ase_awk_getbfn (
|
||||
* because I'm trying to support ase_awk_setword in
|
||||
* a very flimsy way here. Would it be better to drop
|
||||
* ase_awk_setword totally? */
|
||||
pair = ase_map_search (awk->rwtab, name, ASE_NCTONB(len));
|
||||
pair = ase_map_search (awk->rwtab, name, len);
|
||||
if (pair != ASE_NULL)
|
||||
{
|
||||
/* the current name is a target name for
|
||||
* one of the original word. */
|
||||
k = ASE_MAP_VPTR(pair);
|
||||
l = ASE_MAP_VCLEN(pair);
|
||||
l = ASE_MAP_VLEN(pair);
|
||||
}
|
||||
else
|
||||
{
|
||||
pair = ase_map_search (awk->wtab, name, ASE_NCTONB(len));
|
||||
pair = ase_map_search (awk->wtab, name, len);
|
||||
if (pair != ASE_NULL)
|
||||
{
|
||||
k = ASE_MAP_VPTR(pair);
|
||||
l = ASE_MAP_VCLEN(pair);
|
||||
l = ASE_MAP_VLEN(pair);
|
||||
|
||||
if (ase_strxncmp (name, len, k, l) != 0)
|
||||
{
|
||||
@ -204,7 +204,7 @@ ase_awk_bfn_t* ase_awk_getbfn (
|
||||
}
|
||||
/* END NOTE */
|
||||
|
||||
pair = ase_map_search (awk->bfn.user, k, ASE_NCTONB(l));
|
||||
pair = ase_map_search (awk->bfn.user, k, l);
|
||||
if (pair == ASE_NULL) return ASE_NULL;
|
||||
|
||||
bfn = (ase_awk_bfn_t*)ASE_MAP_VPTR(pair);
|
||||
@ -800,7 +800,7 @@ static int bfn_split (
|
||||
|
||||
if (ase_map_insert (
|
||||
((ase_awk_val_map_t*)t1)->map,
|
||||
key, ASE_NCTONB(key_len), t2, 0) == ASE_NULL)
|
||||
key, key_len, t2, 0) == ASE_NULL)
|
||||
{
|
||||
ase_awk_refdownval (run, t2);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c 381 2008-09-24 11:07:24Z baconevi $
|
||||
* $Id: parse.c 389 2008-09-26 08:01:24Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -464,11 +464,11 @@ ase_cstr_t* ase_awk_getkw (ase_awk_t* awk, int id, ase_cstr_t* s)
|
||||
s->ptr = kwtab[id].name;
|
||||
s->len = kwtab[id].name_len;
|
||||
|
||||
p = ase_map_search (awk->wtab, s->ptr, ASE_NCTONB(s->len));
|
||||
p = ase_map_search (awk->wtab, s->ptr, s->len);
|
||||
if (p != ASE_NULL)
|
||||
{
|
||||
s->ptr = ASE_MAP_VPTR(p);
|
||||
s->len = ASE_MAP_VCLEN(p);
|
||||
s->len = ASE_MAP_VLEN(p);
|
||||
}
|
||||
|
||||
return s;
|
||||
@ -558,7 +558,7 @@ static int parse (ase_awk_t* awk)
|
||||
SETERRARG (awk, ASE_AWK_EFNNONE,
|
||||
*(ase_size_t*)ASE_MAP_VPTR(p),
|
||||
ASE_MAP_KPTR(p),
|
||||
ASE_MAP_KCLEN(p));
|
||||
ASE_MAP_KLEN(p));
|
||||
EXIT_PARSE(-1);
|
||||
}
|
||||
|
||||
@ -1097,11 +1097,11 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
|
||||
/* do some trick to save a string. make it back-point at the key part
|
||||
* of the pair */
|
||||
afn->name.ptr = ASE_MAP_KPTR(pair);
|
||||
afn->name.len = ASE_MAP_KCLEN(pair);
|
||||
afn->name.len = ASE_MAP_KLEN(pair);
|
||||
ASE_AWK_FREE (awk, name_dup);
|
||||
|
||||
/* remove an undefined function call entry from the parse.afn table */
|
||||
ase_map_remove (awk->parse.afns, afn->name.ptr, ASE_NCTONB(name_len));
|
||||
ase_map_remove (awk->parse.afns, afn->name.ptr, name_len);
|
||||
return body;
|
||||
}
|
||||
|
||||
@ -1487,7 +1487,7 @@ static int add_global (
|
||||
|
||||
/* check if it conflict with a function name
|
||||
* caught in the function call table */
|
||||
if (ase_map_search (awk->parse.afns, name, ASE_NCTONB(len)) != ASE_NULL)
|
||||
if (ase_map_search (awk->parse.afns, name, len) != ASE_NULL)
|
||||
{
|
||||
SETERRARG (
|
||||
awk, ASE_AWK_EAFNRED, line,
|
||||
@ -1677,7 +1677,7 @@ static ase_awk_t* collect_locals (
|
||||
/* check if it conflict with a function name
|
||||
* caught in the function call table */
|
||||
if (ase_map_search (awk->parse.afns,
|
||||
local.ptr, ASE_NCTONB(local.len)) != ASE_NULL)
|
||||
local.ptr, local.len) != ASE_NULL)
|
||||
{
|
||||
SETERRARG (
|
||||
awk, ASE_AWK_EAFNRED, awk->token.line,
|
||||
@ -3265,7 +3265,7 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line)
|
||||
if (awk->option & ASE_AWK_IMPLICIT)
|
||||
{
|
||||
if (ase_map_search (awk->parse.named,
|
||||
name_dup, ASE_NCTONB(name_len)) != ASE_NULL)
|
||||
name_dup, name_len) != ASE_NULL)
|
||||
{
|
||||
/* a function call conflicts with a named variable */
|
||||
SETERRARG (awk, ASE_AWK_EVARRED, line, name_dup, name_len);
|
||||
@ -3324,7 +3324,7 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line)
|
||||
}
|
||||
|
||||
if (ase_map_search (awk->parse.afns,
|
||||
name_dup, ASE_NCTONB(name_len)) != ASE_NULL)
|
||||
name_dup, name_len) != ASE_NULL)
|
||||
{
|
||||
/* is it one of the function calls found so far? */
|
||||
SETERRARG (awk, ASE_AWK_EAFNRED, line, name_dup, name_len);
|
||||
@ -3344,7 +3344,7 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line)
|
||||
|
||||
/* collect unique instances of a named variables for reference */
|
||||
if (ase_map_upsert (awk->parse.named,
|
||||
name_dup, ASE_NCTONB(name_len),
|
||||
name_dup, name_len,
|
||||
&line, ASE_SIZEOF(line)) == ASE_NULL)
|
||||
{
|
||||
SETERRLIN (awk, ASE_AWK_ENOMEM, line);
|
||||
@ -3507,8 +3507,7 @@ static ase_awk_nde_t* parse_hashidx (
|
||||
}
|
||||
|
||||
if (ase_map_search (
|
||||
awk->parse.afns,
|
||||
name, ASE_NCTONB(name_len)) != ASE_NULL)
|
||||
awk->parse.afns, name, name_len) != ASE_NULL)
|
||||
{
|
||||
/* is it one of the function calls found so far? */
|
||||
SETERRARG (awk, ASE_AWK_EAFNRED, line, name, name_len);
|
||||
@ -3660,8 +3659,7 @@ static ase_awk_nde_t* parse_fncall (
|
||||
|
||||
/* store a non-builtin function call into the parse.afns table */
|
||||
if (ase_map_upsert (
|
||||
awk->parse.afns,
|
||||
name, ASE_NCTONB(name_len),
|
||||
awk->parse.afns, name, name_len,
|
||||
&line, ASE_SIZEOF(line)) == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, call);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: val.c 381 2008-09-24 11:07:24Z baconevi $
|
||||
* $Id: val.c 389 2008-09-26 08:01:24Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -506,6 +506,7 @@ ase_awk_val_t* ase_awk_makemapval (ase_awk_run_t* run)
|
||||
/* the key is copied inline into a pair and is freed when the pair
|
||||
* is destroyed */
|
||||
ase_map_setcopier (val->map, ASE_MAP_KEY, ASE_MAP_COPIER_INLINE);
|
||||
ase_map_setscale (val->map, ASE_MAP_KEY, ASE_SIZEOF(ase_char_t));
|
||||
|
||||
/* not setting copier for a value means that the pointer to the data
|
||||
* allocated somewhere else is remembered in a pair. but the freeing
|
||||
@ -1141,7 +1142,7 @@ static ase_map_walk_t print_pair (
|
||||
ASE_ASSERT (run == *(ase_awk_run_t**)ASE_MAP_EXTENSION(map));
|
||||
|
||||
DPRINTF (DCUSTOM, ASE_T(" %.*s=>"),
|
||||
(int)ASE_MAP_KCLEN(pair), ASE_MAP_KPTR(pair));
|
||||
(int)ASE_MAP_KLEN(pair), ASE_MAP_KPTR(pair));
|
||||
ase_awk_dprintval ((ase_awk_run_t*)arg, ASE_MAP_VPTR(pair));
|
||||
DPRINTF (DCUSTOM, ASE_T(" "));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user