Recovered from cvs revision 2007-06-29 11:24:00
This commit is contained in:
parent
135bfc1626
commit
26a9dfe8f4
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.cpp,v 1.44 2007/06/25 14:01:10 bacon Exp $
|
* $Id: Awk.cpp,v 1.45 2007/06/28 15:45:57 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/awk/Awk.hpp>
|
#include <ase/awk/Awk.hpp>
|
||||||
@ -593,6 +593,23 @@ namespace ASE
|
|||||||
return ase_awk_setword (awk, ow, owl, nw, nwl);
|
return ase_awk_setword (awk, ow, owl, nw, nwl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Awk::unsetWord (const char_t* ow)
|
||||||
|
{
|
||||||
|
return unsetWord (ow, ase_strlen(ow));
|
||||||
|
}
|
||||||
|
|
||||||
|
int Awk::unsetWord (const char_t* ow, ase_size_t owl)
|
||||||
|
{
|
||||||
|
ASE_ASSERT (awk != ASE_NULL);
|
||||||
|
return ase_awk_setword (awk, ow, owl, ASE_NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Awk::unsetAllWords ()
|
||||||
|
{
|
||||||
|
ASE_ASSERT (awk != ASE_NULL);
|
||||||
|
return ase_awk_setword (awk, ASE_NULL, 0, ASE_NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int Awk::parse ()
|
int Awk::parse ()
|
||||||
{
|
{
|
||||||
ASE_ASSERT (awk != ASE_NULL);
|
ASE_ASSERT (awk != ASE_NULL);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.hpp,v 1.42 2007/06/25 14:01:10 bacon Exp $
|
* $Id: Awk.hpp,v 1.43 2007/06/28 15:45:57 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ASE_AWK_AWK_HPP_
|
#ifndef _ASE_AWK_AWK_HPP_
|
||||||
@ -419,6 +419,9 @@ namespace ASE
|
|||||||
const char_t* ow, ase_size_t owl,
|
const char_t* ow, ase_size_t owl,
|
||||||
const char_t* nw, ase_size_t nwl);
|
const char_t* nw, ase_size_t nwl);
|
||||||
|
|
||||||
|
virtual int unsetWord (const char_t* ow);
|
||||||
|
virtual int unsetWord (const char_t* ow, ase_size_t owl);
|
||||||
|
virtual int unsetAllWords ();
|
||||||
|
|
||||||
virtual int parse ();
|
virtual int parse ();
|
||||||
virtual int run (const char_t* main = ASE_NULL,
|
virtual int run (const char_t* main = ASE_NULL,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.java,v 1.11 2007/06/24 11:14:58 bacon Exp $
|
* $Id: Awk.java,v 1.12 2007/06/28 15:45:57 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -263,6 +263,16 @@ public abstract class Awk
|
|||||||
setword (ow, nw);
|
setword (ow, nw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unsetWord (String ow)
|
||||||
|
{
|
||||||
|
setword (ow, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unsetAllWords ()
|
||||||
|
{
|
||||||
|
setword (null, null);
|
||||||
|
}
|
||||||
|
|
||||||
/* == source code management == */
|
/* == source code management == */
|
||||||
protected abstract int openSource (int mode);
|
protected abstract int openSource (int mode);
|
||||||
protected abstract int closeSource (int mode);
|
protected abstract int closeSource (int mode);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: jni.c,v 1.11 2007/06/24 11:14:58 bacon Exp $
|
* $Id: jni.c,v 1.12 2007/06/28 15:45:57 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -2015,8 +2015,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
|||||||
jclass class;
|
jclass class;
|
||||||
jfieldID handle;
|
jfieldID handle;
|
||||||
ase_awk_t* awk;
|
ase_awk_t* awk;
|
||||||
const jchar* op, * np;
|
const jchar* op = NULL, * np = NULL;
|
||||||
jsize ol, nl;
|
jsize ol = 0, nl = 0;
|
||||||
ase_char_t* ox, * nx;
|
ase_char_t* ox, * nx;
|
||||||
jint r;
|
jint r;
|
||||||
|
|
||||||
@ -2033,31 +2033,38 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
|||||||
|
|
||||||
awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle);
|
awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle);
|
||||||
|
|
||||||
ol = (*env)->GetStringLength (env, ow);
|
if (ow != NULL)
|
||||||
op = (*env)->GetStringChars (env, ow, JNI_FALSE);
|
|
||||||
if (op == NULL)
|
|
||||||
{
|
{
|
||||||
(*env)->ExceptionClear (env);
|
ol = (*env)->GetStringLength (env, ow);
|
||||||
throw_exception (
|
op = (*env)->GetStringChars (env, ow, JNI_FALSE);
|
||||||
env,
|
if (op == NULL)
|
||||||
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
|
{
|
||||||
ASE_AWK_ENOMEM,
|
(*env)->ExceptionClear (env);
|
||||||
0);
|
throw_exception (
|
||||||
return;
|
env,
|
||||||
|
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
|
||||||
|
ASE_AWK_ENOMEM,
|
||||||
|
0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nl = (*env)->GetStringLength (env, nw);
|
if (nw != NULL)
|
||||||
np = (*env)->GetStringChars (env, nw, JNI_FALSE);
|
|
||||||
if (np == NULL)
|
|
||||||
{
|
{
|
||||||
(*env)->ReleaseStringChars (env, ow, op);
|
nl = (*env)->GetStringLength (env, nw);
|
||||||
(*env)->ExceptionClear (env);
|
np = (*env)->GetStringChars (env, nw, JNI_FALSE);
|
||||||
throw_exception (
|
if (np == NULL)
|
||||||
env,
|
{
|
||||||
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
|
if (ow != NULL)
|
||||||
ASE_AWK_ENOMEM,
|
(*env)->ReleaseStringChars (env, ow, op);
|
||||||
0);
|
(*env)->ExceptionClear (env);
|
||||||
return;
|
throw_exception (
|
||||||
|
env,
|
||||||
|
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
|
||||||
|
ASE_AWK_ENOMEM,
|
||||||
|
0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ol > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
if (ol > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
||||||
@ -2066,8 +2073,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
|||||||
ox = (ase_char_t*)malloc (ASE_SIZEOF(ase_char_t)*ol);
|
ox = (ase_char_t*)malloc (ASE_SIZEOF(ase_char_t)*ol);
|
||||||
if (ox == ASE_NULL)
|
if (ox == ASE_NULL)
|
||||||
{
|
{
|
||||||
(*env)->ReleaseStringChars (env, nw, np);
|
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||||
(*env)->ReleaseStringChars (env, ow, op);
|
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||||
|
|
||||||
throw_exception (
|
throw_exception (
|
||||||
env,
|
env,
|
||||||
@ -2089,8 +2096,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
|||||||
{
|
{
|
||||||
if (ox != (ase_char_t*)op) free (ox);
|
if (ox != (ase_char_t*)op) free (ox);
|
||||||
|
|
||||||
(*env)->ReleaseStringChars (env, nw, np);
|
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||||
(*env)->ReleaseStringChars (env, ow, op);
|
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||||
|
|
||||||
throw_exception (
|
throw_exception (
|
||||||
env,
|
env,
|
||||||
@ -2109,8 +2116,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
|||||||
if (nx != (ase_char_t*)np) free (nx);
|
if (nx != (ase_char_t*)np) free (nx);
|
||||||
if (ox != (ase_char_t*)op) free (ox);
|
if (ox != (ase_char_t*)op) free (ox);
|
||||||
|
|
||||||
(*env)->ReleaseStringChars (env, nw, np);
|
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||||
(*env)->ReleaseStringChars (env, ow, op);
|
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||||
|
|
||||||
if (r == -1)
|
if (r == -1)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parse.c,v 1.9 2007/06/20 13:28:15 bacon Exp $
|
* $Id: parse.c,v 1.10 2007/06/28 15:45:57 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -403,8 +403,21 @@ int ase_awk_setword (ase_awk_t* awk,
|
|||||||
const ase_char_t* nkw, ase_size_t nlen)
|
const ase_char_t* nkw, ase_size_t nlen)
|
||||||
{
|
{
|
||||||
ase_cstr_t* v;
|
ase_cstr_t* v;
|
||||||
ase_awk_pair_t* pair;
|
|
||||||
|
|
||||||
|
if (nkw == ASE_NULL || nlen == 0)
|
||||||
|
{
|
||||||
|
if (okw == ASE_NULL || olen == 0)
|
||||||
|
{
|
||||||
|
/* clear the entire table */
|
||||||
|
ase_awk_map_clear (awk->kwtab);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* delete the word */
|
||||||
|
return ase_awk_map_remove (awk->kwtab, okw, olen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set the word */
|
||||||
v = (ase_cstr_t*) ASE_AWK_MALLOC (
|
v = (ase_cstr_t*) ASE_AWK_MALLOC (
|
||||||
awk, ASE_SIZEOF(ase_cstr_t)+((nlen+1)*ASE_SIZEOF(*nkw)));
|
awk, ASE_SIZEOF(ase_cstr_t)+((nlen+1)*ASE_SIZEOF(*nkw)));
|
||||||
if (v == ASE_NULL)
|
if (v == ASE_NULL)
|
||||||
@ -416,7 +429,7 @@ int ase_awk_setword (ase_awk_t* awk,
|
|||||||
v->len = nlen;
|
v->len = nlen;
|
||||||
v->ptr = (const ase_char_t*)(v + 1);
|
v->ptr = (const ase_char_t*)(v + 1);
|
||||||
|
|
||||||
ase_strxncpy (v->ptr, v->len+1, nkw, nlen);
|
ase_strxncpy ((ase_char_t*)v->ptr, v->len+1, nkw, nlen);
|
||||||
|
|
||||||
if (ase_awk_map_put (awk->kwtab, okw, olen, v) == ASE_NULL)
|
if (ase_awk_map_put (awk->kwtab, okw, olen, v) == ASE_NULL)
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
* added ase_awk_setword to enable customization of keywords and
|
* added ase_awk_setword to enable customization of keywords and
|
||||||
intrinsic function names.
|
intrinsic function names.
|
||||||
* added setWord method to the awk c++ class (awk/Awk.cpp)
|
* added setWord/unsetWord method to the awk c++ class (awk/Awk.cpp)
|
||||||
* added setErrorString method to the awk c++ class (awk/Awk.cpp)
|
* added setErrorString method to the awk c++ class (awk/Awk.cpp)
|
||||||
* added setWord method to the awk java class (awk/Awk.java)
|
* added setWord/unsetWord method to the awk java class (awk/Awk.java)
|
||||||
|
|
||||||
* changed the wrong macro name WIN32 to _WIN32 in utl/stdio.h
|
* changed the wrong macro name WIN32 to _WIN32 in utl/stdio.h
|
||||||
* changed test/awk/Awk.cpp to include an option(-w) to utilize
|
* changed test/awk/Awk.cpp to include an option(-w) to utilize
|
||||||
|
Loading…
Reference in New Issue
Block a user