aboutsummaryrefslogtreecommitdiff
path: root/src/formula.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-23 22:02:15 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-23 22:02:15 +0000
commitd4cf48613dd9b1338e174edbf4f47a7736bb2505 (patch)
tree404daa83485d75325ef76019e557e5203ba522d4 /src/formula.h
parentb94a6a42c1024c00fab7b678cccaecfaa7604d56 (diff)
downloadlibbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.tar.gz
libbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.tar.bz2
libbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.tar.xz
libbu++-d4cf48613dd9b1338e174edbf4f47a7736bb2505.zip
Fixed a peculiar formula residue bug...eeew, formula residue. Also added a
clear function to Bu::Stack
Diffstat (limited to 'src/formula.h')
-rw-r--r--src/formula.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/formula.h b/src/formula.h
index d1e77e3..20ffa5b 100644
--- a/src/formula.h
+++ b/src/formula.h
@@ -60,6 +60,14 @@ namespace Bu
60 60
61 prec run( const Bu::FString &sFormulaSrc ) 61 prec run( const Bu::FString &sFormulaSrc )
62 { 62 {
63 /*
64 if( !sOper.isEmpty() )
65 printf("sOper.isEmpty() == false!\n");
66 if( !sValue.isEmpty() )
67 printf("sValue.isEmpty() == false!\n");
68 if( !sFunc.isEmpty() )
69 printf("sFunc.isEmpty() == false!\n");
70 */
63 const char *sFormula = sFormulaSrc.getStr(); 71 const char *sFormula = sFormulaSrc.getStr();
64 for(;;) 72 for(;;)
65 { 73 {
@@ -91,8 +99,11 @@ namespace Bu
91 if( tOpr == symEOS ) 99 if( tOpr == symEOS )
92 { 100 {
93 reduce(); 101 reduce();
94 return sValue.top(); 102 prec ret = sValue.top();
95 break; 103 sValue.clear();
104 sFunc.clear();
105 sOper.clear();
106 return ret;
96 } 107 }
97 if( !sOper.isEmpty() && getPrec( sOper.top() ) > getPrec( tOpr ) ) 108 if( !sOper.isEmpty() && getPrec( sOper.top() ) > getPrec( tOpr ) )
98 { 109 {
@@ -108,7 +119,11 @@ namespace Bu
108 goto oppart; 119 goto oppart;
109 } 120 }
110 } 121 }
111 return sValue.top(); 122 prec ret = sValue.top();
123 sValue.clear();
124 sFunc.clear();
125 sOper.clear();
126 return ret;
112 } 127 }
113 128
114 varHash hVars; 129 varHash hVars;