*** empty log message ***

This commit is contained in:
hyung-hwan 2006-11-26 15:55:44 +00:00
parent 2bf83484d8
commit df7b9d975b
4 changed files with 208 additions and 129 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.java,v 1.9 2006-11-24 15:04:23 bacon Exp $
* $Id: Awk.java,v 1.10 2006-11-26 15:55:43 bacon Exp $
*/
package ase.awk;
@ -17,20 +17,29 @@ public abstract class Awk
System.load ("c://projects//ase/awk/aseawk.dll");
}
private long __awk;
private long handle;
public Awk () throws Exception
{
open ();
}
/* == just in case == */
protected void finalize ()
{
if (handle != 0) close ();
}
/* == methods to provide major functionalities */
public native void close ();
public native void parse () throws Exception;
public native void run () throws Exception;
private native void open () throws Exception;
private native int setfilename (long run_id, String name);
private native int setofilename (long run_id, String name);
/* == console name setters == */
public void setInputConsoleName (Extio extio, String name) //throws Exception
{
/* TODO: setconsolename is not safe. for example, it can
@ -47,33 +56,44 @@ public abstract class Awk
setofilename (extio.getRunId(), name);
}
/* abstrace methods */
protected abstract int open_source (int mode);
protected abstract int close_source (int mode);
protected abstract int read_source (char[] buf, int len);
protected abstract int write_source (char[] buf, int len);
/* == recursion depth limiting == */
protected int getMaxParseDepth ()
{
return 0;
}
protected int getMaxRunDepth ()
{
return 0;
}
protected int open_extio (Extio extio)
/* == source code management == */
protected abstract int openSource (int mode);
protected abstract int closeSource (int mode);
protected abstract int readSource (char[] buf, int len);
protected abstract int writeSource (char[] buf, int len);
/* == external io interface == */
protected int openExtio (Extio extio)
{
int type = extio.getType ();
if (type == Extio.TYPE_CONSOLE) return open_console (extio);
if (type == Extio.TYPE_FILE) return open_file (extio);
if (type == Extio.TYPE_PIPE) return open_pipe (extio);
//if (type == Extio.TYPE_COPROC) return open_coproc (extio);
if (type == Extio.TYPE_CONSOLE) return openConsole (extio);
if (type == Extio.TYPE_FILE) return openFile (extio);
if (type == Extio.TYPE_PIPE) return openPipe (extio);
//if (type == Extio.TYPE_COPROC) return openCoproc (extio);
return -1;
}
protected int close_extio (Extio extio)
protected int closeExtio (Extio extio)
{
int type = extio.getType ();
if (type == Extio.TYPE_CONSOLE) return close_console (extio);
if (type == Extio.TYPE_FILE) return close_file (extio);
if (type == Extio.TYPE_PIPE) return close_pipe (extio);
//if (type == Extio.TYPE_COPROC) return close_coproc (extio);
if (type == Extio.TYPE_CONSOLE) return closeConsole (extio);
if (type == Extio.TYPE_FILE) return closeFile (extio);
if (type == Extio.TYPE_PIPE) return closePipe (extio);
//if (type == Extio.TYPE_COPROC) return closeCoproc (extio);
return -1;
}
protected int read_extio (Extio extio, char[] buf, int len)
protected int readExtio (Extio extio, char[] buf, int len)
{
// this check is needed because 0 is used to indicate
// the end of the stream. java streams can return 0
@ -83,65 +103,65 @@ public abstract class Awk
int type = extio.getType ();
if (type == Extio.TYPE_CONSOLE)
return read_console (extio, buf, len);
return readConsole (extio, buf, len);
if (type == Extio.TYPE_FILE)
return read_file (extio, buf, len);
return readFile (extio, buf, len);
if (type == Extio.TYPE_PIPE)
return read_pipe (extio, buf, len);
return readPipe (extio, buf, len);
//if (type == Extio.TYPE_COPROC)
// return read_coproc (extio, buf, len);
// return readCoproc (extio, buf, len);
return -1;
}
protected int write_extio (Extio extio, char[] buf, int len)
protected int writeExtio (Extio extio, char[] buf, int len)
{
if (len <= 0) return -1;
int type = extio.getType ();
if (type == Extio.TYPE_CONSOLE)
return write_console (extio, buf, len);
return writeConsole (extio, buf, len);
if (type == Extio.TYPE_FILE)
return write_file (extio, buf, len);
return writeFile (extio, buf, len);
if (type == Extio.TYPE_PIPE)
return write_pipe (extio, buf, len);
return writePipe (extio, buf, len);
//if (type == Extio.TYPE_COPROC)
// return write_coproc (extio, buf, len);
// return writeCoproc (extio, buf, len);
return -1;
}
protected int flush_extio (Extio extio)
protected int flushExtio (Extio extio)
{
int type = extio.getType ();
if (type == Extio.TYPE_CONSOLE) return flush_console (extio);
if (type == Extio.TYPE_FILE) return flush_file (extio);
if (type == Extio.TYPE_PIPE) return flush_pipe (extio);
//if (type == Extio.TYPE_COPROC) return flush_coproc (extio);
if (type == Extio.TYPE_CONSOLE) return flushConsole (extio);
if (type == Extio.TYPE_FILE) return flushFile (extio);
if (type == Extio.TYPE_PIPE) return flushPipe (extio);
//if (type == Extio.TYPE_COPROC) return flushCoproc (extio);
return -1;
}
protected int next_extio (Extio extio)
protected int nextExtio (Extio extio)
{
int type = extio.getType ();
if (type == Extio.TYPE_CONSOLE) return next_console (extio);
if (type == Extio.TYPE_CONSOLE) return nextConsole (extio);
return -1;
}
protected abstract int open_console (Extio extio);
protected abstract int close_console (Extio extio);
protected abstract int read_console (Extio extio, char[] buf, int len);
protected abstract int write_console (Extio extio, char[] buf, int len);
protected abstract int flush_console (Extio extio);
protected abstract int next_console (Extio extio);
protected abstract int openConsole (Extio extio);
protected abstract int closeConsole (Extio extio);
protected abstract int readConsole (Extio extio, char[] buf, int len);
protected abstract int writeConsole (Extio extio, char[] buf, int len);
protected abstract int flushConsole (Extio extio);
protected abstract int nextConsole (Extio extio);
protected abstract int open_file (Extio extio);
protected abstract int close_file (Extio extio);
protected abstract int read_file (Extio extio, char[] buf, int len);
protected abstract int write_file (Extio extio, char[] buf, int len);
protected abstract int flush_file (Extio extio);
protected abstract int openFile (Extio extio);
protected abstract int closeFile (Extio extio);
protected abstract int readFile (Extio extio, char[] buf, int len);
protected abstract int writeFile (Extio extio, char[] buf, int len);
protected abstract int flushFile (Extio extio);
protected abstract int open_pipe (Extio extio);
protected abstract int close_pipe (Extio extio);
protected abstract int read_pipe (Extio extio, char[] buf, int len);
protected abstract int write_pipe (Extio extio, char[] buf, int len);
protected abstract int flush_pipe (Extio extio);
protected abstract int openPipe (Extio extio);
protected abstract int closePipe (Extio extio);
protected abstract int readPipe (Extio extio, char[] buf, int len);
protected abstract int writePipe (Extio extio, char[] buf, int len);
protected abstract int flushPipe (Extio extio);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.java,v 1.4 2006-11-25 15:51:29 bacon Exp $
* $Id: StdAwk.java,v 1.5 2006-11-26 15:55:43 bacon Exp $
*/
package ase.awk;
@ -25,7 +25,7 @@ public abstract class StdAwk extends Awk
super ();
}
/* ===== overridden major methods ===== */
/* == major methods == */
public void parse () throws Exception
{
sin = getSourceNames (); sin_no = 0;
@ -40,16 +40,16 @@ public abstract class StdAwk extends Awk
super.run ();
}
/* ===== source code names ===== */
/* == source code names == */
protected abstract String[] getSourceNames ();
protected String getDeparsedSourceName () { return null; }
/* ===== console names ===== */
/* == console names == */
protected abstract String[] getInputConsoleNames ();
protected abstract String[] getOutputConsoleNames ();
/* ===== source code ===== */
protected int open_source (int mode)
/* == source code == */
protected int openSource (int mode)
{
if (mode == SOURCE_READ)
{
@ -77,7 +77,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int close_source (int mode)
protected int closeSource (int mode)
{
if (mode == SOURCE_READ)
{
@ -96,12 +96,10 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int read_source (char[] buf, int len)
protected int readSource (char[] buf, int len)
{
int n;
try {
n = src_in.read (buf, 0, len);
int n = src_in.read (buf, 0, len);
while (n == -1)
{
InputStreamReader isr;
@ -127,17 +125,16 @@ public abstract class StdAwk extends Awk
}
}
protected int write_source (char[] buf, int len)
protected int writeSource (char[] buf, int len)
{
//System.out.println (new String(buf, 0, len));
if (src_out == null) return len;
try { src_out.write (buf, 0, len); }
catch (IOException e) { return -1; }
return len;
}
/* ===== console ===== */
protected int open_console (Extio extio)
/* == console interface == */
protected int openConsole (Extio extio)
{
System.err.println ("[open_console called.... name: " + extio.getName() + " mode: " + extio.getMode());
@ -177,7 +174,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int close_console (Extio extio)
protected int closeConsole (Extio extio)
{
System.err.println ("[close_console called.... name: " + extio.getName() + " mode: " + extio.getMode());
@ -203,7 +200,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int read_console (Extio extio, char[] buf, int len)
protected int readConsole (Extio extio, char[] buf, int len)
{
int mode = extio.getMode ();
@ -241,7 +238,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int write_console (Extio extio, char[] buf, int len)
protected int writeConsole (Extio extio, char[] buf, int len)
{
int mode = extio.getMode ();
@ -261,7 +258,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int flush_console (Extio extio)
protected int flushConsole (Extio extio)
{
int mode = extio.getMode ();
@ -277,7 +274,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int next_console (Extio extio)
protected int nextConsole (Extio extio)
{
int mode = extio.getMode ();
@ -310,7 +307,7 @@ public abstract class StdAwk extends Awk
tmp = get_output_stream (cout[cout_no]);
if (tmp == null) return -1;
/* TODO: selective close the stream...
/* TODO: selectively close the stream...
* system.out should not be closed??? */
try { osw.close (); }
catch (IOException e) { /* ignore */ }
@ -363,8 +360,8 @@ public abstract class StdAwk extends Awk
return osw;
}
/* ===== file ===== */
public int open_file (Extio extio)
/* == file interface == */
protected int openFile (Extio extio)
{
int mode = extio.getMode();
@ -408,7 +405,7 @@ public abstract class StdAwk extends Awk
return -1;
}
public int close_file (Extio extio)
protected int closeFile (Extio extio)
{
int mode = extio.getMode();
@ -440,7 +437,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int read_file (Extio extio, char[] buf, int len)
protected int readFile (Extio extio, char[] buf, int len)
{
int mode = extio.getMode();
@ -461,7 +458,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int write_file (Extio extio, char[] buf, int len)
protected int writeFile (Extio extio, char[] buf, int len)
{
int mode = extio.getMode();
@ -478,7 +475,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int flush_file (Extio extio)
protected int flushFile (Extio extio)
{
int mode = extio.getMode ();
@ -495,8 +492,8 @@ public abstract class StdAwk extends Awk
return -1;
}
/* ===== pipe ===== */
public int open_pipe (Extio extio)
/* == pipe interface == */
protected int openPipe (Extio extio)
{
int mode = extio.getMode();
@ -527,7 +524,7 @@ public abstract class StdAwk extends Awk
return -1;
}
public int close_pipe (Extio extio)
protected int closePipe (Extio extio)
{
int mode = extio.getMode();
@ -551,7 +548,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int read_pipe (Extio extio, char[] buf, int len)
protected int readPipe (Extio extio, char[] buf, int len)
{
int mode = extio.getMode();
@ -572,7 +569,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int write_pipe (Extio extio, char[] buf, int len)
protected int writePipe (Extio extio, char[] buf, int len)
{
int mode = extio.getMode();
@ -588,7 +585,7 @@ public abstract class StdAwk extends Awk
return -1;
}
protected int flush_pipe (Extio extio)
protected int flushPipe (Extio extio)
{
int mode = extio.getMode ();

View File

@ -1,5 +1,5 @@
/*
* $Id: jni.c,v 1.25 2006-11-25 15:51:30 bacon Exp $
* $Id: jni.c,v 1.26 2006-11-26 15:55:43 bacon Exp $
*/
#include <ase/awk/jni.h>
@ -22,7 +22,7 @@
#endif
#define EXCEPTION_AWK "ase/awk/Exception"
#define FIELD_AWK "__awk"
#define FIELD_HANDLE "handle"
enum
{
@ -30,8 +30,6 @@ enum
SOURCE_WRITE = 2
};
/* TODO: what if ase_char_t is ase_mchar_t??? */
static ase_ssize_t __read_source (
int cmd, void* arg, ase_char_t* data, ase_size_t count);
static ase_ssize_t __write_source (
@ -189,7 +187,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
return;
}
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
fid = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J");
if (fid == 0) return;
(*env)->SetLongField (env, obj, fid, (jlong)awk);
@ -210,7 +208,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_close (JNIEnv* env, jobject obj)
class = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
fid = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J");
if (fid == 0) return;
ase_awk_close ((ase_awk_t*) (*env)->GetLongField (env, obj, fid));
@ -219,11 +217,40 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_close (JNIEnv* env, jobject obj)
printf ("close (native) done\n");
}
static jint __java_get_max_depth (JNIEnv* env, jobject obj, const char* name)
{
jclass class;
jmethodID mid;
jthrowable thrown;
jint ret;
class = (*env)->GetObjectClass(env, obj);
mid = (*env)->GetMethodID (env, class, name, "()I");
if (mid == NULL)
{
(*env)->DeleteLocalRef (env, class);
return -1;
}
ret = (*env)->CallIntMethod (env, obj, mid);
thrown = (*env)->ExceptionOccurred (env);
if (thrown)
{
(*env)->ExceptionClear (env);
ret = -1;
}
(*env)->DeleteLocalRef (env, class);
return ret;
}
JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj)
{
jclass class;
jfieldID fid;
jthrowable except;
jint depth;
ase_awk_t* awk;
ase_awk_srcios_t srcios;
@ -231,7 +258,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj)
class = (*env)->GetObjectClass (env, obj);
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
fid = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J");
if (fid == 0) return;
awk = (ase_awk_t*) (*env)->GetLongField (env, obj, fid);
@ -243,14 +270,25 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj)
srcios.out = __write_source;
srcios.custom_data = &srcio_data;
ase_awk_setmaxparsedepth (awk, ASE_AWK_DEPTH_BLOCK, 10);
depth = __java_get_max_depth (env, obj, "getMaxParseDepth");
if (depth < 0) depth = 0;
ase_awk_setmaxparsedepth (awk,
ASE_AWK_DEPTH_BLOCK | ASE_AWK_DEPTH_EXPR, depth);
if (ase_awk_parse (awk, &srcios) == -1)
{
printf ("parse error.......\n");
char msg[256];
int n;
except = (*env)->FindClass (env, EXCEPTION_AWK);
if (except == 0) return;
(*env)->ThrowNew (env, except, "Parse Error ...");
printf ("parse error -> line [%d] %S\n", ase_awk_getsrcline(awk), ase_awk_geterrstr(ase_awk_geterrnum(awk)));
snprintf (msg, sizeof(msg), "parse error at line %d: %S",
ase_awk_getsrcline(awk),
ase_awk_geterrstr(ase_awk_geterrnum(awk)));
if (n < 0 || n >= sizeof(msg)) msg[sizeof(msg)-1] = '\0';
(*env)->ThrowNew (env, except, msg);
return;
}
}
@ -267,7 +305,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj)
class = (*env)->GetObjectClass (env, obj);
fid = (*env)->GetFieldID (env, class, FIELD_AWK, "J");
fid = (*env)->GetFieldID (env, class, FIELD_HANDLE, "J");
if (fid == 0) return;
awk = (ase_awk_t*) (*env)->GetLongField (env, obj, fid);
@ -281,6 +319,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj)
runios.console = __process_extio;
runios.custom_data = &runio_data;
//depth = __java_get_max_depth (env, obj, "getMaxRunDepth");
if (ase_awk_run (awk, ASE_NULL, &runios, ASE_NULL, ASE_NULL) == -1)
{
char msg[256];
@ -297,7 +337,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_run (JNIEnv* env, jobject obj)
}
}
static ase_ssize_t __call_java_open_source (JNIEnv* env, jobject obj, int mode)
static ase_ssize_t __java_open_source (JNIEnv* env, jobject obj, int mode)
{
jclass class;
jmethodID mid;
@ -306,7 +346,7 @@ static ase_ssize_t __call_java_open_source (JNIEnv* env, jobject obj, int mode)
class = (*env)->GetObjectClass(env, obj);
mid = (*env)->GetMethodID (env, class, "open_source", "(I)I");
mid = (*env)->GetMethodID (env, class, "openSource", "(I)I");
if (mid == NULL)
{
(*env)->DeleteLocalRef (env, class);
@ -325,7 +365,7 @@ static ase_ssize_t __call_java_open_source (JNIEnv* env, jobject obj, int mode)
return ret;
}
static ase_ssize_t __call_java_close_source (JNIEnv* env, jobject obj, int mode)
static ase_ssize_t __java_close_source (JNIEnv* env, jobject obj, int mode)
{
jclass class;
jmethodID mid;
@ -334,7 +374,7 @@ static ase_ssize_t __call_java_close_source (JNIEnv* env, jobject obj, int mode)
class = (*env)->GetObjectClass(env, obj);
mid = (*env)->GetMethodID (env, class, "close_source", "(I)I");
mid = (*env)->GetMethodID (env, class, "closeSource", "(I)I");
if (mid == NULL)
{
(*env)->DeleteLocalRef (env, class);
@ -353,7 +393,7 @@ static ase_ssize_t __call_java_close_source (JNIEnv* env, jobject obj, int mode)
return ret;
}
static ase_ssize_t __call_java_read_source (
static ase_ssize_t __java_read_source (
JNIEnv* env, jobject obj, ase_char_t* buf, ase_size_t size)
{
jclass class;
@ -365,7 +405,7 @@ static ase_ssize_t __call_java_read_source (
class = (*env)->GetObjectClass(env, obj);
mid = (*env)->GetMethodID (env, class, "read_source", "([CI)I");
mid = (*env)->GetMethodID (env, class, "readSource", "([CI)I");
if (mid == NULL)
{
(*env)->DeleteLocalRef (env, class);
@ -396,7 +436,7 @@ static ase_ssize_t __call_java_read_source (
return i;
}
static ase_ssize_t __call_java_write_source (
static ase_ssize_t __java_write_source (
JNIEnv* env, jobject obj, ase_char_t* buf, ase_size_t size)
{
jclass class;
@ -408,7 +448,7 @@ static ase_ssize_t __call_java_write_source (
class = (*env)->GetObjectClass(env, obj);
mid = (*env)->GetMethodID (env, class, "write_source", "([CI)I");
mid = (*env)->GetMethodID (env, class, "writeSource", "([CI)I");
if (mid == NULL)
{
(*env)->DeleteLocalRef (env, class);
@ -440,7 +480,7 @@ static ase_ssize_t __call_java_write_source (
return ret;
}
static ase_ssize_t __call_java_open_extio (
static ase_ssize_t __java_open_extio (
JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio)
{
jclass class;
@ -527,7 +567,7 @@ static ase_ssize_t __call_java_open_extio (
return ret;
}
static ase_ssize_t __call_java_close_extio (
static ase_ssize_t __java_close_extio (
JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio)
{
jclass class;
@ -566,7 +606,7 @@ static ase_ssize_t __call_java_close_extio (
return ret;
}
static ase_ssize_t __call_java_read_extio (
static ase_ssize_t __java_read_extio (
JNIEnv* env, jobject obj, char* meth,
ase_awk_extio_t* extio, ase_char_t* buf, ase_size_t size)
{
@ -613,7 +653,7 @@ static ase_ssize_t __call_java_read_extio (
return ret;
}
static ase_ssize_t __call_java_write_extio (
static ase_ssize_t __java_write_extio (
JNIEnv* env, jobject obj, char* meth,
ase_awk_extio_t* extio, ase_char_t* data, ase_size_t size)
{
@ -659,7 +699,7 @@ static ase_ssize_t __call_java_write_extio (
}
static ase_ssize_t __call_java_flush_extio (
static ase_ssize_t __java_flush_extio (
JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio)
{
jclass class;
@ -690,7 +730,7 @@ static ase_ssize_t __call_java_flush_extio (
return ret;
}
static ase_ssize_t __call_java_next_extio (
static ase_ssize_t __java_next_extio (
JNIEnv* env, jobject obj, char* meth, ase_awk_extio_t* extio)
{
jclass class;
@ -728,17 +768,17 @@ static ase_ssize_t __read_source (
if (cmd == ASE_AWK_IO_OPEN)
{
return __call_java_open_source (
return __java_open_source (
srcio_data->env, srcio_data->obj, SOURCE_READ);
}
else if (cmd == ASE_AWK_IO_CLOSE)
{
return __call_java_close_source (
return __java_close_source (
srcio_data->env, srcio_data->obj, SOURCE_READ);
}
else if (cmd == ASE_AWK_IO_READ)
{
return __call_java_read_source (
return __java_read_source (
srcio_data->env, srcio_data->obj, data, count);
}
@ -752,17 +792,17 @@ static ase_ssize_t __write_source (
if (cmd == ASE_AWK_IO_OPEN)
{
return __call_java_open_source (
return __java_open_source (
srcio_data->env, srcio_data->obj, SOURCE_WRITE);
}
else if (cmd == ASE_AWK_IO_CLOSE)
{
return __call_java_close_source (
return __java_close_source (
srcio_data->env, srcio_data->obj, SOURCE_WRITE);
}
else if (cmd == ASE_AWK_IO_WRITE)
{
return __call_java_write_source (
return __java_write_source (
srcio_data->env, srcio_data->obj, data, count);
}
@ -777,39 +817,39 @@ static ase_ssize_t __process_extio (
if (cmd == ASE_AWK_IO_OPEN)
{
return __call_java_open_extio (
return __java_open_extio (
runio_data->env, runio_data->obj,
"open_extio", epa);
"openExtio", epa);
}
else if (cmd == ASE_AWK_IO_CLOSE)
{
return __call_java_close_extio (
return __java_close_extio (
runio_data->env, runio_data->obj,
"close_extio", epa);
"closeExtio", epa);
}
else if (cmd == ASE_AWK_IO_READ)
{
return __call_java_read_extio (
return __java_read_extio (
runio_data->env, runio_data->obj,
"read_extio", epa, data, size);
"readExtio", epa, data, size);
}
else if (cmd == ASE_AWK_IO_WRITE)
{
return __call_java_write_extio (
return __java_write_extio (
runio_data->env, runio_data->obj,
"write_extio", epa, data, size);
"writeExtio", epa, data, size);
}
else if (cmd == ASE_AWK_IO_FLUSH)
{
return __call_java_flush_extio (
return __java_flush_extio (
runio_data->env, runio_data->obj,
"flush_console", epa);
"flushExtio", epa);
}
else if (cmd == ASE_AWK_IO_NEXT)
{
return __call_java_next_extio (
return __java_next_extio (
runio_data->env, runio_data->obj,
"next_console", epa);
"nextExtio", epa);
}
return -1;
@ -828,7 +868,6 @@ JNIEXPORT int JNICALL Java_ase_awk_Awk_setfilename (JNIEnv* env, jobject obj, jl
return n;
}
JNIEXPORT int JNICALL Java_ase_awk_Awk_setofilename (JNIEnv* env, jobject obj, jlong run_id, jstring name)
{
ase_awk_run_t* run = (ase_awk_run_t*)run_id;

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.209 2006-11-25 15:51:30 bacon Exp $
* $Id: parse.c,v 1.210 2006-11-26 15:55:44 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -1369,6 +1369,13 @@ static ase_awk_nde_t* __parse_expression (ase_awk_t* awk)
{
ase_awk_nde_t* nde;
if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{
awk->errnum = ASE_AWK_ERECURSION;
return ASE_NULL;
}
awk->parse.depth.cur.expr++;
nde = __parse_expression0 (awk);
awk->parse.depth.cur.expr--;
@ -1971,7 +1978,15 @@ static ase_awk_nde_t* __parse_unary (ase_awk_t* awk)
if (__get_token(awk) == -1) return ASE_NULL;
if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{
awk->errnum = ASE_AWK_ERECURSION;
return ASE_NULL;
}
awk->parse.depth.cur.expr++;
left = __parse_unary (awk);
awk->parse.depth.cur.expr--;
if (left == ASE_NULL) return ASE_NULL;
nde = (ase_awk_nde_exp_t*)
@ -2017,7 +2032,15 @@ static ase_awk_nde_t* __parse_unary_exp (ase_awk_t* awk)
if (__get_token(awk) == -1) return ASE_NULL;
if (awk->parse.depth.max.expr > 0 &&
awk->parse.depth.cur.expr >= awk->parse.depth.max.expr)
{
awk->errnum = ASE_AWK_ERECURSION;
return ASE_NULL;
}
awk->parse.depth.cur.expr++;
left = __parse_unary (awk);
awk->parse.depth.cur.expr--;
if (left == ASE_NULL) return ASE_NULL;
nde = (ase_awk_nde_exp_t*)