*** empty log message ***

This commit is contained in:
hyung-hwan 2006-09-25 06:17:19 +00:00
parent 5754c542db
commit a0e2bd684a
10 changed files with 75 additions and 34 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.117 2006-09-22 14:04:25 bacon Exp $
* $Id: awk.h,v 1.118 2006-09-25 06:17:18 bacon Exp $
*/
#ifndef _XP_AWK_AWK_H_
@ -74,6 +74,9 @@ struct xp_awk_syscas_t
xp_cint_t (*to_upper) (xp_cint_t c);
xp_cint_t (*to_lower) (xp_cint_t c);
/* utilities */
void* (*memcpy) (void* dst, const void* src, xp_size_t n);
void* (*memset) (void* dst, int val, xp_size_t n);
int (*sprintf) (xp_char_t* buf, xp_size_t size, xp_char_t* fmt, ...);
void* custom_data;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.58 2006-09-22 14:04:25 bacon Exp $
* $Id: awk_i.h,v 1.59 2006-09-25 06:17:19 bacon Exp $
*/
#ifndef _XP_AWK_AWKI_H_
@ -12,23 +12,13 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
#include <xp/awk/awk.h>
#ifdef XP_AWK_STAND_ALONE
#if !defined(XP_CHAR_IS_MCHAR) && !defined(XP_CHAR_IS_WCHAR)
#error Neither XP_CHAR_IS_MCHAR nor XP_CHAR_IS_WCHAR is defined.
#endif
#include <string.h>
#include <assert.h>
#define xp_assert assert
#define xp_memset(dst,fill,len) memset(dst,fill,len)
#define xp_memcpy(dst,src,len) memcpy(dst,src,len)
#define xp_memmove(dst,src,len) memmove(dst,src,len)
#define xp_memcmp(src1,src2,len) memcmp(src1,src2,len)
#define xp_memzero(dst,len) memset(dst,0,len)
#else
#include <xp/bas/memory.h>
#include <xp/bas/assert.h>
#endif
@ -96,6 +86,20 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
#define XP_AWK_TOUPPER(awk,c) (awk)->syscas->to_upper(c)
#define XP_AWK_TOLOWER(awk,c) (awk)->syscas->to_lower(c)
#define XP_AWK_MEMCPY(awk,dst,src,len) \
do { \
if ((awk)->syscas->memcpy == XP_NULL) \
xp_awk_memcpy (dst, src, len); \
else (awk)->syscas->memcpy (dst, src, len); \
} while (0)
#define XP_AWK_MEMSET(awk,dst,val,len) \
do { \
if ((awk)->syscas->memset == XP_NULL) \
xp_awk_memset (dst, val, len); \
else (awk)->syscas->memset (dst, val, len); \
} while (0)
struct xp_awk_tree_t
{
xp_size_t nglobals; /* total number of globals */

View File

@ -1,9 +1,38 @@
/*
* $Id: misc.c,v 1.21 2006-09-22 14:04:25 bacon Exp $
* $Id: misc.c,v 1.22 2006-09-25 06:17:19 bacon Exp $
*/
#include <xp/awk/awk_i.h>
void* xp_awk_memcpy (void* dst, const void* src, xp_size_t n)
{
void* p = dst;
void* e = (xp_byte_t*)dst + n;
while (dst < e)
{
*(xp_byte_t*)dst = *(xp_byte_t*)src;
dst = (xp_byte_t*)dst + 1;
src = (xp_byte_t*)src + 1;
}
return p;
}
void* xp_awk_memset (void* dst, int val, xp_size_t n)
{
void* p = dst;
void* e = (xp_byte_t*)p + n;
while (p < e)
{
*(xp_byte_t*)p = (xp_byte_t)val;
p = (xp_byte_t*)p + 1;
}
return dst;
}
xp_long_t xp_awk_strtolong (
xp_awk_t* awk, const xp_char_t* str,
int base, const xp_char_t** endptr)

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.h,v 1.1 2006-09-08 15:26:49 bacon Exp $
* $Id: misc.h,v 1.2 2006-09-25 06:17:19 bacon Exp $
*/
#ifndef _XP_AWK_MISC_H_
@ -13,6 +13,9 @@
extern "C" {
#endif
void* xp_awk_memcpy (void* dst, const void* src, xp_size_t n);
void* xp_awk_memset (void* dst, int val, xp_size_t n);
xp_char_t* xp_awk_strtok (
xp_awk_run_t* awk, const xp_char_t* s,
const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len);

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c,v 1.30 2006-09-22 14:04:26 bacon Exp $
* $Id: rex.c,v 1.31 2006-09-25 06:17:19 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -925,7 +925,7 @@ static int __add_code (__builder_t* builder, void* data, xp_size_t len)
if (capa == 0) capa = DEF_CODE_CAPA;
while (len > capa - builder->code.size) { capa = capa * 2; }
if (builder->awk->syscas->realloc != NULL)
if (builder->awk->syscas->realloc != XP_NULL)
{
tmp = (xp_byte_t*) XP_AWK_REALLOC (
builder->awk, builder->code.buf, capa);
@ -946,7 +946,8 @@ static int __add_code (__builder_t* builder, void* data, xp_size_t len)
if (builder->code.buf != XP_NULL)
{
xp_memcpy (tmp, builder->code.buf, builder->code.capa);
XP_AWK_MEMCPY (builder->awk, tmp,
builder->code.buf, builder->code.capa);
XP_AWK_FREE (builder->awk, builder->code.buf);
}
}
@ -955,7 +956,8 @@ static int __add_code (__builder_t* builder, void* data, xp_size_t len)
builder->code.capa = capa;
}
xp_memcpy (&builder->code.buf[builder->code.size], data, len);
XP_AWK_MEMCPY (builder->awk,
&builder->code.buf[builder->code.size], data, len);
builder->code.size += len;
return 0;

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.204 2006-09-22 14:04:26 bacon Exp $
* $Id: run.c,v 1.205 2006-09-25 06:17:19 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -7,10 +7,6 @@
/* TODO: remove this dependency...*/
#include <math.h>
#ifndef XP_AWK_STAND_ALONE
#include <xp/bas/assert.h>
#endif
#define DEF_BUF_CAPA 256
#define STACK_INCREMENT 512
@ -631,7 +627,7 @@ static int __init_run (
return -1;
}
xp_memzero (run->pattern_range_state,
XP_AWK_MEMSET (run->awk, run->pattern_range_state, 0,
run->awk->tree.chain_size * xp_sizeof(xp_byte_t));
run->extio.handler[XP_AWK_EXTIO_PIPE] = runios->pipe;
@ -4807,7 +4803,7 @@ static int __raw_push (xp_awk_run_t* run, void* val)
if (tmp == XP_NULL) return -1;
if (run->stack != XP_NULL)
{
xp_memcpy (tmp, run->stack,
XP_AWK_MEMCPY (run->awk, tmp, run->stack,
run->stack_limit * xp_sizeof(void*));
XP_AWK_FREE (run->awk, run->stack);
}
@ -4988,7 +4984,7 @@ static int __split_record (xp_awk_run_t* run)
PANIC_I (run, XP_AWK_ENOMEM);
}
if (run->inrec.flds != NULL)
if (run->inrec.flds != XP_NULL)
XP_AWK_FREE (run->awk, run->inrec.flds);
run->inrec.flds = tmp;
run->inrec.maxflds = nflds;
@ -5126,7 +5122,7 @@ static int __recomp_record_fields (
}
if (run->inrec.flds != XP_NULL)
{
xp_memcpy (tmp, run->inrec.flds,
XP_AWK_MEMCPY (run->awk, tmp, run->inrec.flds,
xp_sizeof(*run->inrec.flds) * run->inrec.maxflds);
XP_AWK_FREE (run->awk, run->inrec.flds);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: str.c,v 1.5 2006-09-22 14:04:26 bacon Exp $
* $Id: str.c,v 1.6 2006-09-25 06:17:19 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -124,7 +124,7 @@ xp_size_t xp_awk_str_ncat (xp_awk_str_t* str, const xp_char_t* s, xp_size_t len)
if (tmp == XP_NULL) return (xp_size_t)-1;
if (str->buf != XP_NULL)
{
xp_memcpy (tmp, str->buf,
XP_AWK_MEMCPY (str->awk, tmp, str->buf,
xp_sizeof(xp_char_t) * (str->capa + 1));
XP_AWK_FREE (str->awk, str->buf);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: tab.c,v 1.17 2006-09-22 14:04:26 bacon Exp $
* $Id: tab.c,v 1.18 2006-09-25 06:17:19 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -77,7 +77,9 @@ 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_AWK_MEMCPY (
tab->awk, tmp, tab->buf,
xp_sizeof(*tab->buf) * x);
XP_AWK_FREE (tab->awk, tab->buf);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.60 2006-09-22 14:04:26 bacon Exp $
* $Id: val.c,v 1.61 2006-09-25 06:17:19 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -164,7 +164,7 @@ xp_awk_val_t* xp_awk_makerexval (
return XP_NULL;
}
xp_memcpy (val->code, code, XP_AWK_REX_LEN(code));
XP_AWK_MEMCPY (run->awk, val->code, code, XP_AWK_REX_LEN(code));
return (xp_awk_val_t*)val;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.90 2006-09-22 14:05:30 bacon Exp $
* $Id: awk.c,v 1.91 2006-09-25 06:17:19 bacon Exp $
*/
#include <xp/awk/awk.h>
@ -671,6 +671,8 @@ static int __main (int argc, xp_char_t* argv[])
syscas.to_upper = towupper;
syscas.to_lower = towlower;
#endif
syscas.memcpy = memcpy;
syscas.memset = memset;
syscas.sprintf = xp_sprintf;
#ifdef _WIN32