*** empty log message ***

This commit is contained in:
hyung-hwan 2006-08-31 15:09:24 +00:00
parent 809fb80456
commit ca64ce70f4
3 changed files with 32 additions and 27 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.72 2006-08-31 14:52:11 bacon Exp $
* $Id: awk.c,v 1.73 2006-08-31 15:09:23 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -23,9 +23,11 @@ xp_awk_t* xp_awk_open (xp_awk_syscas_t* syscas)
xp_sizeof(xp_awk_t), syscas->custom_data);
if (awk == XP_NULL) return XP_NULL;
awk->syscas = syscas;
if (xp_str_open (&awk->token.name, 128) == XP_NULL)
{
syscas->free (awk, syscas->custom_data);
XP_AWK_FREE (awk, awk);
return XP_NULL;
}
@ -34,34 +36,34 @@ xp_awk_t* xp_awk_open (xp_awk_syscas_t* syscas)
&awk->tree.afns, awk, 256, __free_afn) == XP_NULL)
{
xp_str_close (&awk->token.name);
syscas->free (awk, syscas->custom_data);
XP_AWK_FREE (awk, awk);
return XP_NULL;
}
if (xp_awk_tab_open (&awk->parse.globals) == XP_NULL)
if (xp_awk_tab_open (&awk->parse.globals, awk) == XP_NULL)
{
xp_str_close (&awk->token.name);
xp_awk_map_close (&awk->tree.afns);
syscas->free (awk, syscas->custom_data);
XP_AWK_FREE (awk, awk);
return XP_NULL;
}
if (xp_awk_tab_open (&awk->parse.locals) == XP_NULL)
if (xp_awk_tab_open (&awk->parse.locals, awk) == XP_NULL)
{
xp_str_close (&awk->token.name);
xp_awk_map_close (&awk->tree.afns);
xp_awk_tab_close (&awk->parse.globals);
syscas->free (awk, syscas->custom_data);
XP_AWK_FREE (awk, awk);
return XP_NULL;
}
if (xp_awk_tab_open (&awk->parse.params) == XP_NULL)
if (xp_awk_tab_open (&awk->parse.params, awk) == XP_NULL)
{
xp_str_close (&awk->token.name);
xp_awk_map_close (&awk->tree.afns);
xp_awk_tab_close (&awk->parse.globals);
xp_awk_tab_close (&awk->parse.locals);
syscas->free (awk, syscas->custom_data);
XP_AWK_FREE (awk, awk);
return XP_NULL;
}
@ -97,7 +99,6 @@ xp_awk_t* xp_awk_open (xp_awk_syscas_t* syscas)
awk->run.count = 0;
awk->run.ptr = XP_NULL;
awk->syscas = syscas;
return awk;
}
@ -113,7 +114,9 @@ int xp_awk_close (xp_awk_t* awk)
xp_awk_tab_close (&awk->parse.params);
xp_str_close (&awk->token.name);
awk->syscas->free (awk, awk->syscas->custom_data);
/* XP_AWK_MALLOC, XP_AWK_FREE, etc can not be used
* from the next line onwards */
XP_AWK_FREE (awk, awk);
return 0;
}
@ -173,7 +176,7 @@ int xp_awk_clear (xp_awk_t* awk)
xp_awk_clrpt (awk->tree.chain->pattern);
if (awk->tree.chain->action != XP_NULL)
xp_awk_clrpt (awk->tree.chain->action);
awk->syscas->free (awk->tree.chain, awk->syscas->custom_data);
XP_AWK_FREE (awk, awk->tree.chain);
awk->tree.chain = next;
}
@ -197,10 +200,10 @@ static void __free_afn (void* owner, void* afn)
xp_awk_afn_t* f = (xp_awk_afn_t*)afn;
/* f->name doesn't have to be freed */
/*xp_free (f->name);*/
/*XP_AWK_FREE ((xp_awk_t*)owner, f->name);*/
xp_awk_clrpt (f->body);
xp_free (f);
XP_AWK_FREE ((xp_awk_t*)owner, f);
}
xp_size_t xp_awk_getsrcline (xp_awk_t* awk)

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.49 2006-08-31 14:52:11 bacon Exp $
* $Id: awk_i.h,v 1.50 2006-08-31 15:09:24 bacon Exp $
*/
#ifndef _XP_AWK_AWKI_H_
@ -61,6 +61,8 @@ struct xp_awk_tree_t
struct xp_awk_t
{
xp_awk_syscas_t* syscas;
/* options */
int option;
@ -134,8 +136,6 @@ struct xp_awk_t
xp_awk_run_t* ptr;
} run;
xp_awk_syscas_t* syscas;
/* housekeeping */
int errnum;
};

