changeset 61:73423b66e511

Fixed error with single char ascii constants
author lost
date Mon, 05 Jan 2009 00:57:14 +0000
parents 309810f39ab7
children da1337724ecd
files src/expr.c
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/expr.c	Mon Jan 05 00:44:38 2009 +0000
+++ b/src/expr.c	Mon Jan 05 00:57:14 2009 +0000
@@ -185,6 +185,8 @@
 	debug_message(2, "Expression string %s", *p);
 
 eval_next:
+	if (!**p || isspace(**p) || **p == ')' || **p == ']')
+		return -1;
 	if (**p == '(')
 	{
 		debug_message(3, "Starting paren");
@@ -304,6 +306,7 @@
 		// single ascii constant
 		int val;
 		(*p)++;
+		debug_message(3, "Single ascii character constant '%c'", **p);
 		if (!**p)
 			return -1;
 		val = **p;
@@ -311,6 +314,7 @@
 		t = lwasm_expr_term_create_int(val);
 		lwasm_expr_stack_push(s, t);
 		lwasm_expr_term_free(t);
+		return 0;
 	}
 	else if (**p == '&')
 	{
@@ -582,14 +586,14 @@
 	lwasm_expr_term_t *operterm;
 	
 	// return if we are at the end of the expression or a subexpression
-	if (!**p || isspace(**p) || **p == ')' || **p == ',')
+	if (!**p || isspace(**p) || **p == ')' || **p == ',' || **p == ']')
 		return 0;
 	
 	if (lwasm_expr_parse_term(s, p) < 0)
 		return -1;
 
 eval_next:
-	if (!**p || isspace(**p) || **p == ')' || **p == ',')
+	if (!**p || isspace(**p) || **p == ')' || **p == ',' || **p == ']')
 		return 0;
 	
 	// expecting an operator here