majintao0131 / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

emitter: writing a string prefixed with '?' when using "auto" quotation results in invalid YAML #156

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Repro with libyamlcpp.so.0.5.0 (built from new api branch):

[code]
#include <yaml-cpp/yaml.h>
#include <iostream>

int main() {
  YAML::Node node;
  node["foo"] = "?bar";
  cout << node << endl;
}
[/code]

built with: g++ foo.cc -lyamlcpp -Wl,-rpath=/usr/local/include/

Expected output:
foo: "?bar"

Actual output:
foo: ?bar

Reason this is a problem:
A leading ? denotes an associative array in YAML.

Original issue reported on code.google.com by peterhu...@gmail.com on 15 Mar 2012 at 12:45

GoogleCodeExporter commented 9 years ago
Corrections: 
 - repro code is missing "using namespace std;" before main()
 - link switch should be "-lyaml-cpp" and not "-lyamlcpp"

Original comment by peterhu...@gmail.com on 15 Mar 2012 at 12:47

GoogleCodeExporter commented 9 years ago
Another correction (why can't we edit the issue as the originator? I don't see 
a way to do so, at least):
  -rpath should be /usr/local/lib (of course, this is system dependent and not needed if libyamlcpp is on the loader's path).

Original comment by peterhu...@gmail.com on 15 Mar 2012 at 12:52

GoogleCodeExporter commented 9 years ago
Nice catch - thanks!

Original comment by jbe...@gmail.com on 15 Mar 2012 at 3:23

GoogleCodeExporter commented 9 years ago

Original comment by jbe...@gmail.com on 19 May 2012 at 9:09

GoogleCodeExporter commented 9 years ago
Hmm, I thought about this some more, and I think that "foo: ?bar" is valid 
YAML; the parser incorrectly flags it as incorrect.

From the spec:

> However, the “:”, “?” and “-” indicators may be used as the first 
character if followed by a non-space “safe” character, as this causes no 
ambiguity.

Original comment by jbe...@gmail.com on 9 Nov 2012 at 12:56

GoogleCodeExporter commented 9 years ago
Fixed, rd042aa2fa32d.

Original comment by jbe...@gmail.com on 9 Nov 2012 at 1:13