[Avida-SVN] r3420 - development/source/main

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Sep 23 08:38:38 PDT 2009


Author: brysonda
Date: 2009-09-23 11:38:38 -0400 (Wed, 23 Sep 2009)
New Revision: 3420

Modified:
   development/source/main/cEventList.cc
   development/source/main/cWorld.cc
Log:
Alter event file processing to report more useful error messages and exit under such failures, rather than proceeding silently.

Modified: development/source/main/cEventList.cc
===================================================================
--- development/source/main/cEventList.cc	2009-09-22 21:07:11 UTC (rev 3419)
+++ development/source/main/cEventList.cc	2009-09-23 15:38:38 UTC (rev 3420)
@@ -84,6 +84,8 @@
     return true;
   }
   
+  cerr << "error: unrecognized event '" << name << "'" << endl; 
+  
   return false;
 }
 
@@ -95,7 +97,7 @@
 
   // Loop through the line_list and change the lines to events.
   for (int line_id = 0; line_id < event_file.GetNumLines(); line_id++) {
-    AddEventFileFormat(event_file.GetLine(line_id));
+    if (!AddEventFileFormat(event_file.GetLine(line_id))) return false;
   }
   
   return true;
@@ -417,9 +419,9 @@
   } else if (cur_word == "o"  || cur_word == "org_id") {
     trigger = BIRTHS_INTERRUPT;
 		cur_word = cur_line.PopWord();
-  }else {
-    // If Trigger is skipped so assume IMMEDIATE
-    trigger = IMMEDIATE;
+  } else {
+    cerr << "error: unrecognized event trigger '" << cur_word << "'" << endl;
+    return false;
   }
   
   // Do we now have timing specified?
@@ -458,11 +460,9 @@
     }
     cur_word = cur_line.PopWord(); // timing provided, so get next word
     
-  } else { // We don't have timing, so assume IMMEDIATE
-    trigger = IMMEDIATE;
-    start = TRIGGER_BEGIN;
-    interval = TRIGGER_ONCE;
-    stop = TRIGGER_END;
+  } else { 
+    cerr << "error: invalid event timing '" << tmp << "'" << endl;
+    return false;
   }
   
   // Get the rest of the info

Modified: development/source/main/cWorld.cc
===================================================================
--- development/source/main/cWorld.cc	2009-09-22 21:07:11 UTC (rev 3419)
+++ development/source/main/cWorld.cc	2009-09-23 15:38:38 UTC (rev 3420)
@@ -90,7 +90,7 @@
   // Initialize the default environment...
   // This must be after the HardwareManager in case REACTIONS that trigger instructions are used.
   if (!m_env->Load(m_conf->ENVIRONMENT_FILE.Get())) {
-    cerr << "Error: Unable to load environment" << endl;
+    cerr << "error: unable to load environment" << endl;
     Avida::Exit(-1);
   }
   
@@ -111,7 +111,7 @@
   // Setup Event List
   m_event_list = new cEventList(this);
   if (!m_event_list->LoadEventFile(m_conf->EVENT_FILE.Get())) {
-    cerr << "Error: Unable to load events" << endl;
+    cerr << "error: unable to load events" << endl;
     Avida::Exit(-1);
   }
 	




More information about the Avida-cvs mailing list