Recovered from cvs revision 2007-06-30 03:05:00
This commit is contained in:
		@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Awk.hpp,v 1.43 2007/06/28 15:45:57 bacon Exp $
 | 
			
		||||
 * $Id: Awk.hpp,v 1.44 2007/06/29 11:36:45 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ASE_AWK_AWK_HPP_
 | 
			
		||||
@ -239,6 +239,7 @@ namespace ASE
 | 
			
		||||
			ERR_SOUTCL = ASE_AWK_ESOUTCL,
 | 
			
		||||
			ERR_SOUTWR = ASE_AWK_ESOUTWR,
 | 
			
		||||
			ERR_LXCHR = ASE_AWK_ELXCHR,
 | 
			
		||||
			ERR_LXDIG = ASE_AWK_ELXDIG,
 | 
			
		||||
			ERR_LXUNG = ASE_AWK_ELXUNG,
 | 
			
		||||
			ERR_ENDSRC = ASE_AWK_EENDSRC,
 | 
			
		||||
			ERR_ENDCMT = ASE_AWK_EENDCMT,
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Exception.java,v 1.4 2007/06/25 14:13:23 bacon Exp $
 | 
			
		||||
 * $Id: Exception.java,v 1.5 2007/06/29 11:36:45 bacon Exp $
 | 
			
		||||
 *
 | 
			
		||||
 * {License}
 | 
			
		||||
 */
 | 
			
		||||
