Changeset 584691 for molecuilder


Ignore:
Timestamp:
Apr 29, 2008, 7:16:32 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
7e2c5c
Parents:
2456db
Message:

bugfix in main: without arguments, code would crash due to access of argv[1]

This bug was introduced because of the huge changes in the command line parsing. Changed the beginning if (argv >= 1) to >1 and put element db and configpath/name scan into else statement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/builder.cpp

    r2456db r584691  
    698698  mol->CalculateOrbitals(*configuration);
    699699  configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
    700   if (ConfigFileName != NULL)
     700  if (ConfigFileName != NULL) {
    701701    output.open(ConfigFileName, ios::trunc);
    702   if (output == NULL)
    703     output.open("main_pcp_linux", ios::trunc);
     702  } else {
     703    output.open(configuration->configname, ios::trunc);
     704  }
    704705  if (configuration->Save(&output, periode, mol))
    705706    cout << Verbose(0) << "Saving of config file successful." << endl;
     
    725726  output.close();
    726727  output.clear();
     728 
    727729  if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    728730    cerr << "WARNING: config is found under different path then stated in config file::defaultpath!" << endl;
     
    765767
    766768  // =========================== PARSE COMMAND LINE OPTIONS ====================================
    767   if (argc >= 1) { // config file specified as option
     769  if (argc > 1) { // config file specified as option
    768770    // 1. : Parse options that just set variables or print help
    769771        argptr = 1;
     
    10181020      return (0);
    10191021    }
     1022  } else {  // no arguments, hence scan the elements db
     1023    if (periode->LoadPeriodentafel(ElementsFileName))
     1024      cout << Verbose(0) << "Element list loaded successfully." << endl;
     1025    else
     1026      cout << Verbose(0) << "Element list loading failed." << endl;
     1027    config_present = absent;
     1028    configuration.RetrieveConfigPathAndName("main_pcp_linux");
    10201029  }
    10211030
Note: See TracChangeset for help on using the changeset viewer.