*** empty log message ***

This commit is contained in:
hyung-hwan 2006-08-31 15:39:14 +00:00
parent c450eb2ac1
commit 3807832056
4 changed files with 100 additions and 142 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: extio.c,v 1.40 2006-08-31 14:52:12 bacon Exp $
* $Id: extio.c,v 1.41 2006-08-31 15:39:13 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -193,8 +193,7 @@ int xp_awk_readextio (
}
else
{
rs_ptr = xp_awk_valtostr (
rs, &run->errnum, xp_true, XP_NULL, &rs_len);
rs_ptr = xp_awk_valtostr (run, rs, xp_true, XP_NULL, &rs_len);
if (rs_ptr == XP_NULL)
{
xp_awk_refdownval (run, rs);
@ -421,8 +420,7 @@ static int __writeextio (
/* TOOD: consider using a shared buffer when calling
* xp_awk_valtostr. maybe run->shared_buf.extio */
str = xp_awk_valtostr (
v, &run->errnum, xp_true, NULL, &len);
str = xp_awk_valtostr (run, v, xp_true, NULL, &len);
if (str == XP_NULL) return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: func.c,v 1.37 2006-08-31 15:22:13 bacon Exp $
* $Id: func.c,v 1.38 2006-08-31 15:39:13 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -146,7 +146,7 @@ static int __bfn_close (xp_awk_t* awk, void* run)
{
xp_size_t nargs;
xp_awk_val_t* v, * a0;
int errnum, n;
int n;
xp_char_t* name;
xp_size_t len;
@ -165,12 +165,8 @@ static int __bfn_close (xp_awk_t* awk, void* run)
}
else
{
name = xp_awk_valtostr (a0, &errnum, xp_true, XP_NULL, &len);
if (name == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
name = xp_awk_valtostr (run, a0, xp_true, XP_NULL, &len);
if (name == XP_NULL) return -1;
}
if (len == 0)
@ -252,7 +248,7 @@ static int __bfn_fflush (xp_awk_t* awk, void* run)
xp_awk_val_t* a0;
xp_char_t* str0;
xp_size_t len0;
int errnum, n;
int n;
nargs = xp_awk_getnargs (run);
xp_assert (nargs >= 0 && nargs <= 1);
@ -283,12 +279,8 @@ static int __bfn_fflush (xp_awk_t* awk, void* run)
else
{
str0 = xp_awk_valtostr (
a0, &errnum, xp_true, XP_NULL, &len0);
if (str0 == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
run, a0, xp_true, XP_NULL, &len0);
if (str0 == XP_NULL) return -1;
}
@ -351,7 +343,6 @@ static int __bfn_index (xp_awk_t* awk, void* run)
xp_char_t* str0, * str1, * ptr;
xp_size_t len0, len1;
xp_long_t idx;
int errnum;
nargs = xp_awk_getnargs (run);
xp_assert (nargs == 2);
@ -366,12 +357,8 @@ static int __bfn_index (xp_awk_t* awk, void* run)
}
else
{
str0 = xp_awk_valtostr (a0, &errnum, xp_true, XP_NULL, &len0);
if (str0 == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
str0 = xp_awk_valtostr (run, a0, xp_true, XP_NULL, &len0);
if (str0 == XP_NULL) return -1;
}
if (a1->type == XP_AWK_VAL_STR)
@ -381,10 +368,9 @@ static int __bfn_index (xp_awk_t* awk, void* run)
}
else
{
str1 = xp_awk_valtostr (a1, &errnum, xp_true, XP_NULL, &len1);
str1 = xp_awk_valtostr (run, a1, xp_true, XP_NULL, &len1);
if (str1 == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
if (a0->type != XP_AWK_VAL_STR) XP_AWK_FREE (awk, str0);
return -1;
}
@ -415,7 +401,6 @@ static int __bfn_length (xp_awk_t* awk, void* run)
xp_awk_val_t* v;
xp_char_t* str;
xp_size_t len;
int errnum;
nargs = xp_awk_getnargs (run);
xp_assert (nargs == 1);
@ -427,12 +412,8 @@ static int __bfn_length (xp_awk_t* awk, void* run)
}
else
{
str = xp_awk_valtostr (v, &errnum, xp_true, XP_NULL, &len);
if (str == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
str = xp_awk_valtostr (run, v, xp_true, XP_NULL, &len);
if (str == XP_NULL) return -1;
XP_AWK_FREE (awk, str);
}
@ -456,7 +437,7 @@ static int __bfn_substr (xp_awk_t* awk, void* run)
xp_size_t len;
xp_long_t lindex, lcount;
xp_real_t rindex, rcount;
int errnum, n;
int n;
nargs = xp_awk_getnargs (run);
xp_assert (nargs >= 2 && nargs <= 3);
@ -472,12 +453,8 @@ static int __bfn_substr (xp_awk_t* awk, void* run)
}
else
{
str = xp_awk_valtostr (a0, &errnum, xp_true, XP_NULL, &len);
if (str == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
str = xp_awk_valtostr (run, a0, xp_true, XP_NULL, &len);
if (str == XP_NULL) return -1;
}
n = xp_awk_valtonum (a1, &lindex, &rindex);
@ -529,7 +506,6 @@ static int __bfn_split (xp_awk_t* awk, void* run)
xp_char_t* str, * p, * tok;
xp_size_t len, left, tok_len;
xp_long_t num;
int errnum;
xp_char_t key[32];
nargs = xp_awk_getnargs (run);
@ -565,12 +541,8 @@ static int __bfn_split (xp_awk_t* awk, void* run)
}
else
{
str = xp_awk_valtostr (a0, &errnum, xp_true, XP_NULL, &len);
if (str == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
str = xp_awk_valtostr (run, a0, xp_true, XP_NULL, &len);
if (str == XP_NULL) return -1;
}
t1 = xp_awk_makemapval (run);
@ -657,7 +629,6 @@ static int __bfn_tolower (xp_awk_t* awk, void* run)
xp_char_t* str;
xp_size_t len, i;
xp_awk_val_t* a0, * r;
int errnum;
nargs = xp_awk_getnargs (run);
xp_assert (nargs == 1);
@ -671,12 +642,8 @@ static int __bfn_tolower (xp_awk_t* awk, void* run)
}
else
{
str = xp_awk_valtostr (a0, &errnum, xp_true, XP_NULL, &len);
if (str == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
str = xp_awk_valtostr (run, a0, xp_true, XP_NULL, &len);
if (str == XP_NULL) return -1;
}
for (i = 0; i < len; i++) str[i] = xp_tolower(str[i]);
@ -700,7 +667,6 @@ static int __bfn_toupper (xp_awk_t* awk, void* run)
xp_char_t* str;
xp_size_t len, i;
xp_awk_val_t* a0, * r;
int errnum;
nargs = xp_awk_getnargs (run);
xp_assert (nargs == 1);
@ -714,12 +680,8 @@ static int __bfn_toupper (xp_awk_t* awk, void* run)
}
else
{
str = xp_awk_valtostr (a0, &errnum, xp_true, XP_NULL, &len);
if (str == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
str = xp_awk_valtostr (run, a0, xp_true, XP_NULL, &len);
if (str == XP_NULL) return -1;
}
for (i = 0; i < len; i++) str[i] = xp_toupper(str[i]);
@ -742,18 +704,14 @@ static int __bfn_system (xp_awk_t* awk, void* run)
xp_size_t nargs;
xp_char_t* cmd;
xp_awk_val_t* v;
int errnum, n;
int n;
nargs = xp_awk_getnargs (run);
xp_assert (nargs == 1);
cmd = xp_awk_valtostr (
xp_awk_getarg(run, 0), &errnum, xp_true, XP_NULL, XP_NULL);
if (cmd == XP_NULL)
{
xp_awk_seterrnum (run, errnum);
return -1;
}
run, xp_awk_getarg(run, 0), xp_true, XP_NULL, XP_NULL);
if (cmd == XP_NULL) return -1;
#ifdef _WIN32
n = _tsystem (cmd);

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.188 2006-08-31 15:22:13 bacon Exp $
* $Id: run.c,v 1.189 2006-08-31 15:39:14 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -252,7 +252,7 @@ int xp_awk_setglobal (void* run, xp_size_t idx, xp_awk_val_t* val)
xp_assert (val->type != XP_AWK_VAL_REX);
rs_ptr = xp_awk_valtostr (
val, &r->errnum, xp_true, XP_NULL, &rs_len);
run, val, xp_true, XP_NULL, &rs_len);
if (rs_ptr == XP_NULL) return -1;
}
@ -1586,8 +1586,7 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
xp_awk_refupval (idx);
key = xp_awk_valtostr (
idx, &run->errnum,
xp_true, XP_NULL, &key_len);
run, idx, xp_true, XP_NULL, &key_len);
xp_awk_refdownval (run, idx);
if (key == XP_NULL) return -1;
@ -1678,8 +1677,7 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde)
xp_awk_refupval (idx);
key = xp_awk_valtostr (
idx, &run->errnum,
xp_true, XP_NULL, &key_len);
run, idx, xp_true, XP_NULL, &key_len);
xp_awk_refdownval (run, idx);
if (key == XP_NULL) return -1;
@ -1709,7 +1707,7 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
const xp_char_t* dst;
xp_awk_val_t* v;
xp_awk_nde_t* np;
int errnum, n;
int n;
xp_assert (
(p->out_type == XP_AWK_OUT_PIPE && p->out != XP_NULL) ||
@ -1726,11 +1724,11 @@ 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_true, XP_NULL, &len);
out = xp_awk_valtostr (run, v, xp_true, XP_NULL, &len);
if (out == XP_NULL)
{
xp_awk_refdownval (run, v);
PANIC_I (run, errnum);
return -1;
}
xp_awk_refdownval (run, v);
@ -2234,8 +2232,8 @@ 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_true, XP_NULL, &len);
if (str == XP_NULL) PANIC (run, errnum);
str = xp_awk_valtostr (run, val, xp_true, XP_NULL, &len);
if (str == XP_NULL) return XP_NULL;
if (lv == 0)
{
@ -3189,16 +3187,15 @@ static xp_awk_val_t* __eval_binop_concat (
xp_char_t* strl, * strr;
xp_size_t strl_len, strr_len;
xp_awk_val_t* res;
int errnum;
strl = xp_awk_valtostr (left, &errnum, xp_true, XP_NULL, &strl_len);
if (strl == XP_NULL) PANIC (run, errnum);
strl = xp_awk_valtostr (run, left, xp_true, XP_NULL, &strl_len);
if (strl == XP_NULL) return XP_NULL;
strr = xp_awk_valtostr (right, &errnum, xp_true, XP_NULL, &strr_len);
strr = xp_awk_valtostr (run, right, xp_true, XP_NULL, &strr_len);
if (strr == XP_NULL)
{
XP_AWK_FREE (run->awk, strl);
PANIC (run, errnum);
return XP_NULL;
}
res = xp_awk_makestrval2 (run, strl, strl_len, strr, strr_len);
@ -3301,8 +3298,8 @@ static xp_awk_val_t* __eval_binop_match0 (
}
else
{
str = xp_awk_valtostr (right, &errnum, xp_true, XP_NULL, &len);
if (str == XP_NULL) PANIC (run, errnum);
str = xp_awk_valtostr (run, right, xp_true, XP_NULL, &len);
if (str == XP_NULL) return XP_NULL;
rex_code = xp_awk_buildrex (str, len, &errnum);
if (rex_code == XP_NULL)
@ -3338,12 +3335,12 @@ static xp_awk_val_t* __eval_binop_match0 (
}
else
{
str = xp_awk_valtostr (left, &errnum, xp_true, XP_NULL, &len);
str = xp_awk_valtostr (run, left, xp_true, XP_NULL, &len);
if (str == XP_NULL)
{
if (right->type != XP_AWK_VAL_REX)
XP_AWK_FREE (run->awk, rex_code);
PANIC (run, errnum);
return XP_NULL;
}
n = xp_awk_matchrex (
@ -4436,7 +4433,7 @@ static xp_awk_val_t* __eval_getline (xp_awk_run_t* run, xp_awk_nde_t* nde)
xp_char_t* in = XP_NULL;
const xp_char_t* dst;
xp_str_t buf;
int errnum, n;
int n;
p = (xp_awk_nde_getline_t*)nde;
@ -4458,11 +4455,11 @@ 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_true, XP_NULL, &len);
in = xp_awk_valtostr (run, v, xp_true, XP_NULL, &len);
if (in == XP_NULL)
{
xp_awk_refdownval (run, v);
PANIC (run, errnum);
return XP_NULL;
}
xp_awk_refdownval (run, v);
@ -4693,7 +4690,7 @@ static int __split_record (xp_awk_run_t* run)
else
{
fs_ptr = xp_awk_valtostr (
fs, &run->errnum, xp_true, XP_NULL, &fs_len);
run, fs, xp_true, XP_NULL, &fs_len);
if (fs_ptr == XP_NULL) return -1;
}
#endif
@ -4897,7 +4894,7 @@ static int __recomp_record_fields (
if (v != xp_awk_val_nil)
{
ofsp = xp_awk_valtostr (
v, &run->errnum, xp_true, XP_NULL, &ofs_len);
run, v, xp_true, XP_NULL, &ofs_len);
if (ofsp == XP_NULL) return -1;
ofs = ofsp;
@ -5025,7 +5022,6 @@ static xp_char_t* __idxnde_to_str (
{
xp_char_t* str;
xp_awk_val_t* idx;
int errnum;
xp_assert (nde != XP_NULL);
@ -5037,11 +5033,11 @@ static xp_char_t* __idxnde_to_str (
xp_awk_refupval (idx);
str = xp_awk_valtostr (idx, &errnum, xp_true, XP_NULL, len);
str = xp_awk_valtostr (run, idx, xp_true, XP_NULL, len);
if (str == XP_NULL)
{
xp_awk_refdownval (run, idx);
PANIC (run, errnum);
return XP_NULL;
}
xp_awk_refdownval (run, idx);
@ -5076,12 +5072,12 @@ static xp_char_t* __idxnde_to_str (
PANIC (run, XP_AWK_ENOMEM);
}
if (xp_awk_valtostr (idx, &errnum,
xp_false, &idxstr, XP_NULL) == XP_NULL)
if (xp_awk_valtostr (run,
idx, xp_false, &idxstr, XP_NULL) == XP_NULL)
{
xp_awk_refdownval (run, idx);
xp_str_close (&idxstr);
PANIC (run, errnum);
return XP_NULL;
}
xp_awk_refdownval (run, idx);

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.53 2006-08-31 15:22:13 bacon Exp $
* $Id: val.c,v 1.54 2006-08-31 15:39:14 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -50,8 +50,8 @@ xp_awk_val_t* xp_awk_makeintval (xp_awk_run_t* run, xp_long_t v)
}
else
{
val = (xp_awk_val_int_t*)
xp_malloc (xp_sizeof(xp_awk_val_int_t));
val = (xp_awk_val_int_t*) XP_AWK_MALLOC (
run->awk, xp_sizeof(xp_awk_val_int_t));
if (val == XP_NULL) return XP_NULL;
}
@ -73,8 +73,8 @@ xp_awk_val_t* xp_awk_makerealval (xp_awk_run_t* run, xp_real_t v)
}
else
{
val = (xp_awk_val_real_t*)
xp_malloc (xp_sizeof(xp_awk_val_real_t));
val = (xp_awk_val_real_t*) XP_AWK_MALLOC (
run->awk, xp_sizeof(xp_awk_val_real_t));
if (val == XP_NULL) return XP_NULL;
}
@ -96,7 +96,8 @@ xp_awk_val_t* xp_awk_makestrval (
{
xp_awk_val_str_t* val;
val = (xp_awk_val_str_t*) xp_malloc (xp_sizeof(xp_awk_val_str_t));
val = (xp_awk_val_str_t*) XP_AWK_MALLOC (
run->awk, xp_sizeof(xp_awk_val_str_t));
if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_STR;
@ -105,7 +106,7 @@ xp_awk_val_t* xp_awk_makestrval (
val->buf = xp_strxdup (str, len);
if (val->buf == XP_NULL)
{
xp_free (val);
XP_AWK_FREE (run->awk, val);
return XP_NULL;
}
@ -120,7 +121,8 @@ xp_awk_val_t* xp_awk_makestrval2 (
{
xp_awk_val_str_t* val;
val = (xp_awk_val_str_t*) xp_malloc (xp_sizeof(xp_awk_val_str_t));
val = (xp_awk_val_str_t*) XP_AWK_MALLOC (
run->awk, xp_sizeof(xp_awk_val_str_t));
if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_STR;
@ -129,7 +131,7 @@ xp_awk_val_t* xp_awk_makestrval2 (
val->buf = xp_strxdup2 (str1, len1, str2, len2);
if (val->buf == XP_NULL)
{
xp_free (val);
XP_AWK_FREE (run->awk, val);
return XP_NULL;
}
@ -142,7 +144,8 @@ xp_awk_val_t* xp_awk_makerexval (
{
xp_awk_val_rex_t* val;
val = (xp_awk_val_rex_t*) xp_malloc (xp_sizeof(xp_awk_val_rex_t));
val = (xp_awk_val_rex_t*) XP_AWK_MALLOC (
run->awk, xp_sizeof(xp_awk_val_rex_t));
if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_REX;
@ -151,15 +154,15 @@ xp_awk_val_t* xp_awk_makerexval (
val->buf = xp_strxdup (buf, len);
if (val->buf == XP_NULL)
{
xp_free (val);
XP_AWK_FREE (run->awk, val);
return XP_NULL;
}
val->code = xp_malloc (XP_AWK_REX_LEN(code));
val->code = XP_AWK_MALLOC (run->awk, XP_AWK_REX_LEN(code));
if (val->code == XP_NULL)
{
xp_free (val->buf);
xp_free (val);
XP_AWK_FREE (run->awk, val->buf);
XP_AWK_FREE (run->awk, val);
return XP_NULL;
}
@ -181,7 +184,8 @@ xp_awk_val_t* xp_awk_makemapval (xp_awk_run_t* run)
{
xp_awk_val_map_t* val;
val = (xp_awk_val_map_t*) xp_malloc (xp_sizeof(xp_awk_val_map_t));
val = (xp_awk_val_map_t*) XP_AWK_MALLOC (
run->awk, xp_sizeof(xp_awk_val_map_t));
if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_MAP;
@ -189,7 +193,7 @@ xp_awk_val_t* xp_awk_makemapval (xp_awk_run_t* run)
val->map = xp_awk_map_open (XP_NULL, run, 256, __free_map_val);
if (val->map == XP_NULL)
{
xp_free (val);
XP_AWK_FREE (run->awk, val);
return XP_NULL;
}
@ -206,8 +210,8 @@ xp_awk_val_t* xp_awk_makerefval (xp_awk_run_t* run, int id, xp_awk_val_t** adr)
}
else
{
val = (xp_awk_val_ref_t*)
xp_malloc (xp_sizeof(xp_awk_val_ref_t));
val = (xp_awk_val_ref_t*) XP_AWK_MALLOC (
run->awk, xp_sizeof(xp_awk_val_ref_t));
if (val == XP_NULL) return XP_NULL;
}
@ -237,7 +241,7 @@ xp_awk_printval (val);
xp_printf (XP_T("\n"));*/
if (val->type == XP_AWK_VAL_NIL)
{
xp_free (val);
XP_AWK_FREE (run->awk, val);
}
else if (val->type == XP_AWK_VAL_INT)
{
@ -247,7 +251,7 @@ xp_printf (XP_T("\n"));*/
run->icache[run->icache_count++] =
(xp_awk_val_int_t*)val;
}
else xp_free (val);
else XP_AWK_FREE (run->awk, val);
}
else if (val->type == XP_AWK_VAL_REAL)
{
@ -257,23 +261,23 @@ xp_printf (XP_T("\n"));*/
run->rcache[run->rcache_count++] =
(xp_awk_val_real_t*)val;
}
else xp_free (val);
else XP_AWK_FREE (run->awk, val);
}
else if (val->type == XP_AWK_VAL_STR)
{
xp_free (((xp_awk_val_str_t*)val)->buf);
xp_free (val);
XP_AWK_FREE (run->awk, ((xp_awk_val_str_t*)val)->buf);
XP_AWK_FREE (run->awk, val);
}
else if (val->type == XP_AWK_VAL_REX)
{
xp_free (((xp_awk_val_rex_t*)val)->buf);
XP_AWK_FREE (run->awk, ((xp_awk_val_rex_t*)val)->buf);
xp_awk_freerex (((xp_awk_val_rex_t*)val)->code);
xp_free (val);
XP_AWK_FREE (run->awk, val);
}
else if (val->type == XP_AWK_VAL_MAP)
{
xp_awk_map_close (((xp_awk_val_map_t*)val)->map);
xp_free (val);
XP_AWK_FREE (run->awk, val);
}
else if (val->type == XP_AWK_VAL_REF)
{
@ -283,7 +287,7 @@ xp_printf (XP_T("\n"));*/
run->fcache[run->fcache_count++] =
(xp_awk_val_ref_t*)val;
}
else xp_free (val);
else XP_AWK_FREE (run->awk, val);
}
else
{
@ -361,7 +365,7 @@ 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_awk_run_t* run, xp_awk_val_t* v,
xp_bool_t clear_buf, xp_str_t* buf, xp_size_t* len)
{
if (v->type == XP_AWK_VAL_NIL)
@ -372,7 +376,7 @@ xp_char_t* xp_awk_valtostr (
tmp = xp_strdup (XP_T(""));
if (tmp == XP_NULL)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -400,10 +404,11 @@ xp_char_t* xp_awk_valtostr (
/* handle zero */
if (buf == XP_NULL)
{
tmp = xp_malloc (2 * xp_sizeof(xp_char_t));
tmp = XP_AWK_MALLOC (
run->awk, 2 * xp_sizeof(xp_char_t));
if (tmp == XP_NULL)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -417,7 +422,7 @@ xp_char_t* xp_awk_valtostr (
if (clear_buf) xp_str_clear (buf);
if (xp_str_cat (buf, XP_T("0")) == (xp_size_t)-1)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -432,10 +437,11 @@ xp_char_t* xp_awk_valtostr (
if (buf == XP_NULL)
{
tmp = xp_malloc ((l + 1) * xp_sizeof(xp_char_t));
tmp = XP_AWK_MALLOC (
run->awk, (l + 1) * xp_sizeof(xp_char_t));
if (tmp == XP_NULL)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -453,7 +459,7 @@ xp_char_t* xp_awk_valtostr (
if (xp_str_nccat (
buf, XP_T(' '), l) == (xp_size_t)-1)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
}
@ -500,7 +506,7 @@ xp_char_t* xp_awk_valtostr (
tmp = xp_strdup (tbuf);
if (tmp == XP_NULL)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -512,7 +518,7 @@ xp_char_t* xp_awk_valtostr (
if (xp_str_cat (buf, tbuf) == (xp_size_t)-1)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -534,7 +540,7 @@ xp_char_t* xp_awk_valtostr (
((xp_awk_val_str_t*)v)->len);
if (tmp == XP_NULL)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -548,7 +554,7 @@ xp_char_t* xp_awk_valtostr (
((xp_awk_val_str_t*)v)->buf,
((xp_awk_val_str_t*)v)->len) == (xp_size_t)-1)
{
*errnum = XP_AWK_ENOMEM;
run->errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
@ -562,7 +568,7 @@ xp_char_t* xp_awk_valtostr (
/* TODO: process more value types */
xp_printf (XP_T("*** ERROR: WRONG VALUE TYPE [%d] in xp_awk_valtostr v=> %p***\n"), v->type, v);
*errnum = XP_AWK_EVALTYPE;
run->errnum = XP_AWK_EVALTYPE;
return XP_NULL;
}