*** empty log message ***

This commit is contained in:
hyung-hwan 2006-04-24 14:38:46 +00:00
parent 8ca03d1397
commit 63a47ebb7c
4 changed files with 33 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.45 2006-04-22 13:54:52 bacon Exp $ * $Id: awk.c,v 1.46 2006-04-24 14:38:46 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -113,17 +113,22 @@ void xp_awk_clear (xp_awk_t* awk)
awk->tree.nglobals = 0; awk->tree.nglobals = 0;
xp_awk_map_clear (&awk->tree.funcs); xp_awk_map_clear (&awk->tree.funcs);
if (awk->tree.begin != XP_NULL) { if (awk->tree.begin != XP_NULL)
{
xp_assert (awk->tree.begin->next == XP_NULL); xp_assert (awk->tree.begin->next == XP_NULL);
xp_awk_clrpt (awk->tree.begin); xp_awk_clrpt (awk->tree.begin);
awk->tree.begin = XP_NULL; awk->tree.begin = XP_NULL;
} }
if (awk->tree.end != XP_NULL) {
if (awk->tree.end != XP_NULL)
{
xp_assert (awk->tree.end->next == XP_NULL); xp_assert (awk->tree.end->next == XP_NULL);
xp_awk_clrpt (awk->tree.end); xp_awk_clrpt (awk->tree.end);
awk->tree.end = XP_NULL; awk->tree.end = XP_NULL;
} }
while (awk->tree.chain != XP_NULL) {
while (awk->tree.chain != XP_NULL)
{
xp_awk_chain_t* next = awk->tree.chain->next; xp_awk_chain_t* next = awk->tree.chain->next;
if (awk->tree.chain->pattern != XP_NULL) if (awk->tree.chain->pattern != XP_NULL)
xp_awk_clrpt (awk->tree.chain->pattern); xp_awk_clrpt (awk->tree.chain->pattern);
@ -150,7 +155,8 @@ int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t src, void* arg)
if (xp_awk_detsrc(awk) == -1) return -1; if (xp_awk_detsrc(awk) == -1) return -1;
xp_assert (awk->srcio == XP_NULL); xp_assert (awk->srcio == XP_NULL);
if (src(XP_AWK_INPUT_OPEN, arg, XP_NULL, 0) == -1) { if (src(XP_AWK_INPUT_OPEN, arg, XP_NULL, 0) == -1)
{
awk->errnum = XP_AWK_ESRCINOPEN; awk->errnum = XP_AWK_ESRCINOPEN;
return -1; return -1;
} }
@ -164,7 +170,8 @@ int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t src, void* arg)
int xp_awk_detsrc (xp_awk_t* awk) int xp_awk_detsrc (xp_awk_t* awk)
{ {
if (awk->srcio != XP_NULL) { if (awk->srcio != XP_NULL)
{
xp_ssize_t n; xp_ssize_t n;
n = awk->srcio (XP_AWK_INPUT_CLOSE, awk->srcio_arg, XP_NULL, 0); n = awk->srcio (XP_AWK_INPUT_CLOSE, awk->srcio_arg, XP_NULL, 0);
@ -185,10 +192,11 @@ int xp_awk_detsrc (xp_awk_t* awk)
static void __free_func (void* owner, void* func) static void __free_func (void* owner, void* func)
{ {
xp_awk_func_t* f = (xp_awk_func_t*) func; xp_awk_func_t* f = (xp_awk_func_t*)func;
/* f->name doesn't have to be freed */ /* f->name doesn't have to be freed */
/*xp_free (f->name);*/ /*xp_free (f->name);*/
xp_awk_clrpt (f->body); xp_awk_clrpt (f->body);
xp_free (f); xp_free (f);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.71 2006-04-24 11:26:00 bacon Exp $ * $Id: run.c,v 1.72 2006-04-24 14:38:46 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -177,9 +177,9 @@ int xp_awk_run (xp_awk_t* awk, xp_awk_io_t txtio, void* txtio_arg)
return n; return n;
} }
static void __free_namedval (xp_awk_run_t* run, void* val) static void __free_namedval (void* run, void* val)
{ {
xp_awk_refdownval (run, val); xp_awk_refdownval ((xp_awk_run_t*)run, val);
} }
static int __open_run ( static int __open_run (

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.c,v 1.40 2006-04-24 11:22:42 bacon Exp $ * $Id: tree.c,v 1.41 2006-04-24 14:38:46 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -79,7 +79,8 @@ static void __print_tabs (int depth)
static int __print_expression (xp_awk_nde_t* nde) static int __print_expression (xp_awk_nde_t* nde)
{ {
switch (nde->type) { switch (nde->type)
{
case XP_AWK_NDE_ASS: case XP_AWK_NDE_ASS:
if (__print_expression (((xp_awk_nde_ass_t*)nde)->left) == -1) return -1; if (__print_expression (((xp_awk_nde_ass_t*)nde)->left) == -1) return -1;
xp_printf (XP_TEXT(" %s "), xp_printf (XP_TEXT(" %s "),
@ -311,11 +312,13 @@ static void __print_statements (xp_awk_nde_t* tree, int depth)
__print_tabs (depth); __print_tabs (depth);
xp_printf (XP_TEXT("{\n")); xp_printf (XP_TEXT("{\n"));
if (((xp_awk_nde_blk_t*)p)->nlocals > 0) { if (((xp_awk_nde_blk_t*)p)->nlocals > 0)
{
__print_tabs (depth + 1); __print_tabs (depth + 1);
xp_printf (XP_TEXT("local ")); xp_printf (XP_TEXT("local "));
for (i = 0; i < ((xp_awk_nde_blk_t*)p)->nlocals - 1; i++) { for (i = 0; i < ((xp_awk_nde_blk_t*)p)->nlocals - 1; i++)
{
xp_printf (XP_TEXT("__local%lu, "), (unsigned long)i); xp_printf (XP_TEXT("__local%lu, "), (unsigned long)i);
} }
xp_printf (XP_TEXT("__local%lu;\n"), (unsigned long)i); xp_printf (XP_TEXT("__local%lu;\n"), (unsigned long)i);
@ -430,7 +433,8 @@ static void __print_statements (xp_awk_nde_t* tree, int depth)
{ {
xp_printf (XP_TEXT("return ")); xp_printf (XP_TEXT("return "));
xp_assert (((xp_awk_nde_return_t*)p)->val->next == XP_NULL); xp_assert (((xp_awk_nde_return_t*)p)->val->next == XP_NULL);
if (__print_expression(((xp_awk_nde_return_t*)p)->val) == 0) { if (__print_expression(((xp_awk_nde_return_t*)p)->val) == 0)
{
xp_printf (XP_TEXT(";\n")); xp_printf (XP_TEXT(";\n"));
} }
else else

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.26 2006-04-24 11:22:42 bacon Exp $ * $Id: val.c,v 1.27 2006-04-24 14:38:46 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -45,7 +45,7 @@ xp_awk_val_t* xp_awk_makeintval (xp_awk_run_t* run, xp_long_t v)
else else
{ {
val = (xp_awk_val_int_t*) val = (xp_awk_val_int_t*)
xp_malloc(xp_sizeof(xp_awk_val_int_t)); xp_malloc (xp_sizeof(xp_awk_val_int_t));
if (val == XP_NULL) return XP_NULL; if (val == XP_NULL) return XP_NULL;
} }
@ -82,7 +82,7 @@ xp_awk_val_t* xp_awk_makestrval (const xp_char_t* str, xp_size_t len)
{ {
xp_awk_val_str_t* val; 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_malloc (xp_sizeof(xp_awk_val_str_t));
if (val == XP_NULL) return XP_NULL; if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_STR; val->type = XP_AWK_VAL_STR;
@ -104,7 +104,7 @@ xp_awk_val_t* xp_awk_makestrval2 (
{ {
xp_awk_val_str_t* val; 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_malloc (xp_sizeof(xp_awk_val_str_t));
if (val == XP_NULL) return XP_NULL; if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_STR; val->type = XP_AWK_VAL_STR;
@ -124,8 +124,8 @@ xp_awk_val_t* xp_awk_makerexval (const xp_char_t* str, xp_size_t len)
{ {
xp_awk_val_rex_t* val; xp_awk_val_rex_t* val;
/* TDOO: XXXXXXXXXXXXxxx */ /* TDOO: XXXXXXXXXXXXXX */
val = (xp_awk_val_rex_t*)xp_malloc(xp_sizeof(xp_awk_val_rex_t)); val = (xp_awk_val_rex_t*) xp_malloc (xp_sizeof(xp_awk_val_rex_t));
if (val == XP_NULL) return XP_NULL; if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_STR; val->type = XP_AWK_VAL_STR;