@@ -356,17 +356,19 @@ static char *Array(char *value, AST array)
356356 */
357357char * Math (AST tree )
358358{
359- long double dx , dy ;
360- char * sx , * sy ;
361- char * result = NULL ;
362-
363- MEM get = NULL ;
364-
365359 switch (tree -> type )
366360 {
367- case NODE_MEMGET :
361+ case NODE_VALUE :
362+
363+ return strdup (tree -> value );
368364
369- get = MemGet (MEMORY , tree -> value );
365+ case NODE_CALL :
366+
367+ return RunFunction (tree );
368+
369+ case NODE_MEMGET :
370+ {
371+ MEM get = MemGet (MEMORY , tree -> value );
370372
371373 if (!get )
372374 return LeaveException (UndefinedReference , tree -> value , tree -> file );
@@ -375,19 +377,12 @@ char *Math(AST tree)
375377 return LeaveException (VariableDefinedAsFunction , tree -> value , tree -> file );
376378
377379 return strdup (get -> value );
378-
379- case NODE_CALL :
380-
381- return RunFunction (tree );
382-
383- case NODE_VALUE :
384-
385- return strdup (tree -> value );
380+ }
386381
387382 case NODE_OPERATOR :
388-
389- sx = Eval (tree -> child );
390- sy = Eval (tree -> child -> sibling );
383+ {
384+ char * sx = Eval (tree -> child );
385+ char * sy = Eval (tree -> child -> sibling );
391386
392387 if (!sx || !sy )
393388 {
@@ -396,6 +391,8 @@ char *Math(AST tree)
396391 return NULL ;
397392 }
398393
394+ char * result = NULL ;
395+
399396 switch (* (tree -> value ))
400397 {
401398 case ',' :
@@ -424,8 +421,9 @@ char *Math(AST tree)
424421 break ;
425422 }
426423
427- dx = strtold (sx , & result );
428- dy = strtold (sy , & result );
424+ long double dx = strtold (sx , & result );
425+ long double dy = strtold (sy , & result );
426+
429427 free (sx );
430428 free (sy );
431429
@@ -434,11 +432,13 @@ char *Math(AST tree)
434432
435433 switch (* (tree -> value ))
436434 {
435+ // < or <=
437436 case '<' :
438- return __boolean (dx < dy || (dx == dy && tree -> value [1 ] == '=' ));
437+ return __boolean (dx < dy || (tree -> value [1 ] == '=' && dx == dy ));
439438
439+ // > or >=
440440 case '>' :
441- return __boolean (dx > dy || (dx == dy && tree -> value [1 ] == '=' ));
441+ return __boolean (dx > dy || (tree -> value [1 ] == '=' && dx == dy ));
442442
443443 case '&' :
444444 return __boolean (dx && dy );
@@ -467,6 +467,7 @@ char *Math(AST tree)
467467 default :
468468 return LeaveException (MathError , tree -> value , tree -> file );
469469 }
470+ }
470471
471472 default :
472473 return LeaveException (MathError , tree -> value , tree -> file );
0 commit comments