*** empty log message ***

This commit is contained in:
hyung-hwan 2006-07-26 15:00:01 +00:00
parent 22de29f11e
commit d9338ade05
9 changed files with 51 additions and 22 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.140 2006-07-26 05:19:45 bacon Exp $
* $Id: parse.c,v 1.141 2006-07-26 14:59:59 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -1916,17 +1916,26 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
nde->type = XP_AWK_NDE_REX;
nde->next = XP_NULL;
nde->buf = xp_awk_buildrex (
nde->len = XP_STR_LEN(&awk->token.name);
nde->buf = xp_strxdup (
XP_STR_BUF(&awk->token.name),
XP_STR_LEN(&awk->token.name));
if (nde->buf == XP_NULL)
{
/* TODO: get the proper errnum */
xp_free (nde);
PANIC (awk, XP_AWK_ENOMEM);
}
/* TODO: is nde->len necessary ? */
nde->len = XP_AWK_REXLEN(nde->buf);
nde->code = xp_awk_buildrex (
XP_STR_BUF(&awk->token.name),
XP_STR_LEN(&awk->token.name));
if (nde->code == XP_NULL)
{
/* TODO: get the proper errnum */
xp_free (nde->buf);
xp_free (nde);
PANIC (awk, XP_AWK_ENOMEM);
}
if (__get_token(awk) == -1)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c,v 1.15 2006-07-26 05:19:45 bacon Exp $
* $Id: rex.c,v 1.16 2006-07-26 15:00:00 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -262,7 +262,11 @@ void* xp_awk_buildrex (const xp_char_t* ptn, xp_size_t len)
builder.ptn.curc.value = XP_T('\0');
//NEXT_CHAR (&builder, LEVEL_TOP);
if (__next_char (&builder, LEVEL_TOP) == -1) return XP_NULL;
if (__next_char (&builder, LEVEL_TOP) == -1)
{
xp_free (builder.code.buf);
return XP_NULL;
}
if (__build_pattern (&builder) == -1)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.138 2006-07-26 05:19:46 bacon Exp $
* $Id: run.c,v 1.139 2006-07-26 15:00:00 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -644,7 +644,7 @@ static int __handle_pattern (xp_awk_run_t* run, xp_awk_val_t* val)
//xp_awk_rex_setpattern (v->buf, v->len);
n = xp_awk_matchrex (
((xp_awk_val_rex_t*)val)->buf,
((xp_awk_val_rex_t*)val)->code,
((xp_awk_val_str_t*)run->inrec.d0)->buf,
((xp_awk_val_str_t*)run->inrec.d0)->len,
XP_NULL, XP_NULL);
@ -3413,7 +3413,8 @@ static xp_awk_val_t* __eval_rex (xp_awk_run_t* run, xp_awk_nde_t* nde)
val = xp_awk_makerexval (
((xp_awk_nde_rex_t*)nde)->buf,
((xp_awk_nde_rex_t*)nde)->len);
((xp_awk_nde_rex_t*)nde)->len,
((xp_awk_nde_rex_t*)nde)->code);
if (val == XP_NULL) PANIC (run, XP_AWK_ENOMEM);
return val;

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.c,v 1.67 2006-07-25 17:15:15 bacon Exp $
* $Id: tree.c,v 1.68 2006-07-26 15:00:00 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -227,8 +227,8 @@ static int __print_expression (xp_awk_nde_t* nde)
case XP_AWK_NDE_REX:
{
/* TODO: print it properly */
xp_printf (XP_T("/**REX**/"));
/* TODO: buf, len */
xp_printf (XP_T("/%s/"), ((xp_awk_nde_rex_t*)nde)->buf);
break;
}
@ -915,6 +915,7 @@ void xp_awk_clrpt (xp_awk_nde_t* tree)
case XP_AWK_NDE_REX:
{
xp_free (((xp_awk_nde_rex_t*)p)->buf);
xp_free (((xp_awk_nde_rex_t*)p)->code);
xp_free (p);
break;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.h,v 1.62 2006-07-25 17:15:15 bacon Exp $
* $Id: tree.h,v 1.63 2006-07-26 15:00:00 bacon Exp $
*/
#ifndef _XP_AWK_TREE_H_
@ -205,8 +205,9 @@ struct xp_awk_nde_str_t
struct xp_awk_nde_rex_t
{
XP_AWK_NDE_HDR;
xp_byte_t* buf;
xp_char_t* buf;
xp_size_t len;
void* code;
};
/* XP_AWK_NDE_NAMED, XP_AWK_NDE_GLOBAL,

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.46 2006-07-25 17:15:15 bacon Exp $
* $Id: val.c,v 1.47 2006-07-26 15:00:00 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -135,7 +135,8 @@ xp_awk_val_t* xp_awk_makestrval2 (
return (xp_awk_val_t*)val;
}
xp_awk_val_t* xp_awk_makerexval (const xp_byte_t* buf, xp_size_t len)
xp_awk_val_t* xp_awk_makerexval (
const xp_char_t* buf, xp_size_t len, void* code)
{
xp_awk_val_rex_t* val;
@ -145,14 +146,22 @@ xp_awk_val_t* xp_awk_makerexval (const xp_byte_t* buf, xp_size_t len)
val->type = XP_AWK_VAL_REX;
val->ref = 0;
val->len = len;
val->buf = xp_malloc (len);
val->buf = xp_strxdup (buf, len);
if (val->buf == XP_NULL)
{
xp_free (val);
return XP_NULL;
}
xp_memcpy (val->buf, buf, len);
val->code = xp_malloc (XP_AWK_REXLEN(code));
if (val->code == XP_NULL)
{
xp_free (val->buf);
xp_free (val);
return XP_NULL;
}
xp_memcpy (val->code, code, XP_AWK_REXLEN(code));
return (xp_awk_val_t*)val;
}
@ -235,6 +244,7 @@ xp_printf (XP_T("\n"));*/
case XP_AWK_VAL_REX:
xp_free (((xp_awk_val_rex_t*)val)->buf);
xp_free (((xp_awk_val_rex_t*)val)->code);
xp_free (val);
return;

View File

@ -1,5 +1,5 @@
/*
* $Id: val.h,v 1.33 2006-07-25 17:15:15 bacon Exp $
* $Id: val.h,v 1.34 2006-07-26 15:00:00 bacon Exp $
*/
#ifndef _XP_AWK_VAL_H_
@ -75,6 +75,7 @@ struct xp_awk_val_rex_t
XP_AWK_VAL_HDR;
xp_char_t* buf;
xp_size_t len;
void* code;
};
/* XP_AWK_VAL_MAP */
@ -104,7 +105,8 @@ xp_awk_val_t* xp_awk_makestrval (const xp_char_t* str, xp_size_t len);
xp_awk_val_t* xp_awk_makestrval2 (
const xp_char_t* str1, xp_size_t len1,
const xp_char_t* str2, xp_size_t len2);
xp_awk_val_t* xp_awk_makerexval (const xp_byte_t* buf, xp_size_t len);
xp_awk_val_t* xp_awk_makerexval (
const xp_char_t* buf, xp_size_t len, void* code);
xp_awk_val_t* xp_awk_makemapval (xp_awk_run_t* run);
xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val);

View File

@ -1 +1 @@
/hello/ { $0=" "; print NF; print "a" $0 "b"; x = $1; }
{ $0=" "; print NF; print "a" $0 "b"; x = $1; }

1
ase/test/awk/t17.awk Normal file
View File

@ -0,0 +1 @@
/hello/ { print $0; }