mail[Wesnoth-commits] r28829 - /trunk/src/formula.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by dragonking on August 21, 2008 - 20:01:
Author: dragonking
Date: Thu Aug 21 20:01:14 2008
New Revision: 28829

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28829&view=rev
Log:
Attempt to fix formula operator problems

Modified:
    trunk/src/formula.cpp

Modified: trunk/src/formula.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula.cpp?rev=28829&r1=28828&r2=28829&view=diff
==============================================================================
--- trunk/src/formula.cpp (original)
+++ trunk/src/formula.cpp Thu Aug 21 20:01:14 2008
@@ -673,16 +673,20 @@
 
        int parens = 0;
        const token* op = NULL;
+       bool operator_group = false;
        for(const token* i = i1; i != i2; ++i) {
                if(i->type == TOKEN_LPARENS || i->type == TOKEN_LSQUARE) {
                        ++parens;
                } else if(i->type == TOKEN_RPARENS || i->type == 
TOKEN_RSQUARE) {
                        --parens;
                } else if(parens == 0 && i->type == TOKEN_OPERATOR) {
-                       if(op == NULL || operator_precedence(*op) >
-                                                        
operator_precedence(*i)) {
+                       if( ( !operator_group ) && (op == NULL || 
operator_precedence(*op) >=
+                                                        
operator_precedence(*i)) ) {
                                op = i;
-                       }
+                               operator_group = true;
+                       }
+               } else {
+                       operator_group = false;
                }
        }
 




Related Messages


Powered by MHonArc, Updated Thu Aug 21 21:41:59 2008