From ed79190a0ce69edc220f2a80d2cda80dc46f3a53 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 2 Mar 2007 10:06:17 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.c | 8 ++++- ase/awk/awk.h | 3 +- ase/awk/awk_i.h | 4 ++- ase/awk/run.c | 34 ++++++++++----------- ase/cmn/makefile.msw.bcc | 2 +- ase/cmn/makefile.msw.cl | 23 ++++++++++++++ ase/doc/awk-en.man | 65 ++++++++++++++++++++++++++++++++-------- 7 files changed, 104 insertions(+), 35 deletions(-) create mode 100644 ase/cmn/makefile.msw.cl diff --git a/ase/awk/awk.c b/ase/awk/awk.c index 134103ab..0403b629 100644 --- a/ase/awk/awk.c +++ b/ase/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.110 2007-02-24 14:31:43 bacon Exp $ + * $Id: awk.c,v 1.111 2007-03-02 10:06:17 bacon Exp $ * * {License} */ @@ -151,8 +151,10 @@ ase_awk_t* ase_awk_open ( ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_BUILD, 0); ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_MATCH, 0); + /* awk->run.count = 0; awk->run.ptr = ASE_NULL; + */ awk->custom_data = custom_data; return awk; @@ -174,7 +176,9 @@ int ase_awk_close (ase_awk_t* awk) if (ase_awk_clear (awk) == -1) return -1; ase_awk_clrbfn (awk); + /* ASE_AWK_ASSERT (awk, awk->run.count == 0 && awk->run.ptr == ASE_NULL); + */ ase_awk_map_close (&awk->tree.afns); ase_awk_tab_close (&awk->parse.globals); @@ -191,11 +195,13 @@ int ase_awk_close (ase_awk_t* awk) int ase_awk_clear (ase_awk_t* awk) { /* you should stop all running instances beforehand */ + /* if (awk->run.ptr != ASE_NULL) { awk->errnum = ASE_AWK_ERUNNING; return -1; } + */ ase_memset (&awk->src.ios, 0, ASE_SIZEOF(awk->src.ios)); awk->src.lex.curc = ASE_CHAR_EOF; diff --git a/ase/awk/awk.h b/ase/awk/awk.h index 5ab7d6c7..462ba778 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.192 2007-02-24 14:31:43 bacon Exp $ + * $Id: awk.h,v 1.193 2007-03-02 10:06:17 bacon Exp $ * * {License} */ @@ -435,7 +435,6 @@ int ase_awk_run ( ase_awk_runarg_t* runarg, void* custom_data); int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run); -void ase_awk_stopall (ase_awk_t* awk); /* functions to access internal stack structure */ ase_size_t ase_awk_getnargs (ase_awk_run_t* run); diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h index d1c69eaa..37b76ad0 100644 --- a/ase/awk/awk_i.h +++ b/ase/awk/awk_i.h @@ -1,5 +1,5 @@ /* - * $Id: awk_i.h,v 1.103 2007-02-23 15:18:36 bacon Exp $ + * $Id: awk_i.h,v 1.104 2007-03-02 10:06:17 bacon Exp $ * * {License} */ @@ -189,8 +189,10 @@ struct ase_awk_t struct { + /* ase_size_t count; ase_awk_run_t* ptr; + */ struct { diff --git a/ase/awk/run.c b/ase/awk/run.c index 6c3eaa6d..b0f77711 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.331 2007-02-28 11:00:33 bacon Exp $ + * $Id: run.c,v 1.332 2007-03-02 10:06:17 bacon Exp $ * * {License} */ @@ -55,8 +55,10 @@ static int __set_global ( ase_awk_run_t* run, ase_size_t idx, ase_awk_nde_var_t* var, ase_awk_val_t* val); +/* static void __add_run (ase_awk_t* awk, ase_awk_run_t* run); static void __del_run (ase_awk_t* awk, ase_awk_run_t* run); +*/ static int __init_run ( ase_awk_run_t* run, ase_awk_t* awk, @@ -663,7 +665,7 @@ int ase_awk_run (ase_awk_t* awk, ase_memset (run, 0, ASE_SIZEOF(ase_awk_run_t)); /* add the run object to the awk object */ - __add_run (awk, run); + /*__add_run (awk, run);*/ /* initialize the run object */ if (__init_run (run, awk, runios, custom_data, &errnum) == -1) @@ -672,7 +674,7 @@ int ase_awk_run (ase_awk_t* awk, * the awk object */ ase_awk_seterror (awk, errnum, 0, ASE_NULL); - __del_run (awk, run); + /*__del_run (awk, run);*/ ASE_AWK_FREE (awk, run); return -1; } @@ -722,7 +724,7 @@ int ase_awk_run (ase_awk_t* awk, __deinit_run (run); /* unregister the run object */ - __del_run (awk, run); + /*__del_run (awk, run);*/ ASE_AWK_FREE (awk, run); return n; @@ -730,8 +732,10 @@ int ase_awk_run (ase_awk_t* awk, int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run) { + /* ase_awk_run_t* r; int n = 0; + */ if (ase_awk_getrunawk(run) != awk) { @@ -739,6 +743,11 @@ int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run) return -1; } + + run->exit_level = EXIT_ABORT; + return 0; + +#if 0 ASE_AWK_LOCK (awk); /* check if the run handle given is valid */ @@ -763,20 +772,7 @@ int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run) ASE_AWK_UNLOCK (awk); return n; -} - -void ase_awk_stopall (ase_awk_t* awk) -{ - ase_awk_run_t* r; - - ASE_AWK_LOCK (awk); - - for (r = awk->run.ptr; r != ASE_NULL; r = r->next) - { - r->exit_level = EXIT_ABORT; - } - - ASE_AWK_UNLOCK (awk); +#endif } static void __free_namedval (void* run, void* val) @@ -784,6 +780,7 @@ static void __free_namedval (void* run, void* val) ase_awk_refdownval ((ase_awk_run_t*)run, val); } +/* static void __add_run (ase_awk_t* awk, ase_awk_run_t* run) { ASE_AWK_LOCK (awk); @@ -820,6 +817,7 @@ static void __del_run (ase_awk_t* awk, ase_awk_run_t* run) ASE_AWK_UNLOCK (awk); } +*/ static int __init_run ( ase_awk_run_t* run, ase_awk_t* awk, diff --git a/ase/cmn/makefile.msw.bcc b/ase/cmn/makefile.msw.bcc index f7ccc884..f49a17c0 100644 --- a/ase/cmn/makefile.msw.bcc +++ b/ase/cmn/makefile.msw.bcc @@ -1,6 +1,6 @@ OUT = asecmn -C_SRCS = mem.c str.c rex.c +C_SRCS = mem.c str.c C_OBJS = $(C_SRCS:.c=.obj) CC = bcc32 diff --git a/ase/cmn/makefile.msw.cl b/ase/cmn/makefile.msw.cl new file mode 100644 index 00000000..0d01bdf3 --- /dev/null +++ b/ase/cmn/makefile.msw.cl @@ -0,0 +1,23 @@ +OUT = asecmn + +C_SRCS = mem.c str.c +C_OBJS = $(C_SRCS:.c=.obj) + +CC = cl +LD = link + +CFLAGS = /nologo /O2 /MT /W3 /GR- /Za -I../.. -DNDEBUG + +all: lib + +lib: $(C_OBJS) + $(LD) /lib @<< +/nologo /out:$(OUT).lib $(C_OBJS) +<< + +clean: + del $(OBJS) $(OUT).lib *.obj + +.SUFFIXES: .c .obj +.c.obj: + $(CC) $(CFLAGS) /c $< diff --git a/ase/doc/awk-en.man b/ase/doc/awk-en.man index 7c17ce9e..76b779d2 100644 --- a/ase/doc/awk-en.man +++ b/ase/doc/awk-en.man @@ -3,16 +3,7 @@ == ASEAWK == ASE provides an embeddable processor of a dialect of the AWK programming language. The language implemented is slightly different from {the version developed by Brian W. Kernighan, http://cm.bell-labs.com/cm/cs/awkbook/index.html} and has been adjusted to the author's preference. -Embedding a processor requires the following basic steps. - -[[[ -* Create a processor instance -* Parse an AWK script -* Run the script parsed -* Destroy the instance -]]] - -The following code fragment illustrates the basic steps. +The following code fragment illustrates the basic steps of embedding the processor. {{{ 1) #include @@ -42,9 +33,59 @@ The following code fragment illustrates the basic steps. * ase_awk_close destroys the processor instance. ))) -=== Primitive Functions === +A set of primitive functions should be provided by the caller to create an instance of the processor as the library aims to be system indepenent. -ase_awk_open requires that a set of primitive functions be provided by its caller. This set include pointers to the system primitive functions for system dependent operation such as memory allocation, string formatting, etc. +{{{ +typedef void* (*ase_malloc_t) (void* custom, ase_size_t n); +typedef void* (*ase_realloc_t) (void* custom, void* ptr, ase_size_t n); +typedef void (*ase_free_t) (void* custom, void* ptr); + +typedef ase_bool_t (*ase_isccls_t) (void* custom, ase_cint_t c); +typedef ase_cint_t (*ase_toccls_t) (void* custom, ase_cint_t c); + +struct ase_mmgr_t +{ + ase_malloc_t malloc; + ase_realloc_t realloc; + ase_free_t free; + void* custom_data; +}; + +struct ase_ccls_t +{ + ase_isccls_t is_upper; + ase_isccls_t is_lower; + ase_isccls_t is_alpha; + ase_isccls_t is_digit; + ase_isccls_t is_xdigit; + ase_isccls_t is_alnum; + ase_isccls_t is_space; + ase_isccls_t is_print; + ase_isccls_t is_graph; + ase_isccls_t is_cntrl; + ase_isccls_t is_punct; + ase_toccls_t to_upper; + ase_toccls_t to_lower; + void* custom_data; +}; + +struct ase_awk_prmfns_t +{ + ase_mmgr_t mmgr; + ase_ccls_t ccls; + + struct + { + ase_awk_pow_t pow; + ase_awk_sprintf_t sprintf; + ase_awk_aprintf_t aprintf; + ase_awk_dprintf_t dprintf; + ase_awk_abort_t abort; + void* custom_data; + } misc; +}; + +The primitive functions handle memory allocation, charater classes, and === Source IO Handler ===