From 5e07e55204aede8b5f80e7d01b464f08c6bd611e Mon Sep 17 00:00:00 2001 From: why Date: Wed, 18 Aug 2004 20:42:09 +0000 Subject: * lib/yaml/baseemitter.rb: folding now handles double-quoted strings, fixed problem with extra line feeds at end of folding, whitespace opening scalar blocks. * lib/yaml/rubytypes.rb: subtelties in handling strings with non-printable characters and odd whitespace patterns. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/yaml/rubytypes.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/yaml/rubytypes.rb') diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb index bd91bc039d..47f591ea0c 100644 --- a/lib/yaml/rubytypes.rb +++ b/lib/yaml/rubytypes.rb @@ -1,5 +1,6 @@ # -*- mode: ruby; ruby-indent-level: 4; tab-width: 4 -*- vim: sw=4 ts=4 require 'date' +require 'yaml/compat' # # Type conversions # @@ -315,25 +316,24 @@ class String } elsif self.is_binary_data? out.binary_base64( self ) - # elsif self =~ /^ |#{YAML::ESCAPE_CHAR}| $/ - # complex = false + elsif self =~ /#{YAML::ESCAPE_CHAR}/ + out.node_text( self, '"' ) else out.node_text( self, to_yaml_fold ) end - end - if not complex + else ostr = if out.options(:KeepValue) self elsif empty? "''" elsif self =~ /^[^#{YAML::WORD_CHAR}\/]| \#|#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}]( |$)| $|\n|\'/ - "\"#{YAML.escape( self )}\"" + out.node_text( self, '"' ); nil elsif YAML.detect_implicit( self ) != 'str' - "\"#{YAML.escape( self )}\"" + out.node_text( self, '"' ); nil else self end - out.simple( ostr ) + out.simple( ostr ) unless ostr.nil? end } end -- cgit v1.2.3