sccn / xdf

BSD 2-Clause "Simplified" License
87 stars 34 forks source link

minimal.xdf vs. specification incongruence #61

Closed Garfield100 closed 1 year ago

Garfield100 commented 1 year ago

It seems to me as if the spec and the minimal.xdf example file in the linked example_files repo disagree. While writing a new xdf parser, I tried reading values according to this: Structure of Value
I made sure to assert as much as possible in general, including the following from the linked paragraphs:

For non-numeric (i.e., string or binary) values, a variable-length encoding is used:

[NumLengthBytes] [Length] [StringContent] 
[4, or 8] [...] [Arbitrary] 
[1] [As encoded] [Length] 

Here, the number of length bytes is specified to be either 4, or 8. However, my program throws an error because this is not the case in minimal.xdf: image

As you can see, the length of the string Hello is given by only a single byte, 05.

I checked the commits on the wiki and the specified [4, or 8] was already in the initial commit. Strangely though, there was also a 1 but it wasn't inside the square brackets: image

As such, it was removed in the following clean-up commit. I'm not sure how the wiki came to be or why the first commit looked the way it did. Perhaps the 1 was supposed to stay and be included in the square brackets?

Is the file or the spec outdated or otherwise wrong? Have I missed something else entirely?

chkothe commented 1 year ago

Hi Enrico, good catch, and hopefully it didn't cause too much frustration! I think this error must have crept in when the spec was originally converted to GitHub wiki format. Indeed, this originally said [1, 4, or 8] just like the other variable-length encoded integers (that's why there's still a comma after the 4).

Edit: fixed now