*** empty log message ***

This commit is contained in:
hyung-hwan 2006-11-19 15:24:21 +00:00
parent 6ff7516f42
commit 55e846cc01
4 changed files with 18 additions and 12 deletions

View File

@ -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_ #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. * error number. The third parameter to on_end denotes this error number.
*/ */
int ase_awk_run (ase_awk_t* awk, int ase_awk_run (ase_awk_t* awk,
const ase_char_t* main,
ase_awk_runios_t* runios, ase_awk_runios_t* runios,
ase_awk_runcbs_t* runcbs, ase_awk_runcbs_t* runcbs,
ase_awk_runarg_t* runarg); ase_awk_runarg_t* runarg);

View File

@ -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 <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -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 __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 __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_blocks (ase_awk_run_t* run);
static int __run_pattern_block_chain ( static int __run_pattern_block_chain (
ase_awk_run_t* run, ase_awk_chain_t* 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, int ase_awk_run (ase_awk_t* awk,
const ase_char_t* main,
ase_awk_runios_t* runios, ase_awk_runios_t* runios,
ase_awk_runcbs_t* runcbs, ase_awk_runcbs_t* runcbs,
ase_awk_runarg_t* runarg) 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); runcbs->on_start (awk, run, runcbs->custom_data);
} }
n = __run_main (run, runarg); n = __run_main (run, main, runarg);
if (n == -1) if (n == -1)
{ {
/* if no callback is specified, awk's error number /* 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; 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 nglobals, nargs, i;
ase_size_t saved_stack_top; 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); n = __update_fnr (run, 0);
if (n == 0) n = __set_globals_to_default (run); 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; ase_awk_nde_call_t nde;
nde.type = ASE_AWK_NDE_AFN; nde.type = ASE_AWK_NDE_AFN;
nde.next = ASE_NULL; nde.next = ASE_NULL;
nde.what.afn.name = ASE_T("main"); nde.what.afn.name = main;
nde.what.afn.name_len = 4; nde.what.afn.name_len = ase_awk_strlen(main);
nde.args = ASE_NULL; nde.args = ASE_NULL;
nde.nargs = 0; nde.nargs = 0;

View File

@ -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 <ase/awk/awk.h> #include <ase/awk/awk.h>
@ -742,6 +742,7 @@ static int __main (int argc, ase_char_t* argv[])
#ifdef _WIN32 #ifdef _WIN32
syscas_data_t syscas_data; syscas_data_t syscas_data;
#endif #endif
const ase_char_t* mfn = ASE_NULL;
opt = ASE_AWK_IMPLICIT | ASE_AWK_EXPLICIT | ASE_AWK_UNIQUE | ASE_AWK_HASHSIGN | opt = ASE_AWK_IMPLICIT | ASE_AWK_EXPLICIT | ASE_AWK_UNIQUE | ASE_AWK_HASHSIGN |
/*ASE_AWK_DBLSLASHES |*/ /*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) if (ase_awk_strcmp(argv[i], ASE_T("-m")) == 0)
{ {
opt |= ASE_AWK_RUNMAIN; mfn = ASE_T("main");
} }
else if (file_count == 0) 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].ptr = ASE_NULL;
runarg[3].len = 0; 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); int errnum = ase_awk_geterrnum(awk);
xp_printf ( xp_printf (

View File

@ -13,4 +13,6 @@ function main ()
{ {
if (i in abc) j[i] = i; if (i in abc) j[i] = i;
} }
print "end of program";
} }