[MOAB-dev] r3510 - MOAB/trunk

iulian at mcs.anl.gov iulian at mcs.anl.gov
Fri Jan 29 11:36:52 CST 2010


Author: iulian
Date: 2010-01-29 11:36:52 -0600 (Fri, 29 Jan 2010)
New Revision: 3510

Modified:
   MOAB/trunk/ReadSmf.cpp
   MOAB/trunk/ReadSmf.hpp
   MOAB/trunk/SMF_State.cpp
Log:
remove exit call from a function in a library 
clean up some unused data in ReadSmf



Modified: MOAB/trunk/ReadSmf.cpp
===================================================================
--- MOAB/trunk/ReadSmf.cpp	2010-01-29 16:23:40 UTC (rev 3509)
+++ MOAB/trunk/ReadSmf.cpp	2010-01-29 17:36:52 UTC (rev 3510)
@@ -113,11 +113,6 @@
                                 const MBTag* file_id_tag) 
 {
   MBErrorCode result;
-
-  int major, minor;
-  char vendor_string[257];
-  std::vector<MBRange> element_list;
-  MBRange vertices;
   
   if (subset_list && subset_list_length) {
     readMeshIface->report_error( "Reading subset of files not supported for VTK." );
@@ -131,9 +126,8 @@
   if ( result == MB_SUCCESS )
     mPartitionTagName = partition_tag_name;
 
-  std::ifstream smfFile;
-    //smfFile.open( filename , std::ifstream::in);
-  if (!smfFile.is_open())
+  std::ifstream smfFile ( filename );
+  if (!smfFile)
   {
     return MB_FILE_DOES_NOT_EXIST;
   }
@@ -143,7 +137,11 @@
   while( !smfFile.eof() )
     {
 	if( smfFile.getline(line, SMF_MAXLINE, '\n').good() )
-	    parse_line(line);
+        {
+	    result = parse_line(line);
+            if (MB_SUCCESS != result)
+    		return result;
+	}
     }
 
   // at this point we have _numNodesInFile vertices and _numElementsInFile triangles
@@ -261,7 +259,7 @@
     
 }
 
-void ReadSmf::parse_line(char *line)
+MBErrorCode ReadSmf::parse_line(char *line)
 {
     char *cmd,*s;
     std::vector<std::string>  argv;
@@ -269,10 +267,10 @@
     while( *line==' ' || *line=='\t' ) line++;  // skip initial white space
 
     // Ignore empty lines
-    if( line[0]=='\n' || line[0]=='\0' ) return;
+    if( line[0]=='\n' || line[0]=='\0' ) return MB_SUCCESS;
 
     // Ignore comments
-    if( line[0]=='#' && line[1]!='$' ) return;
+    if( line[0]=='#' && line[1]!='$' ) return MB_SUCCESS;
 
     //
     // First, split the line into tokens
@@ -306,9 +304,10 @@
 	{
 	    // Invalid command:
 	    std::cerr << "SMF: Illegal command [" << cmd << "]" << std::endl;
-	    exit(1);
+	    return MB_UNSUPPORTED_OPERATION;
 	}
     }
+    return MB_SUCCESS;
 }
 
 

Modified: MOAB/trunk/ReadSmf.hpp
===================================================================
--- MOAB/trunk/ReadSmf.hpp	2010-01-29 16:23:40 UTC (rev 3509)
+++ MOAB/trunk/ReadSmf.hpp	2010-01-29 17:36:52 UTC (rev 3510)
@@ -84,7 +84,7 @@
     void mmult(std::vector<std::string> &);
     void mload(std::vector<std::string> &);
 
-    void parse_line(char *line);
+    MBErrorCode parse_line(char *line);
 private:
 
   MBReadUtilIface* readMeshIface;

Modified: MOAB/trunk/SMF_State.cpp
===================================================================
--- MOAB/trunk/SMF_State.cpp	2010-01-29 16:23:40 UTC (rev 3509)
+++ MOAB/trunk/SMF_State.cpp	2010-01-29 17:36:52 UTC (rev 3510)
@@ -4,7 +4,7 @@
 #include <cstring>
 #include <cstdlib>
 
-inline int streq(const char *a,const char *b) { return strcmp(a,b)==0; }
+inline int streq(const char *a,const char *b) { return std::strcmp(a,b)==0; }
 
 
 SMF_State::SMF_State(const SMF_ivars& ivar, SMF_State *link)



More information about the moab-dev mailing list