View File

@ -1,5 +1,5 @@
/*
* $Id: tab.c,v 1.11 2006-08-16 11:35:54 bacon Exp $
* $Id: tab.c,v 1.12 2006-08-31 15:09:24 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -10,16 +10,18 @@
#include <xp/bas/assert.h>
#endif
xp_awk_tab_t* xp_awk_tab_open (xp_awk_tab_t* tab)
xp_awk_tab_t* xp_awk_tab_open (xp_awk_tab_t* tab, xp_awk_t* awk)
{
if (tab == XP_NULL)
{
tab = (xp_awk_tab_t*) xp_malloc (xp_sizeof(xp_awk_tab_t));
tab = (xp_awk_tab_t*) XP_AWK_MALLOC (
awk, xp_sizeof(xp_awk_tab_t));
if (tab == XP_NULL) return XP_NULL;
tab->__dynamic = xp_true;
}
else tab->__dynamic = xp_false;
tab->awk = awk;
tab->buf = XP_NULL;
tab->size = 0;
tab->capa = 0;
@ -32,12 +34,12 @@ void xp_awk_tab_close (xp_awk_tab_t* tab)
xp_awk_tab_clear (tab);
if (tab->buf != XP_NULL)
{
xp_free (tab->buf);
XP_AWK_FREE (tab->awk, tab->buf);
tab->buf = XP_NULL;
tab->capa = 0;
}
if (tab->__dynamic) xp_free (tab);
if (tab->__dynamic) XP_AWK_FREE (tab->awk, tab);
}
xp_size_t xp_awk_tab_getsize (xp_awk_tab_t* tab)
@ -73,13 +75,13 @@ xp_awk_tab_t* xp_awk_tab_setcapa (xp_awk_tab_t* tab, xp_size_t capa)
xp_size_t x;
x = (capa > tab->capa)? tab->capa: capa;
xp_memcpy (tmp, tab->buf, xp_sizeof(*tab->buf) * x);
xp_free (tab->buf);
XP_AWK_FREE (tab->awk, tab->buf);
}
#endif
}
else
{
if (tab->buf != XP_NULL) xp_free (tab->buf);
if (tab->buf != XP_NULL) XP_AWK_FREE (tab->awk, tab->buf);
tmp = XP_NULL;
}
@ -97,7 +99,7 @@ void xp_awk_tab_clear (xp_awk_tab_t* tab)
for (i = 0; i < tab->size; i++)
{
xp_free (tab->buf[i].name);
XP_AWK_FREE (tab->awk, tab->buf[i].name);
tab->buf[i].name = XP_NULL;
tab->buf[i].name_len = 0;
}
@ -128,7 +130,7 @@ xp_size_t xp_awk_tab_insert (
if (xp_awk_tab_setcapa(tab,capa) == XP_NULL)
{
xp_free (str_dup);
XP_AWK_FREE (tab->awk, str_dup);
return (xp_size_t)-1;
}
}
@ -157,7 +159,7 @@ xp_size_t xp_awk_tab_remove (
while (i < k)
{
xp_free (tab->buf[i].name);
XP_AWK_FREE (tab->awk, tab->buf[i].name);
if (j >= tab->size)
{