--- trunk/OOPSE-4/src/utils/ElementsTable.cpp 2008/01/24 21:38:53 3335 +++ trunk/OOPSE-4/src/utils/ElementsTable.cpp 2008/10/16 18:17:41 3462 @@ -29,9 +29,12 @@ GNU General Public License for more details. * @version 1.0 */ +#include #include "config.h" +#include #include #include +#include #include "utils/ElementsTable.hpp" #include "utils/simError.h" #include "io/basic_ifstrstream.hpp" @@ -75,7 +78,6 @@ namespace oopse { RealType red, green, blue; // skip comment line (at the top) - if (line[0] != '#') { sscanf(line,"%d %5s %lf %*f %lf %d %lf %lf %lf %lf %lf %lf %lf %255s", &num, @@ -96,6 +98,7 @@ namespace oopse { elNeg, ionize, elAffin, red, green, blue, name); elements_.push_back(ele); + } } @@ -106,7 +109,7 @@ namespace oopse { return elements_.size(); } - char *ElementsTable::GetSymbol(int atomicnum) { + const char *ElementsTable::GetSymbol(int atomicnum) { if (!init_) Init(); @@ -291,21 +294,28 @@ namespace oopse { buffer = getenv(envvar_.c_str()); buffer += FILE_SEP_CHAR; + + + if (!subdir_.empty()) { subbuffer = buffer; subbuffer += subdir_; subbuffer += FILE_SEP_CHAR; } + + buffer += filename_; subbuffer += filename_; + ifs1.open(subbuffer.c_str()); ifsP= &ifs1; - if (!(*ifsP)) { + if (!(ifsP->is_open())) { ifs2.open(buffer.c_str()); ifsP = &ifs2; } + } else { sprintf( painCave.errMsg, "ElementsTable error.\n" @@ -318,25 +328,25 @@ namespace oopse { if ((*ifsP)) { while(ifsP->getline(charBuffer,BUFF_SIZE)) ParseLine(charBuffer); - - if (ifs1) - ifs1.close(); - if (ifs2) - ifs2.close(); - if (ifs3) - ifs3.close(); - if (ifs4) - ifs4.close(); + + if (ifs1) + ifs1.close(); + if (ifs2) + ifs2.close(); + if (ifs3) + ifs3.close(); + if (ifs4) + ifs4.close(); + + if (GetSize() == 0) { + sprintf( painCave.errMsg, + "ElementsTable error.\n" + "\tCannot initialize database %s \n", filename_.c_str()); + painCave.isFatal = 0; + simError(); + } - if (GetSize() == 0) { - sprintf( painCave.errMsg, - "ElementsTable error.\n" - "\tCannot initialize database %s \n", filename_.c_str()); - painCave.isFatal = 0; - simError(); } - - } } }