[Avida-cvs] [avida-svn] r1015 - in development/source: analyze tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Sep 29 07:09:58 PDT 2006


Author: brysonda
Date: 2006-09-29 10:09:58 -0400 (Fri, 29 Sep 2006)
New Revision: 1015

Modified:
   development/source/analyze/cAnalyze.cc
   development/source/tools/cRandom.h
Log:
Implement cAnalyze and cRandom fixes from trunk.

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2006-09-29 14:09:06 UTC (rev 1014)
+++ development/source/analyze/cAnalyze.cc	2006-09-29 14:09:58 UTC (rev 1015)
@@ -6986,8 +6986,7 @@
 }
 
 
-void cAnalyze::FunctionCreate(cString cur_string,
-                              tList<cAnalyzeCommand> & clist)
+void cAnalyze::FunctionCreate(cString cur_string, tList<cAnalyzeCommand>& clist)
 {
   int num_args = cur_string.CountNumWords();
   if (num_args < 1) {
@@ -7226,13 +7225,11 @@
 }
 
 
-void cAnalyze::LoadCommandList(cInitFile & init_file,
-                               tList<cAnalyzeCommand> & clist)
+void cAnalyze::LoadCommandList(cInitFile& init_file, tList<cAnalyzeCommand>& clist)
 {
   while (init_file.GetLineNum() < init_file.GetNumLines()) {
     cString cur_string = init_file.GetNextLine();
     cString command = cur_string.PopWord();
-    command.ToUpper();
     
     cAnalyzeCommand* cur_command;
     cAnalyzeCommandDefBase* command_def = FindAnalyzeCommandDef(command);
@@ -7240,13 +7237,11 @@
     if (command == "END") {
       // We are done with this section of code; break out...
       break;
-    }
-    else if (command_def != NULL && command_def->IsFlowCommand() == true) {
+    } else if (command_def != NULL && command_def->IsFlowCommand() == true) {
       // This code has a body to it... fill it out!
       cur_command = new cAnalyzeFlowCommand(command, cur_string);
       LoadCommandList( init_file, *(cur_command->GetCommandList()) );
-    }
-    else {
+    } else {
       // This is a normal command...
       cur_command = new cAnalyzeCommand(command, cur_string);
     }
@@ -7326,28 +7321,24 @@
   }
 }
 
-void cAnalyze::ProcessCommands(tList<cAnalyzeCommand> & clist)
+void cAnalyze::ProcessCommands(tList<cAnalyzeCommand>& clist)
 {
   // Process the command list...
   tListIterator<cAnalyzeCommand> command_it(clist);
   command_it.Reset();
-  cAnalyzeCommand * cur_command = NULL;
+  cAnalyzeCommand* cur_command = NULL;
   while ((cur_command = command_it.Next()) != NULL) {
     cString command = cur_command->GetCommand();
     cString args = cur_command->GetArgs();
     PreProcessArgs(args);
     
-    cAnalyzeCommandDefBase * command_fun = FindAnalyzeCommandDef(command);
+    cAnalyzeCommandDefBase* command_fun = FindAnalyzeCommandDef(command);
     
     if (command_fun != NULL) command_fun->Run(this, args, *cur_command);
-    else if (FunctionRun(command, args) == true) {
-      // Found a defined function by this name.
-    }
-    else {
+    else if (!FunctionRun(command, args)) {
       cerr << "Error: Unknown analysis keyword '" << command << "'." << endl;
       exit(1);
-    }
-    
+    }    
   }
 }
 
@@ -7753,8 +7744,8 @@
     cString cur_input(text_input);
     cString command = cur_input.PopWord();
     
-    cAnalyzeCommand * cur_command;
-    cAnalyzeCommandDefBase * command_def = FindAnalyzeCommandDef(command);
+    cAnalyzeCommand* cur_command;
+    cAnalyzeCommandDefBase* command_def = FindAnalyzeCommandDef(command);
     if (command == "") {
       // Don't worry about blank lines...
       continue;
@@ -7773,7 +7764,7 @@
     cString args = cur_command->GetArgs();
     PreProcessArgs(args);
     
-    cAnalyzeCommandDefBase * command_fun = FindAnalyzeCommandDef(command);
+    cAnalyzeCommandDefBase* command_fun = FindAnalyzeCommandDef(command);
     
     // First check for built-in functions...
     if (command_fun != NULL) command_fun->Run(this, args, *cur_command);

Modified: development/source/tools/cRandom.h
===================================================================
--- development/source/tools/cRandom.h	2006-09-29 14:09:06 UTC (rev 1014)
+++ development/source/tools/cRandom.h	2006-09-29 14:09:58 UTC (rev 1015)
@@ -126,7 +126,7 @@
    * @return The pseudo random number.
    * @param max The upper bound for the random numbers (will never be returned).
    **/
-  unsigned int GetUInt(const unsigned int max) { return (int) (GetDouble() * max); }
+  unsigned int GetUInt(const unsigned int max) { return static_cast<int>(GetDouble()) * max; }
   
   /**
    * Generate an unsigned int out of an interval.
@@ -144,8 +144,8 @@
    * @param min The lower bound for the random numbers.
    * @param max The upper bound for the random numbers (will never be returned).
    **/
-  int GetInt(const int max) { return (int)GetUInt(max); }
-  int GetInt(const int min, const int max) { return ((int)GetUInt(max - min)) + min; }
+  int GetInt(const int max) { return static_cast<int>(GetUInt(max)); }
+  int GetInt(const int min, const int max) { return static_cast<int>(GetUInt(max - min)) + min; }
   
   
   // Random Event Generation //////////////////////////////////////////////////




More information about the Avida-cvs mailing list