From e28846adff89ac725147f9c666c6dfbfc54f8805 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 1 Nov 2007 23:01:00 +0000 Subject: [PATCH] Recovered from cvs revision 2007-11-01 14:01:00 --- ase/awk/func.c | 10 +++++----- ase/awk/jni.c | 3 +-- ase/awk/run.c | 26 +++++++++++++++++++------- ase/test/awk/AseAwkPanel.java | 9 +++++---- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/ase/awk/func.c b/ase/awk/func.c index e21f577b..5d27f4d4 100644 --- a/ase/awk/func.c +++ b/ase/awk/func.c @@ -1,5 +1,5 @@ /* - * $Id: func.c,v 1.13 2007/10/25 14:43:17 bacon Exp $ + * $Id: func.c,v 1.14 2007/10/31 13:56:54 bacon Exp $ * * {License} */ @@ -254,7 +254,7 @@ skip_close: return 0; } -static int __flush_extio ( +static int flush_extio ( ase_awk_run_t* run, int extio, const ase_char_t* name, int n) { int n2; @@ -337,15 +337,15 @@ static int bfn_fflush ( } /* flush the given extio */ - n = __flush_extio ( + n = flush_extio ( run, ASE_AWK_EXTIO_FILE, ((len0 == 0)? ASE_NULL: str0), 1); /*if (n == -99) return -1;*/ - n = __flush_extio ( + n = flush_extio ( run, ASE_AWK_EXTIO_PIPE, ((len0 == 0)? ASE_NULL: str0), n); /*if (n == -99) return -1;*/ - n = __flush_extio ( + n = flush_extio ( run, ASE_AWK_EXTIO_COPROC, ((len0 == 0)? ASE_NULL: str0), n); /*if (n == -99) return -1;*/ diff --git a/ase/awk/jni.c b/ase/awk/jni.c index 1be8578d..26d176d0 100644 --- a/ase/awk/jni.c +++ b/ase/awk/jni.c @@ -1,5 +1,5 @@ /* - * $Id: jni.c,v 1.42 2007/10/30 15:01:31 bacon Exp $ + * $Id: jni.c,v 1.43 2007/10/31 13:56:54 bacon Exp $ * * {License} */ @@ -1816,7 +1816,6 @@ static int handle_bfn ( (*env)->CallVoidMethod (env, run_data->context_object, run_data->context_clear); if ((*env)->ExceptionCheck(env)) { -/* TODO #1: if exception is thrown in clear, it seems to end with a lot of memory leask. PLEASE CHECK THIS */ if (is_debug(awk)) (*env)->ExceptionDescribe (env); (*env)->ExceptionClear (env); ase_awk_setrunerrnum (run, ASE_AWK_EBFNIMPL); diff --git a/ase/awk/run.c b/ase/awk/run.c index f84aefb9..5510f4a7 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.20 2007/10/28 06:12:37 bacon Exp $ + * $Id: run.c,v 1.21 2007/10/31 13:56:54 bacon Exp $ * * {License} */ @@ -5502,13 +5502,25 @@ static ase_awk_val_t* eval_call ( ase_dprintf (ASE_T("got return value\n")); #endif - /* this trick has been mentioned in run_return. - * adjust the reference count of the return value. - * the value must not be freed even if the reference count - * is decremented to zero because its reference has been incremented - * in run_return regardless of its reference count. */ v = STACK_RETVAL(run); - ase_awk_refdownval_nofree (run, v); + if (n == -1) + { + /* if the earlier operations failed and this function + * has to return a error, the return value is just + * destroyed and replaced by nil */ + ase_awk_refdownval (run, v); + STACK_RETVAL(run) = ase_awk_val_nil; + } + else + { + /* this trick has been mentioned in run_return. + * adjust the reference count of the return value. + * the value must not be freed even if the reference count + * reached zero because its reference has been incremented + * in run_return or directly by ase_awk_setretval + * regardless of its reference count. */ + ase_awk_refdownval_nofree (run, v); + } run->stack_top = (ase_size_t)run->stack[run->stack_base+1]; run->stack_base = (ase_size_t)run->stack[run->stack_base+0]; diff --git a/ase/test/awk/AseAwkPanel.java b/ase/test/awk/AseAwkPanel.java index 853be3cf..30be5268 100644 --- a/ase/test/awk/AseAwkPanel.java +++ b/ase/test/awk/AseAwkPanel.java @@ -1,5 +1,5 @@ /* - * $Id: AseAwkPanel.java,v 1.15 2007/10/30 15:01:31 bacon Exp $ + * $Id: AseAwkPanel.java,v 1.16 2007/10/31 13:56:54 bacon Exp $ */ import java.awt.*; @@ -107,8 +107,8 @@ public class AseAwkPanel extends Panel //ret.setIntValue (0); // ret.setIndexedRealValue (1, 111.23); - ret.setIndexedStringValue (2, "kdk2kd"); - ret.setIndexedStringValue (3, "3dk3kd"); + ret.setIndexedStringValue (2, "1111111"); + ret.setIndexedStringValue (3, "22222222"); ret.setIndexedIntValue (4, 444); ret.setIndexedIntValue (5, 55555); @@ -117,7 +117,8 @@ public class AseAwkPanel extends Panel Return r2 = new Return (ctx); r.setStringValue ("[[%.6f]]"); - ctx.setGlobal (Context.GLOBAL_CONVFMT, ret); + //ctx.setGlobal (Context.GLOBAL_CONVFMT, ret); + ctx.setGlobal (Context.GLOBAL_CONVFMT, r2); } protected int openSource (int mode)