From e921ea2d78f693c57fcb289faff3fc126dc8617a Mon Sep 17 00:00:00 2001 From: why Date: Tue, 10 Jun 2003 14:15:27 +0000 Subject: * ext/syck/token.c: preserve newlines prepended to a block. * ext/syck/implicit.c (syck_match_implicit): added !merge and !default. * lib/yaml/constants.rb: remove '\z' escape. * lib/yaml/emitter.rb: ensure reset of @seq_map shortcut flag. * lib/yaml/encoding.rb: remove Unicode translation methods. * lib/yaml/rubytypes.rb: improved round-tripping of Strings. [ruby-core:1134] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/yaml/rubytypes.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/yaml/rubytypes.rb') diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index 92aee82dae..b2ac615849 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -295,19 +295,20 @@ class String if complex if self.is_binary_data? out.binary_base64( self ) + elsif self =~ /^ |#{YAML::ESCAPE_CHAR}| $/ + complex = false else out.node_text( self ) end - else + end + if not complex ostr = if out.options[:KeepValue] self elsif empty? "''" - elsif YAML.detect_implicit( self ) != 'str' + elsif self =~ /^[^#{YAML::WORD_CHAR}]|#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}]( |$)| $|\n|\'/ "\"#{YAML.escape( self )}\"" - elsif self =~ /#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}] |\n|\'/ - "\"#{YAML.escape( self )}\"" - elsif self =~ /^[^#{YAML::WORD_CHAR}]/ + elsif YAML.detect_implicit( self ) != 'str' "\"#{YAML.escape( self )}\"" else self -- cgit v1.2.3