From 72a4fe275c85f228addd6e936e3b3d95a810d810 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 3 Feb 2007 10:52:36 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/run.c | 2 +- ase/awk/run.h | 2 +- ase/awk/str.c | 2 +- ase/awk/str.h | 2 +- ase/awk/tab.c | 2 +- ase/awk/tab.h | 2 +- ase/awk/tree.c | 2 +- ase/awk/tree.h | 2 +- ase/awk/val.c | 2 +- ase/awk/val.h | 4 +- ase/com/Awk.cpp | 4 +- ase/com/Awk.h | 4 +- ase/com/AwkExtio.cpp | 4 +- ase/com/AwkExtio.h | 4 +- ase/com/Buffer.cpp | 4 +- ase/com/Buffer.h | 4 +- ase/com/ase.cpp | 4 +- ase/com/awk_cp.h | 4 +- ase/com/stdafx.cpp | 4 +- ase/com/stdafx.h | 4 +- ase/conf_msw.h | 4 +- ase/conf_unx.h.in | 6 +++ ase/conf_vms.h | 4 +- ase/doc/ase.man | 12 ++--- ase/lsp/env.c | 4 +- ase/lsp/env.h | 4 +- ase/lsp/err.c | 4 +- ase/lsp/eval.c | 8 +-- ase/lsp/lsp.c | 4 +- ase/lsp/lsp.h | 16 +++--- ase/lsp/lsp_i.h | 4 +- ase/lsp/mem.c | 5 +- ase/lsp/mem.h | 4 +- ase/lsp/misc.c | 4 +- ase/lsp/misc.h | 4 +- ase/lsp/name.c | 4 +- ase/lsp/name.h | 4 +- ase/lsp/obj.h | 4 +- ase/lsp/prim.c | 42 +++++++++++---- ase/lsp/prim.h | 4 +- ase/lsp/prim_compar.c | 4 +- ase/lsp/prim_let.c | 4 +- ase/lsp/prim_math.c | 10 ++-- ase/lsp/prim_prog.c | 4 +- ase/lsp/print.c | 4 +- ase/lsp/read.c | 39 ++++++++------ ase/macros.h | 4 +- ase/test/awk/awk.c | 116 ++++++++++++++++++++++++++++++---------- ase/test/awk/regress.sh | 2 +- ase/types.h | 4 +- ase/utl/main.c | 4 +- ase/utl/printf.c | 4 +- 52 files changed, 284 insertions(+), 122 deletions(-) diff --git a/ase/awk/run.c b/ase/awk/run.c index 2f02e7a2..7f929423 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.324 2007-02-03 10:47:41 bacon Exp $ + * $Id: run.c,v 1.325 2007-02-03 10:50:39 bacon Exp $ * * {License} */ diff --git a/ase/awk/run.h b/ase/awk/run.h index 0a629c9b..2ab8de12 100644 --- a/ase/awk/run.h +++ b/ase/awk/run.h @@ -1,5 +1,5 @@ /* - * $Id: run.h,v 1.31 2007-02-03 10:47:41 bacon Exp $ + * $Id: run.h,v 1.32 2007-02-03 10:51:13 bacon Exp $ * * {License} */ diff --git a/ase/awk/str.c b/ase/awk/str.c index 207d53bb..fc1c84d7 100644 --- a/ase/awk/str.c +++ b/ase/awk/str.c @@ -1,5 +1,5 @@ /* - * $Id: str.c,v 1.16 2007-02-03 10:47:41 bacon Exp $ + * $Id: str.c,v 1.17 2007-02-03 10:51:14 bacon Exp $ * * {License} */ diff --git a/ase/awk/str.h b/ase/awk/str.h index 1a7da09f..71b47806 100644 --- a/ase/awk/str.h +++ b/ase/awk/str.h @@ -1,5 +1,5 @@ /* - * $Id: str.h,v 1.5 2007-02-03 10:47:41 bacon Exp $ + * $Id: str.h,v 1.6 2007-02-03 10:51:14 bacon Exp $ * * {License} */ diff --git a/ase/awk/tab.c b/ase/awk/tab.c index 31826f31..6a6e83e0 100644 --- a/ase/awk/tab.c +++ b/ase/awk/tab.c @@ -1,5 +1,5 @@ /* - * $Id: tab.c,v 1.29 2007-02-03 10:47:41 bacon Exp $ + * $Id: tab.c,v 1.30 2007-02-03 10:51:14 bacon Exp $ * * {License} */ diff --git a/ase/awk/tab.h b/ase/awk/tab.h index 77f787ab..43091ec7 100644 --- a/ase/awk/tab.h +++ b/ase/awk/tab.h @@ -1,5 +1,5 @@ /* - * $Id: tab.h,v 1.15 2007-02-03 10:47:41 bacon Exp $ + * $Id: tab.h,v 1.16 2007-02-03 10:51:14 bacon Exp $ * * {License} */ diff --git a/ase/awk/tree.c b/ase/awk/tree.c index 8cab35b6..f8acf98f 100644 --- a/ase/awk/tree.c +++ b/ase/awk/tree.c @@ -1,5 +1,5 @@ /* - * $Id: tree.c,v 1.101 2007-02-03 10:47:41 bacon Exp $ + * $Id: tree.c,v 1.102 2007-02-03 10:51:14 bacon Exp $ * * {License} */ diff --git a/ase/awk/tree.h b/ase/awk/tree.h index a4fa2596..a6d717c8 100644 --- a/ase/awk/tree.h +++ b/ase/awk/tree.h @@ -1,5 +1,5 @@ /* - * $Id: tree.h,v 1.86 2007-02-03 10:47:41 bacon Exp $ + * $Id: tree.h,v 1.87 2007-02-03 10:51:14 bacon Exp $ * * {License} */ diff --git a/ase/awk/val.c b/ase/awk/val.c index 80aca2b8..3876700f 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.106 2007-02-03 10:47:41 bacon Exp $ + * $Id: val.c,v 1.107 2007-02-03 10:51:14 bacon Exp $ * * {License} */ diff --git a/ase/awk/val.h b/ase/awk/val.h index 854c966b..c856843f 100644 --- a/ase/awk/val.h +++ b/ase/awk/val.h @@ -1,5 +1,7 @@ /* - * $Id: val.h,v 1.59 2007-01-16 14:20:42 bacon Exp $ + * $Id: val.h,v 1.60 2007-02-03 10:47:42 bacon Exp $ + * + * {License} */ #ifndef _ASE_AWK_VAL_H_ diff --git a/ase/com/Awk.cpp b/ase/com/Awk.cpp index c8fe3138..122c58d2 100644 --- a/ase/com/Awk.cpp +++ b/ase/com/Awk.cpp @@ -1,5 +1,7 @@ /* - * $Id: Awk.cpp,v 1.23 2007-02-01 08:38:24 bacon Exp $ + * $Id: Awk.cpp,v 1.24 2007-02-03 10:52:11 bacon Exp $ + * + * {License} */ #include "stdafx.h" diff --git a/ase/com/Awk.h b/ase/com/Awk.h index d8d42f1e..9cf47ef9 100644 --- a/ase/com/Awk.h +++ b/ase/com/Awk.h @@ -1,5 +1,7 @@ /* - * $Id: Awk.h,v 1.15 2007-01-25 14:14:56 bacon Exp $ + * $Id: Awk.h,v 1.16 2007-02-03 10:52:11 bacon Exp $ + * + * {License} */ #ifndef _ASE_COM_AWK_H_ diff --git a/ase/com/AwkExtio.cpp b/ase/com/AwkExtio.cpp index 78dbca53..1e559c5a 100644 --- a/ase/com/AwkExtio.cpp +++ b/ase/com/AwkExtio.cpp @@ -1,5 +1,7 @@ /* - * $Id: AwkExtio.cpp,v 1.8 2007-01-10 14:30:44 bacon Exp $ + * $Id: AwkExtio.cpp,v 1.9 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ #include "stdafx.h" diff --git a/ase/com/AwkExtio.h b/ase/com/AwkExtio.h index 9bdce1f5..5bd28e27 100644 --- a/ase/com/AwkExtio.h +++ b/ase/com/AwkExtio.h @@ -1,5 +1,7 @@ /* - * $Id: AwkExtio.h,v 1.8 2006-12-15 06:47:08 bacon Exp $ + * $Id: AwkExtio.h,v 1.9 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ #ifndef _ASE_COM_AWKEXTIO_H_ diff --git a/ase/com/Buffer.cpp b/ase/com/Buffer.cpp index bf42d328..04790d8a 100644 --- a/ase/com/Buffer.cpp +++ b/ase/com/Buffer.cpp @@ -1,5 +1,7 @@ /* - * $Id: Buffer.cpp,v 1.5 2007-01-10 14:30:44 bacon Exp $ + * $Id: Buffer.cpp,v 1.6 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ #include "stdafx.h" diff --git a/ase/com/Buffer.h b/ase/com/Buffer.h index bbcdd69e..8df924b1 100644 --- a/ase/com/Buffer.h +++ b/ase/com/Buffer.h @@ -1,5 +1,7 @@ /* - * $Id: Buffer.h,v 1.4 2006-12-10 16:13:50 bacon Exp $ + * $Id: Buffer.h,v 1.5 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ #ifndef _ASE_COM_BUFFER_H_ diff --git a/ase/com/ase.cpp b/ase/com/ase.cpp index 21fea112..57aab209 100644 --- a/ase/com/ase.cpp +++ b/ase/com/ase.cpp @@ -1,5 +1,7 @@ /* - * $Id: ase.cpp,v 1.1 2006-12-09 11:50:08 bacon Exp $ + * $Id: ase.cpp,v 1.2 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ // Note: Proxy/Stub Information diff --git a/ase/com/awk_cp.h b/ase/com/awk_cp.h index 5bf5fe9e..6228b08b 100644 --- a/ase/com/awk_cp.h +++ b/ase/com/awk_cp.h @@ -1,5 +1,7 @@ /* - * $Id: awk_cp.h,v 1.8 2007-01-17 14:09:49 bacon Exp $ + * $Id: awk_cp.h,v 1.9 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ #ifndef _AWK_CP_H_ diff --git a/ase/com/stdafx.cpp b/ase/com/stdafx.cpp index 28a4bd1d..ca584b31 100644 --- a/ase/com/stdafx.cpp +++ b/ase/com/stdafx.cpp @@ -1,5 +1,7 @@ /* - * $Id: stdafx.cpp,v 1.2 2006-12-09 12:01:26 bacon Exp $ + * $Id: stdafx.cpp,v 1.3 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ // stdafx.cpp : source file that includes just the standard includes diff --git a/ase/com/stdafx.h b/ase/com/stdafx.h index c4a7c8dc..1074dc0f 100644 --- a/ase/com/stdafx.h +++ b/ase/com/stdafx.h @@ -1,5 +1,7 @@ /* - * $Id: stdafx.h,v 1.2 2006-12-09 12:01:26 bacon Exp $ + * $Id: stdafx.h,v 1.3 2007-02-03 10:52:12 bacon Exp $ + * + * {License} */ #ifndef _ASE_COM_STDAFX_H_ diff --git a/ase/conf_msw.h b/ase/conf_msw.h index 05ede6d8..4a481827 100644 --- a/ase/conf_msw.h +++ b/ase/conf_msw.h @@ -1,5 +1,7 @@ /* - * $Id: conf_msw.h,v 1.6 2006-11-19 06:15:57 bacon Exp $ + * $Id: conf_msw.h,v 1.7 2007-02-03 10:52:35 bacon Exp $ + * + * {License} */ /* diff --git a/ase/conf_unx.h.in b/ase/conf_unx.h.in index 6afcdc16..bacf73b7 100644 --- a/ase/conf_unx.h.in +++ b/ase/conf_unx.h.in @@ -1,3 +1,9 @@ +/* + * $Id: conf_unx.h.in,v 1.3 2007-02-03 10:52:36 bacon Exp $ + * + * {License} + */ + /* Big Endian */ #undef ASE_ENDIAN_BIG diff --git a/ase/conf_vms.h b/ase/conf_vms.h index 0db81278..523ca0d3 100644 --- a/ase/conf_vms.h +++ b/ase/conf_vms.h @@ -1,5 +1,7 @@ /* - * $Id: conf_vms.h,v 1.7 2006-10-24 04:30:13 bacon Exp $ + * $Id: conf_vms.h,v 1.8 2007-02-03 10:52:36 bacon Exp $ + * + * {License} */ /* TODO: please complete the itanium portion */ diff --git a/ase/doc/ase.man b/ase/doc/ase.man index 0fde734f..38f01f9b 100644 --- a/ase/doc/ase.man +++ b/ase/doc/ase.man @@ -1,8 +1,10 @@ +.title ASE + == Introduction == -ASE is a collection of scriping engines for various programming languages. It has been written in the hopt that it will be useful for programmers. +ASE is a library implementing various programming languages for embedding purpose. -== Source == +=== Source === ase - the root directory of the ase project ase/awk - AWK module @@ -13,9 +15,3 @@ ase/test/lsp - ase/test/com - ase/etc - ase/doc - - -== License == -The toolkit is distributed under the ASE general license. - -== Author == -Chung, Hyung-Hwan, the sole author of ASE, is ... diff --git a/ase/lsp/env.c b/ase/lsp/env.c index 4c26448f..c99c59a8 100644 --- a/ase/lsp/env.c +++ b/ase/lsp/env.c @@ -1,5 +1,7 @@ /* - * $Id: env.c,v 1.13 2006-10-26 09:31:28 bacon Exp $ + * $Id: env.c,v 1.14 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/env.h b/ase/lsp/env.h index 44ce232b..c05245cd 100644 --- a/ase/lsp/env.h +++ b/ase/lsp/env.h @@ -1,5 +1,7 @@ /* - * $Id: env.h,v 1.10 2006-10-26 08:17:37 bacon Exp $ + * $Id: env.h,v 1.11 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_ENV_H_ diff --git a/ase/lsp/err.c b/ase/lsp/err.c index b8e8e026..6e3ab5c0 100644 --- a/ase/lsp/err.c +++ b/ase/lsp/err.c @@ -1,5 +1,7 @@ /* - * $Id: err.c,v 1.8 2006-11-29 02:54:17 bacon Exp $ + * $Id: err.c,v 1.9 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/eval.c b/ase/lsp/eval.c index aa804b7c..621a8682 100644 --- a/ase/lsp/eval.c +++ b/ase/lsp/eval.c @@ -1,5 +1,7 @@ /* - * $Id: eval.c,v 1.23 2006-11-02 11:10:12 bacon Exp $ + * $Id: eval.c,v 1.24 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #include @@ -41,7 +43,7 @@ static ase_lsp_obj_t* __eval (ase_lsp_t* lsp, ase_lsp_obj_t* obj) /* if (obj == lsp->mem->lambda || obj == lsp->mem->macro) { printf ("lambda or macro can't be used as a normal symbol\n"); - lsp->errnum = ASE_LSP_ERR_BAD_SYMBOL; + lsp->errnum = ASE_LSP_EBADSYM; return ASE_NULL; } */ @@ -84,7 +86,7 @@ static ase_lsp_obj_t* make_func (ase_lsp_t* lsp, ase_lsp_obj_t* cdr, int is_macr if (body == lsp->mem->nil) { - lsp->errnum = ASE_LSP_ERR_EMPTY_BODY; + lsp->errnum = ASE_LSP_EEMPBDY; return ASE_NULL; } diff --git a/ase/lsp/lsp.c b/ase/lsp/lsp.c index 59f121fe..ae5451d2 100644 --- a/ase/lsp/lsp.c +++ b/ase/lsp/lsp.c @@ -1,5 +1,7 @@ /* - * $Id: lsp.c,v 1.20 2007-02-01 08:49:51 bacon Exp $ + * $Id: lsp.c,v 1.21 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #if defined(__BORLANDC__) diff --git a/ase/lsp/lsp.h b/ase/lsp/lsp.h index 8bc7e35c..d74344d2 100644 --- a/ase/lsp/lsp.h +++ b/ase/lsp/lsp.h @@ -1,5 +1,7 @@ /* - * $Id: lsp.h,v 1.34 2007-02-01 08:49:51 bacon Exp $ + * $Id: lsp.h,v 1.35 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_LSP_H_ @@ -86,25 +88,25 @@ enum ASE_LSP_ENOERR, ASE_LSP_ENOMEM, - ASE_LSP_ERR_EXIT, - ASE_LSP_ERR_END, + ASE_LSP_EEXIT, + ASE_LSP_EEND, ASE_LSP_ERR_INPUT_NOT_ATTACHED, ASE_LSP_ERR_INPUT, ASE_LSP_ERR_OUTPUT_NOT_ATTACHED, ASE_LSP_ERR_OUTPUT, - ASE_LSP_ERR_SYNTAX, + ASE_LSP_ESYNTAX, ASE_LSP_EARGBAD, ASE_LSP_EARGFEW, ASE_LSP_EARGMANY, ASE_LSP_ERR_UNDEF_FUNC, ASE_LSP_ERR_BAD_FUNC, ASE_LSP_ERR_DUP_FORMAL, - ASE_LSP_ERR_BAD_SYMBOL, + ASE_LSP_EBADSYM, ASE_LSP_ERR_UNDEF_SYMBOL, - ASE_LSP_ERR_EMPTY_BODY, + ASE_LSP_EEMPBDY, ASE_LSP_EVALBAD, - ASE_LSP_EDIVBYZERO + ASE_LSP_EDIVBY0 }; typedef ase_lsp_obj_t* (*ase_lsp_prim_t) (ase_lsp_t* lsp, ase_lsp_obj_t* obj); diff --git a/ase/lsp/lsp_i.h b/ase/lsp/lsp_i.h index 1b535abf..27cf17e5 100644 --- a/ase/lsp/lsp_i.h +++ b/ase/lsp/lsp_i.h @@ -1,5 +1,7 @@ /* - * $Id: lsp_i.h,v 1.6 2007-02-01 08:49:52 bacon Exp $ + * $Id: lsp_i.h,v 1.7 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_LSPI_H_ diff --git a/ase/lsp/mem.c b/ase/lsp/mem.c index 95820c0c..0d4a2b09 100644 --- a/ase/lsp/mem.c +++ b/ase/lsp/mem.c @@ -1,5 +1,7 @@ /* - * $Id: mem.c,v 1.25 2006-11-29 02:54:17 bacon Exp $ + * $Id: mem.c,v 1.26 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #include @@ -90,6 +92,7 @@ ase_lsp_obj_t* ase_lsp_alloc (ase_lsp_mem_t* mem, int type, ase_size_t size) { ase_lsp_obj_t* obj; +/* TODO: remove the following line... */ ase_lsp_collectgarbage(mem); if (mem->count >= mem->ubound) ase_lsp_collectgarbage (mem); if (mem->count >= mem->ubound) diff --git a/ase/lsp/mem.h b/ase/lsp/mem.h index 87319627..dd2c3186 100644 --- a/ase/lsp/mem.h +++ b/ase/lsp/mem.h @@ -1,5 +1,7 @@ /* - * $Id: mem.h,v 1.16 2006-11-02 10:12:01 bacon Exp $ + * $Id: mem.h,v 1.17 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_MEM_H_ diff --git a/ase/lsp/misc.c b/ase/lsp/misc.c index 2662f253..a68e110a 100644 --- a/ase/lsp/misc.c +++ b/ase/lsp/misc.c @@ -1,5 +1,7 @@ /* - * $Id: misc.c,v 1.7 2007-02-01 08:49:52 bacon Exp $ + * $Id: misc.c,v 1.8 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/misc.h b/ase/lsp/misc.h index 9fc71112..155a24ed 100644 --- a/ase/lsp/misc.h +++ b/ase/lsp/misc.h @@ -1,5 +1,7 @@ /* - * $Id: misc.h,v 1.3 2006-10-26 09:31:28 bacon Exp $ + * $Id: misc.h,v 1.4 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_MISC_H_ diff --git a/ase/lsp/name.c b/ase/lsp/name.c index d486fe70..1b7e0afe 100644 --- a/ase/lsp/name.c +++ b/ase/lsp/name.c @@ -1,5 +1,7 @@ /* - * $Id: name.c,v 1.13 2006-12-05 03:38:11 bacon Exp $ + * $Id: name.c,v 1.14 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/name.h b/ase/lsp/name.h index db8d7a51..ac9a4855 100644 --- a/ase/lsp/name.h +++ b/ase/lsp/name.h @@ -1,5 +1,7 @@ /* - * $Id: name.h,v 1.8 2006-11-02 10:12:01 bacon Exp $ + * $Id: name.h,v 1.9 2007-02-03 10:51:52 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_NAME_H_ diff --git a/ase/lsp/obj.h b/ase/lsp/obj.h index 1d334710..a14ef701 100644 --- a/ase/lsp/obj.h +++ b/ase/lsp/obj.h @@ -1,5 +1,7 @@ /* - * $Id: obj.h,v 1.15 2006-11-02 10:12:01 bacon Exp $ + * $Id: obj.h,v 1.16 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_OBJ_H_ diff --git a/ase/lsp/prim.c b/ase/lsp/prim.c index d7f8f661..1f417e10 100644 --- a/ase/lsp/prim.c +++ b/ase/lsp/prim.c @@ -1,5 +1,7 @@ /* - * $Id: prim.c,v 1.18 2006-11-02 11:10:12 bacon Exp $ + * $Id: prim.c,v 1.19 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #include @@ -33,33 +35,51 @@ static int __add_prim (ase_lsp_mem_t* mem, ase_lsp_lockobj (mem->lsp, n); p = ase_lsp_makeprim (mem, pimpl, min_args, max_args); - if (p == ASE_NULL) return -1; + if (p == ASE_NULL) + { + ase_lsp_unlockobj (mem->lsp, n); + return -1; + } + ase_lsp_lockobj (mem->lsp, p); + + if (ase_lsp_setfunc(mem, n, p) == ASE_NULL) + { + ase_lsp_unlockobj (mem->lsp, p); + ase_lsp_unlockobj (mem->lsp, n); + return -1; + } + + ase_lsp_unlockobj (mem->lsp, p); ase_lsp_unlockobj (mem->lsp, n); - - if (ase_lsp_setfunc(mem, n, p) == ASE_NULL) return -1; - return 0; } ase_lsp_obj_t* ase_lsp_prim_exit (ase_lsp_t* lsp, ase_lsp_obj_t* args) { - lsp->errnum = ASE_LSP_ERR_EXIT; + lsp->errnum = ASE_LSP_EEXIT; return ASE_NULL; } ase_lsp_obj_t* ase_lsp_prim_eval (ase_lsp_t* lsp, ase_lsp_obj_t* args) { - ase_lsp_obj_t* tmp; + ase_lsp_obj_t* tmp1, * tmp2; ASE_LSP_ASSERT (lsp, ASE_LSP_TYPE(args) == ASE_LSP_OBJ_CONS); - tmp = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); - if (tmp == ASE_NULL) return ASE_NULL; + tmp1 = ase_lsp_eval (lsp, ASE_LSP_CAR(args)); + if (tmp1 == ASE_NULL) return ASE_NULL; - tmp = ase_lsp_eval (lsp, tmp); - if (tmp == ASE_NULL) return ASE_NULL; + ase_lsp_lockobj (mem->lsp, tmp1); + tmp2 = ase_lsp_eval (lsp, tmp1); + if (tmp2 == ASE_NULL) + { + ase_lsp_unlockobj (mem->lsp, tmp1); + return ASE_NULL; + } + + ase_lsp_unlockobj (mem->lsp, tmp1); return tmp; } diff --git a/ase/lsp/prim.h b/ase/lsp/prim.h index a3828fcf..8ee9fd7b 100644 --- a/ase/lsp/prim.h +++ b/ase/lsp/prim.h @@ -1,5 +1,7 @@ /* - * $Id: prim.h,v 1.13 2006-11-02 11:10:12 bacon Exp $ + * $Id: prim.h,v 1.14 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #ifndef _ASE_LSP_PRIM_H_ diff --git a/ase/lsp/prim_compar.c b/ase/lsp/prim_compar.c index 32e7fef6..e0c75b55 100644 --- a/ase/lsp/prim_compar.c +++ b/ase/lsp/prim_compar.c @@ -1,5 +1,7 @@ /* - * $Id: prim_compar.c,v 1.10 2006-10-30 11:26:56 bacon Exp $ + * $Id: prim_compar.c,v 1.11 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/prim_let.c b/ase/lsp/prim_let.c index 2e611059..c0d60cb3 100644 --- a/ase/lsp/prim_let.c +++ b/ase/lsp/prim_let.c @@ -1,5 +1,7 @@ /* - * $Id: prim_let.c,v 1.9 2006-10-30 03:34:41 bacon Exp $ + * $Id: prim_let.c,v 1.10 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/prim_math.c b/ase/lsp/prim_math.c index 8e2f6a54..74dfe3cf 100644 --- a/ase/lsp/prim_math.c +++ b/ase/lsp/prim_math.c @@ -1,5 +1,7 @@ /* - * $Id: prim_math.c,v 1.15 2006-10-30 11:26:57 bacon Exp $ + * $Id: prim_math.c,v 1.16 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #include @@ -257,7 +259,7 @@ ase_lsp_obj_t* ase_lsp_prim_div (ase_lsp_t* lsp, ase_lsp_obj_t* args) { if (ASE_LSP_IVAL(tmp) == 0) { - lsp->errnum = ASE_LSP_EDIVBYZERO; + lsp->errnum = ASE_LSP_EDIVBY0; return ASE_NULL; } ival = ival / ASE_LSP_IVAL(tmp); @@ -332,7 +334,7 @@ ase_lsp_obj_t* ase_lsp_prim_mod (ase_lsp_t* lsp, ase_lsp_obj_t* args) { if (ASE_LSP_IVAL(tmp) == 0) { - lsp->errnum = ASE_LSP_EDIVBYZERO; + lsp->errnum = ASE_LSP_EDIVBY0; return ASE_NULL; } ival = ival % ASE_LSP_IVAL(tmp); @@ -349,7 +351,7 @@ ase_lsp_obj_t* ase_lsp_prim_mod (ase_lsp_t* lsp, ase_lsp_obj_t* args) ase_long_t tmpi = (ase_long_t)ASE_LSP_RVAL(tmp); if (tmpi == 0) { - lsp->errnum = ASE_LSP_EDIVBYZERO; + lsp->errnum = ASE_LSP_EDIVBY0; return ASE_NULL; } ival = ival % tmpi; diff --git a/ase/lsp/prim_prog.c b/ase/lsp/prim_prog.c index 75f49cc8..fe60bdd0 100644 --- a/ase/lsp/prim_prog.c +++ b/ase/lsp/prim_prog.c @@ -1,5 +1,7 @@ /* - * $Id: prim_prog.c,v 1.6 2006-10-30 11:26:57 bacon Exp $ + * $Id: prim_prog.c,v 1.7 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/print.c b/ase/lsp/print.c index e7b7bb98..a59fae3f 100644 --- a/ase/lsp/print.c +++ b/ase/lsp/print.c @@ -1,5 +1,7 @@ /* - * $Id: print.c,v 1.20 2007-02-01 08:49:52 bacon Exp $ + * $Id: print.c,v 1.21 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #include diff --git a/ase/lsp/read.c b/ase/lsp/read.c index e39a47ad..bbedb2fe 100644 --- a/ase/lsp/read.c +++ b/ase/lsp/read.c @@ -1,5 +1,7 @@ /* - * $Id: read.c,v 1.29 2006-11-02 10:12:01 bacon Exp $ + * $Id: read.c,v 1.30 2007-02-03 10:51:53 bacon Exp $ + * + * {License} */ #include @@ -77,7 +79,7 @@ static ase_lsp_obj_t* read_obj (ase_lsp_t* lsp) switch (TOKEN_TYPE(lsp)) { case TOKEN_END: - lsp->errnum = ASE_LSP_ERR_END; + lsp->errnum = ASE_LSP_EEND; return ASE_NULL; case TOKEN_LPAREN: @@ -128,7 +130,7 @@ static ase_lsp_obj_t* read_obj (ase_lsp_t* lsp) return obj; } - lsp->errnum = ASE_LSP_ERR_SYNTAX; + lsp->errnum = ASE_LSP_ESYNTAX; return ASE_NULL; } @@ -141,7 +143,8 @@ static ase_lsp_obj_t* read_list (ase_lsp_t* lsp) { if (TOKEN_TYPE(lsp) == TOKEN_END) { - lsp->errnum = ASE_LSP_ERR_SYNTAX; /* unexpected end of input */ + /* unexpected end of input */ + lsp->errnum = ASE_LSP_ESYNTAX; return ASE_NULL; } @@ -149,7 +152,8 @@ static ase_lsp_obj_t* read_list (ase_lsp_t* lsp) { if (prev == ASE_NULL) { - lsp->errnum = ASE_LSP_ERR_SYNTAX; /* unexpected dot */ + /* unexpected dot */ + lsp->errnum = ASE_LSP_ESYNTAX; return ASE_NULL; } @@ -157,10 +161,10 @@ static ase_lsp_obj_t* read_list (ase_lsp_t* lsp) obj = read_obj (lsp); if (obj == ASE_NULL) { - if (lsp->errnum == ASE_LSP_ERR_END) + if (lsp->errnum == ASE_LSP_EEND) { /* unexpected end of input */ - lsp->errnum = ASE_LSP_ERR_SYNTAX; + lsp->errnum = ASE_LSP_ESYNTAX; } return ASE_NULL; } @@ -169,7 +173,8 @@ static ase_lsp_obj_t* read_list (ase_lsp_t* lsp) NEXT_TOKEN (lsp); if (TOKEN_TYPE(lsp) != TOKEN_RPAREN) { - lsp->errnum = ASE_LSP_ERR_SYNTAX; /* ) expected */ + /* ) expected */ + lsp->errnum = ASE_LSP_ESYNTAX; return ASE_NULL; } @@ -179,10 +184,10 @@ static ase_lsp_obj_t* read_list (ase_lsp_t* lsp) obj = read_obj (lsp); if (obj == ASE_NULL) { - if (lsp->errnum == ASE_LSP_ERR_END) + if (lsp->errnum == ASE_LSP_EEND) { /* unexpected end of input */ - lsp->errnum = ASE_LSP_ERR_SYNTAX; + lsp->errnum = ASE_LSP_ESYNTAX; } return ASE_NULL; } @@ -215,10 +220,10 @@ static ase_lsp_obj_t* read_quote (ase_lsp_t* lsp) tmp = read_obj (lsp); if (tmp == ASE_NULL) { - if (lsp->errnum == ASE_LSP_ERR_END) + if (lsp->errnum == ASE_LSP_EEND) { - // unexpected end of input - lsp->errnum = ASE_LSP_ERR_SYNTAX; + /* unexpected end of input */ + lsp->errnum = ASE_LSP_ESYNTAX; } return ASE_NULL; } @@ -273,10 +278,10 @@ static int read_token (ase_lsp_t* lsp) while (1) { - // skip white spaces + /* skip white spaces */ while (ASE_LSP_ISSPACE(lsp, lsp->curc)) NEXT_CHAR (lsp); - // skip the comments here + /* skip the comments here */ if (lsp->curc == ASE_T(';')) { do @@ -355,7 +360,7 @@ static int read_token (ase_lsp_t* lsp) } TOKEN_TYPE(lsp) = TOKEN_INVALID; - NEXT_CHAR (lsp); // consume + NEXT_CHAR (lsp); /* consume */ return 0; } @@ -522,7 +527,7 @@ static int read_string (ase_lsp_t* lsp) return 0; } - // TODO: + /* TODO: */ if (escaped == 3) { /* \xNN */ diff --git a/ase/macros.h b/ase/macros.h index a251b656..fec72e45 100644 --- a/ase/macros.h +++ b/ase/macros.h @@ -1,5 +1,7 @@ /* - * $Id: macros.h,v 1.44 2006-11-29 03:18:18 bacon Exp $ + * $Id: macros.h,v 1.45 2007-02-03 10:52:36 bacon Exp $ + * + * {License} */ #ifndef _ASE_MACROS_H_ diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index d1bb3786..d098af75 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.161 2007-02-01 09:19:15 bacon Exp $ + * $Id: awk.c,v 1.162 2007-02-03 10:52:36 bacon Exp $ */ #include @@ -115,7 +115,7 @@ static void awk_printf (const ase_char_t* fmt, ...) static FILE* awk_fopen (const ase_char_t* path, const ase_char_t* mode) { -#ifdef _WIN32 +#if defined(_WIN32) return _tfopen (path, mode); #elif defined(ASE_CHAR_IS_MCHAR) return fopen (path, mode); @@ -745,13 +745,17 @@ static void* awk_memset (void* dst, int val, ase_size_t n) #define awk_tolower towlower #endif +static void print_usage (const ase_char_t* argv0) +{ + awk_printf (ASE_T("Usage: %s [-m] [-d] [-a argument]* -f source-file [data-file]*\n"), argv0); +} + static int __main (int argc, ase_char_t* argv[]) { ase_awk_t* awk; ase_awk_srcios_t srcios; ase_awk_runcbs_t runcbs; ase_awk_runios_t runios; - ase_awk_runarg_t runarg[10]; ase_awk_prmfns_t prmfns; struct src_io src_io = { NULL, NULL }; int opt, i, file_count = 0, errnum; @@ -759,6 +763,10 @@ static int __main (int argc, ase_char_t* argv[]) prmfns_data_t prmfns_data; #endif const ase_char_t* mfn = ASE_NULL; + int mode = 0; + int runarg_count = 0; + ase_awk_runarg_t runarg[128]; + int deparse = 0; opt = ASE_AWK_IMPLICIT | ASE_AWK_EXPLICIT | @@ -775,34 +783,96 @@ static int __main (int argc, ase_char_t* argv[]) if (argc <= 1) { - awk_printf (ASE_T("Usage: %s [-m] source_file [data_file ...]\n"), argv[0]); + print_usage (argv[0]); return -1; } for (i = 1; i < argc; i++) { - if (ase_awk_strcmp(argv[i], ASE_T("-m")) == 0) + if (mode == 0) { - mfn = ASE_T("main"); + if (ase_awk_strcmp(argv[i], ASE_T("-m")) == 0) + { + mfn = ASE_T("main"); + } + else if (ase_awk_strcmp(argv[i], ASE_T("-d")) == 0) + { + deparse = 1; + } + else if (ase_awk_strcmp(argv[i], ASE_T("-f")) == 0) + { + /* specify source file */ + mode = 1; + } + else if (ase_awk_strcmp(argv[i], ASE_T("-a")) == 0) + { + /* specify arguments */ + mode = 2; + } + else if (argv[i][0] == ASE_T('-')) + { + print_usage (argv[0]); + return -1; + } + else if (file_count < ASE_COUNTOF(infiles)-1) + { + infiles[file_count] = argv[i]; + file_count++; + } + else + { + print_usage (argv[0]); + return -1; + } } - else if (file_count == 0) + else if (mode == 1) /* source mode */ { + if (argv[i][0] == ASE_T('-')) + { + print_usage (argv[0]); + return -1; + } + + if (src_io.input_file != NULL) + { + print_usage (argv[0]); + return -1; + } + src_io.input_file = argv[i]; - file_count++; + mode = 0; } - else if (file_count >= 1 && file_count < ASE_COUNTOF(infiles)-1) + else if (mode == 2) /* argument mode */ { - infiles[file_count-1] = argv[i]; - infiles[file_count] = ASE_NULL; - file_count++; - } - else - { - awk_printf (ASE_T("Usage: %s [-m] [-f source_file] [data_file ...]\n"), argv[0]); - return -1; + if (argv[i][0] == ASE_T('-')) + { + print_usage (argv[0]); + return -1; + } + + if (runarg_count >= ASE_COUNTOF(runarg)-1) + { + print_usage (argv[0]); + return -1; + } + + runarg[runarg_count].ptr = argv[i]; + runarg[runarg_count].len = ase_awk_strlen(argv[i]); + runarg_count++; + mode = 0; } } + infiles[file_count] = ASE_NULL; + runarg[runarg_count].ptr = NULL; + runarg[runarg_count].len = 0; + + if (mode != 0 || src_io.input_file == NULL) + { + print_usage (argv[0]); + return -1; + } + memset (&prmfns, 0, ASE_SIZEOF(prmfns)); prmfns.malloc = awk_malloc; @@ -858,10 +928,9 @@ static int __main (int argc, ase_char_t* argv[]) ase_awk_setoption (awk, opt); srcios.in = process_source; - srcios.out = dump_source; + srcios.out = deparse? dump_source: NULL; srcios.custom_data = &src_io; - ase_awk_setmaxdepth ( awk, ASE_AWK_DEPTH_BLOCK_PARSE | ASE_AWK_DEPTH_EXPR_PARSE, 20); ase_awk_setmaxdepth ( @@ -893,15 +962,6 @@ static int __main (int argc, ase_char_t* argv[]) runcbs.on_end = on_run_end; runcbs.custom_data = ASE_NULL; - runarg[0].ptr = ASE_T("argument 0"); - runarg[0].len = ase_awk_strlen(runarg[0].ptr); - runarg[1].ptr = ASE_T("argumetn 1"); - runarg[1].len = ase_awk_strlen(runarg[1].ptr); - runarg[2].ptr = ASE_T("argumetn 2"); - runarg[2].len = ase_awk_strlen(runarg[2].ptr); - runarg[3].ptr = ASE_NULL; - runarg[3].len = 0; - if (ase_awk_run (awk, mfn, &runios, &runcbs, runarg, ASE_NULL) == -1) { int errnum = ase_awk_geterrnum(awk); diff --git a/ase/test/awk/regress.sh b/ase/test/awk/regress.sh index d7e2e225..6ed1d4d5 100755 --- a/ase/test/awk/regress.sh +++ b/ase/test/awk/regress.sh @@ -29,7 +29,7 @@ run_script_for_test() output=`echo $script | sed 's/\.awk$/.out/g'` echo ">> RUNNING $script" - ./awk "$script" "$data" > "$output.$pid" + ./awk -f "$script" "$data" > "$output.$pid" #diff -y "$output" "$output.$pid" diff "$output" "$output.$pid" diff --git a/ase/types.h b/ase/types.h index 6b9da74a..11080b2b 100644 --- a/ase/types.h +++ b/ase/types.h @@ -1,5 +1,7 @@ /* - * $Id: types.h,v 1.65 2007-01-29 06:40:29 bacon Exp $ + * $Id: types.h,v 1.66 2007-02-03 10:52:36 bacon Exp $ + * + * {License} */ #ifndef _ASE_TYPES_H_ diff --git a/ase/utl/main.c b/ase/utl/main.c index 01103cc2..9e09c5e9 100644 --- a/ase/utl/main.c +++ b/ase/utl/main.c @@ -1,5 +1,7 @@ /* - * $Id: main.c,v 1.7 2007-01-29 02:47:19 bacon Exp $ + * $Id: main.c,v 1.8 2007-02-03 10:52:36 bacon Exp $ + * + * {License} */ #include diff --git a/ase/utl/printf.c b/ase/utl/printf.c index 70e4d293..ab003eec 100644 --- a/ase/utl/printf.c +++ b/ase/utl/printf.c @@ -1,5 +1,7 @@ /* - * $Id: printf.c,v 1.8 2007-01-28 11:33:23 bacon Exp $ + * $Id: printf.c,v 1.9 2007-02-03 10:52:36 bacon Exp $ + * + * {License} */ #include