[PATCH] Support || and && in preprocessor's conditions.
Przemyslaw Pawelczyk
przemyslaw@pawelczyk.it
Sat Jun 20 13:43:00 GMT 2009
---
parse.cxx | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/parse.cxx b/parse.cxx
index a26d594..a74b513 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -332,16 +332,42 @@ parser::scan_pp (bool wildcard)
// Do not evaluate the condition if we haven't expanded everything.
// This may occur when having several recursive conditionals.
- bool result = eval_pp_conditional (session, l, op, r);
+ bool and_result = eval_pp_conditional (session, l, op, r);
delete l;
delete op;
delete r;
+ bool result = false;
+ const token *n;
+ while ((n = input.scan ()) && n->type == tok_operator)
+ {
+ if (n->content == "||")
+ {
+ result |= and_result;
+ and_result = true;
+ }
+ else if (n->content != "&&")
+ break;
+ l = input.scan (false);
+ op = input.scan (false);
+ r = input.scan (false);
+ if (l == 0 || op == 0 || r == 0)
+ throw parse_error ("incomplete condition after '%('", t);
+
+ and_result &= eval_pp_conditional (session, l, op, r);
+ delete l;
+ delete op;
+ delete r;
+ delete n;
+ }
+
+ result |= and_result;
+
/*
clog << "PP eval (" << *t << ") == " << result << endl;
*/
- const token *m = input.scan (); // NB: not recursive
+ const token *m = n; // NB: not recursive
if (! (m && m->type == tok_operator && m->content == "%?"))
throw parse_error ("expected '%?' marker for conditional", t);
delete m; // "%?"
--
1.5.6.5
More information about the Systemtap
mailing list