diff --git a/IO/Reader.cpp b/IO/Reader.cpp index b7450d09..d6144a87 100644 --- a/IO/Reader.cpp +++ b/IO/Reader.cpp @@ -12,6 +12,14 @@ #include +// Inline function to read line without a return argument +static inline void fgetl( char * str, int num, FILE * stream ) +{ + char* ptr = fgets( str, num, stream ); + if ( 0 ) {char *temp = (char *)&ptr; temp++;} +} + + // List the timesteps in the given directors (dumps.LBPM) std::vector IO::readTimesteps( const std::string& filename ) { @@ -102,7 +110,7 @@ shared_ptr IO::getMesh( const std::string& path, const std::string& ti FILE *fid = fopen(filename.c_str(),"rb"); fseek(fid,database.offset,SEEK_SET); char line[1000]; - std::fgets(line,1000,fid); + fgetl(line,1000,fid); size_t i1 = find(line,':'); size_t i2 = find(&line[i1+1],':')+i1+1; size_t bytes = atol(&line[i2+1]); @@ -143,7 +151,7 @@ shared_ptr IO::getVariable( const std::string& path, const std::st FILE *fid = fopen(filename.c_str(),"rb"); fseek(fid,database.offset,SEEK_SET); char line[1000]; - std::fgets(line,1000,fid); + fgetl(line,1000,fid); size_t i1 = find(line,':'); size_t i2 = find(&line[i1+1],':')+i1+1; std::vector values = splitList(&line[i2+1],','); diff --git a/common/Domain.h b/common/Domain.h index 17818a6f..07925c66 100755 --- a/common/Domain.h +++ b/common/Domain.h @@ -200,6 +200,13 @@ private: } }; +// Inline function to read line without a return argument +static inline void fgetl( char * str, int num, FILE * stream ) +{ + char* ptr = fgets( str, num, stream ); + if ( 0 ) {char *temp = (char *)&ptr; temp++;} +} + Domain::~Domain(){ delete sendData_x; delete sendData_y; @@ -775,11 +782,11 @@ inline void ReadSpherePacking(int nspheres, double *List_cx, double *List_cy, do INSIST(fid!=NULL,"Error opening pack.out"); //.........Trash the header lines.......... char * line = new char[100]; - fgets(line, 100, fid); - fgets(line, 100, fid); - fgets(line, 100, fid); - fgets(line, 100, fid); - fgets(line, 100, fid); + fgetl(line, 100, fid); + fgetl(line, 100, fid); + fgetl(line, 100, fid); + fgetl(line, 100, fid); + fgetl(line, 100, fid); //........read the spheres.................. // We will read until a blank like or end-of-file is reached int count = 0; diff --git a/common/Utilities.cpp b/common/Utilities.cpp index 491c8283..0075986a 100644 --- a/common/Utilities.cpp +++ b/common/Utilities.cpp @@ -32,12 +32,14 @@ #include #include #include + #include #elif defined(__linux) || defined(__unix) || defined(__posix) #define USE_LINUX #include #include #include #include + #include #else #error Unknown OS #endif