[kaffe] CVS kaffe (doogie): Add default case to several switches, fixing more warnings.

Kaffe CVS cvs-commits at kaffe.org
Mon May 30 02:29:21 PDT 2005


PatchSet 6601 
Date: 2005/05/30 09:24:04
Author: doogie
Branch: HEAD
Tag: (none) 
Log:
Add default case to several switches, fixing more warnings.

Members: 
	ChangeLog:1.4126->1.4127 
	kaffe/kaffe/main.c:1.83->1.84 
	kaffe/kaffevm/classMethod.c:1.143->1.144 
	kaffe/kaffevm/classPool.c:1.35->1.36 
	kaffe/kaffevm/gcFuncs.c:1.73->1.74 
	kaffe/kaffevm/lookup.c:1.46->1.47 
	kaffe/kaffevm/stringParsing.c:INITIAL->1.11 
	kaffe/kaffevm/jit/native-wrapper.c:1.9->1.10 
	kaffe/kaffevm/jit3/constpool.c:INITIAL->1.15 
	kaffe/kaffevm/jit3/icode.c:1.54->1.55 
	kaffe/kaffevm/jit3/labels.c:INITIAL->1.19 
	kaffe/kaffevm/jni/jni-arrays.c:1.7->1.8 
	kaffe/kaffevm/jni/jni-base.c:1.19->1.20 
	kaffe/kaffevm/systems/unix-pthreads/thread-impl.c:1.83->1.84 
	kaffe/kaffevm/verifier/verify-block.c:1.23->1.24 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c:1.2->1.3 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c:1.9->1.10 
	libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c:1.1->1.2 
	libraries/clib/fdlibm/dtoa.c:1.1->1.2 
	libraries/clib/fdlibm/e_atan2.c:1.1->1.2 
	libraries/clib/fdlibm/k_rem_pio2.c:1.1->1.2 
	libraries/clib/fdlibm/strtod.c:1.1->1.2 
	libraries/clib/native/Method.c:1.42->1.43 
	libraries/clib/net/InetAddressImpl.c:1.31->1.32 
	libraries/clib/security/sha-1.h:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4126 kaffe/ChangeLog:1.4127
--- kaffe/ChangeLog:1.4126	Mon May 30 08:54:18 2005
+++ kaffe/ChangeLog	Mon May 30 09:24:04 2005
@@ -1,5 +1,24 @@
 2005-05-30  Adam Heath  <doogie at brainfood.com>
 
+	* kaffe/kaffe/main.c, kaffe/kaffevm/classMethod.c,
+	  kaffe/kaffevm/classPool.c, kaffe/kaffevm/gcFuncs.c,
+	  kaffe/kaffevm/lookup.c, kaffe/kaffevm/stringParsing.c,
+	  kaffe/kaffevm/jit/native-wrapper.c, kaffe/kaffevm/jit3/constpool.c,
+	  kaffe/kaffevm/jit3/icode.c, kaffe/kaffevm/jit3/labels.c,
+	  kaffe/kaffevm/jni/jni-arrays.c, kaffe/kaffevm/jni/jni-base.c,
+	  kaffe/kaffevm/systems/unix-pthreads/thread-impl.c,
+	  kaffe/kaffevm/verifier/verify-block.c,
+	  libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GdkRobotPeer.c,
+	  libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c,
+	  libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollPanePeer.c,
+	  libraries/clib/fdlibm/dtoa.c, libraries/clib/fdlibm/e_atan2.c,
+	  libraries/clib/fdlibm/k_rem_pio2.c, libraries/clib/fdlibm/strtod.c,
+	  libraries/clib/native/Method.c, libraries/clib/net/InetAddressImpl.c,
+	  libraries/clib/security/sha-1.h:
+	  Add default case to several switches, fixing more warnings.
+
+2005-05-30  Adam Heath  <doogie at brainfood.com>
+
 	* kaffe/kaffevm/classPool.c, kaffe/kaffevm/findInJar.c,
 	  libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c,
 	  libraries/clib/awt/classpath-gtk/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c:
Index: kaffe/kaffe/kaffe/main.c
diff -u kaffe/kaffe/kaffe/main.c:1.83 kaffe/kaffe/kaffe/main.c:1.84
--- kaffe/kaffe/kaffe/main.c:1.83	Sat May 14 21:46:29 2005
+++ kaffe/kaffe/kaffe/main.c	Mon May 30 09:23:59 2005
@@ -988,6 +988,8 @@
 	case 'm': case 'M':
 		sz *= 1024 * 1024;
 		break;
