Skip to content

Commit

Permalink
Discard white space when parsing key/value pairs from eds file and al…
Browse files Browse the repository at this point in the history
…so don't assume first index is key[1] fixes #70
  • Loading branch information
robincornelius committed Apr 4, 2017
1 parent a59872e commit e03b8b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion EDSTest/DeviceODView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,12 @@ public void validateanddisplaydata()
{
if (od.subobjects.Count >= 2)
{
comboBox_datatype.SelectedItem = od.subobjects[1].datatype.ToString();
// BUG #70 Select the first non subindex count entry, note this may not be key[1] so we are using an ordinal hack
// to retrieve it.
// Whilst this will likely work forever, there is nothing stopping the implementation from being
// changed in the future and causing your code which uses this to break in horrible ways. You have been warned

comboBox_datatype.SelectedItem = od.subobjects.ElementAt(1).Value.datatype.ToString();
}

}
Expand Down
3 changes: 2 additions & 1 deletion libEDSsharp/eds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,8 @@ public void parseline(string linex)

//extract keyvalues
{
string pat = @"^([a-z0-9_]+)=(.*)";
//Bug #70 Eat whitespace!
string pat = @"^([a-z0-9_]+)[ ]*=[ ]*(.*)";

Regex r = new Regex(pat, RegexOptions.IgnoreCase);
Match m = r.Match(line);
Expand Down

0 comments on commit e03b8b8

Please sign in to comment.