Changeset 181
- Timestamp:
- 1999-03-02T09:39:54+13:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/display.cpp
r178 r181 12 12 /* 13 13 $Log$ 14 Revision 1.10 1999/03/01 20:39:54 sjboddie 15 Added eq and ne functionality to _If_ 16 14 17 Revision 1.9 1999/03/01 01:18:09 sjboddie 15 18 … … 981 984 982 985 void displayclass::expandstring (text_t package, const text_t &inputtext, 983 986 text_t &outputtext, int recursiondepth) 984 987 { 985 988 text_t macroname, macropackage, macroargs; … … 1213 1216 } 1214 1217 1218 1219 // evaluates a boolean expression 1220 // returns false if expr equals "" or "0". 1221 // otherwise returns true *unless* expr is 1222 // format "XXXX" eq/ne "dddd" in which case 1223 // the two quoted strings are compared 1224 bool displayclass::boolexpr (text_t package, const text_t &expr, int recursiondepth) { 1225 1226 if (expr.empty()) return false; 1227 1228 text_t expexpr; 1229 if (package.empty()) package = "Global"; 1230 expandstring (package, expr, expexpr, recursiondepth); 1231 1232 if (expexpr.empty() || expexpr == "0") return false; 1233 if (expr[0] != '\"') return true; 1234 1235 // don't use expexpr while separating quoted parts of 1236 // expression just in case expanded out macros contain 1237 // quotes 1238 text_t::const_iterator here = expr.begin(); 1239 text_t::const_iterator end = expr.end(); 1240 1241 int quotecount = 0; 1242 text_t string1, expstring1; 1243 text_t string2, expstring2; 1244 text_t op; 1245 while (here != end) { 1246 if (*here == '"') quotecount++; 1247 else if (quotecount == 1) string1.push_back(*here); 1248 else if ((quotecount == 2) && (*here != ' ') && (*here != '\n')) 1249 op.push_back(*here); 1250 else if (quotecount == 3) string2.push_back(*here); 1251 else if (quotecount == 4) break; 1252 here ++; 1253 } 1254 1255 expandstring (package, string1, expstring1, recursiondepth); 1256 expandstring (package, string2, expstring2, recursiondepth); 1257 1258 if (op == "eq") 1259 if (expstring1 == expstring2) return true; 1260 else return false; 1261 else if (op == "ne") 1262 if (expstring1 != expstring2) return true; 1263 else return false; 1264 else 1265 return true; // any badly formatted string will return true 1266 } 1267 1268 1215 1269 // (recursively) expand out a macro 1216 1270 // returns true if the macro was found … … 1265 1319 // found a quoted section 1266 1320 quote = c; 1321 aparam.push_back(c); 1267 1322 1268 1323 } else if (quote!='\0' && c==quote) { 1269 1324 // found the end of a quote 1270 1325 quote = '\0'; 1326 aparam.push_back(c); 1271 1327 1272 1328 } else if (quote=='\0' && c==',') { … … 1288 1344 } 1289 1345 1290 // I'm only supporting a simple version of _If_ at the moment1291 1346 if (macroname == "If") { 1292 1347 // get the condition, then clause and else clause … … 1315 1370 1316 1371 // test the expanded string 1317 if ((tmpoutput.size()) && (tmpoutput != "false") && (tmpoutput != "0")) { 1372 if (boolexpr (macropackage, *paramcond, recursiondepth+1)) { 1373 //(tmpoutput.size()) && (tmpoutput != "false") && (tmpoutput != "0")) { 1318 1374 // true 1319 1375 if (paramthen != paramend)
Note:
See TracChangeset
for help on using the changeset viewer.