From 902bd2b10698d404d15ce8cfff500519a1df4adb Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 2 May 2010 23:15:08 +0000 Subject: [PATCH] * ext/syck/emitter.c (syck_scan_scalar): set SCAN_WHITEEDGE flag when scalar begins with newline. patches from Dave B at [ruby-core:23019] and caleb clausen at [ruby-core:25851]. [ruby-core:23006][ruby-core:29925] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++ ext/syck/emitter.c | 2 +- test/syck/test_yaml.rb | 116 +++++++++++++++++++++++++++++++++-------- version.h | 4 +- 4 files changed, 103 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 308946a5ac..28c654e663 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon May 3 08:15:05 2010 Nobuyoshi Nakada + + * ext/syck/emitter.c (syck_scan_scalar): set SCAN_WHITEEDGE flag + when scalar begins with newline. patches from Dave B at [ruby-core:23019] and caleb clausen at + [ruby-core:25851]. [ruby-core:23006][ruby-core:29925] + Sun May 2 17:52:16 2010 Nobuyoshi Nakada * lib/rdoc/task.rb (RDoc::Task): should not override newer code. diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c index eb01033653..985bfb2500 100644 --- a/ext/syck/emitter.c +++ b/ext/syck/emitter.c @@ -570,7 +570,7 @@ syck_scan_scalar( int req_width, const char *cursor, long len ) flags |= SCAN_MANYNL_E; } if ( - ( len > 0 && ( cursor[0] == ' ' || cursor[0] == '\t' ) ) || + ( len > 0 && ( cursor[0] == ' ' || cursor[0] == '\t' || cursor[0] == '\n' || cursor[0] == '\r' ) ) || ( len > 1 && ( cursor[len-1] == ' ' || cursor[len-1] == '\t' ) ) ) { flags |= SCAN_WHITEEDGE; diff --git a/test/syck/test_yaml.rb b/test/syck/test_yaml.rb index 1a78e9d216..3d9d7abe1d 100644 --- a/test/syck/test_yaml.rb +++ b/test/syck/test_yaml.rb @@ -1,4 +1,4 @@ -# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- +# -*- mode: ruby; ruby-indent-level: 4; tab-width: 4; indent-tabs-mode: t -*- # vim:sw=4:ts=4 # $Id$ # @@ -26,31 +26,31 @@ class YAML_Unit_Tests < Test::Unit::TestCase # Convert between YAML and the object to verify correct parsing and # emitting # - def assert_to_yaml( obj, yaml ) - assert_equal( obj, YAML::load( yaml ) ) - assert_equal( obj, YAML::parse( yaml ).transform ) - assert_equal( obj, YAML::load( obj.to_yaml ) ) - assert_equal( obj, YAML::parse( obj.to_yaml ).transform ) + def assert_to_yaml( obj, yaml, msg = nil ) + assert_equal( obj, YAML::load( yaml ), msg ) + assert_equal( obj, YAML::parse( yaml ).transform, msg ) + assert_equal( obj, YAML::load( obj.to_yaml ), msg ) + assert_equal( obj, YAML::parse( obj.to_yaml ).transform, msg ) assert_equal( obj, YAML::load( obj.to_yaml( :UseVersion => true, :UseHeader => true, :SortKeys => true ) - ) ) + ), msg ) end # # Test parser only # - def assert_parse_only( obj, yaml ) - assert_equal( obj, YAML::load( yaml ) ) - assert_equal( obj, YAML::parse( yaml ).transform ) + def assert_parse_only( obj, yaml, msg = nil ) + assert_equal( obj, YAML::load( yaml ), msg ) + assert_equal( obj, YAML::parse( yaml ).transform, msg ) end - def assert_cycle( obj ) - assert_equal( obj, YAML::load( obj.to_yaml ) ) + def assert_cycle( obj, msg = nil ) + assert_equal( obj, YAML::load( obj.to_yaml ), msg ) end - def assert_path_segments( path, segments ) + def assert_path_segments( path, segments, msg = nil ) YAML::YPath.each_path( path ) { |choice| - assert_equal( choice.segments, segments.shift ) + assert_equal( choice.segments, segments.shift, msg ) } assert_equal( segments.length, 0, "Some segments leftover: #{ segments.inspect }" ) end @@ -438,6 +438,85 @@ EOY ) end + # + # Reports from N.Easterly & J.Trupiano : Tests with patch from daz + # [ruby-core:23006] [Bug #1311] http://redmine.ruby-lang.org/issues/show/1311 + # + def test_scan_scalar_nl + bug1311 = '[ruby-core:23006]' + assert_cycle(< klass) - end - require 'test/unit/ui/console/testrunner' - Test::Unit::UI::Console::TestRunner.run(suite).passed? -end diff --git a/version.h b/version.h index 92474f8ea0..c8f9c6707f 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_RELEASE_DATE "2010-05-02" +#define RUBY_RELEASE_DATE "2010-05-03" #define RUBY_PATCHLEVEL -1 #define RUBY_BRANCH_NAME "trunk" @@ -8,7 +8,7 @@ #define RUBY_VERSION_TEENY 1 #define RUBY_RELEASE_YEAR 2010 #define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h"