@ -43,100 +43,101 @@ public class Exception extends java.lang.Exception
 | 
			
		||||
	public static final int SOUTCL = 28;
 | 
			
		||||
	public static final int SOUTWR = 29;
 | 
			
		||||
	public static final int LXCHR = 30;
 | 
			
		||||
	public static final int LXUNG = 31;
 | 
			
		||||
	public static final int ENDSRC = 32;
 | 
			
		||||
	public static final int ENDCMT = 33;
 | 
			
		||||
	public static final int ENDSTR = 34;
 | 
			
		||||
	public static final int ENDREX = 35;
 | 
			
		||||
	public static final int LBRACE = 36;
 | 
			
		||||
	public static final int LPAREN = 37;
 | 
			
		||||
	public static final int RPAREN = 38;
 | 
			
		||||
	public static final int RBRACK = 39;
 | 
			
		||||
	public static final int COMMA = 40;
 | 
			
		||||
	public static final int SCOLON = 41;
 | 
			
		||||
	public static final int COLON = 42;
 | 
			
		||||
	public static final int STMEND = 43;
 | 
			
		||||
	public static final int IN = 44;
 | 
			
		||||
	public static final int NOTVAR = 45;
 | 
			
		||||
	public static final int EXPRES = 46;
 | 
			
		||||
	public static final int WHILE = 47;
 | 
			
		||||
	public static final int ASSIGN = 48;
 | 
			
		||||
	public static final int IDENT = 49;
 | 
			
		||||
	public static final int FNNAME = 50;
 | 
			
		||||
	public static final int BLKBEG = 51;
 | 
			
		||||
	public static final int BLKEND = 52;
 | 
			
		||||
	public static final int DUPBEG = 53;
 | 
			
		||||
	public static final int DUPEND = 54;
 | 
			
		||||
	public static final int BFNRED = 55;
 | 
			
		||||
	public static final int AFNRED = 56;
 | 
			
		||||
	public static final int GBLRED = 57;
 | 
			
		||||
	public static final int PARRED = 58;
 | 
			
		||||
	public static final int DUPPAR = 59;
 | 
			
		||||
	public static final int DUPGBL = 60;
 | 
			
		||||
	public static final int DUPLCL = 61;
 | 
			
		||||
	public static final int BADPAR = 62;
 | 
			
		||||
	public static final int BADVAR = 63;
 | 
			
		||||
	public static final int UNDEF = 64;
 | 
			
		||||
	public static final int LVALUE = 65;
 | 
			
		||||
	public static final int GBLTM = 66;
 | 
			
		||||
	public static final int LCLTM = 67;
 | 
			
		||||
	public static final int PARTM = 68;
 | 
			
		||||
	public static final int DELETE = 69;
 | 
			
		||||
	public static final int BREAK = 70;
 | 
			
		||||
	public static final int CONTINUE = 71;
 | 
			
		||||
	public static final int NEXTBEG = 72;
 | 
			
		||||
	public static final int NEXTEND = 73;
 | 
			
		||||
	public static final int NEXTFBEG = 74;
 | 
			
		||||
	public static final int NEXTFEND = 75;
 | 
			
		||||
	public static final int PRINTFARG = 76;
 | 
			
		||||
	public static final int PREPST = 77;
 | 
			
		||||
	public static final int GLNCPS = 78;
 | 
			
		||||
	public static final int DIVBY0 = 79;
 | 
			
		||||
	public static final int OPERAND = 80;
 | 
			
		||||
	public static final int POSIDX = 81;
 | 
			
		||||
	public static final int ARGTF = 82;
 | 
			
		||||
	public static final int ARGTM = 83;
 | 
			
		||||
	public static final int FNNONE = 84;
 | 
			
		||||
	public static final int NOTIDX = 85;
 | 
			
		||||
	public static final int NOTDEL = 86;
 | 
			
		||||
	public static final int NOTMAP = 87;
 | 
			
		||||
	public static final int NOTMAPIN = 88;
 | 
			
		||||
	public static final int NOTMAPNILIN = 89;
 | 
			
		||||
	public static final int NOTREF = 90;
 | 
			
		||||
	public static final int NOTASS = 91;
 | 
			
		||||
	public static final int IDXVALASSMAP = 92;
 | 
			
		||||
	public static final int POSVALASSMAP = 93;
 | 
			
		||||
	public static final int MAPTOSCALAR = 94;
 | 
			
		||||
	public static final int SCALARTOMAP = 95;
 | 
			
		||||
	public static final int MAPNOTALLOWED = 96;
 | 
			
		||||
	public static final int VALTYPE = 97;
 | 
			
		||||
	public static final int RDELETE = 98;
 | 
			
		||||
	public static final int RNEXTBEG = 99;
 | 
			
		||||
	public static final int RNEXTEND = 100;
 | 
			
		||||
	public static final int RNEXTFBEG = 101;
 | 
			
		||||
	public static final int RNEXTFEND = 102;
 | 
			
		||||
	public static final int BFNUSER = 103;
 | 
			
		||||
	public static final int BFNIMPL = 104;
 | 
			
		||||
	public static final int IOUSER = 105;
 | 
			
		||||
	public static final int IONONE = 106;
 | 
			
		||||
	public static final int IOIMPL = 107;
 | 
			
		||||
	public static final int IONMEM = 108;
 | 
			
		||||
	public static final int IONMNL = 109;
 | 
			
		||||
	public static final int FMTARG = 110;
 | 
			
		||||
	public static final int FMTCNV = 111;
 | 
			
		||||
	public static final int CONVFMTCHR = 112;
 | 
			
		||||
	public static final int OFMTCHR = 113;
 | 
			
		||||
	public static final int REXRECUR = 114;
 | 
			
		||||
	public static final int REXRPAREN = 115;
 | 
			
		||||
	public static final int REXRBRACKET = 116;
 | 
			
		||||
	public static final int REXRBRACE = 117;
 | 
			
		||||
	public static final int REXUNBALPAR = 118;
 | 
			
		||||
	public static final int REXCOLON = 119;
 | 
			
		||||
	public static final int REXCRANGE = 120;
 | 
			
		||||
	public static final int REXCCLASS = 121;
 | 
			
		||||
	public static final int REXBRANGE = 122;
 | 
			
		||||
	public static final int REXEND = 123;
 | 
			
		||||
	public static final int REXGARBAGE = 124;
 | 
			
		||||
	public static final int LXDIG = 31;
 | 
			
		||||
	public static final int LXUNG = 32;
 | 
			
		||||
	public static final int ENDSRC = 33;
 | 
			
		||||
	public static final int ENDCMT = 34;
 | 
			
		||||
	public static final int ENDSTR = 35;
 | 
			
		||||
	public static final int ENDREX = 36;
 | 
			
		||||
	public static final int LBRACE = 37;
 | 
			
		||||
	public static final int LPAREN = 38;
 | 
			
		||||
	public static final int RPAREN = 39;
 | 
			
		||||
	public static final int RBRACK = 40;
 | 
			
		||||
	public static final int COMMA = 41;
 | 
			
		||||
	public static final int SCOLON = 42;
 | 
			
		||||
	public static final int COLON = 43;
 | 
			
		||||
	public static final int STMEND = 44;
 | 
			
		||||
	public static final int IN = 45;
 | 
			
		||||
	public static final int NOTVAR = 46;
 | 
			
		||||
	public static final int EXPRES = 47;
 | 
			
		||||
	public static final int WHILE = 48;
 | 
			
		||||
	public static final int ASSIGN = 49;
 | 
			
		||||
	public static final int IDENT = 50;
 | 
			
		||||
	public static final int FNNAME = 51;
 | 
			
		||||
	public static final int BLKBEG = 52;
 | 
			
		||||
	public static final int BLKEND = 53;
 | 
			
		||||
	public static final int DUPBEG = 54;
 | 
			
		||||
	public static final int DUPEND = 55;
 | 
			
		||||
	public static final int BFNRED = 56;
 | 
			
		||||
	public static final int AFNRED = 57;
 | 
			
		||||
	public static final int GBLRED = 58;
 | 
			
		||||
	public static final int PARRED = 59;
 | 
			
		||||
	public static final int DUPPAR = 60;
 | 
			
		||||
	public static final int DUPGBL = 61;
 | 
			
		||||
	public static final int DUPLCL = 62;
 | 
			
		||||
	public static final int BADPAR = 63;
 | 
			
		||||
	public static final int BADVAR = 64;
 | 
			
		||||
	public static final int UNDEF = 65;
 | 
			
		||||
	public static final int LVALUE = 66;
 | 
			
		||||
	public static final int GBLTM = 67;
 | 
			
		||||
	public static final int LCLTM = 68;
 | 
			
		||||
	public static final int PARTM = 69;
 | 
			
		||||
	public static final int DELETE = 70;
 | 
			
		||||
	public static final int BREAK = 71;
 | 
			
		||||
	public static final int CONTINUE = 72;
 | 
			
		||||
	public static final int NEXTBEG = 73;
 | 
			
		||||
	public static final int NEXTEND = 74;
 | 
			
		||||
	public static final int NEXTFBEG = 75;
 | 
			
		||||
	public static final int NEXTFEND = 76;
 | 
			
		||||
	public static final int PRINTFARG = 77;
 | 
			
		||||
	public static final int PREPST = 78;
 | 
			
		||||
	public static final int GLNCPS = 79;
 | 
			
		||||
	public static final int DIVBY0 = 80;
 | 
			
		||||
	public static final int OPERAND = 81;
 | 
			
		||||
	public static final int POSIDX = 82;
 | 
			
		||||
	public static final int ARGTF = 83;
 | 
			
		||||
	public static final int ARGTM = 84;
 | 
			
		||||
	public static final int FNNONE = 85;
 | 
			
		||||
	public static final int NOTIDX = 86;
 | 
			
		||||
	public static final int NOTDEL = 87;
 | 
			
		||||
	public static final int NOTMAP = 88;
 | 
			
		||||
	public static final int NOTMAPIN = 89;
 | 
			
		||||
	public static final int NOTMAPNILIN = 90;
 | 
			
		||||
	public static final int NOTREF = 91;
 | 
			
		||||
	public static final int NOTASS = 92;
 | 
			
		||||
	public static final int IDXVALASSMAP = 93;
 | 
			
		||||
	public static final int POSVALASSMAP = 94;
 | 
			
		||||
	public static final int MAPTOSCALAR = 95;
 | 
			
		||||
	public static final int SCALARTOMAP = 96;
 | 
			
		||||
	public static final int MAPNOTALLOWED = 97;
 | 
			
		||||
	public static final int VALTYPE = 98;
 | 
			
		||||
	public static final int RDELETE = 99;
 | 
			
		||||
	public static final int RNEXTBEG = 100;
 | 
			
		||||
	public static final int RNEXTEND = 101;
 | 
			
		||||
	public static final int RNEXTFBEG = 102;
 | 
			
		||||
	public static final int RNEXTFEND = 103;
 | 
			
		||||
	public static final int BFNUSER = 104;
 | 
			
		||||
	public static final int BFNIMPL = 105;
 | 
			
		||||
	public static final int IOUSER = 106;
 | 
			
		||||
	public static final int IONONE = 107;
 | 
			
		||||
	public static final int IOIMPL = 108;
 | 
			
		||||
	public static final int IONMEM = 109;
 | 
			
		||||
	public static final int IONMNL = 110;
 | 
			
		||||
	public static final int FMTARG = 111;
 | 
			
		||||
	public static final int FMTCNV = 112;
 | 
			
		||||
	public static final int CONVFMTCHR = 113;
 | 
			
		||||
	public static final int OFMTCHR = 114;
 | 
			
		||||
	public static final int REXRECUR = 115;
 | 
			
		||||
	public static final int REXRPAREN = 116;
 | 
			
		||||
	public static final int REXRBRACKET = 117;
 | 
			
		||||
	public static final int REXRBRACE = 118;
 | 
			
		||||
	public static final int REXUNBALPAR = 119;
 | 
			
		||||
	public static final int REXCOLON = 120;
 | 
			
		||||
	public static final int REXCRANGE = 121;
 | 
			
		||||
	public static final int REXCCLASS = 122;
 | 
			
		||||
	public static final int REXBRANGE = 123;
 | 
			
		||||
	public static final int REXEND = 124;
 | 
			
		||||
	public static final int REXGARBAGE = 125;
 | 
			
		||||
	// end of error codes
 | 
			
		||||
 | 
			
		||||
	public Exception () 
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/* 
 | 
			
		||||
 * $Id: awk.h,v 1.7 2007/06/18 14:05:18 bacon Exp $
 | 
			
		||||
 * $Id: awk.h,v 1.8 2007/06/29 11:36:45 bacon Exp $
 | 
			
		||||
 *
 | 
			
		||||
 * {License}
 | 
			
		||||
 */
 | 
			
		||||
