*** empty log message ***

This commit is contained in:
hyung-hwan 2006-12-13 14:13:07 +00:00
parent 282c147373
commit 496f412e8f
12 changed files with 209 additions and 187 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.97 2006-12-12 05:16:29 bacon Exp $
* $Id: awk.c,v 1.98 2006-12-13 14:13:06 bacon Exp $
*/
#if defined(__BORLANDC__)
@ -11,41 +11,41 @@
static void __free_afn (void* awk, void* afn);
ase_awk_t* ase_awk_open (const ase_awk_syscas_t* syscas)
ase_awk_t* ase_awk_open (const ase_awk_sysfns_t* sysfns)
{
ase_awk_t* awk;
if (syscas == ASE_NULL) return ASE_NULL;
if (sysfns == ASE_NULL) return ASE_NULL;
if (syscas->malloc == ASE_NULL ||
syscas->free == ASE_NULL) return ASE_NULL;
if (sysfns->malloc == ASE_NULL ||
sysfns->free == ASE_NULL) return ASE_NULL;
if (syscas->is_upper == ASE_NULL ||
syscas->is_lower == ASE_NULL ||
syscas->is_alpha == ASE_NULL ||
syscas->is_digit == ASE_NULL ||
syscas->is_xdigit == ASE_NULL ||
syscas->is_alnum == ASE_NULL ||
syscas->is_space == ASE_NULL ||
syscas->is_print == ASE_NULL ||
syscas->is_graph == ASE_NULL ||
syscas->is_cntrl == ASE_NULL ||
syscas->is_punct == ASE_NULL ||
syscas->to_upper == ASE_NULL ||
syscas->to_lower == ASE_NULL) return ASE_NULL;
if (sysfns->is_upper == ASE_NULL ||
sysfns->is_lower == ASE_NULL ||
sysfns->is_alpha == ASE_NULL ||
sysfns->is_digit == ASE_NULL ||
sysfns->is_xdigit == ASE_NULL ||
sysfns->is_alnum == ASE_NULL ||
sysfns->is_space == ASE_NULL ||
sysfns->is_print == ASE_NULL ||
sysfns->is_graph == ASE_NULL ||
sysfns->is_cntrl == ASE_NULL ||
sysfns->is_punct == ASE_NULL ||
sysfns->to_upper == ASE_NULL ||
sysfns->to_lower == ASE_NULL) return ASE_NULL;
if (syscas->sprintf == ASE_NULL ||
syscas->aprintf == ASE_NULL ||
syscas->dprintf == ASE_NULL ||
syscas->abort == ASE_NULL) return ASE_NULL;
if (sysfns->sprintf == ASE_NULL ||
sysfns->aprintf == ASE_NULL ||
sysfns->dprintf == ASE_NULL ||
sysfns->abort == ASE_NULL) return ASE_NULL;
if (syscas->pow == ASE_NULL) return ASE_NULL;
if (sysfns->pow == ASE_NULL) return ASE_NULL;
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
awk = (ase_awk_t*) malloc (ASE_SIZEOF(ase_awk_t));
#else
awk = (ase_awk_t*) syscas->malloc (
ASE_SIZEOF(ase_awk_t), syscas->custom_data);
awk = (ase_awk_t*) sysfns->malloc (
ASE_SIZEOF(ase_awk_t), sysfns->custom_data);
#endif
if (awk == ASE_NULL) return ASE_NULL;
@ -53,13 +53,13 @@ ase_awk_t* ase_awk_open (const ase_awk_syscas_t* syscas)
* fully initialized yet */
ase_awk_memset (awk, 0, ASE_SIZEOF(ase_awk_t));
if (syscas->memcpy == ASE_NULL)
if (sysfns->memcpy == ASE_NULL)
{
ase_awk_memcpy (&awk->syscas, syscas, ASE_SIZEOF(awk->syscas));
awk->syscas.memcpy = ase_awk_memcpy;
ase_awk_memcpy (&awk->sysfns, sysfns, ASE_SIZEOF(awk->sysfns));
awk->sysfns.memcpy = ase_awk_memcpy;
}
else syscas->memcpy (&awk->syscas, syscas, ASE_SIZEOF(awk->syscas));
if (syscas->memset == ASE_NULL) awk->syscas.memset = ase_awk_memset;
else sysfns->memcpy (&awk->sysfns, sysfns, ASE_SIZEOF(awk->sysfns));
if (sysfns->memset == ASE_NULL) awk->sysfns.memset = ase_awk_memset;
if (ase_awk_str_open (&awk->token.name, 128, awk) == ASE_NULL)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.163 2006-12-12 05:16:29 bacon Exp $
* $Id: awk.h,v 1.164 2006-12-13 14:13:07 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_H_
@ -13,13 +13,29 @@ typedef struct ase_awk_run_t ase_awk_run_t;
typedef struct ase_awk_val_t ase_awk_val_t;
typedef struct ase_awk_extio_t ase_awk_extio_t;
typedef struct ase_awk_syscas_t ase_awk_syscas_t;
typedef struct ase_awk_sysfns_t ase_awk_sysfns_t;
typedef struct ase_awk_srcios_t ase_awk_srcios_t;
typedef struct ase_awk_runios_t ase_awk_runios_t;
typedef struct ase_awk_runcbs_t ase_awk_runcbs_t;
typedef struct ase_awk_runarg_t ase_awk_runarg_t;
typedef void (*ase_awk_lk_t) (ase_awk_t* awk, void* arg);
typedef void* (*ase_awk_malloc_t) (ase_size_t n, void* custom_data);
typedef void* (*ase_awk_realloc_t) (void* ptr, ase_size_t n, void* custom_data);
typedef void* (*ase_awk_free_t) (void* ptr, void* custom_data);
typedef void* (*ase_awk_memcpy_t) (void* dst, const void* src, ase_size_t n);
typedef void* (*ase_awk_memset_t) (void* dst, int val, ase_size_t n);
typedef ase_bool_t (*ase_awk_isctype_t) (ase_cint_t c);
typedef ase_cint_t (*ase_awk_toctype_t) (ase_cint_t c);
typedef ase_real_t (*ase_awk_pow_t) (ase_real_t x, ase_real_t y);
typedef int (*ase_awk_sprintf_t) (
ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...);
typedef void (*ase_awk_aprintf_t) (const ase_char_t* fmt, ...);
typedef void (*ase_awk_dprintf_t) (const ase_char_t* fmt, ...);
typedef void (*ase_awk_abort_t) (void);
typedef void (*ase_awk_lock_t) (ase_awk_t* awk, void* custom_data);
typedef ase_ssize_t (*ase_awk_io_t) (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
@ -52,43 +68,43 @@ struct ase_awk_extio_t
ase_awk_extio_t* next;
};
struct ase_awk_syscas_t
struct ase_awk_sysfns_t
{
/* memory */
void* (*malloc) (ase_size_t n, void* custom_data);
void* (*realloc) (void* ptr, ase_size_t n, void* custom_data);
void (*free) (void* ptr, void* custom_data);
/* memory allocation/deallocation */
ase_awk_malloc_t malloc; /* required */
ase_awk_realloc_t realloc; /* optional */
ase_awk_free_t free; /* required */
ase_awk_memcpy_t memcpy; /* optional */
ase_awk_memset_t memset; /* optional */
/* thread lock */
ase_awk_lk_t lock;
ase_awk_lk_t unlock;
/* character class */
ase_bool_t (*is_upper) (ase_cint_t c);
ase_bool_t (*is_lower) (ase_cint_t c);
ase_bool_t (*is_alpha) (ase_cint_t c);
ase_bool_t (*is_digit) (ase_cint_t c);
ase_bool_t (*is_xdigit) (ase_cint_t c);
ase_bool_t (*is_alnum) (ase_cint_t c);
ase_bool_t (*is_space) (ase_cint_t c);
ase_bool_t (*is_print) (ase_cint_t c);
ase_bool_t (*is_graph) (ase_cint_t c);
ase_bool_t (*is_cntrl) (ase_cint_t c);
ase_bool_t (*is_punct) (ase_cint_t c);
ase_cint_t (*to_upper) (ase_cint_t c);
ase_cint_t (*to_lower) (ase_cint_t c);
/* character classes */
ase_awk_isctype_t is_upper; /* required */
ase_awk_isctype_t is_lower; /* required */
ase_awk_isctype_t is_alpha; /* required */
ase_awk_isctype_t is_digit; /* required */
ase_awk_isctype_t is_xdigit; /* required */
ase_awk_isctype_t is_alnum; /* required */
ase_awk_isctype_t is_space; /* required */
ase_awk_isctype_t is_print; /* required */
ase_awk_isctype_t is_graph; /* required */
ase_awk_isctype_t is_cntrl; /* required */
ase_awk_isctype_t is_punct; /* required */
ase_awk_toctype_t to_upper; /* required */
ase_awk_toctype_t to_lower; /* required */
/* utilities */
void* (*memcpy) (void* dst, const void* src, ase_size_t n);
void* (*memset) (void* dst, int val, ase_size_t n);
ase_real_t (*pow) (ase_real_t x, ase_real_t y);
ase_awk_pow_t pow; /* required */
ase_awk_sprintf_t sprintf; /* required */
ase_awk_aprintf_t aprintf; /* required in the debug mode */
ase_awk_dprintf_t dprintf; /* required in the debug mode */
ase_awk_abort_t abort; /* required in the debug mode */
int (*sprintf) (ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...);
void (*aprintf) (const ase_char_t* fmt, ...); /* assertion */
void (*dprintf) (const ase_char_t* fmt, ...); /* debug */
void (*abort) (void);
/* thread lock */
ase_awk_lock_t lock; /* required if multi-threaded */
ase_awk_lock_t unlock; /* required if multi-threaded */
void* custom_data;
/* user-defined data passed to selected system functions */
void* custom_data; /* optional */
};
struct ase_awk_srcios_t
@ -367,7 +383,7 @@ enum
extern "C" {
#endif
ase_awk_t* ase_awk_open (const ase_awk_syscas_t* syscas);
ase_awk_t* ase_awk_open (const ase_awk_sysfns_t* sysfns);
int ase_awk_close (ase_awk_t* awk);
int ase_awk_clear (ase_awk_t* awk);

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.89 2006-12-12 05:16:29 bacon Exp $
* $Id: awk_i.h,v 1.90 2006-12-13 14:13:07 bacon Exp $
*/
#ifndef _ASE_AWK_AWKI_H_
@ -45,41 +45,41 @@ typedef struct ase_awk_tree_t ase_awk_tree_t;
#define ASE_AWK_FREE(awk,ptr) free (ptr)
#else
#define ASE_AWK_MALLOC(awk,size) \
(awk)->syscas.malloc (size, (awk)->syscas.custom_data)
(awk)->sysfns.malloc (size, (awk)->sysfns.custom_data)
#define ASE_AWK_REALLOC(awk,ptr,size) \
(awk)->syscas.realloc (ptr, size, (awk)->syscas.custom_data)
(awk)->sysfns.realloc (ptr, size, (awk)->sysfns.custom_data)
#define ASE_AWK_FREE(awk,ptr) \
(awk)->syscas.free (ptr, (awk)->syscas.custom_data)
(awk)->sysfns.free (ptr, (awk)->sysfns.custom_data)
#endif
#define ASE_AWK_LOCK(awk) \
do { \
if ((awk)->syscas.lock != ASE_NULL) \
(awk)->syscas.lock (awk, (awk)->syscas.custom_data); \
if ((awk)->sysfns.lock != ASE_NULL) \
(awk)->sysfns.lock (awk, (awk)->sysfns.custom_data); \
} while (0)
#define ASE_AWK_UNLOCK(awk) \
do { \
if ((awk)->syscas.unlock != ASE_NULL) \
(awk)->syscas.unlock (awk, (awk)->syscas.custom_data); \
if ((awk)->sysfns.unlock != ASE_NULL) \
(awk)->sysfns.unlock (awk, (awk)->sysfns.custom_data); \
} while (0)
#define ASE_AWK_ISUPPER(awk,c) (awk)->syscas.is_upper(c)
#define ASE_AWK_ISLOWER(awk,c) (awk)->syscas.is_lower(c)
#define ASE_AWK_ISALPHA(awk,c) (awk)->syscas.is_alpha(c)
#define ASE_AWK_ISDIGIT(awk,c) (awk)->syscas.is_digit(c)
#define ASE_AWK_ISXDIGIT(awk,c) (awk)->syscas.is_xdigit(c)
#define ASE_AWK_ISALNUM(awk,c) (awk)->syscas.is_alnum(c)
#define ASE_AWK_ISSPACE(awk,c) (awk)->syscas.is_space(c)
#define ASE_AWK_ISPRINT(awk,c) (awk)->syscas.is_print(c)
#define ASE_AWK_ISGRAPH(awk,c) (awk)->syscas.is_graph(c)
#define ASE_AWK_ISCNTRL(awk,c) (awk)->syscas.is_cntrl(c)
#define ASE_AWK_ISPUNCT(awk,c) (awk)->syscas.is_punct(c)
#define ASE_AWK_TOUPPER(awk,c) (awk)->syscas.to_upper(c)
#define ASE_AWK_TOLOWER(awk,c) (awk)->syscas.to_lower(c)
#define ASE_AWK_ISUPPER(awk,c) (awk)->sysfns.is_upper(c)
#define ASE_AWK_ISLOWER(awk,c) (awk)->sysfns.is_lower(c)
#define ASE_AWK_ISALPHA(awk,c) (awk)->sysfns.is_alpha(c)
#define ASE_AWK_ISDIGIT(awk,c) (awk)->sysfns.is_digit(c)
#define ASE_AWK_ISXDIGIT(awk,c) (awk)->sysfns.is_xdigit(c)
#define ASE_AWK_ISALNUM(awk,c) (awk)->sysfns.is_alnum(c)
#define ASE_AWK_ISSPACE(awk,c) (awk)->sysfns.is_space(c)
#define ASE_AWK_ISPRINT(awk,c) (awk)->sysfns.is_print(c)
#define ASE_AWK_ISGRAPH(awk,c) (awk)->sysfns.is_graph(c)
#define ASE_AWK_ISCNTRL(awk,c) (awk)->sysfns.is_cntrl(c)
#define ASE_AWK_ISPUNCT(awk,c) (awk)->sysfns.is_punct(c)
#define ASE_AWK_TOUPPER(awk,c) (awk)->sysfns.to_upper(c)
#define ASE_AWK_TOLOWER(awk,c) (awk)->sysfns.to_lower(c)
#define ASE_AWK_MEMCPY(awk,dst,src,len) (awk)->syscas.memcpy (dst, src, len)
#define ASE_AWK_MEMSET(awk,dst,val,len) (awk)->syscas.memset (dst, val, len)
#define ASE_AWK_MEMCPY(awk,dst,src,len) (awk)->sysfns.memcpy (dst, src, len)
#define ASE_AWK_MEMSET(awk,dst,val,len) (awk)->sysfns.memset (dst, val, len)
struct ase_awk_tree_t
{
@ -96,7 +96,7 @@ struct ase_awk_tree_t
struct ase_awk_t
{
ase_awk_syscas_t syscas;
ase_awk_sysfns_t sysfns;
/* options */
int option;

View File

@ -1,5 +1,5 @@
/*
* $Id: jni.c,v 1.38 2006-12-12 05:44:41 bacon Exp $
* $Id: jni.c,v 1.39 2006-12-13 14:13:07 bacon Exp $
*/
#include <stdio.h>
@ -181,37 +181,37 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
jfieldID fid_handle;
jthrowable except;
ase_awk_t* awk;
ase_awk_syscas_t syscas;
ase_awk_sysfns_t sysfns;
int opt;
memset (&syscas, 0, sizeof(syscas));
syscas.malloc = __awk_malloc;
syscas.realloc = __awk_realloc;
syscas.free = __awk_free;
memset (&sysfns, 0, sizeof(sysfns));
sysfns.malloc = __awk_malloc;
sysfns.realloc = __awk_realloc;
sysfns.free = __awk_free;
syscas.is_upper = iswupper;
syscas.is_lower = iswlower;
syscas.is_alpha = iswalpha;
syscas.is_digit = iswdigit;
syscas.is_xdigit = iswxdigit;
syscas.is_alnum = iswalnum;
syscas.is_space = iswspace;
syscas.is_print = iswprint;
syscas.is_graph = iswgraph;
syscas.is_cntrl = iswcntrl;
syscas.is_punct = iswpunct;
syscas.to_upper = towupper;
syscas.to_lower = towlower;
sysfns.is_upper = iswupper;
sysfns.is_lower = iswlower;
sysfns.is_alpha = iswalpha;
sysfns.is_digit = iswdigit;
sysfns.is_xdigit = iswxdigit;
sysfns.is_alnum = iswalnum;
sysfns.is_space = iswspace;
sysfns.is_print = iswprint;
sysfns.is_graph = iswgraph;
sysfns.is_cntrl = iswcntrl;
sysfns.is_punct = iswpunct;
sysfns.to_upper = towupper;
sysfns.to_lower = towlower;
syscas.memcpy = memcpy;
syscas.memset = memset;
syscas.pow = __awk_pow;
syscas.sprintf = __awk_sprintf;
syscas.aprintf = __awk_aprintf;
syscas.dprintf = __awk_dprintf;
syscas.abort = abort;
sysfns.memcpy = memcpy;
sysfns.memset = memset;
sysfns.pow = __awk_pow;
sysfns.sprintf = __awk_sprintf;
sysfns.aprintf = __awk_aprintf;
sysfns.dprintf = __awk_dprintf;
sysfns.abort = abort;
awk = ase_awk_open (&syscas);
awk = ase_awk_open (&sysfns);
if (awk == NULL)
{
except = (*env)->FindClass (env, CLASS_EXCEPTION);

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c,v 1.44 2006-12-04 07:17:12 bacon Exp $
* $Id: misc.c,v 1.45 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -1087,18 +1087,18 @@ int ase_awk_assertfail (ase_awk_t* awk,
{
if (desc == ASE_NULL)
{
awk->syscas.aprintf (
awk->sysfns.aprintf (
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n"),
file, line, expr);
}
else
{
awk->syscas.aprintf (
awk->sysfns.aprintf (
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n\nDESCRIPTION:\n%s\n"),
file, line, expr, desc);
}
awk->syscas.abort ();
awk->sysfns.abort ();
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: rec.c,v 1.9 2006-12-04 07:17:12 bacon Exp $
* $Id: rec.c,v 1.10 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -302,7 +302,7 @@ static int __recomp_record_fields (
* number of fields that the current record can hold,
* the field spaces are resized */
if (run->awk->syscas.realloc != ASE_NULL)
if (run->awk->sysfns.realloc != ASE_NULL)
{
tmp = ASE_AWK_REALLOC (
run->awk, run->inrec.flds,

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c,v 1.50 2006-12-04 06:50:26 bacon Exp $
* $Id: rex.c,v 1.51 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -718,7 +718,7 @@ static int __build_charset (__builder_t* builder, struct __code_t* cmd)
{
/* invalid range */
#ifdef DEBUG_REX
builder->awk->syscas.dprintf (
builder->awk->sysfns.dprintf (
ASE_T("__build_charset: invalid character set range\n"));
#endif
builder->errnum = ASE_AWK_EREXCRANGE;
@ -751,7 +751,7 @@ static int __build_cclass (__builder_t* builder, ase_char_t* cc)
{
/* wrong class name */
#ifdef DEBUG_REX
builder->awk->syscas.dprintf (
builder->awk->sysfns.dprintf (
ASE_T("__build_cclass: wrong class name\n"));
#endif
builder->errnum = ASE_AWK_EREXCCLASS;
@ -765,7 +765,7 @@ static int __build_cclass (__builder_t* builder, ase_char_t* cc)
builder->ptn.curc.value != ASE_T(':'))
{
#ifdef BUILD_REX
builder->awk->syscas.dprintf (
builder->awk->sysfns.dprintf (
ASE_T("__build_cclass: a colon(:) expected\n"));
#endif
builder->errnum = ASE_AWK_EREXCOLON;
@ -779,7 +779,7 @@ static int __build_cclass (__builder_t* builder, ase_char_t* cc)
builder->ptn.curc.value != ASE_T(']'))
{
#ifdef DEBUG_REX
builder->awk->syscas.dprintf (
builder->awk->sysfns.dprintf (
ASE_T("__build_cclass: ] expected\n"));
#endif
builder->errnum = ASE_AWK_EREXRBRACKET;
@ -960,7 +960,7 @@ static int __add_code (__builder_t* builder, void* data, ase_size_t len)
if (capa == 0) capa = DEF_CODE_CAPA;
while (len > capa - builder->code.size) { capa = capa * 2; }
if (builder->awk->syscas.realloc != ASE_NULL)
if (builder->awk->sysfns.realloc != ASE_NULL)
{
tmp = (ase_byte_t*) ASE_AWK_REALLOC (
builder->awk, builder->code.buf, capa);
@ -1027,7 +1027,7 @@ static const ase_byte_t* __match_pattern (
el = *(ase_size_t*)p; p += ASE_SIZEOF(el);
#ifdef BUILD_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_pattern: NB = %u, EL = %u\n"),
(unsigned)nb, (unsigned)el);
#endif
@ -1215,7 +1215,7 @@ static const ase_byte_t* __match_any_char (
}
#ifdef BUILD_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_any_char: lbound = %u, ubound = %u\n"),
(unsigned int)lbound, (unsigned int)ubound);
#endif
@ -1228,7 +1228,7 @@ static const ase_byte_t* __match_any_char (
}
#ifdef BUILD_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_any_char: max si = %u\n"), (unsigned)si);
#endif
@ -1288,7 +1288,7 @@ static const ase_byte_t* __match_ord_char (
}
#ifdef BUILD_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_ord_char: cc = %c, lbound = %u, ubound = %u\n"),
cc, (unsigned int)lbound, (unsigned int)ubound);
#endif
@ -1303,7 +1303,7 @@ static const ase_byte_t* __match_ord_char (
{
if (&mat->match_ptr[si] >= matcher->match.str.end) break;
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_ord_char: <ignorecase> %c %c\n"),
cc, mat->match_ptr[si]);
#endif
@ -1317,7 +1317,7 @@ static const ase_byte_t* __match_ord_char (
{
if (&mat->match_ptr[si] >= matcher->match.str.end) break;
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_ord_char: %c %c\n"),
cc, mat->match_ptr[si]);
#endif
@ -1327,7 +1327,7 @@ static const ase_byte_t* __match_ord_char (
}
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_ord_char: max occurrences=%u, lbound=%u, ubound=%u\n"),
(unsigned)si, (unsigned)lbound, (unsigned)ubound);
#endif
@ -1359,7 +1359,7 @@ static const ase_byte_t* __match_charset (
csl = *(ase_size_t*)p; p += ASE_SIZEOF(csl);
#ifdef BUILD_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_charset: lbound = %u, ubound = %u\n"),
(unsigned int)lbound, (unsigned int)ubound);
#endif
@ -1384,7 +1384,7 @@ static const ase_byte_t* __match_charset (
p = p + csl - (ASE_SIZEOF(csc) + ASE_SIZEOF(csl));
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_charset: max occurrences=%u, lbound=%u, ubound=%u\n"),
(unsigned)si, (unsigned)lbound, (unsigned)ubound);
#endif
@ -1497,7 +1497,7 @@ static const ase_byte_t* __match_group (
mat2.branch_end = mat->branch_end;
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_group: GROUP si=%d [%s]\n"),
(unsigned)si, mat->match_ptr);
#endif
@ -1598,7 +1598,7 @@ static const ase_byte_t* __match_occurrences (
mat2.branch_end = mat->branch_end;
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match occurrences: si=%u [%s]\n"),
(unsigned)si, mat->match_ptr);
#endif
@ -1638,7 +1638,7 @@ static ase_bool_t __test_charset (
if (matcher->ignorecase)
c1 = ASE_AWK_TOUPPER(matcher->awk, c1);
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_charset: <one> %c %c\n"), c, c1);
#endif
if (c == c1) return ase_true;
@ -1655,7 +1655,7 @@ static ase_bool_t __test_charset (
c2 = ASE_AWK_TOUPPER(matcher->awk, c2);
}
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_charset: <range> %c %c-%c\n"), c, c1, c2);
#endif
if (c >= c1 && c <= c2) return ase_true;
@ -1664,7 +1664,7 @@ static ase_bool_t __test_charset (
{
c1 = *(const ase_char_t*)p;
#ifdef DEBUG_REX
matcher->awk->syscas.dprintf (
matcher->awk->sysfns.dprintf (
ASE_T("__match_charset: <class> %c %s\n"),
c, __char_class[c1].name);
#endif
@ -1749,7 +1749,7 @@ static ase_bool_t __cc_isxdigit (ase_awk_t* awk, ase_char_t c)
void ase_awk_printrex (ase_awk_t* awk, void* rex)
{
__print_pattern (rex);
awk->syscas.dprintf (ASE_T("\n"));
awk->sysfns.dprintf (ASE_T("\n"));
}
static const ase_byte_t* __print_pattern (const ase_byte_t* p)

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.298 2006-12-12 14:34:13 bacon Exp $
* $Id: run.c,v 1.299 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -212,9 +212,9 @@ typedef ase_awk_val_t* (*eval_expr_t) (ase_awk_run_t* run, ase_awk_nde_t* nde);
static int __printval (ase_awk_pair_t* pair, void* arg)
{
ase_awk_run_t* run = (ase_awk_run_t*)arg;
run->awk->syscas.dprintf (ASE_T("%s = "), (const ase_char_t*)pair->key);
run->awk->sysfns.dprintf (ASE_T("%s = "), (const ase_char_t*)pair->key);
ase_awk_dprintval (run, (ase_awk_val_t*)pair->val);
run->awk->syscas.dprintf (ASE_T("\n"));
run->awk->sysfns.dprintf (ASE_T("\n"));
return 0;
}
#endif
@ -1211,6 +1211,7 @@ static int __run_main (
if (runarg != ASE_NULL)
{
/* prepare to pass the arguments to the main function */
for (i = nrunargs; i > 0; )
{
ase_awk_nde_str_t* tmp, * tmp2;
@ -1265,6 +1266,11 @@ static int __run_main (
if (v == ASE_NULL) n = -1;
else
{
#ifdef _DEBUG
run->awk->sysfns.dprintf (ASE_T("[RETURN] - "));
ase_awk_dprintval (run, v);
run->awk->sysfns.dprintf (ASE_T("\n"));
#endif
/* destroy the return value if necessary */
ase_awk_refupval (run, v);
ase_awk_refdownval (run, v);
@ -1368,9 +1374,9 @@ static int __run_main (
v = STACK_RETVAL(run);
#ifdef _DEBUG
run->awk->syscas.dprintf (ASE_T("[RETURN] - "));
run->awk->sysfns.dprintf (ASE_T("[RETURN] - "));
ase_awk_dprintval (run, v);
run->awk->syscas.dprintf (ASE_T("\n"));
run->awk->sysfns.dprintf (ASE_T("\n"));
#endif
/* the life of the global return value is over here
@ -1397,9 +1403,9 @@ static int __run_main (
run->exit_level = EXIT_NONE;
#ifdef _DEBUG
run->awk->syscas.dprintf (ASE_T("[VARIABLES]\n"));
run->awk->sysfns.dprintf (ASE_T("[VARIABLES]\n"));
ase_awk_map_walk (&run->named, __printval, run);
run->awk->syscas.dprintf (ASE_T("[END VARIABLES]\n"));
run->awk->sysfns.dprintf (ASE_T("[END VARIABLES]\n"));
#endif
return n;
@ -1661,7 +1667,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
p = nde->body;
nlocals = nde->nlocals;
/*run->awk->syscas.dprintf (ASE_T("securing space for local variables nlocals = %d\n"), (int)nlocals);*/
/*run->awk->sysfns.dprintf (ASE_T("securing space for local variables nlocals = %d\n"), (int)nlocals);*/
saved_stack_top = run->stack_top;
/* secure space for local variables */
@ -1678,10 +1684,10 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
/* refupval is not required for ase_awk_val_nil */
}
/*run->awk->syscas.dprintf (ASE_T("executing block statements\n"));*/
/*run->awk->sysfns.dprintf (ASE_T("executing block statements\n"));*/
while (p != ASE_NULL && run->exit_level == EXIT_NONE)
{
/*run->awk->syscas.dprintf (ASE_T("running a statement\n"));*/
/*run->awk->sysfns.dprintf (ASE_T("running a statement\n"));*/
if (__run_statement(run,p) == -1)
{
n = -1;
@ -1690,7 +1696,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
p = p->next;
}
/*run->awk->syscas.dprintf (ASE_T("popping off local variables\n"));*/
/*run->awk->sysfns.dprintf (ASE_T("popping off local variables\n"));*/
/* pop off local variables */
nlocals = nde->nlocals;
while (nlocals > 0)
@ -2107,14 +2113,14 @@ static int __run_return (ase_awk_run_t* run, ase_awk_nde_return_t* nde)
* by the parser first of all */
ASE_AWK_ASSERT (run->awk, nde->val->next == ASE_NULL);
/*run->awk->syscas.dprintf (ASE_T("returning....\n"));*/
/*run->awk->sysfns.dprintf (ASE_T("returning....\n"));*/
val = __eval_expression (run, nde->val);
if (val == ASE_NULL) return -1;
ase_awk_refdownval (run, STACK_RETVAL(run));
STACK_RETVAL(run) = val;
ase_awk_refupval (run, val); /* see __eval_call for the trick */
/*run->awk->syscas.dprintf (ASE_T("set return value....\n"));*/
/*run->awk->sysfns.dprintf (ASE_T("set return value....\n"));*/
}
run->exit_level = EXIT_FUNCTION;
@ -3056,7 +3062,7 @@ static ase_awk_val_t* __do_assignment_map (
str = __idxnde_to_str (run, var->idx, &len);
if (str == ASE_NULL) return ASE_NULL;
/*run->awk->syscas.dprintf (ASE_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)map->ref, (int)map->type);*/
/*run->awk->sysfns.dprintf (ASE_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)map->ref, (int)map->type);*/
n = ase_awk_map_putx (map->map, str, len, val, ASE_NULL);
if (n < 0)
{
@ -4008,7 +4014,7 @@ static ase_awk_val_t* __eval_binop_exp (
ase_real_t r1, r2;
ase_awk_val_t* res;
ASE_AWK_ASSERTX (run->awk, run->awk->syscas.pow != ASE_NULL,
ASE_AWK_ASSERTX (run->awk, run->awk->sysfns.pow != ASE_NULL,
"the pow function should be provided when the awk object is created to make the exponentiation work properly.");
n1 = ase_awk_valtonum (run, left, &l1, &r1);
@ -4063,14 +4069,14 @@ static ase_awk_val_t* __eval_binop_exp (
{
/* left - int, right - real */
res = ase_awk_makerealval (run,
run->awk->syscas.pow((ase_real_t)l1,(ase_real_t)r2));
run->awk->sysfns.pow((ase_real_t)l1,(ase_real_t)r2));
}
else
{
/* left - real, right - real */
ASE_AWK_ASSERT (run->awk, n3 == 3);
res = ase_awk_makerealval (run,
run->awk->syscas.pow((ase_real_t)r1,(ase_real_t)r2));
run->awk->sysfns.pow((ase_real_t)r1,(ase_real_t)r2));
}
if (res == ASE_NULL) PANIC (run, ASE_AWK_ENOMEM);
@ -4868,7 +4874,7 @@ static ase_awk_val_t* __eval_call (
saved_stack_top = run->stack_top;
/*run->awk->syscas.dprintf (ASE_T("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */
/*run->awk->sysfns.dprintf (ASE_T("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */
if (__raw_push(run,(void*)run->stack_base) == -1)
{
PANIC (run, ASE_AWK_ENOMEM);
@ -4981,7 +4987,7 @@ static ase_awk_val_t* __eval_call (
run->stack_base = saved_stack_top;
STACK_NARGS(run) = (void*)nargs;
/*run->awk->syscas.dprintf (ASE_T("running function body\n")); */
/*run->awk->sysfns.dprintf (ASE_T("running function body\n")); */
if (afn != ASE_NULL)
{
@ -5007,16 +5013,16 @@ static ase_awk_val_t* __eval_call (
}
}
/*run->awk->syscas.dprintf (ASE_T("block run complete\n")); */
/*run->awk->sysfns.dprintf (ASE_T("block run complete\n")); */
/* refdown args in the run.stack */
nargs = (ase_size_t)STACK_NARGS(run);
/*run->awk->syscas.dprintf (ASE_T("block run complete nargs = %d\n"), (int)nargs); */
/*run->awk->sysfns.dprintf (ASE_T("block run complete nargs = %d\n"), (int)nargs); */
for (i = 0; i < nargs; i++)
{
ase_awk_refdownval (run, STACK_ARG(run,i));
}
/*run->awk->syscas.dprintf (ASE_T("got return value\n")); */
/*run->awk->sysfns.dprintf (ASE_T("got return value\n")); */
/* this trick has been mentioned in __run_return.
* adjust the reference count of the return value.
@ -5031,7 +5037,7 @@ static ase_awk_val_t* __eval_call (
if (run->exit_level == EXIT_FUNCTION) run->exit_level = EXIT_NONE;
/*run->awk->syscas.dprintf (ASE_T("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */
/*run->awk->sysfns.dprintf (ASE_T("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */
return (n == -1)? ASE_NULL: v;
}
@ -5531,7 +5537,7 @@ static int __raw_push (ase_awk_run_t* run, void* val)
n = run->stack_limit + STACK_INCREMENT;
if (run->awk->syscas.realloc != ASE_NULL)
if (run->awk->sysfns.realloc != ASE_NULL)
{
tmp = (void**) ASE_AWK_REALLOC (
run->awk, run->stack, n * ASE_SIZEOF(void*));
@ -5584,7 +5590,7 @@ static int __read_record (ase_awk_run_t* run)
return -1;
}
/*
run->awk->syscas.dprintf (ASE_T("len = %d str=[%s]\n"),
run->awk->sysfns.dprintf (ASE_T("len = %d str=[%s]\n"),
(int)ASE_AWK_STR_LEN(&run->inrec.line),
ASE_AWK_STR_BUF(&run->inrec.line));
*/
@ -5894,7 +5900,7 @@ ase_char_t* ase_awk_format (
do
{
n = run->awk->syscas.sprintf (
n = run->awk->sysfns.sprintf (
run->format.tmp.ptr,
run->format.tmp.len,
#if ASE_SIZEOF_LONG_LONG > 0
@ -5997,7 +6003,7 @@ ase_char_t* ase_awk_format (
do
{
n = run->awk->syscas.sprintf (
n = run->awk->sysfns.sprintf (
run->format.tmp.ptr,
run->format.tmp.len,
#if ASE_SIZEOF_LONG_LONG > 0
@ -6117,7 +6123,7 @@ ase_char_t* ase_awk_format (
do
{
n = run->awk->syscas.sprintf (
n = run->awk->sysfns.sprintf (
run->format.tmp.ptr,
run->format.tmp.len,
ASE_AWK_STR_BUF(fbu),
@ -6204,7 +6210,7 @@ ase_char_t* ase_awk_format (
do
{
n = run->awk->syscas.sprintf (
n = run->awk->sysfns.sprintf (
run->format.tmp.ptr,
run->format.tmp.len,
ASE_AWK_STR_BUF(fbu),

View File

@ -1,5 +1,5 @@
/*
* $Id: str.c,v 1.12 2006-11-29 02:54:16 bacon Exp $
* $Id: str.c,v 1.13 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -109,7 +109,7 @@ ase_size_t ase_awk_str_ncat (
/* double the capa if necessary for concatenation */
if (capa < str->capa * 2) capa = str->capa * 2;
if (str->awk->syscas.realloc != ASE_NULL)
if (str->awk->sysfns.realloc != ASE_NULL)
{
tmp = (ase_char_t*) ASE_AWK_REALLOC (
str->awk, str->buf,

View File

@ -1,5 +1,5 @@
/*
* $Id: tab.c,v 1.25 2006-11-29 02:54:16 bacon Exp $
* $Id: tab.c,v 1.26 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -58,7 +58,7 @@ ase_awk_tab_t* ase_awk_tab_setcapa (ase_awk_tab_t* tab, ase_size_t capa)
if (capa > 0)
{
if (tab->awk->syscas.realloc != ASE_NULL)
if (tab->awk->sysfns.realloc != ASE_NULL)
{
tmp = ASE_AWK_REALLOC (tab->awk,
tab->buf, ASE_SIZEOF(*tab->buf) * capa);

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.c,v 1.96 2006-12-12 05:16:30 bacon Exp $
* $Id: tree.c,v 1.97 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -252,11 +252,11 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
{
ase_char_t tmp[256];
#if (ASE_SIZEOF_LONG_DOUBLE != 0)
awk->syscas.sprintf (
awk->sysfns.sprintf (
tmp, ASE_COUNTOF(tmp), ASE_T("%Lf"),
(long double)((ase_awk_nde_real_t*)nde)->val);
#elif (ASE_SIZEOF_DOUBLE != 0)
awk->syscas.sprintf (
awk->sysfns.sprintf (
tmp, ASE_COUNTOF(tmp), ASE_T("%f"),
(double)((ase_awk_nde_real_t*)nde)->val);
#else

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.96 2006-12-04 12:58:24 bacon Exp $
* $Id: val.c,v 1.97 2006-12-13 14:13:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -331,9 +331,9 @@ void ase_awk_refupval (ase_awk_run_t* run, ase_awk_val_t* val)
if (ase_awk_isbuiltinval(val)) return;
/*
run->awk->syscas.dprintf (ASE_T("ref up [ptr=%p] [count=%d] "), val, (int)val->ref);
run->awk->sysfns.dprintf (ASE_T("ref up [ptr=%p] [count=%d] "), val, (int)val->ref);
ase_awk_dprintval (run, val);
run->awk->syscas.dprintf (ASE_T("\n"));
run->awk->sysfns.dprintf (ASE_T("\n"));
*/
val->ref++;
@ -344,9 +344,9 @@ void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val)
if (ase_awk_isbuiltinval(val)) return;
/*
run->awk->syscas.dprintf (ASE_T("ref down [ptr=%p] [count=%d]\n"), val, (int)val->ref);
run->awk->sysfns.dprintf (ASE_T("ref down [ptr=%p] [count=%d]\n"), val, (int)val->ref);
ase_awk_dprintval (run, val);
run->awk->syscas.dprintf (ASE_T("\n"));
run->awk->sysfns.dprintf (ASE_T("\n"));
*/
ASE_AWK_ASSERTX (run->awk, val->ref > 0,
@ -454,7 +454,7 @@ ase_char_t* ase_awk_valtostr (
}
/* TODO: process more value types */
run->awk->syscas.dprintf (
run->awk->sysfns.dprintf (
ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtostr\n"),
v->type);
@ -708,7 +708,7 @@ int ase_awk_valtonum (
}
#ifdef _DEBUG
run->awk->syscas.dprintf (
run->awk->sysfns.dprintf (
ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtonum\n"),
v->type);
#endif
@ -737,7 +737,7 @@ int ase_awk_strtonum (
}
#define __DPRINTF run->awk->syscas.dprintf
#define __DPRINTF run->awk->sysfns.dprintf
static int __print_pair (ase_awk_pair_t* pair, void* arg)
{