Possible bug with null document in libyaml

William Spitzak <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
libyaml treats a file containing nothing but zero or more newlines as 
being completely empty and parses nothing out of it. However this 
appears to be inconsistent:

The text "---\nx\n..." and "x" produce the same result: a start, "x" 
scalar, and an end token.

But the text "---\n\n..." and "" produce different results. The first 
produces start, a "" scalar, and an end. The second produces nothing.

In addition writing a single "" scalar using libyaml without the 
document start/end produces a file containing only a newline and thus is 
not inverted by the parser.

This may seem trivial but I am using yaml internally to store serialized 
values of small pieces of data, and blank strings were breaking because 
of this. I had to modify libyaml to quote zero-length strings but I do 
not think that is the desired solution.

My recommendation is that a completely blank yaml file be parsed as a 
single "" scalar. This may seem dangerous, because this file will 
"vanish" if concatenated with other data, but concatenation is not 
supposed to work anyway if the surrounding "---" and "..." are missing.

Any opinions or have I missed anything?

Thanks
Bill Spitzak
Rhythm & Hues software department.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.