diff --git a/ase/awk/awk.h b/ase/awk/awk.h index c1ee3df7..17a4b5a8 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.213 2007-03-23 07:45:22 bacon Exp $ + * $Id: awk.h,v 1.214 2007-04-15 15:26:57 bacon Exp $ * * {License} */ @@ -187,7 +187,10 @@ enum ASE_AWK_NEXTOFILE = (1 << 12), /* cr + lf by default */ - ASE_AWK_CRLF = (1 << 13) + ASE_AWK_CRLF = (1 << 13), + + /* pass the arguments to the main function */ + ASE_AWK_ARGSTOMAIN = (1 << 14) }; /* error code */ diff --git a/ase/awk/run.c b/ase/awk/run.c index e4896025..5b26f631 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.347 2007-03-20 10:44:44 bacon Exp $ + * $Id: run.c,v 1.348 2007-04-15 15:26:57 bacon Exp $ * * {License} */ @@ -1209,6 +1209,14 @@ static int run_main ( if (runarg != ASE_NULL) { + if (!(run->awk->option & ASE_AWK_ARGSTOMAIN)) + { + /* if the option is not set, the arguments + * arenot passed to the main function as + * parameters */ + nrunargs = 0; + } + /* prepare to pass the arguments to the main function */ for (i = nrunargs; i > 0; ) { diff --git a/ase/com/Awk.cpp b/ase/com/Awk.cpp index 8b382b8b..3604539b 100644 --- a/ase/com/Awk.cpp +++ b/ase/com/Awk.cpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.cpp,v 1.33 2007-04-15 14:25:35 bacon Exp $ + * $Id: Awk.cpp,v 1.34 2007-04-15 15:26:57 bacon Exp $ * * {License} */ @@ -790,7 +790,7 @@ HRESULT CAwk::Run (VARIANT_BOOL* ret) } STDMETHODIMP CAwk::AddFunction ( - BSTR name, int min_args, int max_args, VARIANT_BOOL* ret) + BSTR name, int minArgs, int maxArgs, VARIANT_BOOL* ret) { bfn_t* bfn; size_t name_len = SysStringLen(name); @@ -843,8 +843,8 @@ STDMETHODIMP CAwk::AddFunction ( } memcpy (bfn->name.ptr, name, sizeof(TCHAR) * bfn->name.len); - bfn->min_args = min_args; - bfn->max_args = max_args; + bfn->min_args = minArgs; + bfn->max_args = maxArgs; bfn->next = bfn_list; bfn_list = bfn; @@ -1103,6 +1103,21 @@ STDMETHODIMP CAwk::put_UseCrlf(VARIANT_BOOL newVal) return S_OK; } +STDMETHODIMP CAwk::get_ArgsToMain(VARIANT_BOOL *pVal) +{ + if (handle != NULL) option = ase_awk_getoption (handle); + *pVal = (option & ASE_AWK_ARGSTOMAIN) == 1; + return S_OK; +} + +STDMETHODIMP CAwk::put_ArgsToMain(VARIANT_BOOL newVal) +{ + if (newVal) option = option | ASE_AWK_ARGSTOMAIN; + else option = option & ~ASE_AWK_ARGSTOMAIN; + if (handle != NULL) ase_awk_setoption (handle, option); + return S_OK; +} + STDMETHODIMP CAwk::get_MaxDepthForBlockParse(int *pVal) { if (handle != NULL) diff --git a/ase/com/Awk.h b/ase/com/Awk.h index 0b6f0bf8..1b4a7317 100644 --- a/ase/com/Awk.h +++ b/ase/com/Awk.h @@ -1,5 +1,5 @@ /* - * $Id: Awk.h,v 1.20 2007-04-15 14:25:35 bacon Exp $ + * $Id: Awk.h,v 1.21 2007-04-15 15:26:58 bacon Exp $ * * {License} */ @@ -124,6 +124,8 @@ public: STDMETHOD(put_MaxDepthForBlockRun)(/*[in]*/ int newVal); STDMETHOD(get_MaxDepthForBlockParse)(/*[out, retval]*/ int *pVal); STDMETHOD(put_MaxDepthForBlockParse)(/*[in]*/ int newVal); + STDMETHOD(get_ArgsToMain)(/*[out, retval]*/ VARIANT_BOOL *pVal); + STDMETHOD(put_ArgsToMain)(/*[in]*/ VARIANT_BOOL newVal); STDMETHOD(get_UseCrlf)(/*[out, retval]*/ VARIANT_BOOL *pVal); STDMETHOD(put_UseCrlf)(/*[in]*/ VARIANT_BOOL newVal); STDMETHOD(get_Nextofile)(/*[out, retval]*/ VARIANT_BOOL *pVal); @@ -154,8 +156,12 @@ public: STDMETHOD(get_ErrorLine)(/*[out, retval]*/ int *pVal); STDMETHOD(get_ErrorCode)(/*[out, retval]*/ int *pVal); - STDMETHOD(DeleteFunction)(/*[in]*/ BSTR name, /*[out, retval]*/ VARIANT_BOOL* ret); - STDMETHOD(AddFunction)(/*[in]*/ BSTR name, /*[in]*/ int min_args, /*[in]*/ int max_args, /*[out, retval]*/ VARIANT_BOOL* ret); + HRESULT __stdcall DeleteFunction ( + /*[in]*/ BSTR name, /*[out, retval]*/ VARIANT_BOOL* ret); + HRESULT __stdcall AddFunction ( + /*[in]*/ BSTR name, /*[in]*/ int minArgs, + /*[in]*/ int maxArgs, /*[out, retval]*/ VARIANT_BOOL* ret); + HRESULT __stdcall Parse (/*[out, retval]*/ VARIANT_BOOL* ret); HRESULT __stdcall Run (/*[out, retval]*/ VARIANT_BOOL* ret); }; diff --git a/ase/com/asecom.idl b/ase/com/asecom.idl index 9571ccea..f79844a7 100644 --- a/ase/com/asecom.idl +++ b/ase/com/asecom.idl @@ -1,5 +1,5 @@ /* - * $Id: asecom.idl,v 1.4 2007-04-15 14:25:35 bacon Exp $ + * $Id: asecom.idl,v 1.5 2007-04-15 15:26:58 bacon Exp $ */ import "oaidl.idl"; @@ -22,7 +22,7 @@ interface IAwk : IDispatch HRESULT Run([out,retval] VARIANT_BOOL* ret); [id(3), helpstring("method AddFunction")] - HRESULT AddFunction([in] BSTR name, [in] int min_args, [in] int max_args, [out,retval] VARIANT_BOOL* ret); + HRESULT AddFunction([in] BSTR name, [in] int minArgs, [in] int maxArgs, [out,retval] VARIANT_BOOL* ret); [id(4), helpstring("method DeleteFunction")] HRESULT DeleteFunction([in] BSTR name, [out,retval] VARIANT_BOOL* ret); @@ -101,49 +101,54 @@ interface IAwk : IDispatch [propput, id(20), helpstring("property UseCrlf")] HRESULT UseCrlf([in] VARIANT_BOOL newVal); - [propget, id(21), helpstring("property MaxDepthForBlockParse")] + [propget, id(21), helpstring("property ArgsToMain")] + HRESULT ArgsToMain([out,retval] VARIANT_BOOL *pVal); + [propput, id(21), helpstring("property ArgsToMain")] + HRESULT ArgsToMain([in] VARIANT_BOOL newVal); + + [propget, id(22), helpstring("property MaxDepthForBlockParse")] HRESULT MaxDepthForBlockParse([out,retval] int *pVal); - [propput, id(21), helpstring("property MaxDepthForBlockParse")] + [propput, id(22), helpstring("property MaxDepthForBlockParse")] HRESULT MaxDepthForBlockParse([in] int newVal); - [propget, id(22), helpstring("property MaxDepthForBlockRun")] + [propget, id(23), helpstring("property MaxDepthForBlockRun")] HRESULT MaxDepthForBlockRun([out,retval] int *pVal); - [propput, id(22), helpstring("property MaxDepthForBlockRun")] + [propput, id(23), helpstring("property MaxDepthForBlockRun")] HRESULT MaxDepthForBlockRun([in] int newVal); - [propget, id(23), helpstring("property MaxDepthForExprParse")] + [propget, id(24), helpstring("property MaxDepthForExprParse")] HRESULT MaxDepthForExprParse([out,retval] int *pVal); - [propput, id(23), helpstring("property MaxDepthForExprParse")] + [propput, id(24), helpstring("property MaxDepthForExprParse")] HRESULT MaxDepthForExprParse([in] int newVal); - [propget, id(24), helpstring("property MaxDepthForExprRun")] + [propget, id(25), helpstring("property MaxDepthForExprRun")] HRESULT MaxDepthForExprRun([out,retval] int *pVal); - [propput, id(24), helpstring("property MaxDepthForExprRun")] + [propput, id(25), helpstring("property MaxDepthForExprRun")] HRESULT MaxDepthForExprRun([in] int newVal); - [propget, id(25), helpstring("property MaxDepthForRexBuild")] + [propget, id(26), helpstring("property MaxDepthForRexBuild")] HRESULT MaxDepthForRexBuild([out,retval] int *pVal); - [propput, id(25), helpstring("property MaxDepthForRexBuild")] + [propput, id(26), helpstring("property MaxDepthForRexBuild")] HRESULT MaxDepthForRexBuild([in] int newVal); - [propget, id(26), helpstring("property MaxDepthForRexMatch")] + [propget, id(27), helpstring("property MaxDepthForRexMatch")] HRESULT MaxDepthForRexMatch([out,retval] int *pVal); - [propput, id(26), helpstring("property MaxDepthForRexMatch")] + [propput, id(27), helpstring("property MaxDepthForRexMatch")] HRESULT MaxDepthForRexMatch([in] int newVal); - [propget, id(27), helpstring("property EntryPoint")] + [propget, id(28), helpstring("property EntryPoint")] HRESULT EntryPoint([out,retval] BSTR *pVal); - [propput, id(27), helpstring("property EntryPoint")] + [propput, id(28), helpstring("property EntryPoint")] HRESULT EntryPoint([in] BSTR newVal); - [propget, id(28), helpstring("property Debug")] + [propget, id(29), helpstring("property Debug")] HRESULT Debug([out,retval] VARIANT_BOOL *pVal); - [propput, id(28), helpstring("property Debug")] + [propput, id(29), helpstring("property Debug")] HRESULT Debug([in] VARIANT_BOOL newVal); - [propget, id(29), helpstring("property UseLongLong")] + [propget, id(30), helpstring("property UseLongLong")] HRESULT UseLongLong([out,retval] VARIANT_BOOL *pVal); - [propput, id(29), helpstring("property UseLongLong")] + [propput, id(30), helpstring("property UseLongLong")] HRESULT UseLongLong([in] VARIANT_BOOL newVal); }; diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index fcf471d9..6e1a6162 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.192 2007-03-20 10:44:45 bacon Exp $ + * $Id: awk.c,v 1.193 2007-04-15 15:26:58 bacon Exp $ */ #include @@ -835,7 +835,8 @@ static int awk_main (int argc, ase_char_t* argv[]) ASE_AWK_BLOCKLESS | ASE_AWK_STRBASEONE | ASE_AWK_STRIPSPACES | - ASE_AWK_NEXTOFILE; + ASE_AWK_NEXTOFILE /*| + ASE_AWK_ARGSTOMAIN*/; if (argc <= 1) { diff --git a/ase/test/com/AwkForm.frm b/ase/test/com/AwkForm.frm index 31de648d..90533ffc 100644 --- a/ase/test/com/AwkForm.frm +++ b/ase/test/com/AwkForm.frm @@ -1,6 +1,6 @@ VERSION 5.00 Begin VB.Form AwkForm - Caption = "ASE COM AWK" + Caption = "ASE.COM.AWK" ClientHeight = 7635 ClientLeft = 60 ClientTop = 345 diff --git a/ase/test/com/ase.vbw b/ase/test/com/ase.vbw index a068e5db..f5ccef48 100644 --- a/ase/test/com/ase.vbw +++ b/ase/test/com/ase.vbw @@ -1,2 +1,2 @@ -AwkForm = 13, 12, 735, 661, , 22, 22, 753, 640, C +AwkForm = 13, 12, 735, 661, C, 22, 22, 753, 640, C AwkExtioConsole = 0, 0, 547, 460, C