*** empty log message ***

This commit is contained in:
hyung-hwan 2007-02-03 10:52:36 +00:00
parent adb88864bd
commit 72a4fe275c
52 changed files with 284 additions and 122 deletions

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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}
*/

View File

@ -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_

View File

@ -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"

View File

@ -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_

View File

@ -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"

View File

@ -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_

View File

@ -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"

View File

@ -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_

View File

@ -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

View File

@ -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_

View File

@ -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

View File

@ -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_

View File

@ -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}
*/
/*

View File

@ -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

View File

@ -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 */

View File

@ -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 ...

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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_

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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 <ase/lsp/lsp_i.h>
@ -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;
}

View File

@ -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__)

View File

@ -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);

View File

@ -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_

View File

@ -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 <ase/lsp/lsp_i.h>
@ -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)

View File

@ -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_

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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_

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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_

View File

@ -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_

View File

@ -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 <ase/lsp/lsp_i.h>
@ -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;
}

View File

@ -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_

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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 <ase/lsp/lsp_i.h>
@ -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;

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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 <ase/lsp/lsp_i.h>

View File

@ -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 <ase/lsp/lsp_i.h>
@ -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 */

View File

@ -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_

View File

@ -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 <ase/awk/awk.h>
@ -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);

View File

@ -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"

View File

@ -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_

View File

@ -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 <ase/types.h>

View File

@ -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 <stdarg.h>