*** empty log message ***

This commit is contained in:
hyung-hwan 2006-07-26 05:19:46 +00:00
parent f6c98e99ec
commit 22de29f11e
6 changed files with 295 additions and 454 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.59 2006-07-25 16:41:40 bacon Exp $
* $Id: awk.c,v 1.60 2006-07-26 05:19:44 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -61,17 +61,6 @@ xp_awk_t* xp_awk_open (void)
return XP_NULL;
}
if (xp_awk_rex_open (&awk->rex) == 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);
xp_awk_tab_close (&awk->parse.params);
xp_free (awk);
return XP_NULL;
}
awk->opt.parse = 0;
awk->opt.run = 0;
awk->errnum = XP_AWK_ENOERR;
@ -116,7 +105,6 @@ int xp_awk_close (xp_awk_t* awk)
xp_awk_tab_close (&awk->parse.globals);
xp_awk_tab_close (&awk->parse.locals);
xp_awk_tab_close (&awk->parse.params);
xp_awk_rex_close (&awk->rex);
xp_str_close (&awk->token.name);
xp_free (awk);

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.32 2006-07-25 16:41:40 bacon Exp $
* $Id: awk_i.h,v 1.33 2006-07-26 05:19:45 bacon Exp $
*/
#ifndef _XP_AWK_AWKI_H_
@ -103,9 +103,6 @@ struct xp_awk_t
xp_size_t nlocals_max;
} parse;
/* regular expression compiler */
xp_awk_rex_t rex;
/* source buffer management */
struct
{
@ -192,9 +189,6 @@ struct xp_awk_run_t
/* extio chain */
xp_awk_extio_t* extio;
/* regular expression matcher */
xp_awk_rex_t rex_matcher;
int opt;
int errnum;

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,18 @@
/*
* $Id: rex.h,v 1.8 2006-07-26 02:25:47 bacon Exp $
* $Id: rex.h,v 1.9 2006-07-26 05:19:45 bacon Exp $
**/
#ifndef _XP_AWK_REX_H_
#define _XP_AWK_REX_H_
/*
#ifndef _XP_AWK_AWK_H_
#error Never include this file directly. Include <xp/awk/awk.h> instead
#endif
*/
#include <xp/types.h>
#include <xp/macros.h>
/*
* Regular Expression Syntax
@ -37,40 +42,6 @@
* ab|xy -> |2|10|4|ORD_CHAR(no bound)|a|ORD_CHAR(no bound)|b|4|ORD_CHAR(no bound)|x|ORD_CHAR(no bound)|y|
*/
struct xp_awk_rex_t
{
struct
{
const xp_char_t* ptr;
const xp_char_t* end;
const xp_char_t* curp;
struct
{
int type;
xp_char_t value;
} curc;
} ptn;
struct
{
xp_byte_t* buf;
xp_size_t size;
xp_size_t capa;
} code;
struct
{
struct
{
const xp_char_t* ptr;
const xp_char_t* end;
} str;
} match;
int errnum;
xp_bool_t __dynamic;
};
enum
{
XP_AWK_REX_ENOERR, /* no error */
@ -87,27 +58,24 @@ enum
XP_AWK_REX_EGARBAGE /* garbage after the pattern */
};
#define XP_AWK_REXNA(code) (*(xp_size_t*)(code))
#define XP_AWK_REXLEN(code) \
(*(xp_size_t*)((xp_byte_t*)(code)+xp_sizeof(xp_size_t)))
#ifdef __cplusplus
extern "C" {
#endif
const xp_char_t* xp_awk_rex_geterrstr (int errnum);
void* xp_awk_buildrex (const xp_char_t* ptn, xp_size_t len);
int xp_awk_matchrex (void* code,
const xp_char_t* str, xp_size_t len,
const xp_char_t** match_ptr, xp_size_t* match_len);
xp_awk_rex_t* xp_awk_rex_open (xp_awk_rex_t* rex);
void xp_awk_rex_close (xp_awk_rex_t* rex);
int xp_awk_rex_compile (
xp_awk_rex_t* rex, const xp_char_t* ptn, xp_size_t len);
int xp_awk_rex_match (xp_awk_rex_t* rex,
const xp_char_t* str, xp_size_t len,
const xp_char_t** match_ptr, xp_size_t* match_len);
void xp_awk_rex_print (xp_awk_rex_t* rex);
void xp_awk_printrex (void* code);
#ifdef __cplusplus
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.137 2006-07-25 17:15:15 bacon Exp $
* $Id: run.c,v 1.138 2006-07-26 05:19:46 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -291,14 +291,6 @@ static int __open_run (
return -1;
}
if (xp_awk_rex_open (&run->rex_matcher) == XP_NULL)
{
xp_awk_map_close (&run->named);
xp_str_close (&run->inrec.line);
run->errnum = XP_AWK_ENOMEM;
return -1;
}
run->extio = XP_NULL;
return 0;
}
@ -333,9 +325,6 @@ static void __close_run (xp_awk_run_t* run)
run->stack_limit = 0;
}
/* destroy the regular expression matcher */
xp_awk_rex_close (&run->rex_matcher);
/* destroy named variables */
xp_awk_map_close (&run->named);
@ -654,7 +643,8 @@ static int __handle_pattern (xp_awk_run_t* run, xp_awk_val_t* val)
/* TODO: do it properly match value...*/
//xp_awk_rex_setpattern (v->buf, v->len);
n = xp_awk_rex_match (&run->rex_matcher,
n = xp_awk_matchrex (
((xp_awk_val_rex_t*)val)->buf,
((xp_awk_val_str_t*)run->inrec.d0)->buf,
((xp_awk_val_str_t*)run->inrec.d0)->len,
XP_NULL, XP_NULL);