*** empty log message ***

This commit is contained in:
hyung-hwan 2006-10-12 14:36:25 +00:00
parent e94b5729ef
commit 85a2b9c33b
12 changed files with 112 additions and 69 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.79 2006-10-12 04:17:30 bacon Exp $
* $Id: awk.c,v 1.80 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -41,7 +41,13 @@ xp_awk_t* xp_awk_open (xp_awk_syscas_t* syscas)
#endif
if (awk == XP_NULL) return XP_NULL;
awk->syscas = syscas;
if (syscas->memcpy == XP_NULL)
{
xp_awk_memcpy (&awk->syscas, syscas, xp_sizeof(awk->syscas));
awk->syscas.memcpy = xp_awk_memcpy;
}
else syscas->memcpy (&awk->syscas, syscas, xp_sizeof(awk->syscas));
if (syscas->memset == XP_NULL) awk->syscas.memset = xp_awk_memset;
if (xp_awk_str_open (&awk->token.name, 128, awk) == XP_NULL)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.64 2006-10-12 04:17:30 bacon Exp $
* $Id: awk_i.h,v 1.65 2006-10-12 14:36:25 bacon Exp $
*/
#ifndef _XP_AWK_AWKI_H_
@ -45,52 +45,41 @@ typedef struct xp_awk_tree_t xp_awk_tree_t;
#define XP_AWK_FREE(awk,ptr) free (ptr)
#else
#define XP_AWK_MALLOC(awk,size) \
(awk)->syscas->malloc (size, (awk)->syscas->custom_data)
(awk)->syscas.malloc (size, (awk)->syscas.custom_data)
#define XP_AWK_REALLOC(awk,ptr,size) \
(awk)->syscas->realloc (ptr, size, (awk)->syscas->custom_data)
(awk)->syscas.realloc (ptr, size, (awk)->syscas.custom_data)
#define XP_AWK_FREE(awk,ptr) \
(awk)->syscas->free (ptr, (awk)->syscas->custom_data)
(awk)->syscas.free (ptr, (awk)->syscas.custom_data)
#endif
#define XP_AWK_LOCK(awk) \
do { \
if ((awk)->syscas != XP_NULL && (awk)->syscas->lock != XP_NULL) \
(awk)->syscas->lock (awk, (awk)->syscas->custom_data); \
if ((awk)->syscas.lock != XP_NULL) \
(awk)->syscas.lock (awk, (awk)->syscas.custom_data); \
} while (0)
#define XP_AWK_UNLOCK(awk) \
do { \
if ((awk)->syscas != XP_NULL && (awk)->syscas->unlock != XP_NULL) \
(awk)->syscas->unlock (awk, (awk)->syscas->custom_data); \
if ((awk)->syscas.unlock != XP_NULL) \
(awk)->syscas.unlock (awk, (awk)->syscas.custom_data); \
} while (0)
#define XP_AWK_ISUPPER(awk,c) (awk)->syscas->is_upper(c)
#define XP_AWK_ISLOWER(awk,c) (awk)->syscas->is_lower(c)
#define XP_AWK_ISALPHA(awk,c) (awk)->syscas->is_alpha(c)
#define XP_AWK_ISDIGIT(awk,c) (awk)->syscas->is_digit(c)
#define XP_AWK_ISXDIGIT(awk,c) (awk)->syscas->is_xdigit(c)
#define XP_AWK_ISALNUM(awk,c) (awk)->syscas->is_alnum(c)
#define XP_AWK_ISSPACE(awk,c) (awk)->syscas->is_space(c)
#define XP_AWK_ISPRINT(awk,c) (awk)->syscas->is_print(c)
#define XP_AWK_ISGRAPH(awk,c) (awk)->syscas->is_graph(c)
#define XP_AWK_ISCNTRL(awk,c) (awk)->syscas->is_cntrl(c)
#define XP_AWK_ISPUNCT(awk,c) (awk)->syscas->is_punct(c)
#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_ISUPPER(awk,c) (awk)->syscas.is_upper(c)
#define XP_AWK_ISLOWER(awk,c) (awk)->syscas.is_lower(c)
#define XP_AWK_ISALPHA(awk,c) (awk)->syscas.is_alpha(c)
#define XP_AWK_ISDIGIT(awk,c) (awk)->syscas.is_digit(c)
#define XP_AWK_ISXDIGIT(awk,c) (awk)->syscas.is_xdigit(c)
#define XP_AWK_ISALNUM(awk,c) (awk)->syscas.is_alnum(c)
#define XP_AWK_ISSPACE(awk,c) (awk)->syscas.is_space(c)
#define XP_AWK_ISPRINT(awk,c) (awk)->syscas.is_print(c)
#define XP_AWK_ISGRAPH(awk,c) (awk)->syscas.is_graph(c)
#define XP_AWK_ISCNTRL(awk,c) (awk)->syscas.is_cntrl(c)
#define XP_AWK_ISPUNCT(awk,c) (awk)->syscas.is_punct(c)
#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)
#define XP_AWK_MEMCPY(awk,dst,src,len) (awk)->syscas.memcpy (dst, src, len)
#define XP_AWK_MEMSET(awk,dst,val,len) (awk)->syscas.memset (dst, val, len)
struct xp_awk_tree_t
{
@ -106,7 +95,7 @@ struct xp_awk_tree_t
struct xp_awk_t
{
xp_awk_syscas_t* syscas;
xp_awk_syscas_t syscas;
/* options */
int option;

View File

@ -1,10 +1,14 @@
/*
* $Id: jni.c,v 1.4 2006-08-06 15:02:55 bacon Exp $
* $Id: jni.c,v 1.5 2006-10-12 14:36:25 bacon Exp $
*/
#include "jni.h"
#include "awk.h"
#include "sa.h"
#include <xp/awk/jni.h>
#include <xp/awk/awk.h>
#include <stdlib.h>
#include <string.h>
#include <wctype.h>
#include <wchar.h>
#include <stdio.h>
#define EXCEPTION_AWK "xpkit/xpj/awk/AwkException"
#define FIELD_AWK "__awk"
@ -27,6 +31,20 @@ struct srcio_data_t
jobject obj;
};
static void* __awk_malloc (xp_size_t n, void* custom_data)
{
return malloc (n);
}
static void* __awk_realloc (void* ptr, xp_size_t n, void* custom_data)
{
return realloc (ptr, n);
}
static void __awk_free (void* ptr, void* custom_data)
{
free (ptr);
}
JNIEXPORT void JNICALL Java_xpkit_xpj_awk_Awk_open (JNIEnv* env, jobject obj)
{
@ -34,11 +52,38 @@ JNIEXPORT void JNICALL Java_xpkit_xpj_awk_Awk_open (JNIEnv* env, jobject obj)
jfieldID fid;
jthrowable except;
xp_awk_t* awk;
xp_awk_syscas_t syscas;
int opt;
class = (*env)->GetObjectClass(env, obj);
awk = xp_awk_open ();
memset (&syscas, 0, sizeof(syscas));
syscas.malloc = __awk_malloc;
syscas.realloc = __awk_realloc;
syscas.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;
syscas.memcpy = memcpy;
syscas.memset = memset;
/* TODO: */
syscas.sprintf = _snwprintf;
syscas.dprintf = wprintf;
syscas.abort = abort;
awk = xp_awk_open (&syscas);
if (awk == NULL)
{
except = (*env)->FindClass (env, EXCEPTION_AWK);
@ -57,7 +102,7 @@ JNIEXPORT void JNICALL Java_xpkit_xpj_awk_Awk_open (JNIEnv* env, jobject obj)
XP_AWK_EXTIO | XP_AWK_BLOCKLESS;
xp_awk_setopt (awk, opt);
xp_printf (XP_T("__awk(native) done => %u, 0x%X\n"), awk, awk);
printf ("__awk(native) done => %u, 0x%X\n", awk, awk);
}
JNIEXPORT void JNICALL Java_xpkit_xpj_awk_Awk_close (JNIEnv* env, jobject obj)
@ -73,7 +118,7 @@ JNIEXPORT void JNICALL Java_xpkit_xpj_awk_Awk_close (JNIEnv* env, jobject obj)
xp_awk_close ((xp_awk_t*) (*env)->GetLongField (env, obj, fid));
(*env)->SetLongField (env, obj, fid, (jlong)0);
xp_printf (XP_T("close (native) done\n"));
printf ("close (native) done\n");
}
JNIEXPORT void JNICALL Java_xpkit_xpj_awk_Awk_parse (JNIEnv* env, jobject obj)
@ -100,12 +145,14 @@ JNIEXPORT void JNICALL Java_xpkit_xpj_awk_Awk_parse (JNIEnv* env, jobject obj)
srcios.out = __write_source;
srcios.custom_data = &srcio_data;
printf ("OK.......\n");
if (xp_awk_parse (awk, &srcios) == -1)
{
printf ("parse error.......\n");
except = (*env)->FindClass (env, EXCEPTION_AWK);
if (except == 0) return;
(*env)->ThrowNew (env, except, "ERROR ....");
xp_printf (XP_T("parse error -> line [%d] %s\n"), xp_awk_getsrcline(awk), xp_awk_geterrstr(awk));
printf ("parse error -> line [%d] %S\n", xp_awk_getsrcline(awk), xp_awk_geterrstr(xp_awk_geterrnum(awk)));
return;
}
}
@ -122,6 +169,7 @@ static xp_ssize_t __read_source (
srcio_data = (srcio_data_t*)arg;
if (cmd == XP_AWK_IO_OPEN || cmd == XP_AWK_IO_CLOSE) return 0;
if (cmd == XP_AWK_IO_READ)
{
return __call_java_read_source (

View File

@ -9,24 +9,24 @@ JAVA_INC = \
/I"C:\Program Files\IBM\Java141\Include\Win32"
CC = cl
#CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../..
CFLAGS = /nologo /O2 /MT /W3 /GR- /Za /D_WIN32_WINNT=0x0400 -I../.. -DXP_AWK_STAND_ALONE -DXP_CHAR_IS_WCHAR $(JAVA_INC)
LD = link
CFLAGS = /nologo /O2 /MT /W3 /GR- /Za /D_WIN32_WINNT=0x0400 -I../.. -DXP_CHAR_IS_WCHAR $(JAVA_INC)
all: lib
lib: $(OBJS)
link /lib @<<
$(LD) /lib @<<
/nologo /out:$(OUT).lib $(OBJS)
<<
dll: $(OBJS)
link /dll /def:awk.def /subsystem:console /version:0.1 /release @<<
$(LD) /dll /def:awk.def /subsystem:console /version:0.1 /release @<<
/nologo /out:$(OUT).dll $(OBJS)
<<
jni: $(OBJS) jni.obj
link /dll /def:jni.def /subsystem:console /version:0.1 /release @<<
/nologo /out:$(OUT).dll $(OBJS) jni.obj
$(LD) /dll /def:jni.def /subsystem:console /version:0.1 /release @<<
/nologo /out:$(OUT).dll $(OBJS) jni.obj ..\bas\xpbas.lib
<<
clean:

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c,v 1.27 2006-10-12 04:17:31 bacon Exp $
* $Id: misc.c,v 1.28 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -1063,9 +1063,9 @@ exit_loop:
int xp_awk_abort (xp_awk_t* awk,
const xp_char_t* expr, const xp_char_t* file, int line)
{
awk->syscas->dprintf (
awk->syscas.dprintf (
XP_T("ASSERTION FAILURE AT FILE %s, LINE %d\n%s\n"),
file, line, expr);
awk->syscas->abort ();
awk->syscas.abort ();
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: rec.c,v 1.2 2006-10-12 04:17:31 bacon Exp $
* $Id: rec.c,v 1.3 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -301,7 +301,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 != XP_NULL)
if (run->awk->syscas.realloc != XP_NULL)
{
tmp = XP_AWK_REALLOC (
run->awk, run->inrec.flds,

View File

@ -1,5 +1,5 @@
/*
* $Id: rex.c,v 1.35 2006-10-12 04:17:31 bacon Exp $
* $Id: rex.c,v 1.36 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -958,7 +958,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 != XP_NULL)
if (builder->awk->syscas.realloc != XP_NULL)
{
tmp = (xp_byte_t*) XP_AWK_REALLOC (
builder->awk, builder->code.buf, capa);

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.233 2006-10-12 04:17:31 bacon Exp $
* $Id: run.c,v 1.234 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -4885,7 +4885,7 @@ static int __raw_push (xp_awk_run_t* run, void* val)
n = run->stack_limit + STACK_INCREMENT;
if (run->awk->syscas->realloc != XP_NULL)
if (run->awk->syscas.realloc != XP_NULL)
{
tmp = (void**) XP_AWK_REALLOC (
run->awk, run->stack, n * xp_sizeof(void*));

View File

@ -1,5 +1,5 @@
/*
* $Id: str.c,v 1.7 2006-09-28 06:56:30 bacon Exp $
* $Id: str.c,v 1.8 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -106,7 +106,7 @@ xp_size_t xp_awk_str_ncat (xp_awk_str_t* str, const xp_char_t* s, xp_size_t len)
/* double the capa if necessary for concatenation */
if (capa < str->capa * 2) capa = str->capa * 2;
if (str->awk->syscas->realloc != XP_NULL)
if (str->awk->syscas.realloc != XP_NULL)
{
tmp = (xp_char_t*) XP_AWK_REALLOC (
str->awk, str->buf,

View File

@ -1,5 +1,5 @@
/*
* $Id: tab.c,v 1.20 2006-10-12 04:17:31 bacon Exp $
* $Id: tab.c,v 1.21 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -58,7 +58,7 @@ xp_awk_tab_t* xp_awk_tab_setcapa (xp_awk_tab_t* tab, xp_size_t capa)
if (capa > 0)
{
if (tab->awk->syscas->realloc != XP_NULL)
if (tab->awk->syscas.realloc != XP_NULL)
{
tmp = XP_AWK_REALLOC (tab->awk,
tab->buf, xp_sizeof(*tab->buf) * capa);

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.c,v 1.79 2006-10-12 04:17:31 bacon Exp $
* $Id: tree.c,v 1.80 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -248,11 +248,11 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
{
xp_char_t tmp[128];
#if (XP_SIZEOF_LONG_DOUBLE != 0)
awk->syscas->sprintf (
awk->syscas.sprintf (
tmp, xp_countof(tmp), XP_T("%Lf"),
(long double)((xp_awk_nde_real_t*)nde)->val);
#elif (XP_SIZEOF_DOUBLE != 0)
awk->syscas->sprintf (
awk->syscas.sprintf (
tmp, xp_countof(tmp), XP_T("%f"),
(double)((xp_awk_nde_real_t*)nde)->val);
#else

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.72 2006-10-12 04:17:31 bacon Exp $
* $Id: val.c,v 1.73 2006-10-12 14:36:25 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -572,7 +572,7 @@ static xp_char_t* __val_real_to_str (
/* TODO: need to use awk's own version of sprintf so that it would have
* problems with handling long double or double... */
/* TODO: does it need to check if a null character is included in convfmt??? */
run->awk->syscas->sprintf (tbuf, xp_countof(tbuf), tmp, (double)v->val);
run->awk->syscas.sprintf (tbuf, xp_countof(tbuf), tmp, (double)v->val);
if (buf == XP_NULL)
{
tmp = xp_awk_strdup (run->awk, tbuf);