* ext/syck/syck.c (syck_new_parser): clear parser on init.

thanks, ts. [ruby-core:02931]

* ext/syck/token.c (sycklex_yaml_utf8): buffer underflow.
  thanks, ts. [ruby-core:02929]

* lib/yaml/baseemitter.rb (indent_text): simpler flow block code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
why 2004-05-25 14:57:25 +00:00
Родитель 82572952ec
Коммит ca1dca02b0
5 изменённых файлов: 24 добавлений и 25 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Wed May 26 00:00:00 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/syck.c (syck_new_parser): clear parser on init.
thanks, ts. [ruby-core:02931]
* ext/syck/token.c (sycklex_yaml_utf8): buffer underflow.
thanks, ts. [ruby-core:02929]
* lib/yaml/baseemitter.rb (indent_text): simpler flow block code.
Tue May 25 11:54:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue May 25 11:54:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_yield_0, proc_invoke, proc_arity): allow passing a block * eval.c (rb_yield_0, proc_invoke, proc_arity): allow passing a block

Просмотреть файл

@ -159,6 +159,7 @@ syck_new_parser()
{ {
SyckParser *p; SyckParser *p;
p = S_ALLOC( SyckParser ); p = S_ALLOC( SyckParser );
S_MEMZERO( p, SyckParser, 1 );
p->lvl_capa = ALLOC_CT; p->lvl_capa = ALLOC_CT;
p->levels = S_ALLOC_N( SyckLevel, p->lvl_capa ); p->levels = S_ALLOC_N( SyckLevel, p->lvl_capa );
p->input_type = syck_yaml_utf8; p->input_type = syck_yaml_utf8;

Просмотреть файл

@ -2297,7 +2297,7 @@ yy215:
#line 938 #line 938
{ if ( YYTOKEN == YYLINEPTR ) { if ( YYTOKEN == YYLINEPTR )
{ {
if ( blockType == BLOCK_FOLD ) if ( blockType == BLOCK_FOLD && qidx > 0 )
{ {
qidx -= 1; qidx -= 1;
} }

Просмотреть файл

@ -45,9 +45,13 @@ module YAML
else else
'>' '>'
end end
if valx =~ /\A[ \t#]/
block += options(:Indent).to_s indt = $&.to_i if block =~ /\d+/
if valx =~ /(\A[ \t#]|^---\s+)/
indt = options(:Indent) unless indt.to_i > 0
block += indt.to_s
end end
block += block +=
if valx =~ /\n\Z\n/ if valx =~ /\n\Z\n/
"+" "+"
@ -63,8 +67,6 @@ module YAML
if block[0] == ?> if block[0] == ?>
valx = fold( valx ) valx = fold( valx )
end end
indt = nil
indt = $&.to_i if block =~ /\d+/
#p [block, indt] #p [block, indt]
self << block + indent_text( valx, indt ) + "\n" self << block + indent_text( valx, indt ) + "\n"
end end
@ -125,25 +127,9 @@ module YAML
# Folding paragraphs within a column # Folding paragraphs within a column
# #
def fold( value ) def fold( value )
value.gsub!( /\A\n+/, '' ) value.gsub( /(^[ \t]+.*$)|(\S.{0,#{options(:BestWidth) - 1}})(?:[ \t]+|(\n+(?=[ \t]))|$)/ ) do |s|
folded = $&.to_s $1 || $2 + ( $3 || "\n" )
width = (0..options(:BestWidth)) end
while not value.empty?
last = value.index( /(\n+)/ )
chop_s = false
if width.include?( last )
last += $1.length - 1
elsif width.include?( value.length )
last = value.length
else
last = value.rindex( /[ \t]/, options(:BestWidth) )
chop_s = true
end
folded += value.slice!( 0, width.include?( last ) ? last + 1 : options(:BestWidth) )
folded.chop! if chop_s
folded += "\n" unless value.empty?
end
folded
end end
# #

Просмотреть файл

@ -392,7 +392,9 @@ class Range
end end
def to_yaml( opts = {} ) def to_yaml( opts = {} )
YAML::quick_emit( self.object_id, opts ) { |out| YAML::quick_emit( self.object_id, opts ) { |out|
if self.begin.is_complex_yaml? or self.end.is_complex_yaml? or not to_yaml_properties.empty? if self.begin.is_complex_yaml? or self.begin.respond_to? :to_str or
self.end.is_complex_yaml? or self.end.respond_to? :to_str or
not to_yaml_properties.empty?
out.map( to_yaml_type ) { |map| out.map( to_yaml_type ) { |map|
map.add( 'begin', self.begin ) map.add( 'begin', self.begin )
map.add( 'end', self.end ) map.add( 'end', self.end )