Skip to content

Commit e03b8b8

Browse files
Discard white space when parsing key/value pairs from eds file and also don't assume first index is key[1] fixes #70
1 parent a59872e commit e03b8b8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

EDSTest/DeviceODView.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ public void validateanddisplaydata()
229229
{
230230
if (od.subobjects.Count >= 2)
231231
{
232-
comboBox_datatype.SelectedItem = od.subobjects[1].datatype.ToString();
232+
// BUG #70 Select the first non subindex count entry, note this may not be key[1] so we are using an ordinal hack
233+
// to retrieve it.
234+
// Whilst this will likely work forever, there is nothing stopping the implementation from being
235+
// changed in the future and causing your code which uses this to break in horrible ways. You have been warned
236+
237+
comboBox_datatype.SelectedItem = od.subobjects.ElementAt(1).Value.datatype.ToString();
233238
}
234239

235240
}

libEDSsharp/eds.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,8 @@ public void parseline(string linex)
10721072

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

10771078
Regex r = new Regex(pat, RegexOptions.IgnoreCase);
10781079
Match m = r.Match(line);

0 commit comments

Comments
 (0)