@ -233,6 +233,7 @@ enum ase_awk_errnum_t
 | 
			
		||||
	ASE_AWK_ESOUTWR,
 | 
			
		||||
 | 
			
		||||
	ASE_AWK_ELXCHR,         /* lexer came accross an wrong character */
 | 
			
		||||
	ASE_AWK_ELXDIG,         /* invalid digit */
 | 
			
		||||
	ASE_AWK_ELXUNG,         /* lexer failed to unget a character */
 | 
			
		||||
 | 
			
		||||
	ASE_AWK_EENDSRC,        /* unexpected end of source */
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: err.c,v 1.4 2007/05/19 12:13:41 bacon Exp $
 | 
			
		||||
 * $Id: err.c,v 1.5 2007/06/29 11:36:45 bacon Exp $
 | 
			
		||||
 *
 | 
			
		||||
 * {License}
 | 
			
		||||
 */
 | 
			
		||||
@ -47,6 +47,7 @@ static const ase_char_t* __geterrstr (int errnum)
 | 
			
		||||
		ASE_T("cannot write source output"),
 | 
			
		||||
 | 
			
		||||
		ASE_T("invalid character '%.*s'"),
 | 
			
		||||
		ASE_T("invalid digit '%.*s'"),
 | 
			
		||||
		ASE_T("cannot unget character"),
 | 
			
		||||
 | 
			
		||||
		ASE_T("unexpected end of source"),
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: parse.c,v 1.10 2007/06/28 15:45:57 bacon Exp $
 | 
			
		||||
 * $Id: parse.c,v 1.11 2007/06/29 11:36:45 bacon Exp $
 | 
			
		||||
 *
 | 
			
		||||
 * {License}
 | 
			
		||||
 */
 | 
			
		||||