+	default:
+		break;
 	}
 
 	return (sz);
Index: kaffe/kaffe/kaffevm/classMethod.c
diff -u kaffe/kaffe/kaffevm/classMethod.c:1.143 kaffe/kaffe/kaffevm/classMethod.c:1.144
--- kaffe/kaffe/kaffevm/classMethod.c:1.143	Wed May 18 04:14:18 2005
+++ kaffe/kaffe/kaffevm/classMethod.c	Mon May 30 09:24:00 2005
@@ -1936,6 +1936,8 @@
 				*(jref*)mem = (jref)CLASS_CONST_DATA(class, idx);
 				FIELD_SIZE(fld) = PTR_TYPE_SIZE;
 				break;
+			default:
+				break;
 			}
 		}
 	}
@@ -2626,6 +2628,8 @@
 	case '[':
 	case 'L':
 		return want_wide_refs ? sizeof(void*) / sizeof(int32) : 1;
+	default:
+		break;
 	}
 
 	return -1;
Index: kaffe/kaffe/kaffevm/classPool.c
diff -u kaffe/kaffe/kaffevm/classPool.c:1.35 kaffe/kaffe/kaffevm/classPool.c:1.36
--- kaffe/kaffe/kaffevm/classPool.c:1.35	Mon May 30 08:54:26 2005
+++ kaffe/kaffe/kaffevm/classPool.c	Mon May 30 09:24:00 2005
@@ -387,6 +387,8 @@
 			*out_cl = ce->data.cl;
 			done = 1;
 			break;
+		default:
+			break;
 		}
 		unlockStaticMutex(&ce->slock);
 	}
@@ -451,6 +453,8 @@
 			/* Its already been loaded and linked. */
 			*out_cl = ce->data.cl;
 			done = 1;
+			break;
+		default:
 			break;
 		}
 		unlockStaticMutex(&ce->slock);
Index: kaffe/kaffe/kaffevm/gcFuncs.c
diff -u kaffe/kaffe/kaffevm/gcFuncs.c:1.73 kaffe/kaffe/kaffevm/gcFuncs.c:1.74
--- kaffe/kaffe/kaffevm/gcFuncs.c:1.73	Sat May  7 16:20:10 2005
+++ kaffe/kaffe/kaffevm/gcFuncs.c	Mon May 30 09:24:00 2005
@@ -165,6 +165,8 @@
 		case CONSTANT_Utf8:
 			utf8ConstRelease(WORD2UTF(pool->data[idx]));
 			break;
+		default:
+			break;
 		}
 	}
 	/* free constant pool */
@@ -352,6 +354,8 @@
                 case CONSTANT_ResolvedString:
                         KGC_markObject(collector, gc_info, (void*)pool->data[idx]);
                         break;
+		default:
+			break;
                 }
         }
 
Index: kaffe/kaffe/kaffevm/lookup.c
diff -u kaffe/kaffe/kaffevm/lookup.c:1.46 kaffe/kaffe/kaffevm/lookup.c:1.47
--- kaffe/kaffe/kaffevm/lookup.c:1.46	Sat May 14 21:46:31 2005
+++ kaffe/kaffe/kaffevm/lookup.c	Mon May 30 09:24:00 2005
@@ -226,6 +226,8 @@
 				discardErrorInfo(&einfo_copy);
 			}
 			break;
+		default:
+			break;
 		}
 		return NULL;
 	}
