This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Support OR (using ||) in preprocessor's conditions.


---
 parse.cxx |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/parse.cxx b/parse.cxx
index a26d594..52712bd 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -337,11 +337,27 @@ parser::scan_pp (bool wildcard)
       delete op;
       delete r;
 
+      const token *n;
+      while ((n = input.scan ()) && n->type == tok_operator && n->content == "||")
+        {
+          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);
+
+          result |= eval_pp_conditional (session, l, op, r);
+          delete l;
+          delete op;
+          delete r;
+          delete n;
+        }
+
       /*
       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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]