@ -4423,6 +4423,13 @@ static int get_number (ase_awk_t* awk)
 | 
			
		||||
				GET_CHAR_TO (awk, c);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (c == ASE_T('8') || c == ASE_T('9'))
 | 
			
		||||
			{
 | 
			
		||||
				ase_char_t cc = (ase_char_t)c;
 | 
			
		||||
				SETERRARG (awk, ASE_AWK_ELXDIG, awk->token.line, &cc, 1);
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,8 @@
 | 
			
		||||
* added setWord/unsetWord method to the awk c++ class (awk/Awk.cpp)
 | 
			
		||||
* added setErrorString method to the awk c++ class (awk/Awk.cpp)
 | 
			
		||||
* added setWord/unsetWord method to the awk java class (awk/Awk.java)
 | 
			
		||||
* added the error code ASE_AWK_ELXDIG to indicate a wrong digit in
 | 
			
		||||
  octal number tokenization. 
 | 
			
		||||
 | 
			
		||||
* changed the wrong macro name WIN32 to _WIN32 in utl/stdio.h
 | 
			
		||||
* changed test/awk/Awk.cpp to include an option(-w) to utilize
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										129
									
								
								ase/com/Awk.cpp
									
									
									
									
									
								
							
							
						
						
									
										129
									
								
								ase/com/Awk.cpp
									
									
									
									
									
								
							@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Awk.cpp,v 1.4 2007/06/27 15:27:21 bacon Exp $
 | 
			
		||||
 * $Id: Awk.cpp,v 1.5 2007/06/29 11:24:27 bacon Exp $
 | 
			
		||||
 *
 | 
			
		||||
 * {License}
 | 
			
		||||
 */
 | 
			
		||||
@ -47,6 +47,7 @@ CAwk::CAwk ():
 | 
			
		||||
	write_src_buf (NULL),
 | 
			
		||||
	write_extio_buf (NULL),
 | 
			
		||||
	bfn_list (NULL),
 | 
			
		||||
	word_list (NULL),
 | 
			
		||||
	entry_point (NULL),
 | 
			
		||||
	debug (FALSE),
 | 
			
		||||
	use_longlong (FALSE)
 | 
			
		||||
@ -74,11 +75,16 @@ CAwk::CAwk ():
 | 
			
		||||
 | 
			
		||||
CAwk::~CAwk ()
 | 
			
		||||
{
 | 
			
		||||
	while (word_list != NULL)
 | 
			
		||||
	{
 | 
			
		||||
		word_t* next = word_list->next;
 | 
			
		||||
		free (word_list);
 | 
			
		||||
		word_list = next;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (bfn_list != NULL)
 | 
			
		||||
	{
 | 
			
		||||
		bfn_t* next = bfn_list->next;
 | 
			
		||||
		free (bfn_list->name.ptr);
 | 
			
		||||
		free (bfn_list);
 | 
			
		||||
		bfn_list = next;
 | 
			
		||||
	}
 | 
			
		||||
@ -566,6 +572,25 @@ HRESULT CAwk::Parse (VARIANT_BOOL* ret)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ase_awk_setword (handle, NULL, 0, NULL, 0);
 | 
			
		||||
	for (word_t* word = word_list; word != NULL; word = word->next)
 | 
			
		||||
	{
 | 
			
		||||
		if (ase_awk_setword (handle, 
 | 
			
		||||
			word->ow.ptr, word->ow.len,
 | 
			
		||||
			word->nw.ptr, word->nw.len) == -1)
 | 
			
		||||
		{
 | 
			
		||||
			const ase_char_t* msg;
 | 
			
		||||
 | 
			
		||||
			DBGOUT (_T("cannot set the word"));
 | 
			
		||||
 | 
			
		||||
			ase_awk_geterror (handle, &errnum, &errlin, &msg);
 | 
			
		||||
			ase_strxcpy (errmsg, ASE_COUNTOF(errmsg), msg);
 | 
			
		||||
 | 
			
		||||
			*ret = VARIANT_FALSE;
 | 
			
		||||
			return S_OK;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ase_awk_srcios_t srcios;
 | 
			
		||||
 | 
			
		||||
	srcios.in = __read_source;
 | 
			
		||||
@ -906,7 +931,7 @@ STDMETHODIMP CAwk::AddFunction (
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bfn = (bfn_t*)malloc (sizeof(bfn_t));
 | 
			
		||||
	bfn = (bfn_t*)malloc (sizeof(bfn_t) + name_len*sizeof(TCHAR));
 | 
			
		||||
	if (bfn == NULL) 
 | 
			
		||||
	{
 | 
			
		||||
		errnum = ASE_AWK_ENOMEM;
 | 
			
		||||
@ -920,20 +945,7 @@ STDMETHODIMP CAwk::AddFunction (
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bfn->name.len = name_len;
 | 
			
		||||
	bfn->name.ptr = (TCHAR*)malloc (bfn->name.len * sizeof(TCHAR));
 | 
			
		||||
	if (bfn->name.ptr == NULL) 
 | 
			
		||||
	{
 | 
			
		||||
		free (bfn);
 | 
			
		||||
 | 
			
		||||
		errnum = ASE_AWK_ENOMEM;
 | 
			
		||||
		errlin = 0;
 | 
			
		||||
		ase_strxcpy (
 | 
			
		||||
			errmsg, ASE_COUNTOF(errmsg), 
 | 
			
		||||
			ase_awk_geterrstr(NULL, errnum));
 | 
			
		||||
 | 
			
		||||
		*ret = VARIANT_FALSE;
 | 
			
		||||
		return S_OK;
 | 
			
		||||
	}
 | 
			
		||||
	bfn->name.ptr = (TCHAR*)(bfn + 1);
 | 
			
		||||
	memcpy (bfn->name.ptr, name, sizeof(TCHAR) * bfn->name.len);
 | 
			
		||||
 | 
			
		||||
	bfn->min_args = minArgs;
 | 
			
		||||
@ -958,7 +970,6 @@ STDMETHODIMP CAwk::DeleteFunction (BSTR name, VARIANT_BOOL* ret)
 | 
			
		||||
			bfn->name.ptr, bfn->name.len,
 | 
			
		||||
			name, name_len) == 0)
 | 
			
		||||
		{
 | 
			
		||||
			free (bfn->name.ptr);
 | 
			
		||||
			free (bfn);
 | 
			
		||||
 | 
			
		||||
			if (prev == NULL) bfn_list = next;
 | 
			
		||||
@ -983,12 +994,88 @@ STDMETHODIMP CAwk::DeleteFunction (BSTR name, VARIANT_BOOL* ret)
 | 
			
		||||
 | 
			
		||||
STDMETHODIMP CAwk::SetWord (BSTR ow, BSTR nw, VARIANT_BOOL* ret)
 | 
			
		||||
{
 | 
			
		||||
	word_t* word;
 | 
			
		||||
	size_t ow_len = SysStringLen(ow);
 | 
			
		||||
	size_t nw_len = SysStringLen(nw);
 | 
			
		||||
 | 
			
		||||
// TODO: 
 | 
			
		||||
	*ret = (ase_awk_setword (handle, ow, ow_len, nw, nw_len) == -1)? 
 | 
			
		||||
		VARIANT_FALSE: VARIANT_TRUE;
 | 
			
		||||
	for (word = word_list; word != NULL; word = word->next)
 | 
			
		||||
	{
 | 
			
		||||
		if (ase_strxncmp (
 | 
			
		||||
			word->ow.ptr, word->ow.len,
 | 
			
		||||
			ow, ow_len) == 0)
 | 
			
		||||
		{
 | 
			
		||||
			errnum = ASE_AWK_EEXIST;
 | 
			
		||||
			errlin = 0;
 | 
			
		||||
			_sntprintf (
 | 
			
		||||
				errmsg, ASE_COUNTOF(errmsg), 
 | 
			
		||||
				_T("'%.*s' added already"), 
 | 
			
		||||
				word->ow.len, word->ow.ptr);
 | 
			
		||||
 | 
			
		||||
			*ret = VARIANT_FALSE;
 | 
			
		||||
			return S_OK;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	word = (word_t*)malloc (sizeof(word_t)+(ow_len+nw_len)*sizeof(TCHAR));
 | 
			
		||||
	if (word == NULL) 
 | 
			
		||||
	{
 | 
			
		||||
		errnum = ASE_AWK_ENOMEM;
 | 
			
		||||
		errlin = 0;
 | 
			
		||||
		ase_strxcpy (
 | 
			
		||||
			errmsg, ASE_COUNTOF(errmsg), 
 | 
			
		||||
			ase_awk_geterrstr(NULL, errnum));
 | 
			
		||||
 | 
			
		||||
		*ret = VARIANT_FALSE;
 | 
			
		||||
		return S_OK;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	word->ow.len = ow_len;
 | 
			
		||||
	word->ow.ptr = (TCHAR*)(word+1);
 | 
			
		||||
	word->nw.len = nw_len;
 | 
			
		||||
	word->nw.ptr = word->ow.ptr + word->ow.len;
 | 
			
		||||
 | 
			
		||||
	memcpy (word->ow.ptr, ow, sizeof(TCHAR)*word->ow.len);
 | 
			
		||||
	memcpy (word->nw.ptr, nw, sizeof(TCHAR)*word->nw.len);
 | 
			
		||||
 | 
			
		||||
	word->next = word_list;
 | 
			
		||||
	word_list = word;
 | 
			
		||||
 | 
			
		||||
	*ret = VARIANT_TRUE;
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STDMETHODIMP CAwk::UnsetWord (BSTR ow, VARIANT_BOOL* ret)
 | 
			
		||||
{
 | 
			
		||||
	size_t ow_len = SysStringLen(ow);
 | 
			
		||||
	word_t* word, * next, * prev = NULL;
 | 
			
		||||
 | 
			
		||||
	for (word = word_list; word != NULL; word = next)
 | 
			
		||||
	{
 | 
			
		||||
		next = word->next;
 | 
			
		||||
 | 
			
		||||
		if (ase_strxncmp (
 | 
			
		||||
			word->ow.ptr, word->ow.len,
 | 
			
		||||
			ow, ow_len) == 0)
 | 
			
		||||
		{
 | 
			
		||||
			free (word);
 | 
			
		||||
 | 
			
		||||
			if (prev == NULL) word_list = next;
 | 
			
		||||
			else prev->next = next;
 | 
			
		||||
 | 
			
		||||
			*ret = VARIANT_TRUE;
 | 
			
		||||
			return S_OK;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		prev = word;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	errnum = ASE_AWK_ENOENT;
 | 
			
		||||
	errlin = 0;
 | 
			
		||||
	ase_strxcpy (
 | 
			
		||||
		errmsg, ASE_COUNTOF(errmsg), 
 | 
			
		||||
		ase_awk_geterrstr(NULL, errnum));
 | 
			
		||||
 | 
			
		||||
	*ret = VARIANT_FALSE;
 | 
			
		||||
	return S_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: Awk.h,v 1.4 2007/06/27 15:27:21 bacon Exp $
 | 
			
		||||
 * $Id: Awk.h,v 1.5 2007/06/29 11:24:27 bacon Exp $
 | 
			
		||||
 *
 | 
			
		||||
 * {License}
 | 
			
		||||
 */
 | 
			
		||||
@ -76,6 +76,23 @@ public:
 | 
			
		||||
		struct bfn_t* next;
 | 
			
		||||
	} * bfn_list;
 | 
			
		||||
 | 
			
		||||
	struct word_t
 | 
			
		||||
	{
 | 
			
		||||
		struct
 | 
			
		||||
		{
 | 
			
		||||
			TCHAR* ptr;
 | 
			
		||||
			size_t len;
 | 
			
		||||
		} ow;
 | 
			
		||||
 | 
			
		||||
		struct
 | 
			
		||||
		{
 | 
			
		||||
			TCHAR* ptr;
 | 
			
		||||
			size_t len;
 | 
			
		||||
		} nw;
 | 
			
		||||
 | 
			
		||||
		struct word_t* next;
 | 
			
		||||
	} * word_list;
 | 
			
		||||
 | 
			
		||||
	BSTR entry_point;
 | 
			
		||||
	VARIANT_BOOL debug;
 | 
			
		||||
	VARIANT_BOOL use_longlong;
 | 
			
		||||
@ -156,6 +173,8 @@ public:
 | 
			
		||||
	STDMETHOD(get_ErrorLine)(/*[out, retval]*/ int *pVal);
 | 
			
		||||
	STDMETHOD(get_ErrorCode)(/*[out, retval]*/ int *pVal);
 | 
			
		||||
 | 
			
		||||
	HRESULT __stdcall UnsetWord (
 | 
			
		||||
		/*[in]*/ BSTR ow, /*[out, retval]*/ VARIANT_BOOL* ret);
 | 
			
		||||
	HRESULT __stdcall SetWord (
 | 
			
		||||
		/*[in]*/ BSTR ow, /*[in]*/ BSTR nw, /*[out, retval]*/ VARIANT_BOOL* ret);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
 * $Id: asecom.idl,v 1.4 2007/06/27 15:27:21 bacon Exp $
 | 
			
		||||
 * $Id: asecom.idl,v 1.5 2007/06/29 11:24:27 bacon Exp $
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import "oaidl.idl";
 | 
			
		||||
@ -30,128 +30,131 @@ interface IAwk : IDispatch
 | 
			
		||||
	[id(5), helpstring("method SetWord")]
 | 
			
		||||
	HRESULT SetWord([in] BSTR ow, [in] BSTR nw, [out,retval] VARIANT_BOOL* ret);
 | 
			
		||||
 | 
			
		||||
	[propget, id(6), helpstring("property ErrorCode")] 
 | 
			
		||||
	[id(6), helpstring("method UnsetWord")]
 | 
			
		||||
	HRESULT UnsetWord([in] BSTR ow, [out,retval] VARIANT_BOOL* ret);
 | 
			
		||||
 | 
			
		||||
	[propget, id(7), helpstring("property ErrorCode")] 
 | 
			
		||||
	HRESULT ErrorCode([out,retval] int *pVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(7), helpstring("property ErrorLine")] 
 | 
			
		||||
	[propget, id(8), helpstring("property ErrorLine")] 
 | 
			
		||||
	HRESULT ErrorLine([out,retval] int *pVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(8), helpstring("property ErrorMessage")] 
 | 
			
		||||
	[propget, id(9), helpstring("property ErrorMessage")] 
 | 
			
		||||
	HRESULT ErrorMessage([out,retval] BSTR *pVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(9), helpstring("property ImplicitVariable")] 
 | 
			
		||||
	[propget, id(10), helpstring("property ImplicitVariable")] 
 | 
			
		||||
	HRESULT ImplicitVariable([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(9), helpstring("property ImplicitVariable")] 
 | 
			
		||||
	[propput, id(10), helpstring("property ImplicitVariable")] 
 | 
			
		||||
	HRESULT ImplicitVariable([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(10), helpstring("property ExplicitVariable")]
 | 
			
		||||
	[propget, id(11), helpstring("property ExplicitVariable")]
 | 
			
		||||
	HRESULT ExplicitVariable([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(10), helpstring("property ExplicitVariable")] 
 | 
			
		||||
	[propput, id(11), helpstring("property ExplicitVariable")] 
 | 
			
		||||
	HRESULT ExplicitVariable([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(11), helpstring("property UniqueFunction")] 
 | 
			
		||||
	[propget, id(12), helpstring("property UniqueFunction")] 
 | 
			
		||||
	HRESULT UniqueFunction([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(11), helpstring("property UniqueFunction")]
 | 
			
		||||
	[propput, id(12), helpstring("property UniqueFunction")]
 | 
			
		||||
	HRESULT UniqueFunction([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(12), helpstring("property VariableShading")] 
 | 
			
		||||
	[propget, id(13), helpstring("property VariableShading")] 
 | 
			
		||||
	HRESULT VariableShading([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(12), helpstring("property VariableShading")]
 | 
			
		||||
	[propput, id(13), helpstring("property VariableShading")]
 | 
			
		||||
	HRESULT VariableShading([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(13), helpstring("property ShiftOperators")]
 | 
			
		||||
	[propget, id(14), helpstring("property ShiftOperators")]
 | 
			
		||||
	HRESULT ShiftOperators([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(13), helpstring("property ShiftOperators")] 
 | 
			
		||||
	[propput, id(14), helpstring("property ShiftOperators")] 
 | 
			
		||||
	HRESULT ShiftOperators([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(14), helpstring("property IdivOperator")]
 | 
			
		||||
	[propget, id(15), helpstring("property IdivOperator")]
 | 
			
		||||
	HRESULT IdivOperator([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(14), helpstring("property IdivOperator")]
 | 
			
		||||
	[propput, id(15), helpstring("property IdivOperator")]
 | 
			
		||||
	HRESULT IdivOperator([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(15), helpstring("property ConcatString")]
 | 
			
		||||
	[propget, id(16), helpstring("property ConcatString")]
 | 
			
		||||
	HRESULT ConcatString([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(15), helpstring("property ConcatString")]
 | 
			
		||||
	[propput, id(16), helpstring("property ConcatString")]
 | 
			
		||||
	HRESULT ConcatString([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(16), helpstring("property SupportExtio")]
 | 
			
		||||
	[propget, id(17), helpstring("property SupportExtio")]
 | 
			
		||||
	HRESULT SupportExtio([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(16), helpstring("property SupportExtio")]
 | 
			
		||||
	[propput, id(17), helpstring("property SupportExtio")]
 | 
			
		||||
	HRESULT SupportExtio([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(17), helpstring("property SupportBlockless")]
 | 
			
		||||
	[propget, id(18), helpstring("property SupportBlockless")]
 | 
			
		||||
	HRESULT SupportBlockless([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(17), helpstring("property SupportBlockless")]
 | 
			
		||||
	[propput, id(18), helpstring("property SupportBlockless")]
 | 
			
		||||
	HRESULT SupportBlockless([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(18), helpstring("property StringBaseOne")]
 | 
			
		||||
	[propget, id(19), helpstring("property StringBaseOne")]
 | 
			
		||||
	HRESULT StringBaseOne([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(18), helpstring("property StringBaseOne")]
 | 
			
		||||
	[propput, id(19), helpstring("property StringBaseOne")]
 | 
			
		||||
	HRESULT StringBaseOne([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(19), helpstring("property StripSpaces")]
 | 
			
		||||
	[propget, id(20), helpstring("property StripSpaces")]
 | 
			
		||||
	HRESULT StripSpaces([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(19), helpstring("property StripSpaces")]
 | 
			
		||||
	[propput, id(20), helpstring("property StripSpaces")]
 | 
			
		||||
	HRESULT StripSpaces([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(20), helpstring("property Nextofile")]
 | 
			
		||||
	[propget, id(21), helpstring("property Nextofile")]
 | 
			
		||||
	HRESULT Nextofile([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(20), helpstring("property Nextofile")]
 | 
			
		||||
	[propput, id(21), helpstring("property Nextofile")]
 | 
			
		||||
	HRESULT Nextofile([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(21), helpstring("property UseCrlf")]
 | 
			
		||||
	[propget, id(22), helpstring("property UseCrlf")]
 | 
			
		||||
	HRESULT UseCrlf([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(21), helpstring("property UseCrlf")]
 | 
			
		||||
	[propput, id(22), helpstring("property UseCrlf")]
 | 
			
		||||
	HRESULT UseCrlf([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(22), helpstring("property ArgumentsToEntryPoint")]
 | 
			
		||||
	[propget, id(23), helpstring("property ArgumentsToEntryPoint")]
 | 
			
		||||
	HRESULT ArgumentsToEntryPoint([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(22), helpstring("property ArgumentsToEntryPoint")]
 | 
			
		||||
	[propput, id(23), helpstring("property ArgumentsToEntryPoint")]
 | 
			
		||||
	HRESULT ArgumentsToEntryPoint([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(23), helpstring("property MaxDepthForBlockParse")]
 | 
			
		||||
	[propget, id(24), helpstring("property MaxDepthForBlockParse")]
 | 
			
		||||
	HRESULT MaxDepthForBlockParse([out,retval] int *pVal);
 | 
			
		||||
	[propput, id(23), helpstring("property MaxDepthForBlockParse")]
 | 
			
		||||
	[propput, id(24), helpstring("property MaxDepthForBlockParse")]
 | 
			
		||||
	HRESULT MaxDepthForBlockParse([in] int newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(24), helpstring("property MaxDepthForBlockRun")]
 | 
			
		||||
	[propget, id(25), helpstring("property MaxDepthForBlockRun")]
 | 
			
		||||
	HRESULT MaxDepthForBlockRun([out,retval] int *pVal);
 | 
			
		||||
	[propput, id(24), helpstring("property MaxDepthForBlockRun")]
 | 
			
		||||
	[propput, id(25), helpstring("property MaxDepthForBlockRun")]
 | 
			
		||||
	HRESULT MaxDepthForBlockRun([in] int newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(25), helpstring("property MaxDepthForExprParse")]
 | 
			
		||||
	[propget, id(26), helpstring("property MaxDepthForExprParse")]
 | 
			
		||||
	HRESULT MaxDepthForExprParse([out,retval] int *pVal);
 | 
			
		||||
	[propput, id(25), helpstring("property MaxDepthForExprParse")]
 | 
			
		||||
	[propput, id(26), helpstring("property MaxDepthForExprParse")]
 | 
			
		||||
	HRESULT MaxDepthForExprParse([in] int newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(26), helpstring("property MaxDepthForExprRun")]
 | 
			
		||||
	[propget, id(27), helpstring("property MaxDepthForExprRun")]
 | 
			
		||||
	HRESULT MaxDepthForExprRun([out,retval] int *pVal);
 | 
			
		||||
	[propput, id(26), helpstring("property MaxDepthForExprRun")]
 | 
			
		||||
	[propput, id(27), helpstring("property MaxDepthForExprRun")]
 | 
			
		||||
	HRESULT MaxDepthForExprRun([in] int newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(27), helpstring("property MaxDepthForRexBuild")]
 | 
			
		||||
	[propget, id(28), helpstring("property MaxDepthForRexBuild")]
 | 
			
		||||
	HRESULT MaxDepthForRexBuild([out,retval] int *pVal);
 | 
			
		||||
	[propput, id(27), helpstring("property MaxDepthForRexBuild")]
 | 
			
		||||
	[propput, id(28), helpstring("property MaxDepthForRexBuild")]
 | 
			
		||||
	HRESULT MaxDepthForRexBuild([in] int newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(28), helpstring("property MaxDepthForRexMatch")]
 | 
			
		||||
	[propget, id(29), helpstring("property MaxDepthForRexMatch")]
 | 
			
		||||
	HRESULT MaxDepthForRexMatch([out,retval] int *pVal);
 | 
			
		||||
	[propput, id(28), helpstring("property MaxDepthForRexMatch")]
 | 
			
		||||
	[propput, id(29), helpstring("property MaxDepthForRexMatch")]
 | 
			
		||||
	HRESULT MaxDepthForRexMatch([in] int newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(29), helpstring("property EntryPoint")]
 | 
			
		||||
	[propget, id(30), helpstring("property EntryPoint")]
 | 
			
		||||
	HRESULT EntryPoint([out,retval] BSTR *pVal);
 | 
			
		||||
	[propput, id(29), helpstring("property EntryPoint")]
 | 
			
		||||
	[propput, id(30), helpstring("property EntryPoint")]
 | 
			
		||||
	HRESULT EntryPoint([in] BSTR newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(30), helpstring("property Debug")]
 | 
			
		||||
	[propget, id(31), helpstring("property Debug")]
 | 
			
		||||
	HRESULT Debug([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(30), helpstring("property Debug")]
 | 
			
		||||
	[propput, id(31), helpstring("property Debug")]
 | 
			
		||||
	HRESULT Debug([in] VARIANT_BOOL newVal);
 | 
			
		||||
 | 
			
		||||
	[propget, id(31), helpstring("property UseLongLong")]
 | 
			
		||||
	[propget, id(32), helpstring("property UseLongLong")]
 | 
			
		||||
	HRESULT UseLongLong([out,retval] VARIANT_BOOL *pVal);
 | 
			
		||||
	[propput, id(31), helpstring("property UseLongLong")]
 | 
			
		||||
	[propput, id(32), helpstring("property UseLongLong")]
 | 
			
		||||
	HRESULT UseLongLong([in] VARIANT_BOOL newVal);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -224,6 +224,11 @@ Private Sub btnExecute_Click()
 | 
			
		||||
    
 | 
			
		||||
    Set Awk = New ASECOM.Awk
 | 
			
		||||
    
 | 
			
		||||
    'Awk.SetWord "BEGIN", "xxx"
 | 
			
		||||
    'Awk.SetWord "END", "yyy"
 | 
			
		||||
    'Awk.SetWord "length", "len"
 | 
			
		||||
    'Awk.UnsetWord "END"
 | 
			
		||||
 | 
			
		||||
    Awk.ExplicitVariable = True
 | 
			
		||||
    Awk.ImplicitVariable = True
 | 
			
		||||
    Awk.UseCrlf = True
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
Type=Exe
 | 
			
		||||
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINDOWS\System32\stdole2.tlb#OLE Automation
 | 
			
		||||
Reference=*\G{F9C69806-16A1-4162-998A-876B33C470BF}#1.0#0#..\..\Debug\lib\asecom.dll#ASE 1.0 Type Library
 | 
			
		||||
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\WINDOWS\System32\stdole2.tlb#OLE Automation
 | 
			
		||||
Reference=*\G{F9C69806-16A1-4162-998A-876B33C470BF}#1.0#0#..\..\release\lib\asecom.dll#ASE 1.0 Type Library
 | 
			
		||||
Form=AwkForm.frm
 | 
			
		||||
Class=AwkExtioConsole; AwkExtioConsole.cls
 | 
			
		||||
IconForm="AwkForm"
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user