diff options
author | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-10 14:15:27 +0000 |
---|---|---|
committer | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-10 14:15:27 +0000 |
commit | e921ea2d78f693c57fcb289faff3fc126dc8617a (patch) | |
tree | 6931c25c8907d5e481be1281be1a30297a3fff53 /lib/yaml/rubytypes.rb | |
parent | 3079dcab4ad9e7624703d772f6fc54dc10e45bce (diff) | |
download | ruby-e921ea2d78f693c57fcb289faff3fc126dc8617a.tar.gz |
* 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
Diffstat (limited to 'lib/yaml/rubytypes.rb')
-rw-r--r-- | lib/yaml/rubytypes.rb | 11 |
1 files changed, 6 insertions, 5 deletions
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 |