1.8.0, YAML funny feature

hi
i happened to edit a yaml file manually. after doing so it didn t load
anymore - parse error!
i think this should not happen. the parser /must/ become a bit more robust.

the problem: the parser handles “\n” and “\r\n” differently. a windos-
specific problem?
See following irb session:

irb(main):006:0> YAML::load “-1\n-\n - 1\n - 2\n - 3\n-2”=> [1, [1, 2, 3],
2]
irb(main):007:0> YAML::load "-1\r\n-\r\n - 1\r\n - 2\r\n - 3\r\n-2"
ArgumentError: parse error on line 5, col 3: -2'from F:/SCRIPT/ruby/lib/ruby/1.8/yaml.rb:28:inload’
from F:/SCRIPT/ruby/lib/ruby/1.8/yaml.rb:28:in `load’
from (irb):7
irb(main):010:0> YAML::load “-1\r\n-\r\n - 1\r\n - 2\r\n - 3\r\n-2”=>
[“1\r”, “\r-1\r - 2\r - 3\r”, 2]

the last line loads (due to a space added at index 8) but is completely
inacceptable.

annother question:
why does to_yaml print a space after a single - (dash)? ok - not against
yaml syntax rules.
i have no real evidence yet,
but i believe that the parser relies on this in some special cases (as seen
in the irb output).

win2k, ruby 1.8.0

···

  • Henon
    ’mmeeiinnnrrrrraaaaddd.rrreeeeecccchhhhhheeeeiiiiiissss@gggggggmmmmxxxxxx.aaaaattt’.squeeze!

Ah, good catch. I haven’t been ignoring this. Just been on vacation.

I’ll report back when I get a chance to repair this. Need to school my parser
on the carriage return.

_why

···

On Sunday 10 August 2003 04:15 pm, Henon wrote:

the problem: the parser handles “\n” and “\r\n” differently. a windos-
specific problem?

The strings you’re using below are not valid YAML, so my parser throws errors.
These sequences:

-1

···
    • 1
    • 2
    • 3
      -2

…need spaces after the dashes. So here’s my IRb session:

YAML::load “- 1\n-\n - 1\n - 2\n - 3\n- 2”
=> [1, [1, 2, 3], 2]
YAML::load “- 1\r\n-\r\n - 1\r\n - 2\r\n - 3\r\n- 2”
=> [1, [1, 2, 3], 2]

So I’m getting back the right arrays with either line ending. This is with
Andy’s latest Ruby 1.8.0 Windows Installer.

_why

On Sunday 10 August 2003 04:15 pm, Henon wrote:

irb(main):006:0> YAML::load “-1\n-\n - 1\n - 2\n - 3\n-2”=> [1, [1, 2, 3],
2]
irb(main):007:0> YAML::load “-1\r\n-\r\n - 1\r\n - 2\r\n - 3\r\n-2”
ArgumentError: parse error on line 5, col 3: -2'from F:/SCRIPT/ruby/lib/ruby/1.8/yaml.rb:28:in load’
from F:/SCRIPT/ruby/lib/ruby/1.8/yaml.rb:28:in `load’
from (irb):7
irb(main):010:0> YAML::load “-1\r\n-\r\n - 1\r\n - 2\r\n - 3\r\n-2”=>
[“1\r”, “\r-1\r - 2\r - 3\r”, 2]