From 55e846cc0118e7ebbce7b1c7efa9f25404df0df1 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 19 Nov 2006 15:24:21 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.h | 3 ++- ase/awk/run.c | 18 ++++++++++-------- ase/test/awk/awk.c | 7 ++++--- ase/test/awk/t4.awk | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ase/awk/awk.h b/ase/awk/awk.h index 19247539..27e1431a 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.146 2006-11-19 11:21:06 bacon Exp $ + * $Id: awk.h,v 1.147 2006-11-19 15:24:20 bacon Exp $ */ #ifndef _ASE_AWK_AWK_H_ @@ -365,6 +365,7 @@ int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios); * error number. The third parameter to on_end denotes this error number. */ int ase_awk_run (ase_awk_t* awk, + const ase_char_t* main, ase_awk_runios_t* runios, ase_awk_runcbs_t* runcbs, ase_awk_runarg_t* runarg); diff --git a/ase/awk/run.c b/ase/awk/run.c index 2af32789..2afde35c 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.277 2006-11-19 15:16:06 bacon Exp $ + * $Id: run.c,v 1.278 2006-11-19 15:24:20 bacon Exp $ */ #include @@ -60,7 +60,8 @@ static void __deinit_run (ase_awk_run_t* run); static int __build_runarg (ase_awk_run_t* run, ase_awk_runarg_t* runarg); static int __set_globals_to_default (ase_awk_run_t* run); -static int __run_main (ase_awk_run_t* run, ase_awk_runarg_t* runarg); +static int __run_main ( + ase_awk_run_t* run, const ase_char_t* main, ase_awk_runarg_t* runarg); static int __run_pattern_blocks (ase_awk_run_t* run); static int __run_pattern_block_chain ( ase_awk_run_t* run, ase_awk_chain_t* chain); @@ -508,6 +509,7 @@ void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum) } int ase_awk_run (ase_awk_t* awk, + const ase_char_t* main, ase_awk_runios_t* runios, ase_awk_runcbs_t* runcbs, ase_awk_runarg_t* runarg) @@ -541,7 +543,7 @@ int ase_awk_run (ase_awk_t* awk, runcbs->on_start (awk, run, runcbs->custom_data); } - n = __run_main (run, runarg); + n = __run_main (run, main, runarg); if (n == -1) { /* if no callback is specified, awk's error number @@ -1048,7 +1050,8 @@ static int __set_globals_to_default (ase_awk_run_t* run) return 0; } -static int __run_main (ase_awk_run_t* run, ase_awk_runarg_t* runarg) +static int __run_main ( + ase_awk_run_t* run, const ase_char_t* main, ase_awk_runarg_t* runarg) { ase_size_t nglobals, nargs, i; ase_size_t saved_stack_top; @@ -1109,15 +1112,14 @@ static int __run_main (ase_awk_run_t* run, ase_awk_runarg_t* runarg) n = __update_fnr (run, 0); if (n == 0) n = __set_globals_to_default (run); - if (n == 0 && (run->awk->option & ASE_AWK_RUNMAIN)) + if (n == 0 && main != ASE_NULL) { -/* TODO: should the main function be user-specifiable? */ ase_awk_nde_call_t nde; nde.type = ASE_AWK_NDE_AFN; nde.next = ASE_NULL; - nde.what.afn.name = ASE_T("main"); - nde.what.afn.name_len = 4; + nde.what.afn.name = main; + nde.what.afn.name_len = ase_awk_strlen(main); nde.args = ASE_NULL; nde.nargs = 0; diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index ed23753a..48906672 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.118 2006-11-19 11:21:06 bacon Exp $ + * $Id: awk.c,v 1.119 2006-11-19 15:24:20 bacon Exp $ */ #include @@ -742,6 +742,7 @@ static int __main (int argc, ase_char_t* argv[]) #ifdef _WIN32 syscas_data_t syscas_data; #endif + const ase_char_t* mfn = ASE_NULL; opt = ASE_AWK_IMPLICIT | ASE_AWK_EXPLICIT | ASE_AWK_UNIQUE | ASE_AWK_HASHSIGN | /*ASE_AWK_DBLSLASHES |*/ @@ -759,7 +760,7 @@ static int __main (int argc, ase_char_t* argv[]) { if (ase_awk_strcmp(argv[i], ASE_T("-m")) == 0) { - opt |= ASE_AWK_RUNMAIN; + mfn = ASE_T("main"); } else if (file_count == 0) { @@ -870,7 +871,7 @@ static int __main (int argc, ase_char_t* argv[]) runarg[3].ptr = ASE_NULL; runarg[3].len = 0; - if (ase_awk_run (awk, &runios, &runcbs, runarg) == -1) + if (ase_awk_run (awk, mfn, &runios, &runcbs, runarg) == -1) { int errnum = ase_awk_geterrnum(awk); xp_printf ( diff --git a/ase/test/awk/t4.awk b/ase/test/awk/t4.awk index d3b88742..12b4b6fb 100644 --- a/ase/test/awk/t4.awk +++ b/ase/test/awk/t4.awk @@ -13,4 +13,6 @@ function main () { if (i in abc) j[i] = i; } + + print "end of program"; }