*** empty log message ***

This commit is contained in:
hyung-hwan 2007-01-11 03:56:02 +00:00
parent bdaa443901
commit 1ecd0723c7
4 changed files with 66 additions and 32 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.15 2007-01-10 14:30:43 bacon Exp $ * $Id: Awk.cpp,v 1.16 2007-01-11 03:55:35 bacon Exp $
*/ */
#include "stdafx.h" #include "stdafx.h"
@ -13,6 +13,9 @@
#include <wctype.h> #include <wctype.h>
#include <stdio.h> #include <stdio.h>
#define DBGOUT(x) do { if (debug) OutputDebugString (x); } while(0)
#define DBGOUT2(awk,x) do { if (awk->debug) OutputDebugString (x); } while(0)
STDMETHODIMP CAwk::InterfaceSupportsErrorInfo(REFIID riid) STDMETHODIMP CAwk::InterfaceSupportsErrorInfo(REFIID riid)
{ {
static const IID* arr[] = static const IID* arr[] =
@ -33,7 +36,8 @@ CAwk::CAwk ():
read_src_buf (NULL), read_src_buf (NULL),
write_src_buf (NULL), write_src_buf (NULL),
write_extio_buf (NULL), write_extio_buf (NULL),
entry_point (NULL) entry_point (NULL),
debug (FALSE)
{ {
/* TODO: what is the best default option? */ /* TODO: what is the best default option? */
option = option =
@ -68,6 +72,7 @@ CAwk::~CAwk ()
{ {
ase_awk_close (handle); ase_awk_close (handle);
handle = NULL; handle = NULL;
DBGOUT (_T("closed awk"));
} }
} }
@ -103,19 +108,12 @@ static int awk_sprintf (
va_list ap; va_list ap;
va_start (ap, fmt); va_start (ap, fmt);
#if defined(_WIN32)
n = _vsntprintf (buf, len, fmt, ap); n = _vsntprintf (buf, len, fmt, ap);
if (n < 0 || (ase_size_t)n >= len) if (n < 0 || (ase_size_t)n >= len)
{ {
if (len > 0) buf[len-1] = ASE_T('\0'); if (len > 0) buf[len-1] = ASE_T('\0');
n = -1; n = -1;
} }
#elif defined(__MSDOS__)
/* TODO: check buffer overflow */
n = vsprintf (buf, fmt, ap);
#else
n = xp_vsprintf (buf, len, fmt, ap);
#endif
va_end (ap); va_end (ap);
return n; return n;
} }
@ -123,13 +121,10 @@ static int awk_sprintf (
static void awk_aprintf (const ase_char_t* fmt, ...) static void awk_aprintf (const ase_char_t* fmt, ...)
{ {
va_list ap; va_list ap;
#ifdef _WIN32
int n; int n;
ase_char_t buf[1024]; ase_char_t buf[1024];
#endif
va_start (ap, fmt); va_start (ap, fmt);
#if defined(_WIN32)
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap); n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0'); if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
@ -140,11 +135,6 @@ static void awk_aprintf (const ase_char_t* fmt, ...)
MessageBox (NULL, buf, MessageBox (NULL, buf,
ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR); ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR);
#endif #endif
#elif defined(__MSDOS__)
vprintf (fmt, ap);
#else
xp_vprintf (fmt, ap);
#endif
va_end (ap); va_end (ap);
} }
@ -152,15 +142,7 @@ static void awk_dprintf (const ase_char_t* fmt, ...)
{ {
va_list ap; va_list ap;
va_start (ap, fmt); va_start (ap, fmt);
#if defined(_WIN32)
_vftprintf (stderr, fmt, ap); _vftprintf (stderr, fmt, ap);
#elif defined(__MSDOS__)
vfprintf (stderr, fmt, ap);
#else
xp_vfprintf (stderr, fmt, ap);
#endif
va_end (ap); va_end (ap);
} }
@ -184,7 +166,11 @@ static ase_ssize_t __read_source (
HRESULT hr = CoCreateInstance ( HRESULT hr = CoCreateInstance (
CLSID_Buffer, NULL, CLSCTX_ALL, CLSID_Buffer, NULL, CLSCTX_ALL,
IID_IBuffer, (void**)&awk->read_src_buf); IID_IBuffer, (void**)&awk->read_src_buf);
if (FAILED(hr)) return -1; if (FAILED(hr))
{
DBGOUT2 (awk, _T("cannot create source input buffer"));
return -1;
}
awk->read_src_pos = 0; awk->read_src_pos = 0;
awk->read_src_len = 0; awk->read_src_len = 0;
@ -251,11 +237,19 @@ static ase_ssize_t __write_source (
hr = CoCreateInstance ( hr = CoCreateInstance (
CLSID_Buffer, NULL, CLSCTX_ALL, CLSID_Buffer, NULL, CLSCTX_ALL,
IID_IBuffer, (void**)&awk->write_src_buf); IID_IBuffer, (void**)&awk->write_src_buf);
if (FAILED(hr)) return -1; if (FAILED(hr))
{
DBGOUT2 (awk, _T("cannot create source output buffer"));
return -1;
}
} }
CBuffer* tmp = (CBuffer*)awk->write_src_buf; CBuffer* tmp = (CBuffer*)awk->write_src_buf;
if (tmp->PutValue (data, count) == FALSE) return -1; if (tmp->PutValue (data, count) == FALSE)
{
DBGOUT2 (awk, _T("cannot set source output buffer"));
return -1;
}
INT n = awk->Fire_WriteSource (awk->write_src_buf); INT n = awk->Fire_WriteSource (awk->write_src_buf);
if (n > (INT)count) return -1; if (n > (INT)count) return -1;
@ -307,8 +301,11 @@ HRESULT CAwk::Parse (int* ret)
ase_awk_geterrstr(errnum)); ase_awk_geterrstr(errnum));
*ret = -1; *ret = -1;
DBGOUT (_T("cannot open awk"));
return S_OK; return S_OK;
} }
else DBGOUT (_T("opened awk successfully"));
ase_awk_setoption (handle, option); ase_awk_setoption (handle, option);
@ -339,9 +336,12 @@ HRESULT CAwk::Parse (int* ret)
ase_awk_geterror (handle, &errnum, &errlin, &msg); ase_awk_geterror (handle, &errnum, &errlin, &msg);
ase_awk_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg); ase_awk_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg);
DBGOUT (_T("cannot parse the source code"));
*ret = -1; *ret = -1;
return S_OK; return S_OK;
} }
else DBGOUT (_T("parsed the source code successfully"));
*ret = 0; *ret = 0;
return S_OK; return S_OK;
@ -362,13 +362,18 @@ static ase_ssize_t __process_extio (
HRESULT hr = CoCreateInstance ( HRESULT hr = CoCreateInstance (
CLSID_AwkExtio, NULL, CLSCTX_ALL, CLSID_AwkExtio, NULL, CLSCTX_ALL,
IID_IAwkExtio, (void**)&extio); IID_IAwkExtio, (void**)&extio);
if (FAILED(hr)) return -1; if (FAILED(hr))
{
DBGOUT2 (awk, _T("cannot create extio"));
return -1;
}
hr = CoCreateInstance ( hr = CoCreateInstance (
CLSID_Buffer, NULL, CLSCTX_ALL, CLSID_Buffer, NULL, CLSCTX_ALL,
IID_IBuffer, (void**)&read_buf); IID_IBuffer, (void**)&read_buf);
if (FAILED(hr)) if (FAILED(hr))
{ {
DBGOUT2 (awk, _T("cannot create extio input buffer"));
extio->Release (); extio->Release ();
return -1; return -1;
} }
@ -378,6 +383,7 @@ static ase_ssize_t __process_extio (
{ {
read_buf->Release (); read_buf->Release ();
extio->Release (); extio->Release ();
DBGOUT2 (awk, _T("cannot set the name of the extio input buffer"));
return -1; return -1;
} }
extio2->type = epa->type & 0xFF; extio2->type = epa->type & 0xFF;
@ -474,7 +480,11 @@ static ase_ssize_t __process_extio (
hr = CoCreateInstance ( hr = CoCreateInstance (
CLSID_Buffer, NULL, CLSCTX_ALL, CLSID_Buffer, NULL, CLSCTX_ALL,
IID_IBuffer, (void**)&awk->write_extio_buf); IID_IBuffer, (void**)&awk->write_extio_buf);
if (FAILED(hr)) return -1; if (FAILED(hr))
{
DBGOUT2 (awk, _T("cannot create extio output buffer"));
return -1;
}
} }
CBuffer* tmp = (CBuffer*)awk->write_extio_buf; CBuffer* tmp = (CBuffer*)awk->write_extio_buf;
@ -531,9 +541,11 @@ HRESULT CAwk::Run (int* ret)
ase_awk_geterror (handle, &errnum, &errlin, &msg); ase_awk_geterror (handle, &errnum, &errlin, &msg);
ase_awk_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg); ase_awk_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg);
DBGOUT (_T("cannot run the program"));
*ret = -1; *ret = -1;
return S_OK; return S_OK;
} }
else DBGOUT (_T("run the program successfully"));
*ret = 0; *ret = 0;
return S_OK; return S_OK;
@ -912,3 +924,15 @@ STDMETHODIMP CAwk::put_EntryPoint(BSTR newVal)
return S_OK; return S_OK;
} }
STDMETHODIMP CAwk::get_Debug(BOOL *pVal)
{
*pVal = debug;
return S_OK;
}
STDMETHODIMP CAwk::put_Debug(BOOL newVal)
{
debug = newVal;
return S_OK;
}

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.h,v 1.9 2007-01-10 14:30:44 bacon Exp $ * $Id: Awk.h,v 1.10 2007-01-11 03:55:35 bacon Exp $
*/ */
#ifndef _ASE_COM_AWK_H_ #ifndef _ASE_COM_AWK_H_
@ -62,6 +62,7 @@ public:
IBuffer* write_extio_buf; IBuffer* write_extio_buf;
BSTR entry_point; BSTR entry_point;
BOOL debug;
public: public:
CAwk(); CAwk();
~CAwk (); ~CAwk ();
@ -89,6 +90,8 @@ DECLARE_REGISTRY_RESOURCEID(IDR_AWK)
// IAwk // IAwk
public: public:
STDMETHOD(get_Debug)(/*[out, retval]*/ BOOL *pVal);
STDMETHOD(put_Debug)(/*[in]*/ BOOL newVal);
STDMETHOD(get_EntryPoint)(/*[out, retval]*/ BSTR *pVal); STDMETHOD(get_EntryPoint)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_EntryPoint)(/*[in]*/ BSTR newVal); STDMETHOD(put_EntryPoint)(/*[in]*/ BSTR newVal);
STDMETHOD(get_MaxDepthForRexMatch)(/*[out, retval]*/ int *pVal); STDMETHOD(get_MaxDepthForRexMatch)(/*[out, retval]*/ int *pVal);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ase.idl,v 1.10 2007-01-10 14:32:20 bacon Exp $ * $Id: ase.idl,v 1.11 2007-01-11 03:55:35 bacon Exp $
*/ */
import "oaidl.idl"; import "oaidl.idl";
@ -130,6 +130,11 @@ interface IAwk : IDispatch
HRESULT EntryPoint([out, retval] BSTR *pVal); HRESULT EntryPoint([out, retval] BSTR *pVal);
[propput, id(25), helpstring("property EntryPoint")] [propput, id(25), helpstring("property EntryPoint")]
HRESULT EntryPoint([in] BSTR newVal); HRESULT EntryPoint([in] BSTR newVal);
[propget, id(26), helpstring("property Debug")]
HRESULT Debug([out, retval] BOOL *pVal);
[propput, id(26), helpstring("property Debug")]
HRESULT Debug([in] BOOL newVal);
}; };
/* ASELib */ /* ASELib */

View File

@ -172,6 +172,8 @@ Private Sub Execute_Click()
'Awk.MaxDepthForRexBuild = 10 'Awk.MaxDepthForRexBuild = 10
'Awk.MaxDepthForRexMatch = 10 'Awk.MaxDepthForRexMatch = 10
Awk.Debug = True
If Awk.Parse() = -1 Then If Awk.Parse() = -1 Then
MsgBox "PARSE ERROR [" + Str(Awk.ErrorLine) + "]" + Awk.ErrorMessage MsgBox "PARSE ERROR [" + Str(Awk.ErrorLine) + "]" + Awk.ErrorMessage
Else Else