Ignore:
Timestamp:
Jun 16, 2008, 2:09:27 PM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
b73d28
Parents:
0779a9
Message:

BUGFIX: If other databases could not be loaded, no error was produced, resulting in strange behaviour of the fragmentation routine.

Now an error message is produced, though we still continue. The problem was the switch in handling const char * and a huge mess in LoadPeriodenTafel() with strncat and strncpy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/periodentafel.cpp

    r0779a9 r1f9f1b  
    217217
    218218  // fill valence DB per element
    219   strncat(filename, path, MAXSTRINGSIZE);
    220   strncpy(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
     219  strncpy(filename, path, MAXSTRINGSIZE);
     220  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     221  strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
    221222  infile.open(filename);
    222223  if (infile != NULL) {
     
    226227        infile >> FindElement((int)tmp)->Valence;
    227228        infile >> ws;
    228         //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->Valence << " valence electrons." << endl;
     229        //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
    229230    }
    230231    infile.close();
     
    234235
    235236  // fill valence DB per element
    236   strncat(filename, path, MAXSTRINGSIZE);
    237   strncpy(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
     237  strncpy(filename, path, MAXSTRINGSIZE);
     238  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     239  strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
    238240  infile.open(filename);
    239241  if (infile != NULL) {
     
    243245      infile >> FindElement((int)tmp)->NoValenceOrbitals;
    244246      infile >> ws;
    245       //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
     247      //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
    246248    }
    247249    infile.close();
     
    251253 
    252254  // fill H-BondDistance DB per element
    253   strncat(filename, path, MAXSTRINGSIZE);
    254   strncpy(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
     255  strncpy(filename, path, MAXSTRINGSIZE);
     256  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     257  strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
    255258  infile.open(filename);
    256259  if (infile != NULL) {
     
    263266      infile >> ptr->HBondDistance[2];
    264267        infile >> ws;
    265       //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
     268      //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    266269    }
    267270    infile.close();
     
    271274 
    272275  // fill H-BondAngle DB per element
    273   strncat(filename, path, MAXSTRINGSIZE);
    274   strncpy(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
     276  strncpy(filename, path, MAXSTRINGSIZE);
     277  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
     278  strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
    275279  infile.open(filename);
    276280  if (infile != NULL) {
     
    288292  } else
    289293    otherstatus = false;
     294 
     295  if (!otherstatus)
     296    cerr << "ERROR: Something went wrong while parsing the databases!" << endl;
    290297 
    291298  return status;
Note: See TracChangeset for help on using the changeset viewer.