Fix parsing crash if xy plot definition has extraneous ‘.’ after a number.

This commit is contained in:
Kathy Ruffing 2013-09-05 15:51:07 +00:00
parent 15cfa2d671
commit 99b055f4ac

View File

@ -397,6 +397,18 @@ namespace XYPlots
string ystr = xystr[1];
if (ystr.EndsWith(".0")) // bug fix B2012-169, the Trim converted a ".75" value to a "75.0" value
ystr = ystr.Trim(trimEndDot);
// count the number of '.', if there are two and the last char is a '.', trim it (this was causing
// a crash in CAL-OTO-OTO-BG-00001. This was done this way so as to be very specific to the
// problem found in Callaway, i.e. didn't want to break something else.
int cnt = 0;
int indx = ystr.IndexOf(".");
while (indx >= 0)
{
cnt++;
indx = indx+1==ystr.Length?-1:ystr.IndexOf(".", indx + 1);
}
if (cnt > 1) ystr = ystr.TrimEnd(trimEndDot);
y = double.Parse(ystr);
if (doLOG10[flag, X])
retval.xyValue[X] = (int)(Offset[flag, X] + Scale[flag, X] * Math.Log10(x) + .5);