Recovered from cvs revision 2007-11-08 15:08:00
This commit is contained in:
parent
8e65525420
commit
c1b6c78f76
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.81 2007/10/28 06:12:37 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.82 2007/11/07 15:32:41 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -1244,6 +1244,14 @@ int Awk::setErrorString (ErrorCode num, const char_t* str)
|
||||
return ase_awk_seterrstr (awk, (int)num, str);
|
||||
}
|
||||
|
||||
int Awk::getWord (
|
||||
const char_t* ow, ase_size_t owl,
|
||||
const char_t** nw, ase_size_t* nwl)
|
||||
{
|
||||
ASE_ASSERT (awk != ASE_NULL);
|
||||
return ase_awk_getword (awk, ow, owl, nw, nwl);
|
||||
}
|
||||
|
||||
int Awk::setWord (const char_t* ow, const char_t* nw)
|
||||
{
|
||||
return setWord (ow, ase_strlen(ow), nw, ase_strlen(nw));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.80 2007/10/28 06:12:37 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.81 2007/11/07 15:32:41 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -795,6 +795,9 @@ public:
|
||||
virtual const char_t* getErrorString (ErrorCode num) const;
|
||||
virtual int setErrorString (ErrorCode num, const char_t* str);
|
||||
|
||||
virtual int getWord (
|
||||
const char_t* ow, ase_size_t owl,
|
||||
const char_t** nw, ase_size_t* nwl);
|
||||
virtual int setWord (
|
||||
const char_t* ow, const char_t* nw);
|
||||
virtual int setWord (
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.java,v 1.30 2007/10/28 15:03:22 bacon Exp $
|
||||
* $Id: Awk.java,v 1.31 2007/11/07 15:32:41 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -117,6 +117,7 @@ public abstract class Awk
|
||||
protected native void setoption (long awkid, int opt) throws Exception;
|
||||
protected native boolean getdebug (long awkid) throws Exception;
|
||||
protected native void setdebug (long awkid, boolean debug) throws Exception;
|
||||
protected native String getword (long awkid, String ow) throws Exception;
|
||||
protected native void setword (long awkid, String ow, String nw) throws Exception;
|
||||
|
||||
|
||||
@ -232,6 +233,11 @@ public abstract class Awk
|
||||
}
|
||||
|
||||
/* == word replacement == */
|
||||
public String getWord (String ow) throws Exception
|
||||
{
|
||||
return getword (this.awkid, ow);
|
||||
}
|
||||
|
||||
public void setWord (String ow, String nw) throws Exception
|
||||
{
|
||||
setword (this.awkid, ow, nw);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.23 2007/10/25 14:43:17 bacon Exp $
|
||||
* $Id: awk.h,v 1.24 2007/11/07 15:32:41 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -465,8 +465,12 @@ void ase_awk_setoption (ase_awk_t* awk, int opt);
|
||||
ase_size_t ase_awk_getmaxdepth (ase_awk_t* awk, int type);
|
||||
void ase_awk_setmaxdepth (ase_awk_t* awk, int types, ase_size_t depth);
|
||||
|
||||
int ase_awk_getword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t** nkw, ase_size_t* nlen);
|
||||
/*
|
||||
* Enables replacement of a name of a keyword.
|
||||
* Enables replacement of a name of a keyword, intrinsic global variables,
|
||||
* and intrinsic functions.
|
||||
*/
|
||||
int ase_awk_setword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: func.c,v 1.18 2007/11/06 09:47:12 bacon Exp $
|
||||
* $Id: func.c,v 1.19 2007/11/07 14:40:37 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -161,17 +161,47 @@ ase_awk_bfn_t* ase_awk_getbfn (
|
||||
if (ase_strxncmp (k, l, name, len) == 0) return bfn;
|
||||
}
|
||||
|
||||
/* NOTE: I suspect this block of code might be very fragile.
|
||||
* because I'm trying to support ase_awk_setword in
|
||||
* a very flimsy way here. Would it be better to drop
|
||||
* ase_awk_setword totally? */
|
||||
pair = ase_awk_map_get (awk->rwtab, name, len);
|
||||
if (pair != ASE_NULL)
|
||||
{
|
||||
/* the current name is a target name for
|
||||
* one of the original word. */
|
||||
k = ((ase_cstr_t*)(pair->val))->ptr;
|
||||
l = ((ase_cstr_t*)(pair->val))->len;
|
||||
}
|
||||
else
|
||||
{
|
||||
k = name;
|
||||
l = len;
|
||||
pair = ase_awk_map_get (awk->wtab, name, len);
|
||||
if (pair != ASE_NULL)
|
||||
{
|
||||
k = ((ase_cstr_t*)(pair->val))->ptr;
|
||||
l = ((ase_cstr_t*)(pair->val))->len;
|
||||
|
||||
if (ase_strxncmp (name, len, k, l) != 0)
|
||||
{
|
||||
/* it name is not a target name but has
|
||||
* a target name different from itself,
|
||||
* it cannot be a intrinsic function name.
|
||||
*
|
||||
* For instance, name is "sin" here after
|
||||
* ase_awk_setword ("sin", "cain") is called.
|
||||
* If name were "cain", it would be handled
|
||||
* in the outmost if block */
|
||||
|
||||
return ASE_NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
k = name;
|
||||
l = len;
|
||||
}
|
||||
}
|
||||
/* END NOTE */
|
||||
|
||||
pair = ase_awk_map_get (awk->bfn.user, k, l);
|
||||
if (pair == ASE_NULL) return ASE_NULL;
|
||||
|
@ -13,6 +13,7 @@ EXPORTS
|
||||
Java_ase_awk_Awk_setoption
|
||||
Java_ase_awk_Awk_getdebug
|
||||
Java_ase_awk_Awk_setdebug
|
||||
Java_ase_awk_Awk_getword
|
||||
Java_ase_awk_Awk_setword
|
||||
Java_ase_awk_Awk_addfunc
|
||||
Java_ase_awk_Awk_delfunc
|
||||
|
206
ase/awk/jni.c
206
ase/awk/jni.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: jni.c,v 1.46 2007/11/02 10:47:51 bacon Exp $
|
||||
* $Id: jni.c,v 1.47 2007/11/07 15:32:41 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -74,6 +74,9 @@ static void free_str (
|
||||
JNIEnv* env, ase_awk_t* awk, jstring str,
|
||||
const jchar* jptr, ase_char_t* aptr);
|
||||
|
||||
static jstring new_str (
|
||||
JNIEnv* env, ase_awk_t* awk, const ase_char_t* ptr, ase_size_t len);
|
||||
|
||||
typedef struct awk_data_t awk_data_t;
|
||||
typedef struct srcio_data_t srcio_data_t;
|
||||
typedef struct runio_data_t runio_data_t;
|
||||
@ -1138,7 +1141,6 @@ static ase_ssize_t java_open_extio (
|
||||
jstring extio_name;
|
||||
jint ret;
|
||||
ase_awk_t* awk;
|
||||
ase_size_t len;
|
||||
|
||||
/* get the method - meth */
|
||||
class = (*env)->GetObjectClass(env, obj);
|
||||
@ -1181,30 +1183,9 @@ static ase_ssize_t java_open_extio (
|
||||
}
|
||||
|
||||
/* construct the name */
|
||||
len = ase_strlen(extio->name);
|
||||
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
||||
{
|
||||
ase_size_t i;
|
||||
jchar* tmp = (jchar*) ase_awk_malloc (awk, ASE_SIZEOF(jchar)*len);
|
||||
if (tmp == ASE_NULL)
|
||||
{
|
||||
(*env)->DeleteLocalRef (env, extio_class);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) tmp[i] = (jchar)extio->name[i];
|
||||
extio_name = (*env)->NewString (env, tmp, len);
|
||||
ase_awk_free (awk, tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
extio_name = (*env)->NewString (env, (jchar*)extio->name, len);
|
||||
}
|
||||
|
||||
extio_name = new_str (env, awk, extio->name, ase_strlen(extio->name));
|
||||
if (extio_name == ASE_NULL)
|
||||
{
|
||||
if (is_debug(awk)) (*env)->ExceptionDescribe (env);
|
||||
(*env)->ExceptionClear (env);
|
||||
(*env)->DeleteLocalRef (env, extio_class);
|
||||
return -1;
|
||||
}
|
||||
@ -1607,30 +1588,9 @@ static int handle_bfn (
|
||||
env = run_data->env;
|
||||
obj = run_data->obj;
|
||||
|
||||
if (fnl > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
||||
{
|
||||
ase_size_t i;
|
||||
jchar* tmp = (jchar*) ase_awk_malloc (
|
||||
awk, ASE_SIZEOF(jchar)*(fnl+4));
|
||||
if (tmp == ASE_NULL)
|
||||
{
|
||||
ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < fnl; i++) tmp[i] = (jchar)fnm[i];
|
||||
name = (*env)->NewString (env, tmp, fnl+4);
|
||||
ase_awk_free (awk, tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = (*env)->NewString (env, (jchar*)fnm, fnl);
|
||||
}
|
||||
|
||||
name = new_str (env, awk, fnm, fnl);
|
||||
if (name == ASE_NULL)
|
||||
{
|
||||
if (is_debug(awk)) (*env)->ExceptionDescribe (env);
|
||||
(*env)->ExceptionClear (env);
|
||||
ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
@ -2002,13 +1962,46 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setdebug (
|
||||
((awk_data_t*)ase_awk_getcustomdata(awk))->debug = debug;
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_ase_awk_Awk_getword (
|
||||
JNIEnv* env, jobject obj, jlong awkid, jstring ow)
|
||||
{
|
||||
ase_awk_t* awk;
|
||||
const jchar* ojp = ASE_NULL;
|
||||
jsize olen = 0, nlen;
|
||||
ase_char_t* oap, * nap;
|
||||
jstring ret;
|
||||
|
||||
awk = (ase_awk_t*) awkid;
|
||||
EXCEPTION_ON_ASE_NULL_AWK_RETURNING (env, awk, ASE_NULL);
|
||||
|
||||
if (ow == ASE_NULL) return ASE_NULL;
|
||||
|
||||
if (get_str(env,awk,ow,&ojp,&oap,&olen) == -1)
|
||||
{
|
||||
THROW_NOMEM_EXCEPTION (env);
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
if (ase_awk_getword (awk, oap, olen, &nap, &nlen) == -1)
|
||||
{
|
||||
free_str (env, awk, ow, ojp, oap);
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
free_str (env, awk, ow, ojp, oap);
|
||||
|
||||
ret = new_str (env, awk, nap, nlen);
|
||||
if (ret == ASE_NULL) THROW_NOMEM_EXCEPTION (env);
|
||||
return ret;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
JNIEnv* env, jobject obj, jlong awkid, jstring ow, jstring nw)
|
||||
{
|
||||
ase_awk_t* awk;
|
||||
const jchar* op = ASE_NULL, * np = ASE_NULL;
|
||||
jsize ol = 0, nl = 0;
|
||||
ase_char_t* ox, * nx;
|
||||
const jchar* ojp = ASE_NULL, * njp = ASE_NULL;
|
||||
jsize olen = 0, nlen = 0;
|
||||
ase_char_t* oap = ASE_NULL, * nap = ASE_NULL;
|
||||
jint r;
|
||||
|
||||
awk = (ase_awk_t*) awkid;
|
||||
@ -2016,11 +2009,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
|
||||
if (ow != ASE_NULL)
|
||||
{
|
||||
ol = (*env)->GetStringLength (env, ow);
|
||||
op = (*env)->GetStringChars (env, ow, JNI_FALSE);
|
||||
if (op == ASE_NULL)
|
||||
if (get_str(env,awk,ow,&ojp,&oap,&olen) == -1)
|
||||
{
|
||||
(*env)->ExceptionClear (env);
|
||||
THROW_NOMEM_EXCEPTION (env);
|
||||
return;
|
||||
}
|
||||
@ -2028,61 +2018,18 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
|
||||
if (nw != ASE_NULL)
|
||||
{
|
||||
nl = (*env)->GetStringLength (env, nw);
|
||||
np = (*env)->GetStringChars (env, nw, JNI_FALSE);
|
||||
if (np == ASE_NULL)
|
||||
if (get_str(env,awk,nw,&njp,&nap,&nlen) == -1)
|
||||
{
|
||||
if (ow != ASE_NULL)
|
||||
(*env)->ReleaseStringChars (env, ow, op);
|
||||
(*env)->ExceptionClear (env);
|
||||
if (ow != ASE_NULL) free_str (env, awk, ow, ojp, oap);
|
||||
THROW_NOMEM_EXCEPTION (env);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ol > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
||||
{
|
||||
jsize x;
|
||||
ox = (ase_char_t*)ase_awk_malloc (awk, ASE_SIZEOF(ase_char_t)*ol);
|
||||
if (ox == ASE_NULL)
|
||||
{
|
||||
if (nw != ASE_NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||
if (ow != ASE_NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||
r = ase_awk_setword (awk, oap, olen, nap, nlen);
|
||||
|
||||
THROW_NOMEM_EXCEPTION (env);
|
||||
return;
|
||||
}
|
||||
|
||||
for (x = 0; x < ol; x++) ox[x] = (ase_char_t)op[x];
|
||||
}
|
||||
else ox = (ase_char_t*)op;
|
||||
|
||||
if (nl > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
||||
{
|
||||
jsize x;
|
||||
nx = (ase_char_t*) ase_awk_malloc (awk, ASE_SIZEOF(ase_char_t)*nl);
|
||||
if (nx == ASE_NULL)
|
||||
{
|
||||
if (ox != (ase_char_t*)op) ase_awk_free (awk, ox);
|
||||
|
||||
if (nw != ASE_NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||
if (ow != ASE_NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||
|
||||
THROW_NOMEM_EXCEPTION (env);
|
||||
return;
|
||||
}
|
||||
|
||||
for (x = 0; x < nl; x++) nx[x] = (ase_char_t)np[x];
|
||||
}
|
||||
else nx = (ase_char_t*)np;
|
||||
|
||||
r = ase_awk_setword (awk, ox, ol, nx, nl);
|
||||
|
||||
if (nx != (ase_char_t*)np) ase_awk_free (awk, nx);
|
||||
if (ox != (ase_char_t*)op) ase_awk_free (awk, ox);
|
||||
|
||||
if (nw != ASE_NULL) (*env)->ReleaseStringChars (env, nw, np);
|
||||
if (ow != ASE_NULL) (*env)->ReleaseStringChars (env, ow, op);
|
||||
if (nw != ASE_NULL) free_str (env, awk, nw, njp, nap);
|
||||
if (ow != ASE_NULL) free_str (env, awk, ow, ojp, oap);
|
||||
|
||||
if (r == -1) THROW_AWK_EXCEPTION (env, awk);
|
||||
}
|
||||
@ -2184,7 +2131,6 @@ static jstring JNICALL call_strftime (
|
||||
ase_size_t len, i;
|
||||
const jchar* ptr;
|
||||
ase_char_t* tmp;
|
||||
jchar* tmp2;
|
||||
jstring ret;
|
||||
|
||||
jclass class;
|
||||
@ -2228,29 +2174,8 @@ static jstring JNICALL call_strftime (
|
||||
ase_awk_free (awk, tmp);
|
||||
(*env)->ReleaseStringChars (env, fmt, ptr);
|
||||
|
||||
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
||||
{
|
||||
tmp2 = (jchar*) ase_awk_malloc (awk, ASE_SIZEOF(jchar)*len);
|
||||
if (tmp2 == ASE_NULL)
|
||||
{
|
||||
THROW_NOMEM_EXCEPTION (env);
|
||||
return ASE_NULL;
|
||||
}
|
||||
for (i = 0; i < len; i++) tmp2[i] = (jchar)buf[i];
|
||||
ret = (*env)->NewString (env, tmp2, len);
|
||||
ase_awk_free (awk, tmp2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = (*env)->NewString (env, (jchar*)buf, len);
|
||||
}
|
||||
|
||||
if (ret == ASE_NULL)
|
||||
{
|
||||
(*env)->ExceptionClear (env);
|
||||
THROW_NOMEM_EXCEPTION (env);
|
||||
}
|
||||
|
||||
ret = new_str (env, awk, buf, len);
|
||||
if (ret == ASE_NULL) THROW_NOMEM_EXCEPTION (env);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3059,3 +2984,34 @@ static void free_str (
|
||||
if (jptr != aptr) ase_awk_free (awk, aptr);
|
||||
(*env)->ReleaseStringChars (env, str, jptr);
|
||||
}
|
||||
|
||||
|
||||
static jstring new_str (
|
||||
JNIEnv* env, ase_awk_t* awk, const ase_char_t* ptr, ase_size_t len)
|
||||
{
|
||||
jstring ret;
|
||||
|
||||
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
|
||||
{
|
||||
ase_size_t i;
|
||||
jchar* tmp = (jchar*) ase_awk_malloc (awk, ASE_SIZEOF(jchar)*len);
|
||||
if (tmp == ASE_NULL) return ASE_NULL;
|
||||
|
||||
for (i = 0; i < len; i++) tmp[i] = (jchar)ptr[i];
|
||||
ret = (*env)->NewString (env, tmp, len);
|
||||
ase_awk_free (awk, tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = (*env)->NewString (env, (jchar*)ptr, len);
|
||||
}
|
||||
|
||||
if (ret == ASE_NULL)
|
||||
{
|
||||
if (is_debug(awk)) (*env)->ExceptionDescribe (env);
|
||||
(*env)->ExceptionClear (env);
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ EXPORTS
|
||||
Java_ase_awk_Awk_setoption
|
||||
Java_ase_awk_Awk_getdebug
|
||||
Java_ase_awk_Awk_setdebug
|
||||
Java_ase_awk_Awk_getword
|
||||
Java_ase_awk_Awk_setword
|
||||
Java_ase_awk_Awk_addfunc
|
||||
Java_ase_awk_Awk_delfunc
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: jni.h,v 1.16 2007/11/02 05:49:19 bacon Exp $
|
||||
* $Id: jni.h,v 1.17 2007/11/07 15:32:41 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -44,6 +44,8 @@ JNIEXPORT jboolean JNICALL Java_ase_awk_Awk_getdebug (
|
||||
JNIEXPORT void JNICALL Java_ase_awk_Awk_setdebug (
|
||||
JNIEnv* env, jobject obj, jlong awkid, jboolean debug);
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_ase_awk_Awk_getword (
|
||||
JNIEnv* env, jobject obj, jlong awkid, jstring ow);
|
||||
JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
|
||||
JNIEnv* env, jobject obj, jlong awkid, jstring ow, jstring nw);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.27 2007/11/06 09:47:12 bacon Exp $
|
||||
* $Id: parse.c,v 1.29 2007/11/07 15:32:41 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -436,6 +436,20 @@ const ase_char_t* ase_awk_getglobalname (
|
||||
return awk->parse.globals.buf[idx].name.ptr;
|
||||
}
|
||||
|
||||
int ase_awk_getword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t** nkw, ase_size_t* nlen)
|
||||
{
|
||||
ase_awk_pair_t* p;
|
||||
|
||||
p = ase_awk_map_get (awk->wtab, okw, olen);
|
||||
if (p == ASE_NULL) return -1;
|
||||
|
||||
*nkw = ((ase_cstr_t*)p->val)->ptr;
|
||||
*nlen = ((ase_cstr_t*)p->val)->len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ase_awk_setword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
@ -1375,7 +1389,7 @@ int ase_awk_initglobals (ase_awk_t* awk)
|
||||
gtab[id].name, gtab[id].name_len);
|
||||
if (g == (ase_size_t)-1) return -1;
|
||||
|
||||
ASE_ASSERT (g == id);
|
||||
ASE_ASSERT ((int)g == id);
|
||||
|
||||
awk->tree.nbglobals++;
|
||||
awk->tree.nglobals++;
|
||||
@ -3427,17 +3441,21 @@ static ase_awk_nde_t* parse_fncall (
|
||||
call->next = ASE_NULL;
|
||||
|
||||
/*call->what.bfn = bfn; */
|
||||
/*
|
||||
call->what.bfn.name.ptr = bfn->name.ptr;
|
||||
call->what.bfn.name.len = bfn->name.len;
|
||||
*/
|
||||
call->what.bfn.name.ptr = name;
|
||||
call->what.bfn.name.len = name_len;
|
||||
|
||||
/* NOTE: oname is the original as in the bfn table.
|
||||
* it would not duplicated here and not freed in
|
||||
* ase_awk_clrpt either. so ase_awk_delfunc between
|
||||
* ase_awk_parse and ase_awk_run may cause the program
|
||||
* to fail. */
|
||||
call->what.bfn.oname.ptr = bfn->name.ptr;
|
||||
call->what.bfn.oname.len = bfn->name.len;
|
||||
|
||||
call->what.bfn.arg.min = bfn->arg.min;
|
||||
call->what.bfn.arg.max = bfn->arg.max;
|
||||
call->what.bfn.arg.spec = bfn->arg.spec;
|
||||
call->what.bfn.handler = bfn->handler;
|
||||
call->what.bfn.handler = bfn->handler;
|
||||
|
||||
call->args = head;
|
||||
call->nargs = nargs;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.21 2007/10/31 13:56:54 bacon Exp $
|
||||
* $Id: run.c,v 1.22 2007/11/07 14:40:37 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -5461,10 +5461,13 @@ static ase_awk_val_t* eval_call (
|
||||
{
|
||||
run->errnum = ASE_AWK_ENOERR;
|
||||
|
||||
/* NOTE: oname is used when the handler is invoked.
|
||||
* name might be differnt from oname if
|
||||
* ase_awk_setword has been used */
|
||||
n = call->what.bfn.handler (
|
||||
run,
|
||||
call->what.bfn.name.ptr,
|
||||
call->what.bfn.name.len);
|
||||
call->what.bfn.oname.ptr,
|
||||
call->what.bfn.oname.len);
|
||||
|
||||
if (n <= -1)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tree.h,v 1.6 2007/11/06 09:47:12 bacon Exp $
|
||||
* $Id: tree.h,v 1.7 2007/11/07 14:40:37 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -275,6 +275,14 @@ struct ase_awk_nde_call_t
|
||||
ase_size_t len;
|
||||
} name;
|
||||
|
||||
/* original name. if ase_awk_setword has been
|
||||
* invoked, oname can be different from name */
|
||||
struct
|
||||
{
|
||||
ase_char_t* ptr;
|
||||
ase_size_t len;
|
||||
} oname;
|
||||
|
||||
struct
|
||||
{
|
||||
ase_size_t min;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: AseAwkPanel.java,v 1.24 2007/11/06 09:47:12 bacon Exp $
|
||||
* $Id: AseAwkPanel.java,v 1.26 2007/11/07 15:32:41 bacon Exp $
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
@ -108,6 +108,14 @@ public class AseAwkPanel extends Panel implements DropTargetListener
|
||||
setWord ("length", "len");
|
||||
setWord ("OFMT", "ofmt");
|
||||
setWord ("END", "end");
|
||||
setWord ("sleep", "cleep");
|
||||
try{
|
||||
setWord ("end", "END");
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sleep (Context ctx, String name, Return ret, Argument[] args) throws ase.awk.Exception
|
||||
@ -115,6 +123,7 @@ public class AseAwkPanel extends Panel implements DropTargetListener
|
||||
Argument t = args[0];
|
||||
//if (args[0].isIndexed()) t = args[0].getIndexed(0);
|
||||
|
||||
System.out.println ("Original: " + getWord(name));
|
||||
try { Thread.sleep (t.getIntValue() * 1000); }
|
||||
catch (InterruptedException e) {}
|
||||
|
||||
@ -349,7 +358,7 @@ public class AseAwkPanel extends Panel implements DropTargetListener
|
||||
{
|
||||
new Option("IMPLICIT", AseAwk.OPTION_IMPLICIT, true),
|
||||
new Option("EXPLICIT", AseAwk.OPTION_EXPLICIT, false),
|
||||
new Option("UNIQUEFN", AseAwk.OPTION_UNIQUEFN, false),
|
||||
new Option("UNIQUEFN", AseAwk.OPTION_UNIQUEFN, true),
|
||||
new Option("SHADING", AseAwk.OPTION_SHADING, true),
|
||||
new Option("SHIFT", AseAwk.OPTION_SHIFT, false),
|
||||
new Option("IDIV", AseAwk.OPTION_IDIV, false),
|
||||
|
Loading…
Reference in New Issue
Block a user