===================================================================
Checking out kaffe/kaffe/kaffevm/stringParsing.c
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/stringParsing.c,v
VERS: 1.11
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/stringParsing.c	Mon May 30 09:29:20 2005
@@ -0,0 +1,885 @@
+/*
+ * stringParsing.c
+ * A handy string parsing function.
+ *
+ * Copyright (c) 2000, 2001, 2002, 2003 The University of Utah and the Flux Group.
+ * All rights reserved.
+ *
+ * @JANOSVM_KAFFE_MISC_LICENSE@
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+
+#include "stringParsing.h"
+
+/* We use this in JSI stuff too, and we don't want to drag in kaffe goo. */
+#include "gtypes.h"
+#include "gc.h"
+#include "kaffe/jmalloc.h"
+#include "defs.h"
+
+#define spMalloc(x) gc_malloc(x, KGC_ALLOC_FIXED)
+#define spFree(x) gc_free(x)
+
+int cmpPStrStr(parsedString *ps, char *str)
+{
+	char *ps_pos, *ps_end;
+	int retval = 0;
+
+	assert(ps != 0);
+	assert(str != 0);
+	
+	for( ps_pos = ps->data, ps_end = ps->data + ps->len;
+	     !retval && (ps_pos < ps_end) && *str;
+	     ps_pos++, str++ )
+	{
+		if( *ps_pos != *str )
+		{
+			/* XXX */
+			retval = *ps_pos - *str;
+		}
+	}
+	if( !retval && ((ps_pos != ps_end) || (*str != 0)) )
+	{
+		/* XXX */
+		retval = 1;
+	}
+	return( retval );
+}
+
+typedef struct _parseValue {
+	int type;
+	char *value;
+	union {
+		void *p;
+		char *c;
+		short *s;
+		int *i;
+		float *f;
+		double *d;
+		long long *ll;
+		parsedString *ps;
+	} storage;
+} parseValue;
+
+typedef struct _parseFrame {
+	struct _parseFrame *prev;
+	int op;
+	parseValue pv;
+	stringScript *script_pos;
+	int values_pos;
+	va_list args;
+} parseFrame;
+
+#define PREALLOC_FRAMES 8
+
+typedef struct _parseStack {
+	struct _parseFrame *top;
+	struct _parseFrame frames[PREALLOC_FRAMES];
+	int depth;
+} parseStack;
+
+static
+int pushFrame(parseErrorInfo *pe,
+	      parseStack *ps,
+	      int op,
+	      stringScript *script_pos,
+	      int values_pos,
+	      va_list args)
+{
+	parseFrame *pf;
+	int retval = 0;
+
+	assert(ps != 0);
+
+	ps->depth++;
+	if( ps->depth < PREALLOC_FRAMES )
+	{
+		pf = &ps->frames[ps->depth];
+	}
+	else
+	{
+		pf = spMalloc(sizeof(parseFrame));
+	}
+	if( pf )
+	{
+		pf->prev = ps->top;
+		pf->op = op;
+		pf->pv.type = SPO_Noop;
+		pf->script_pos = script_pos;
+		pf->values_pos = values_pos;
+		VA_LIST_COPY(pf->args, args);
+		ps->top = pf;
+		retval = 1;
+	}
+	else
+	{
+		pe->position = NULL;
+		pe->op = op;
+	}
+	return( retval );
+}
+
+static
+void popFrame(parseStack *ps)
+{
+	parseFrame *prev;
+
+	assert(ps != NULL);
+
+	prev = ps->top->prev;
+	if( ps->depth >= PREALLOC_FRAMES )
+		spFree(ps->top);
+	ps->depth--;
+	ps->top = prev;
+}
+
+static
+void cutFrames(parseStack *ps)
+{
+	assert(ps != NULL);
+	
+	while( ps->depth >= PREALLOC_FRAMES )
+	{
+		popFrame(ps);
+	}
+}
+
+static
+int storeValue(parseErrorInfo *pe, parseValue *pv, char *str, int clear)
+{
+	int retval = 1;
+
+	assert(pv != 0);
+	assert(str != 0);
+	
+	switch( pv->type )
+	{
+	case SPO_String:
+		pv->storage.ps->data = pv->value;
+		pv->storage.ps->len = str - pv->value;
+		break;
+	case SPO_NonEmptyString:
+		if( (str - pv->value) > 0 )
+		{
+			pv->storage.ps->data = pv->value;
+			pv->storage.ps->len = str - pv->value;
+		}
+		else
+		{
+			retval = 0;
+		}
+		break;
+	case SPO_Character:
+		if( (str - pv->value) == 1 )
+			*pv->storage.c = pv->value[0];
+		else
+			retval = 0;
+		break;
+	case SPO_Byte:
+		if( strncasecmp(pv->value, "0x", 2) == 0 )
+		{
+			int c;
+			
+			if( sscanf(&pv->value[2], "%x", &c) != 1 )
+				retval = 0;
+			else
+				*pv->storage.c = (char)(c & 0xff);
+		}
+		else
+		{
+			int c;
+			
+			if( sscanf(pv->value, "%d", &c) != 1 )
+				retval = 0;
+			else
+				*pv->storage.c = (char)(c & 0xff);
+		}
+		break;
+	case SPO_HexByte:
+		{
+			int c;
+			
+			if( !(((strncasecmp(pv->value, "0x", 2) == 0) &&
+			       (sscanf(&pv->value[2], "%x", &c) == 1)) ||
+			      (sscanf(pv->value, "%x", &c) == 1)) )
+			{
+				retval = 0;
+			}
+			else
+			{
+				*pv->storage.c = (char)(c & 0xff);
+			}
+		}
+		break;
+	case SPO_Short:
+		if( strncasecmp(pv->value, "0x", 2) == 0 )
+		{
+			if( sscanf(&pv->value[2], "%hx", pv->storage.s) != 1 )
+				retval = 0;
+		}
+		else
+		{
+			if( sscanf(pv->value, "%hd", pv->storage.s) != 1 )
+				retval = 0;
+		}
+		break;
+	case SPO_HexShort:
+		if( !(((strncasecmp(pv->value, "0x", 2) == 0) &&
+		       (sscanf(&pv->value[2], "%hx", pv->storage.s) == 1)) ||
+		      (sscanf(pv->value, "%hx", pv->storage.s) == 1)) )
+		{
+			retval = 0;
+		}
+		break;
+	case SPO_Integer:
+		if( strncasecmp(pv->value, "0x", 2) == 0 )
+		{
+			if( sscanf(&pv->value[2], "%x", pv->storage.i) != 1 )
+				retval = 0;
+		}
+		else
+		{
+			if( sscanf(pv->value, "%d", pv->storage.i) != 1 )
+				retval = 0;
+		}
+		break;
+	case SPO_LongInteger:
+		if( strncasecmp(pv->value, "0x", 2) == 0 )
+		{
+			if( sscanf(&pv->value[2], "%qx", pv->storage.ll) != 1 )
+				retval = 0;
+		}
+		else
+		{
+			if( sscanf(pv->value, "%qd", pv->storage.ll) != 1 )
+				retval = 0;
+		}
+		break;
+	case SPO_HexInteger:
+		if( !(((strncasecmp(pv->value, "0x", 2) == 0) &&
+		       (sscanf(&pv->value[2], "%x", pv->storage.i) == 1)) ||
+		      (sscanf(pv->value, "%x", pv->storage.i) == 1)) )
+		{
+			retval = 0;
+		}
+		break;
+	case SPO_HexLongInteger:
+		if( !(((strncasecmp(pv->value, "0x", 2) == 0) &&
+		       (sscanf(&pv->value[2], "%qx", pv->storage.ll) == 1)) ||
+		      (sscanf(pv->value, "%qx", pv->storage.ll) == 1)) )
+		{
+			retval = 0;
+		}
+		break;
+	case SPO_Float:
+		if( sscanf(pv->value, "%f", pv->storage.f) != 1 )
+		{
+			retval = 0;
+		}
+		break;
+	case SPO_Double:
+		if( sscanf(pv->value, "%lf", pv->storage.d) != 1 )
+		{
+			retval = 0;
+		}
+		break;
+	case SPO_Count:
+		pv->storage.i[0]++;
+		break;
+	default:
+		break;
+	}
+	if( clear )
+		pv->type = SPO_Noop;
+	if( retval == 0 )
+	{
+		pe->position = pv->value;
+		pe->op = pv->type;
+	}
+	return( retval );
+}
+
+static
+void skipBlock(stringScript *script, void **values,
+	       stringScript **script_pos, int *values_pos, va_list *args)
+{
+	int op, skip_depth = 0;
+	/* Used to quiet the compiler */
+	char *c_ptr;
+	void *v_ptr;
+
+	if( script )
+	{
+		op = (*script_pos)->op;
+	}
+	else
+	{
+		op = va_arg(*args, int);
+	}
+	while( skip_depth >= 0 )
+	{
+		switch( op )
+		{
+		case SPO_End:
+			skip_depth--;
+			(*script_pos)++;
+			break;
+		case SPO_Noop:
+			(*script_pos)++;
+			break;
+		case SPO_Cond:
+			if( script )
+			{
+				(*script_pos) = STRING_SCRIPT_NEXT(*script_pos,
+								   1);
+			}
+			else
+			{
+				c_ptr = va_arg(*args, char *);
+			}
+			skip_depth++;
+			break;
+		case SPO_Do:
+		case SPO_NotEmpty:
+			skip_depth++;
+			(*script_pos)++;
+			break;
+		case SPO_Character:
+		case SPO_Byte:
+		case SPO_HexByte:
+		case SPO_Short:
+		case SPO_HexShort:
+		case SPO_Integer:
+		case SPO_LongInteger:
+		case SPO_HexInteger:
+		case SPO_HexLongInteger:
+		case SPO_Float:
+		case SPO_Double:
+		case SPO_Count:
+		case SPO_NonEmptyString:
+		case SPO_String:
+			if( values )
+				(*values_pos)++;
+			else
+				v_ptr = va_arg(*args, void *);
+			(*script_pos)++;
+			break;
+		case SPO_While:
+			if( script )
+			{
+				(*script_pos) = STRING_SCRIPT_NEXT(*script_pos,
+								   2);
+			}
+			else
+			{
+				c_ptr = va_arg(*args, char *);
+				c_ptr = va_arg(*args, char *);
+			}
+			break;
+		case SPO_Expect:
+			if( script )
+			{
+				(*script_pos) = STRING_SCRIPT_NEXT(*script_pos,
+								   1);
+			}
+			else
+			{
+				c_ptr = va_arg(*args, char *);
+			}
+			break;
+		case SPO_WhileSpace:
+		case SPO_ExpectSpace:
+			(*script_pos)++;
+			break;
+		case SPO_Handle:
+			if( script )
+			{
+				(*script_pos) = STRING_SCRIPT_NEXT(*script_pos,
+								   2);
+			}
+			else
+			{
+				v_ptr = va_arg(*args, void *);
+				v_ptr = va_arg(*args, void *);
+			}
+			break;
+		case SPO_OneOf:
+			if( script )
+			{
+				(*script_pos) = STRING_SCRIPT_NEXT(*script_pos,
+								   1);
+			}
+			else
+			{
+				c_ptr = va_arg(*args, char *);
+			}
+			break;
+		default:
+			break;
+		}
+		if( skip_depth >= 0 )
+		{
+			if( script )
+				op = (*script_pos)->op;
+			else
+				op = va_arg(*args, int);
+		}
+	}
+}
+
+static
+char *skipChars(unsigned char *str, unsigned char *str_end)
+{
+	assert(str != 0);
+	assert(str_end != 0);
+	
+	while( (str < str_end) && !isspace(*str) )
+	{
+		str++;
+	}
+	return( str );
+}
+
+static
+char *skipSpace(unsigned char *str, unsigned char *str_end)
+{
+	assert(str != 0);
+	assert(str_end != 0);
+	
+	while( (str < str_end) && isspace(*str) )
+	{
+		str++;
+	}
+	return( str );
+}
+
+static
+int parseString_private(parseErrorInfo *pe,
+			parsedString *subString,
+			stringScript *script,
+			void **values,
+			int op,
+			va_list args)
+{
+	char *str, *str_end, *str_ptr = NULL, *term_ptr, *new_pos = NULL;
+	int values_pos = 0, len, retval = 1;
+	stringScript *script_pos = script;
+	parseValue pv;
+	parseStack ps;
+
+#ifdef VA_LIST_IS_ARRAY
+	/* Use temporary copy of args on platforms where va_list
+	 * is an array.
+	 *
+	 * We sometimes need to pass the address of a va_list to
+	 * another function. C Standard mandates array types in
+	 * prototypes to be silently coerced into pointers to base
+	 * objects. If va_list is an array, this results in the
+	 * receiving function expecting a pointer to a va_list array
+	 * member, but getting a pointer to a pointer instead when
+	 * we pass &args.
+	 *
+	 * Copying the va_list into a temporary buffer, and copying
+	 * it back 'undoes' the coercion.
+	 *
+	 * A longer explanation was posted by Graeme Peterson on the
+	 * GDB mailing list on 2002-04-15.
+	 */
+
+        va_list     tmp_args;
+        VA_LIST_COPY (tmp_args, args);
+#endif
+
+	assert(subString != NULL);
+
+	str = subString->data;
+	str_end = subString->data + subString->len;
+	pv.type = SPO_Noop;
+	ps.top = &ps.frames[0];
+	ps.top->op = SPO_Noop;
+	ps.depth = 0;
+	if( script )
+	{
+		op = script_pos->op;
+	}
+	while( retval && (ps.depth >= 0) )
+	{
+		switch( op )
+		{
+		case SPO_End:
+			if( ps.top->op == SPO_Do )
+				VA_LIST_COPY(args, ps.top->args);
+			else
+				popFrame(&ps);
+			script_pos++;
+			break;
+		case SPO_Expect:
+			if( script )
+			{
+				str_ptr = script_pos->args[0];
+				script_pos = STRING_SCRIPT_NEXT(script_pos, 1);
+			}
+			else
+			{
+				str_ptr = va_arg(args, char *);
+			}
+			if( (str = strstr(str, str_ptr)) &&
+			    (str < str_end) )
+			{
+				retval = storeValue(pe, &pv, str, 1);
+				str += strlen(str_ptr);
+			}
+			else
+			{
+				pe->position = str_end;
+				pe->op = op;
+				pe->args[0] = str_ptr;
+				retval = 0;
+			}
+			break;
+		case SPO_ExpectSpace:
+			str = skipChars(str, str_end);
+			retval = storeValue(pe, &pv, str, 1);
+			str = skipSpace(str, str_end);
+			script_pos++;
+			break;
+		case SPO_Character:
+		case SPO_Byte:
+		case SPO_HexByte:
+		case SPO_Short:
+		case SPO_HexShort:
+		case SPO_Integer:
+		case SPO_LongInteger:
+		case SPO_HexInteger:
+		case SPO_HexLongInteger:
+		case SPO_Float:
+		case SPO_Double:
+		case SPO_Count:
+		case SPO_String:
+		case SPO_NonEmptyString:
+			pv.type = op;
+			pv.value = str;
+			if( values )
+				pv.storage.p = values[values_pos++];
+			else
+				pv.storage.p = va_arg(args, void *);
+			script_pos++;
+			break;
+		case SPO_OneOf:
+			if( script )
+			{
+				str_ptr = script_pos->args[0];
+				script_pos = STRING_SCRIPT_NEXT(script_pos,
+								1);
+			}
+			else
+			{
+				str_ptr = va_arg(args, char *);
+			}
+			if( (new_pos = strpbrk(str, str_ptr)) &&
+			    (new_pos < str_end) )
+			{
+				retval = storeValue(pe, &pv, new_pos, 1);
+				retval = retval && pushFrame(pe,
+							     &ps,
+							     op,
+							     script_pos,
+							     values_pos,
+							     args);
+				str = new_pos;
+			}
+			else
+			{
+#ifdef VA_LIST_IS_ARRAY
+			        VA_LIST_COPY (args, tmp_args);
+#endif
+				skipBlock(script, values,
+					  &script_pos, &values_pos, &args);
+			}
+			break;
+		case SPO_Do:
+			ps.top->pv = pv;
+			retval = pushFrame(pe,
+					   &ps,
+					   op,
+					   script_pos,
+					   values_pos,
+					   args);
+			script_pos++;
+			break;
+		case SPO_While:
+			if( script )
+			{
+				str_ptr = script_pos->args[0];
+				term_ptr = script_pos->args[1];
+				script_pos = STRING_SCRIPT_NEXT(script_pos,
+								2);
+			}
+			else
+			{
+				str_ptr = va_arg(args, char *);
+				term_ptr = va_arg(args, char *);
+			}
+			if( (new_pos = strstr(str, str_ptr)) &&
+			    (new_pos < str_end) )
+			{
+				retval = storeValue(pe,
+						    &ps.top->prev->pv,
+						    new_pos,
+						    0);
+				retval = retval && storeValue(pe,
+							      &pv,
+							      new_pos,
+							      1);
+				str = new_pos + strlen(str_ptr);
+			}
+			else if( ((term_ptr[0] == '\0') ?
+				  (new_pos = str_end) :
+				  (new_pos = strstr(str, term_ptr))) &&
+				 (new_pos <= str_end) )
+			{
+				retval = storeValue(pe, &pv, new_pos, 1);
+				str = new_pos + strlen(term_ptr);
+				ps.top->op = SPO_Noop;
+			}
+			else
+			{
+				pe->position = str_end;
+				pe->op = op;
+				pe->args[0] = str_ptr;
+				pe->args[1] = term_ptr;
+				retval = 0;
+			}
+			break;
+		case SPO_SkipSpace:
+			str = skipSpace(str, str_end);
+			break;
+		case SPO_WhileSpace:
+			new_pos = skipChars(str, str_end);
+			retval = storeValue(pe, &pv, new_pos, 1);
+			str = skipSpace(new_pos, str_end);
+			if( str == str_end )
+			{
+				ps.top->op = SPO_Noop;
+			}
+			script_pos++;
+			break;
+		case SPO_Cond:
+			if( script )
+			{
+				str_ptr = script_pos->args[0];
+				script_pos = STRING_SCRIPT_NEXT(script_pos,
+								1);
+			}
+			else
+			{
+				str_ptr = va_arg(args, char *);
+			}
+			len = strlen(str_ptr);
+			new_pos = str;
+			if( ((pv.type == SPO_Noop) &&
+			     !strncmp(str, str_ptr, (size_t)len)) ||
+			    ((pv.type != SPO_Noop) &&
+			     (new_pos = strstr(str, str_ptr)) &&
+			     (new_pos < str_end)) )
+			{
+				if( ps.top->op == SPO_OneOf )
+				{
+					ps.top->op = SPO_Noop;
+				}
+				else
+				{
+					retval = storeValue(pe,
+							    &pv,
+							    new_pos,
+							    1);
+				}
+				retval = retval && pushFrame(pe,
+							     &ps,
+							     op,
+							     script_pos,
+							     values_pos,
+							     args);
+				str = new_pos + len;
+			}
+			else
+			{
+#ifdef VA_LIST_IS_ARRAY
+			        VA_LIST_COPY (args, tmp_args);
+#endif
+
+				skipBlock(script, values,
+					  &script_pos, &values_pos, &args);
+			}
+			break;
+		case SPO_Handle:
+			{
+				int (*handler)(void *arg);
+				void *v_ptr;
+
+				if( script )
+				{
+					handler = (int (*)(void *))
+						script_pos->args[0];
+					v_ptr = script_pos->args[1];
+					script_pos =
+						STRING_SCRIPT_NEXT(script_pos,
+								   2);
+				}
+				else
+				{
+					handler = (int (*)(void *))
+						va_arg(args, void *);
+					v_ptr = va_arg(args, void *);
+				}
+				if( !(retval = handler(v_ptr)) )
+				{
+					pe->position = str;
+					pe->op = op;
+					pe->args[0] = handler;
+					pe->args[1] = v_ptr;
+				}
+			}
+			break;
+		case SPO_NotEmpty:
+			if( str < str_end )
+			{
+				retval = pushFrame(pe,
+						   &ps,
+						   op,
+						   script_pos,
+						   values_pos,
+						   args);
+			}
+			else
+			{
+#ifdef VA_LIST_IS_ARRAY
+			        VA_LIST_COPY (args, tmp_args);
+#endif
+
+				skipBlock(script, values,
+					  &script_pos, &values_pos, &args);
+			}
+			script_pos++;
+			break;
+		default:
+			assert(0);
+			break;
+		}
+		if( script )
+			op = script_pos->op;
+		else
+			op = va_arg(args, int);
+	}
+	if( retval && (str < str_end) )
+	{
+		if( pv.type == SPO_Noop )
+		{
+			pe->position = str;
+			pe->op = SPO_Noop;
+			retval = 0;
+		}
+		else
+		{
+			retval = storeValue(pe, &pv, str_end, 1);
+		}
+	}
+	cutFrames(&ps);
+	return( retval );
+}
+
+int parseString(char *str, int op, ...)
+{
+	parseErrorInfo pe;
+	parsedString ps;
+	va_list args;
+	int retval;
+
+	assert(str != 0);
+	
+	va_start(args, op);
+	ps.data = str;
+	ps.len = strlen(str);
+	retval = parseString_private(&pe, &ps, NULL, NULL, op, args);
+	va_end(args);
+	return( retval );
+}
+
+int parseString_error(parseErrorInfo *pe, char *str, int op, ...)
+{
+	parsedString ps;
+	va_list args;
+	int retval;
+
+	assert(str != 0);
+	
+	va_start(args, op);
+	ps.data = str;
+	ps.len = strlen(str);
+	retval = parseString_private(pe, &ps, NULL, NULL, op, args);
+	va_end(args);
+	return( retval );
+}
+
+int parseSubString(parsedString *ps, int op, ...)
+{
+	parseErrorInfo pe;
+	va_list args;
+	int retval;
+
+	assert(ps != 0);

*** Patch too long, truncated ***




More information about the kaffe mailing list