[Avida-SVN] r2356 - in development: Avida.xcodeproj source/main source/tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Thu Feb 21 15:14:38 PST 2008


Author: brysonda
Date: 2008-02-21 18:14:38 -0500 (Thu, 21 Feb 2008)
New Revision: 2356

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/main/cAvidaConfig.cc
   development/source/tools/cInitFile.cc
   development/source/tools/cInitFile.h
Log:
Alter cInitFile to support a flag specifying if the file to open was found, even if it ultimately fails to load.   

Change default behavior of config loading to not write over the config file if it fails to load for reasons other than the file not found, such as #!include failure.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2008-02-21 22:12:45 UTC (rev 2355)
+++ development/Avida.xcodeproj/project.pbxproj	2008-02-21 23:14:38 UTC (rev 2356)
@@ -851,7 +851,7 @@
 		DCC315CE076253A5008F7A48 /* environment.rotate */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = environment.rotate; sourceTree = "<group>"; };
 		DCC315D0076253A5008F7A48 /* task_event_gen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.cc; sourceTree = "<group>"; };
 		DCC315D1076253A5008F7A48 /* task_event_gen.old.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.old.cc; sourceTree = "<group>"; };
-		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
+		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -1796,6 +1796,7 @@
 		DCC30C4D0762532C008F7A48 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
+			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 0;
 			mainGroup = DCC30C490762532C008F7A48;
 			productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;

Modified: development/source/main/cAvidaConfig.cc
===================================================================
--- development/source/main/cAvidaConfig.cc	2008-02-21 22:12:45 UTC (rev 2355)
+++ development/source/main/cAvidaConfig.cc	2008-02-21 23:14:38 UTC (rev 2356)
@@ -70,7 +70,11 @@
     tConstListIterator<cString> err_it(init_file.GetErrors());
     const cString* errstr = NULL;
     while ((errstr = err_it.Next())) cerr << "Error: " << *errstr << endl;
-    if (crash_if_not_found) {
+    if (init_file.WasFound()) {
+      // exit the program if the requested configuration was found but could not be loaded
+      cerr << "Error: failed to load '" << filename << "'.  Ending the program." << endl;
+      exit(-1);
+    } else if (crash_if_not_found) {
       // exit the program if the requested configuration file is not found
       cerr << "Error: Unable to find file '" << filename 
            << "'.  Ending the program." << endl;

Modified: development/source/tools/cInitFile.cc
===================================================================
--- development/source/tools/cInitFile.cc	2008-02-21 22:12:45 UTC (rev 2355)
+++ development/source/tools/cInitFile.cc	2008-02-21 23:14:38 UTC (rev 2356)
@@ -32,7 +32,7 @@
 using namespace std;
 
 
-cInitFile::cInitFile(const cString& filename) : m_filename(filename), m_ftype("unknown")
+cInitFile::cInitFile(const cString& filename) : m_filename(filename), m_found(false), m_opened(false), m_ftype("unknown")
 {
   tSmartArray<sLine*> lines;
   m_opened = LoadFile(filename, lines);
@@ -40,7 +40,7 @@
 }
 
 cInitFile::cInitFile(const cString& filename, const tDictionary<cString>& mappings)
-  : m_filename(filename), m_ftype("unknown")
+  : m_filename(filename), m_found(false), m_opened(false), m_ftype("unknown")
 {
   InitMappings(mappings);
   tSmartArray<sLine*> lines;
@@ -49,7 +49,7 @@
 }
 
 
-cInitFile::cInitFile(istream& in_stream) : m_filename("(stream)"), m_ftype("unknown")
+cInitFile::cInitFile(istream& in_stream) : m_filename("(stream)"), m_found(false), m_opened(false), m_ftype("unknown")
 {
   if (in_stream.good() == false) {
     m_errors.PushRear(new cString("Bad stream, unable to process."));
@@ -99,6 +99,8 @@
     return false;   // The file must be opened!
   }
   
+  m_found = true;
+  
   cStringList line_list;   // Create a list to load all of the lines into.
 
   int linenum = 0;

Modified: development/source/tools/cInitFile.h
===================================================================
--- development/source/tools/cInitFile.h	2008-02-21 22:12:45 UTC (rev 2355)
+++ development/source/tools/cInitFile.h	2008-02-21 23:14:38 UTC (rev 2356)
@@ -53,6 +53,7 @@
 {
 private:
   cString m_filename;
+  bool m_found;
   bool m_opened;
   mutable tList<cString> m_errors;
   
@@ -94,6 +95,7 @@
     while ((errstr = m_errors.Pop())) delete errstr;
   }
   
+  bool WasFound() const { return m_found; }
   bool WasOpened() const { return m_opened; }
   const tList<cString>& GetErrors() const { return m_errors; }
   




More information about the Avida-cvs mailing list