diff --git a/src/vm/parser.c b/src/vm/parser.c index 543890f..a1a8302 100644 --- a/src/vm/parser.c +++ b/src/vm/parser.c @@ -227,7 +227,8 @@ static gboolean parser_value ( GScanner *scanner, GByteArray *code ) static gboolean parser_ops ( GScanner *scanner, GByteArray *code, gint l ) { static gchar *expr_ops_list[] = { "&|", "!<>=", "+-", "*/%", NULL }; - static const gchar *ne = "=!"; + static const guchar *ne = (guchar *)"=!", equal = '='; + gboolean or_equal; guchar op; if(!expr_ops_list[l]) @@ -237,6 +238,7 @@ static gboolean parser_ops ( GScanner *scanner, GByteArray *code, gint l ) return FALSE; while(strchr(expr_ops_list[l], g_scanner_peek_next_token(scanner))) { + or_equal = FALSE; if(g_scanner_eof(scanner)) return TRUE; if( !(op = g_scanner_get_next_token(scanner)) ) @@ -247,13 +249,21 @@ static gboolean parser_ops ( GScanner *scanner, GByteArray *code, gint l ) else if(op=='!') g_scanner_get_next_token(scanner); + if((op=='>' || op=='<') && g_scanner_peek_next_token(scanner)=='=') + { + or_equal = TRUE; + g_scanner_get_next_token(scanner); + } if(!parser_ops(scanner, code, l+1)) return FALSE; if(op!='!') g_byte_array_append(code, &op, 1); else - g_byte_array_append(code, (guchar *)ne, 2); + g_byte_array_append(code, ne, 2); + + if(or_equal) + g_byte_array_append(code, &equal, 1); } return TRUE; } diff --git a/src/vm/vm.c b/src/vm/vm.c index 185b24c..d15962d 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -82,10 +82,11 @@ static gboolean vm_op_binary ( vm_t *vm ) else result= value_na; - if(!value_get_numeric(result) && (op=='<' || op=='>') && *(vm->ip+1)=='=') + if((op=='<' || op=='>') && *(vm->ip+1)=='=') { - result = value_new_numeric(value_get_numeric(v1)==value_get_numeric(v2)); vm->ip++; + result.value.numeric = value_get_numeric(result) || + (value_get_numeric(v1)==value_get_numeric(v2)); } }