ruby-changes:18604
From: tenderlove <ko1@a...>
Date: Sat, 22 Jan 2011 11:24:08 +0900 (JST)
Subject: [ruby-changes:18604] Ruby:r30628 (trunk): * ext/psych/parser.c (parse): fixing off-by-one error on line numbers
tenderlove 2011-01-22 11:23:12 +0900 (Sat, 22 Jan 2011) New Revision: 30628 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30628 Log: * ext/psych/parser.c (parse): fixing off-by-one error on line numbers in parse exceptions. [ruby-core:34690] * test/psych/test_parser.rb: test for error Modified files: trunk/ChangeLog trunk/ext/psych/parser.c trunk/test/psych/test_parser.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 30627) +++ ChangeLog (revision 30628) @@ -1,3 +1,10 @@ +Sat Jan 22 11:21:40 2011 Aaron Patterson <aaron@t...> + + * ext/psych/parser.c (parse): fixing off-by-one error on line numbers + in parse exceptions. [ruby-core:34690] + + * test/psych/test_parser.rb: test for error + Sat Jan 22 10:25:19 2011 Aaron Patterson <aaron@t...> * ext/psych/parser.c (parse): add the file name to the exception when Index: ext/psych/parser.c =================================================================== --- ext/psych/parser.c (revision 30627) +++ ext/psych/parser.c (revision 30628) @@ -95,7 +95,7 @@ while(!done) { if(!yaml_parser_parse(parser, &event)) { VALUE path; - size_t line = parser->mark.line; + size_t line = parser->mark.line + 1; size_t column = parser->mark.column; if(rb_respond_to(yaml, id_path)) Index: test/psych/test_parser.rb =================================================================== --- test/psych/test_parser.rb (revision 30627) +++ test/psych/test_parser.rb (revision 30628) @@ -155,6 +155,21 @@ assert_match "(#{io.path}):", e.message end + # ruby-core:34690 + def test_exception_line + e = assert_raises(Psych::SyntaxError) do + @parser.parse(<<-eoyaml) +# based on "SGML/XML character entity reference" at http://www.bitjungle.com/isoent/ +# +--- +#DOUBLE LOW-9 QUOTATION MARK +#requires fontenc:T1 +ldquor: ,, + eoyaml + end + assert_match 'line 6', e.message + end + def test_mapping_end @parser.parse("---\n!!map { key: value }") assert_called :end_mapping -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/