Changeset 32
- Timestamp:
- 10/30/09 20:23:42 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/f8-to-f1/conv_f8tof1.cpp
r26 r32 556 556 const char* src = in; 557 557 558 if (in.len() < 1 &&!this->checkSyntax(src)) {558 if (in.len() < 1 || !this->checkSyntax(src)) { 559 559 return SString(); 560 560 } … … 565 565 } 566 566 if (lsystem->firstProductionName.empty()) { 567 delete lsystem; 567 568 return SString(); 568 569 } … … 598 599 //set parameters for start production 599 600 Production *firstProduction = lsystem->productions[lsystem->firstProductionName]; 601 if (firstProduction==NULL) { 602 delete lsystem; 603 return SString(""); //should never happen because of syntax validation 604 } 605 600 606 vector<double> params; 601 607 params.assign(lsystem->startParams.size(), 0.0); 602 608 //cout << "startParams->size: " << lsystem->startParams.size() << endl; 603 for (map<string, double>::iterator iter = lsystem->startParams.begin(); 604 iter != lsystem->startParams.end(); iter++) { 609 for (map<string, double>::iterator iter = lsystem->startParams.begin(); 610 iter != lsystem->startParams.end(); iter++) 611 { 605 612 int position = firstProduction->parameters.getParameterPosition(stringToSString(iter->first)); 606 613 //cout << "position of " << iter->first << ": " << position << endl; 607 params.insert(params.begin() + (position - 1), iter->second); 608 //params[position - 1] = iter->second; 614 //params.insert(params.begin() + (position - 1), iter->second); //no need because the vector has required length (assign above) 615 if (position>params.size()) { 616 delete lsystem; 617 return SString(""); 618 } 619 params[position - 1] = iter->second; 609 620 } 610 621 … … 651 662 dst += a->getF1Genotype(p); 652 663 if (dst.len() > maxF1Length) { 664 delete lsystem; 653 665 return SString(); //genotype becomes too long so we abort conversion 654 666 } … … 670 682 #endif 671 683 Lsystem *lsys = new Lsystem(); 672 684 673 685 //read production names and create objects for them 674 686 vector<SString> names = this->readProductionNames(in);
Note: See TracChangeset
for help on using the changeset viewer.