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>
|
||||
@ -593,6 +593,23 @@ namespace ASE
|
||||
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 ()
|
||||
{
|
||||
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_
|
||||
@ -419,6 +419,9 @@ namespace ASE
|
||||
const char_t* ow, ase_size_t owl,
|
||||
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 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}
|
||||
*/
|
||||
@ -263,6 +263,16 @@ public abstract class Awk
|
||||
setword (ow, nw);
|
||||
}
|
||||
|
||||
public void unsetWord (String ow)
|
||||
{
|
||||
setword (ow, null);
|
||||
}
|
||||
|
||||
public void unsetAllWords ()
|
||||
{
|
||||
setword (null, null);
|
||||
}
|
||||
|
||||
/* == source code management == */
|
||||
protected abstract int openSource (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}
|
||||
*/
|
||||
@ -2015,8 +2015,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
jclass class;
|
||||
jfieldID handle;
|
||||
ase_awk_t* awk;
|
||||
const jchar* op, * np;
|
||||
jsize ol, nl;
|
||||
const jchar* op = NULL, * np = NULL;
|
||||
jsize ol = 0, nl = 0;
|
||||
ase_char_t* ox, * nx;
|
||||
jint r;
|
||||
|
||||
@ -2033,31 +2033,38 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
|
||||
awk = (ase_awk_t*) (*env)->GetLongField (env, obj, handle);
|
||||
|
||||
ol = (*env)->GetStringLength (env, ow);
|
||||
op = (*env)->GetStringChars (env, ow, JNI_FALSE);
|
||||
if (op == NULL)
|
||||
if (ow != NULL)
|
||||
{
|
||||
(*env)->ExceptionClear (env);
|
||||
throw_exception (
|
||||
env,
|
||||
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
|
||||
ASE_AWK_ENOMEM,
|
||||
0);
|
||||
return;
|
||||
ol = (*env)->GetStringLength (env, ow);
|
||||
op = (*env)->GetStringChars (env, ow, JNI_FALSE);
|
||||
if (op == NULL)
|
||||
{
|
||||
(*env)->ExceptionClear (env);
|
||||
throw_exception (
|
||||
env,
|
||||
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
|
||||
ASE_AWK_ENOMEM,
|
||||
0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nl = (*env)->GetStringLength (env, nw);
|
||||
np = (*env)->GetStringChars (env, nw, JNI_FALSE);
|
||||
if (np == NULL)
|
||||
if (nw != NULL)
|
||||
{
|
||||
(*env)->ReleaseStringChars (env, ow, op);
|
||||
(*env)->ExceptionClear (env);
|
||||
throw_exception (
|
||||
env,
|
||||
ase_awk_geterrstr(ASE_NULL, ASE_AWK_ENOMEM),
|
||||
ASE_AWK_ENOMEM,
|
||||
0);
|
||||
return;
|
||||
nl = (*env)->GetStringLength (env, nw);
|
||||
np = (*env)->GetStringChars (env, nw, JNI_FALSE);
|
||||
if (np == NULL)
|
||||
{
|
||||
if (ow != NULL)
|
||||
(*env)->ReleaseStringChars (env, ow, op);
|
||||
(*env)->ExceptionClear (env);
|
||||
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))
|
||||
@ -2066,8 +2073,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
ox = (ase_char_t*)malloc (ASE_SIZEOF(ase_char_t)*ol);
|
||||
if (ox == ASE_NULL)
|
||||
{
|
||||
(*env)->ReleaseStringChars (env, nw, np);
|
||||
(*env)->ReleaseStringChars (env, ow, op);
|
||||
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||
|
||||
throw_exception (
|
||||
env,
|
||||
@ -2089,8 +2096,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
{
|
||||
if (ox != (ase_char_t*)op) free (ox);
|
||||
|
||||
(*env)->ReleaseStringChars (env, nw, np);
|
||||
(*env)->ReleaseStringChars (env, ow, op);
|
||||
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||
|
||||
throw_exception (
|
||||
env,
|
||||
@ -2109,8 +2116,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
if (nx != (ase_char_t*)np) free (nx);
|
||||
if (ox != (ase_char_t*)op) free (ox);
|
||||
|
||||
(*env)->ReleaseStringChars (env, nw, np);
|
||||
(*env)->ReleaseStringChars (env, ow, op);
|
||||
if (nw != NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||
if (ow != NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||
|
||||
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}
|
||||
*/
|
||||
@ -403,8 +403,21 @@ int ase_awk_setword (ase_awk_t* awk,
|
||||
const ase_char_t* nkw, ase_size_t nlen)
|
||||
{
|
||||
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 (
|
||||
awk, ASE_SIZEOF(ase_cstr_t)+((nlen+1)*ASE_SIZEOF(*nkw)));
|
||||
if (v == ASE_NULL)
|
||||
@ -416,7 +429,7 @@ int ase_awk_setword (ase_awk_t* awk,
|
||||
v->len = nlen;
|
||||
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)
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
* added ase_awk_setword to enable customization of keywords and
|
||||
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 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 test/awk/Awk.cpp to include an option(-w) to utilize
|
||||
|
Loading…
Reference in New Issue
Block a user