Re: Possible bug with null document in libyaml

Kirill Simonov <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
William Spitzak wrote:
> 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.


You could ask libyaml to always produce the '---' indicator by setting 
the flag 'implicit' to 1 when calling 
'yaml_document_start_event_initialize()'.  You could also ask it to 
produce a quoted string by setting the parameter 'style' to 
'YAML_SINGLE_QUOTED_SCALAR_STYLE' or 'YAML_DOUBLE_QUOTED_SCALAR_STYLE' 
when calling 'yaml_scalar_event_initialize()'.


Thanks,
Kirill

------------------------------------------------------------------------------
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.