From 45cdfc07f4384f17c9752b155245c173a7fc5cd3 Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Thu, 12 Mar 2015 19:10:36 +0000
Subject: [PATCH] Fix error for MAC on std=c++11

---
 DDCore/src/Evaluator/Evaluator.cpp      | 19 ++++++++++++++-----
 DDG4/plugins/Geant4EventReaderHepMC.cpp |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/DDCore/src/Evaluator/Evaluator.cpp b/DDCore/src/Evaluator/Evaluator.cpp
index 9252d4a87..ff53648ec 100644
--- a/DDCore/src/Evaluator/Evaluator.cpp
+++ b/DDCore/src/Evaluator/Evaluator.cpp
@@ -695,12 +695,21 @@ namespace XmlTools {
     string item_name = name;
     //std::cout << " ++++++++++++++++++++++++++++ Try to resolve env:" << name << std::endl;
     dic_type::iterator iter = (s->theDictionary).find(item_name);
-    if (iter == (s->theDictionary).end()) {
-      s->theStatus = EVAL::ERROR_UNKNOWN_VARIABLE;
-      return 0;
+    if (iter != (s->theDictionary).end()) {
+      s->theStatus = EVAL::OK;
+      return iter->second.expression.c_str();
     }
-    s->theStatus = EVAL::OK;
-    return iter->second.expression.c_str();
+    if ( ::strlen(item_name.c_str()) > 3 )  {
+      // Need to remove braces from ${xxxx} for call to getenv()
+      string env_name(name+2,::strlen(name)-3);
+      const char* env_str = ::getenv(env_name.c_str());
+      if ( 0 != env_str )    {
+	s->theStatus = EVAL::OK;
+	return env_str;
+      }
+    }
+    s->theStatus = EVAL::ERROR_UNKNOWN_VARIABLE;
+    return 0;
   }
 
   //---------------------------------------------------------------------------
diff --git a/DDG4/plugins/Geant4EventReaderHepMC.cpp b/DDG4/plugins/Geant4EventReaderHepMC.cpp
index b7a53a7c5..adc712ce2 100644
--- a/DDG4/plugins/Geant4EventReaderHepMC.cpp
+++ b/DDG4/plugins/Geant4EventReaderHepMC.cpp
@@ -156,7 +156,7 @@ Geant4EventReaderHepMC::Geant4EventReaderHepMC(const string& nam)
 {
   // Now open the input file:
   m_input.open(nam.c_str(),BOOST_IOS::in|BOOST_IOS::binary);
-  if ( m_input < 0 )   {
+  if ( m_input.is_open() )   {
     string err = "+++ Geant4EventReaderHepMC: Failed to open input stream:"+nam+
       " Error:"+string(strerror(errno));
     throw runtime_error(err);
-- 
GitLab