File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -750,9 +750,17 @@ namespace marxan {
750750 for (string line : infile)
751751 { /* loop through file looking for varname */
752752 // if line contains varname
753- if (line.find (modifiedVar) != string::npos) {
753+ size_t var_start = line.find (modifiedVar);
754+ size_t var_end = var_start + modifiedVar.size ();
755+ if (var_start != string::npos) {
756+ // skip if we found only partial word
757+ if (var_start > 0 && (isalpha (line[var_start-1 ])))
758+ continue ;
759+ if (var_end < line.size () && (isalpha (line[var_end])))
760+ continue ;
761+
754762 // try to parse the value next to the variable by erasing first modifiedVar characters of line
755- string varValue = line.erase (0 , modifiedVar.size ());
763+ string varValue = line.erase (var_start , modifiedVar.size ());
756764 utils::trim (varValue);
757765
758766 if (varValue.empty ()) { // variable defined but no value - keep looping.
You can’t perform that action at this time.
0 commit comments