renamed ASE_STR_XXX macros and added the ase_xstr_t type

This commit is contained in:
2008-09-24 03:51:24 +00:00
parent a1348d4ca5
commit 2230fbd445
9 changed files with 120 additions and 112 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: extio.c 337 2008-08-20 09:17:25Z baconevi $
* $Id: extio.c 372 2008-09-23 09:51:24Z baconevi $
*
* {License}
*/
@ -263,7 +263,7 @@ int ase_awk_readextio (
n = ASE_AWK_MATCHREX (
run->awk, run->global.rs,
((run->global.ignorecase)? ASE_REX_IGNORECASE: 0),
ASE_STR_BUF(buf), ASE_STR_LEN(buf),
ASE_STR_PTR(buf), ASE_STR_LEN(buf),
&match_ptr, &match_len, &run->errnum);
if (n == -1)
{
@ -276,7 +276,7 @@ int ase_awk_readextio (
/* the match should be found at the end of
* the current buffer */
ASE_ASSERT (
ASE_STR_BUF(buf) + ASE_STR_LEN(buf) ==
ASE_STR_PTR(buf) + ASE_STR_LEN(buf) ==
match_ptr + match_len);
ASE_STR_LEN(buf) -= match_len;
@ -351,7 +351,7 @@ int ase_awk_readextio (
n = ASE_AWK_MATCHREX (
run->awk, run->global.rs,
((run->global.ignorecase)? ASE_REX_IGNORECASE: 0),
ASE_STR_BUF(buf), ASE_STR_LEN(buf),
ASE_STR_PTR(buf), ASE_STR_LEN(buf),
&match_ptr, &match_len, &run->errnum);
if (n == -1)
{
@ -365,7 +365,7 @@ int ase_awk_readextio (
/* the match should be found at the end of
* the current buffer */
ASE_ASSERT (
ASE_STR_BUF(buf) + ASE_STR_LEN(buf) ==
ASE_STR_PTR(buf) + ASE_STR_LEN(buf) ==
match_ptr + match_len);
ASE_STR_LEN(buf) -= match_len;

View File

@ -1,5 +1,5 @@
/*
* $Id: func.c 363 2008-09-04 10:58:08Z baconevi $
* $Id: func.c 372 2008-09-23 09:51:24Z baconevi $
*
* {License}
*/
@ -992,7 +992,7 @@ static int __substitute (ase_awk_run_t* run, ase_long_t max_count)
if (a2 == ASE_NULL)
{
/* is this correct? any needs to use inrec.d0? */
a2_ptr = ASE_STR_BUF(&run->inrec.line);
a2_ptr = ASE_STR_PTR(&run->inrec.line);
a2_len = ASE_STR_LEN(&run->inrec.line);
}
else if (((ase_awk_val_ref_t*)a2)->id == ASE_AWK_VAL_REF_POS)
@ -1002,7 +1002,7 @@ static int __substitute (ase_awk_run_t* run, ase_long_t max_count)
idx = (ase_size_t)((ase_awk_val_ref_t*)a2)->adr;
if (idx == 0)
{
a2_ptr = ASE_STR_BUF(&run->inrec.line);
a2_ptr = ASE_STR_PTR(&run->inrec.line);
a2_len = ASE_STR_LEN(&run->inrec.line);
}
else if (idx <= run->inrec.nflds)
@ -1149,7 +1149,7 @@ static int __substitute (ase_awk_run_t* run, ase_long_t max_count)
if (a2 == ASE_NULL)
{
if (ase_awk_setrec (run, 0,
ASE_STR_BUF(&new), ASE_STR_LEN(&new)) == -1)
ASE_STR_PTR(&new), ASE_STR_LEN(&new)) == -1)
{
ase_str_close (&new);
FREE_A_PTRS (run->awk);
@ -1162,7 +1162,7 @@ static int __substitute (ase_awk_run_t* run, ase_long_t max_count)
n = ase_awk_setrec (
run, (ase_size_t)((ase_awk_val_ref_t*)a2)->adr,
ASE_STR_BUF(&new), ASE_STR_LEN(&new));
ASE_STR_PTR(&new), ASE_STR_LEN(&new));
if (n == -1)
{
@ -1174,7 +1174,7 @@ static int __substitute (ase_awk_run_t* run, ase_long_t max_count)
else
{
v = ase_awk_makestrval (run,
ASE_STR_BUF(&new), ASE_STR_LEN(&new));
ASE_STR_PTR(&new), ASE_STR_LEN(&new));
if (v == ASE_NULL)
{
ase_str_close (&new);

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c 363 2008-09-04 10:58:08Z baconevi $
* $Id: parse.c 372 2008-09-23 09:51:24Z baconevi $
*
* {License}
*/
@ -376,7 +376,7 @@ static global_t gtab[] =
do { \
ase_cstr_t errarg; \
errarg.len = ASE_STR_LEN(&(awk)->token.name); \
errarg.ptr = ASE_STR_BUF(&(awk)->token.name); \
errarg.ptr = ASE_STR_PTR(&(awk)->token.name); \
if (MATCH(awk,TOKEN_EOF)) \
ase_awk_seterror (awk, code, (awk)->token.prev.line, &errarg, 1); \
else \
@ -841,7 +841,7 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
return ASE_NULL;
}
name = ASE_STR_BUF(&awk->token.name);
name = ASE_STR_PTR(&awk->token.name);
name_len = ASE_STR_LEN(&awk->token.name);
/* check if it is a builtin function */
@ -930,7 +930,7 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
return ASE_NULL;
}
param = ASE_STR_BUF(&awk->token.name);
param = ASE_STR_PTR(&awk->token.name);
param_len = ASE_STR_LEN(&awk->token.name);
/* NOTE: the following is not a conflict.
@ -1601,7 +1601,7 @@ static ase_awk_t* collect_globals (ase_awk_t* awk)
if (add_global (
awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name),
awk->token.line, 0) == -1) return ASE_NULL;
@ -1639,7 +1639,7 @@ static ase_awk_t* collect_locals (
return ASE_NULL;
}
local = ASE_STR_BUF(&awk->token.name);
local = ASE_STR_PTR(&awk->token.name);
local_len = ASE_STR_LEN(&awk->token.name);
#if 0
@ -2758,10 +2758,10 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
nde->line = line;
nde->next = ASE_NULL;
nde->val = ase_awk_strxtolong (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name), 0, ASE_NULL);
nde->str = ASE_AWK_STRXDUP (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name));
if (nde->str == ASE_NULL)
{
@ -2772,7 +2772,7 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
ASE_ASSERT (
ASE_STR_LEN(&awk->token.name) ==
ase_strlen(ASE_STR_BUF(&awk->token.name)));
ase_strlen(ASE_STR_PTR(&awk->token.name)));
if (get_token(awk) == -1)
{
@ -2799,10 +2799,10 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
nde->line = line;
nde->next = ASE_NULL;
nde->val = ase_awk_strxtoreal (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name), ASE_NULL);
nde->str = ASE_AWK_STRXDUP (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name));
if (nde->str == ASE_NULL)
{
@ -2813,7 +2813,7 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
ASE_ASSERT (
ASE_STR_LEN(&awk->token.name) ==
ase_strlen(ASE_STR_BUF(&awk->token.name)));
ase_strlen(ASE_STR_PTR(&awk->token.name)));
if (get_token(awk) == -1)
{
@ -2841,7 +2841,7 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
nde->next = ASE_NULL;
nde->len = ASE_STR_LEN(&awk->token.name);
nde->buf = ASE_AWK_STRXDUP (awk,
ASE_STR_BUF(&awk->token.name), nde->len);
ASE_STR_PTR(&awk->token.name), nde->len);
if (nde->buf == ASE_NULL)
{
ASE_AWK_FREE (awk, nde);
@ -2885,7 +2885,7 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
nde->len = ASE_STR_LEN(&awk->token.name);
nde->buf = ASE_AWK_STRXDUP (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name));
if (nde->buf == ASE_NULL)
{
@ -2895,7 +2895,7 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
}
nde->code = ASE_AWK_BUILDREX (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name),
&errnum);
if (nde->code == ASE_NULL)
@ -3109,7 +3109,7 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line)
ASE_ASSERT (MATCH(awk,TOKEN_IDENT));
name_dup = ASE_AWK_STRXDUP (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name));
if (name_dup == ASE_NULL)
{
@ -4589,7 +4589,7 @@ static int get_token (ase_awk_t* awk)
c == ASE_T('_') || ASE_AWK_ISDIGIT(awk,c));
type = classify_ident (awk,
ASE_STR_BUF(&awk->token.name),
ASE_STR_PTR(&awk->token.name),
ASE_STR_LEN(&awk->token.name));
SET_TOKEN_TYPE (awk, type);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: rec.c 337 2008-08-20 09:17:25Z baconevi $
* $Id: rec.c 372 2008-09-23 09:51:24Z baconevi $
*
* {License}
*/
@ -19,7 +19,7 @@ int ase_awk_setrec (
if (idx == 0)
{
if (str == ASE_STR_BUF(&run->inrec.line) &&
if (str == ASE_STR_PTR(&run->inrec.line) &&
len == ASE_STR_LEN(&run->inrec.line))
{
if (ase_awk_clrrec (run, ASE_TRUE) == -1) return -1;
@ -66,7 +66,7 @@ int ase_awk_setrec (
/* recompose $0 */
v = ase_awk_makestrval (run,
ASE_STR_BUF(&run->inrec.line),
ASE_STR_PTR(&run->inrec.line),
ASE_STR_LEN(&run->inrec.line));
if (v == ASE_NULL)
{
@ -117,7 +117,7 @@ static int split_record (ase_awk_run_t* run)
}
/* scan the input record to count the fields */
p = ASE_STR_BUF(&run->inrec.line);
p = ASE_STR_PTR(&run->inrec.line);
len = ASE_STR_LEN(&run->inrec.line);
nflds = 0;
@ -153,7 +153,7 @@ static int split_record (ase_awk_run_t* run)
nflds++;
len = ASE_STR_LEN(&run->inrec.line) -
(p - ASE_STR_BUF(&run->inrec.line));
(p - ASE_STR_PTR(&run->inrec.line));
}
/* allocate space */
@ -175,7 +175,7 @@ static int split_record (ase_awk_run_t* run)
}
/* scan again and split it */
p = ASE_STR_BUF(&run->inrec.line);
p = ASE_STR_PTR(&run->inrec.line);
len = ASE_STR_LEN(&run->inrec.line);
while (p != ASE_NULL)
@ -215,7 +215,7 @@ static int split_record (ase_awk_run_t* run)
run->inrec.nflds++;
len = ASE_STR_LEN(&run->inrec.line) -
(p - ASE_STR_BUF(&run->inrec.line));
(p - ASE_STR_PTR(&run->inrec.line));
}
if (fs_free != ASE_NULL) ASE_AWK_FREE (run->awk, fs_free);
@ -354,7 +354,7 @@ static int recomp_record_fields (
ase_awk_val_t* tmp;
run->inrec.flds[i].ptr =
ASE_STR_BUF(&run->inrec.line) +
ASE_STR_PTR(&run->inrec.line) +
ASE_STR_LEN(&run->inrec.line);
run->inrec.flds[i].len = len;
@ -379,7 +379,7 @@ static int recomp_record_fields (
else if (i >= nflds)
{
run->inrec.flds[i].ptr =
ASE_STR_BUF(&run->inrec.line) +
ASE_STR_PTR(&run->inrec.line) +
ASE_STR_LEN(&run->inrec.line);
run->inrec.flds[i].len = 0;
@ -406,7 +406,7 @@ static int recomp_record_fields (
tmp = (ase_awk_val_str_t*)run->inrec.flds[i].val;
run->inrec.flds[i].ptr =
ASE_STR_BUF(&run->inrec.line) +
ASE_STR_PTR(&run->inrec.line) +
ASE_STR_LEN(&run->inrec.line);
run->inrec.flds[i].len = tmp->len;

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 363 2008-09-04 10:58:08Z baconevi $
* $Id: run.c 372 2008-09-23 09:51:24Z baconevi $
*
* {License}
*/
@ -1758,7 +1758,7 @@ static int run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
n = ase_awk_writeextio_str (run,
ASE_AWK_OUT_CONSOLE, ASE_T(""),
ASE_STR_BUF(&run->inrec.line),
ASE_STR_PTR(&run->inrec.line),
ASE_STR_LEN(&run->inrec.line));
if (n == -1)
{
@ -2813,7 +2813,7 @@ static int run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
* input record */
n = ase_awk_writeextio_str (
run, nde->out_type, dst,
ASE_STR_BUF(&run->inrec.line),
ASE_STR_PTR(&run->inrec.line),
ASE_STR_LEN(&run->inrec.line));
if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/)
{
@ -6230,7 +6230,7 @@ static ase_awk_val_t* eval_getline (ase_awk_run_t* run, ase_awk_nde_t* nde)
{
/* set $0 with the input value */
if (ase_awk_setrec (run, 0,
ASE_STR_BUF(&buf),
ASE_STR_PTR(&buf),
ASE_STR_LEN(&buf)) == -1)
{
ase_str_close (&buf);
@ -6244,7 +6244,7 @@ static ase_awk_val_t* eval_getline (ase_awk_run_t* run, ase_awk_nde_t* nde)
ase_awk_val_t* v;
v = ase_awk_makestrval (run,
ASE_STR_BUF(&buf), ASE_STR_LEN(&buf));
ASE_STR_PTR(&buf), ASE_STR_LEN(&buf));
ase_str_close (&buf);
if (v == ASE_NULL)
{
@ -6335,7 +6335,7 @@ static int read_record (ase_awk_run_t* run)
ase_dprintf (ASE_T("record len = %d str=[%.*s]\n"),
(int)ASE_STR_LEN(&run->inrec.line),
(int)ASE_STR_LEN(&run->inrec.line),
ASE_STR_BUF(&run->inrec.line));
ASE_STR_PTR(&run->inrec.line));
#endif
if (n == 0)
{
@ -6344,7 +6344,7 @@ static int read_record (ase_awk_run_t* run)
}
if (ase_awk_setrec (run, 0,
ASE_STR_BUF(&run->inrec.line),
ASE_STR_PTR(&run->inrec.line),
ASE_STR_LEN(&run->inrec.line)) == -1) return -1;
return 1;
@ -6421,7 +6421,7 @@ static int shorten_record (ase_awk_run_t* run, ase_size_t nflds)
if (nflds > 1) ase_awk_refdownval (run, v);
v = (ase_awk_val_t*) ase_awk_makestrval (
run, ASE_STR_BUF(&tmp), ASE_STR_LEN(&tmp));
run, ASE_STR_PTR(&tmp), ASE_STR_LEN(&tmp));
if (v == ASE_NULL) return -1;
ase_awk_refdownval (run, run->inrec.d0);
@ -6897,7 +6897,7 @@ ase_char_t* ase_awk_format (
run->awk->prmfns->data,
run->format.tmp.ptr,
run->format.tmp.len,
ASE_STR_BUF(fbu),
ASE_STR_PTR(fbu),
#if ASE_SIZEOF_LONG_LONG > 0
(long long)l
#elif ASE_SIZEOF___INT64 > 0
@ -6985,7 +6985,7 @@ ase_char_t* ase_awk_format (
run->awk->prmfns->data,
run->format.tmp.ptr,
run->format.tmp.len,
ASE_STR_BUF(fbu),
ASE_STR_PTR(fbu),
(long double)r);
if (n == -1)
@ -7251,6 +7251,6 @@ ase_char_t* ase_awk_format (
OUT_CHAR (ASE_STR_CHAR(fbu,j));
*len = ASE_STR_LEN(out);
return ASE_STR_BUF(out);
return ASE_STR_PTR(out);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c 363 2008-09-04 10:58:08Z baconevi $
* $Id: val.c 372 2008-09-23 09:51:24Z baconevi $
*
* {License}
*/
@ -772,7 +772,7 @@ static ase_char_t* str_to_str (
}
if (len != ASE_NULL) *len = ASE_STR_LEN(buf);
return ASE_STR_BUF(buf);
return ASE_STR_PTR(buf);
}
}
@ -833,7 +833,7 @@ static ase_char_t* val_int_to_str (
}
if (len != ASE_NULL) *len = ASE_STR_LEN(buf);
return ASE_STR_BUF(buf);
return ASE_STR_PTR(buf);
}
}
@ -876,7 +876,7 @@ static ase_char_t* val_int_to_str (
/* clear the buffer */
if (opt & ASE_AWK_VALTOSTR_CLEAR) ase_str_clear (buf);
tmp = ASE_STR_BUF(buf) + ASE_STR_LEN(buf);
tmp = ASE_STR_PTR(buf) + ASE_STR_LEN(buf);
/* extend the buffer */
if (ase_str_nccat (
@ -901,7 +901,7 @@ static ase_char_t* val_int_to_str (
if (buf != ASE_NULL && !(opt & ASE_AWK_VALTOSTR_FIXED))
{
tmp = ASE_STR_BUF(buf);
tmp = ASE_STR_PTR(buf);
if (len != ASE_NULL) *len = ASE_STR_LEN(buf);
}
@ -992,7 +992,7 @@ static ase_char_t* val_real_to_str (
return ASE_NULL;
}
tmp = ASE_STR_BUF(buf);
tmp = ASE_STR_PTR(buf);
if (len != ASE_NULL) *len = ASE_STR_LEN(buf);
ase_str_fini (&fbu);