Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 80603 Details for
Bug 123938
Ruby Syck(YAML) fails with parse error on parsing multiple documents
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
The complete Backport-patch
ruby-1.8.4-yaml.diff (text/plain), 11.89 KB, created by
Hannes Wyss
on 2006-02-24 07:10:21 UTC
(
hide
)
Description:
The complete Backport-patch
Filename:
MIME Type:
Creator:
Hannes Wyss
Created:
2006-02-24 07:10:21 UTC
Size:
11.89 KB
patch
obsolete
>diff -Nbr -U4 ruby-1.8.4/ext/syck/emitter.c yarv-0.4.0/ext/syck/emitter.c >--- ruby-1.8.4/ext/syck/emitter.c 2005-09-20 08:46:43.000000000 +0200 >+++ yarv-0.4.0/ext/syck/emitter.c 2006-02-20 07:16:38.000000000 +0100 >@@ -1,9 +1,9 @@ > /* > * emitter.c > * >- * $Author: why $ >- * $Date: 2005/09/20 06:46:43 $ >+ * $Author: ocean $ >+ * $Date: 2006/02/02 15:02:49 $ > * > * Copyright (C) 2003 why the lucky stiff > * > * All Base64 code from Ruby's pack.c. >@@ -313,9 +313,8 @@ > * Write to buffer > */ > S_MEMCPY( e->marker, str, char, len ); > e->marker += len; >- e->marker[0] = '\0'; > } > > /* > * Write a chunk of data out. >@@ -1002,8 +1001,13 @@ > if ( style == seq_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) { > syck_emitter_write( e, "[", 1 ); > lvl->status = syck_lvl_iseq; > } else { >+ /* complex key */ >+ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) { >+ syck_emitter_write( e, "? ", 2 ); >+ parent->status = syck_lvl_mapx; >+ } > lvl->status = syck_lvl_seq; > } > } > >@@ -1018,8 +1022,13 @@ > if ( style == map_inline || ( parent->status == syck_lvl_imap || parent->status == syck_lvl_iseq ) ) { > syck_emitter_write( e, "{", 1 ); > lvl->status = syck_lvl_imap; > } else { >+ /* complex key */ >+ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) { >+ syck_emitter_write( e, "? ", 2 ); >+ parent->status = syck_lvl_mapx; >+ } > lvl->status = syck_lvl_map; > } > } > >@@ -1035,21 +1044,14 @@ > case syck_lvl_seq: > { > SyckLevel *parent = syck_emitter_parent_level( e ); > >- /* seq-in-map shortcut */ >- if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) { >- /* complex key */ >- if ( parent->ncount % 2 == 1 ) { >- syck_emitter_write( e, "?", 1 ); >- parent->status = syck_lvl_mapx; >- /* shortcut -- the lvl->anctag check should be unneccesary but >+ /* seq-in-map shortcut -- the lvl->anctag check should be unneccesary but > * there is a nasty shift/reduce in the parser on this point and > * i'm not ready to tickle it. */ >- } else if ( lvl->anctag == 0 ) { >+ if ( lvl->anctag == 0 && parent->status == syck_lvl_map && lvl->ncount == 0 ) { > lvl->spaces = parent->spaces; > } >- } > > /* seq-in-seq shortcut */ > else if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) { > int spcs = ( lvl->spaces - parent->spaces ) - 2; >@@ -1079,17 +1081,8 @@ > case syck_lvl_map: > { > SyckLevel *parent = syck_emitter_parent_level( e ); > >- /* map-in-map */ >- if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) { >- /* complex key */ >- if ( parent->ncount % 2 == 1 ) { >- syck_emitter_write( e, "?", 1 ); >- parent->status = syck_lvl_mapx; >- } >- } >- > /* map-in-seq shortcut */ > if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) { > int spcs = ( lvl->spaces - parent->spaces ) - 2; > if ( spcs >= 0 ) { > >diff -Nbr -U4 ruby-1.8.4/ext/syck/rubyext.c yarv-0.4.0/ext/syck/rubyext.c >--- ruby-1.8.4/ext/syck/rubyext.c 2005-12-20 05:13:26.000000000 +0100 >+++ yarv-0.4.0/ext/syck/rubyext.c 2006-02-20 07:16:38.000000000 +0100 >@@ -2,9 +2,9 @@ > /* > * rubyext.c > * > * $Author: ocean $ >- * $Date: 2005/12/20 04:13:26 $ >+ * $Date: 2006/02/03 10:28:27 $ > * > * Copyright (C) 2003-2005 why the lucky stiff > */ > >@@ -48,10 +48,10 @@ > > /* > * symbols and constants > */ >-static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_haskey, s_match, s_keys, s_unpack, s_tr_bang, s_default_set, s_tag_read_class, s_tag_subclasses, s_resolver, s_push, s_emitter, s_level, s_detect_implicit, s_node_import, s_out, s_input, s_intern, s_transform, s_yaml_new, s_yaml_initialize, s_node_export, s_to_yaml, s_write, s_set_resolver; >-static ID s_tags, s_domain, s_kind, s_name, s_options, s_type_id, s_type_id_set, s_style, s_style_set, s_value, s_value_set; >+static ID s_new, s_utc, s_at, s_to_f, s_to_i, s_read, s_binmode, s_call, s_cmp, s_transfer, s_update, s_dup, s_haskey, s_match, s_keys, s_unpack, s_tr_bang, s_default_set, s_tag_read_class, s_tag_subclasses, s_resolver, s_push, s_emitter, s_level, s_detect_implicit, s_node_import, s_out, s_input, s_intern, s_transform, s_yaml_new, s_yaml_initialize, s_node_export, s_to_yaml, s_write, s_set_resolver, s_each; >+static ID s_tags, s_kind, s_name, s_options, s_type_id, s_type_id_set, s_style, s_style_set, s_value, s_value_set; > static VALUE sym_model, sym_generic, sym_input, sym_bytecode; > static VALUE sym_scalar, sym_seq, sym_map; > static VALUE sym_1quote, sym_2quote, sym_fold, sym_literal, sym_plain, sym_inline; > static VALUE cDate, cNode, cMap, cSeq, cScalar, cOut, cParser, cResolver, cPrivateType, cDomainType, cYObject, cBadAlias, cDefaultKey, cMergeKey, cEmitter; >@@ -114,16 +114,16 @@ > syck_parser_taguri_expansion( parser, 0 ); > oid = syck_parse( parser ); > syck_lookup_sym( parser, oid, (char **)&sav ); > >- ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 ); >+ ret = S_ALLOCA_N( char, strlen( sav->buffer ) + 3 ); > ret[0] = '\0'; > strcat( ret, "D\n" ); > strcat( ret, sav->buffer ); > > syck_free_parser( parser ); > >- bc = rb_str_new2( ret ); S_FREE( ret ); >+ bc = rb_str_new2( ret ); > if ( taint ) OBJ_TAINT( bc ); > return bc; > } > >@@ -1042,14 +1042,13 @@ > { > VALUE ivname = rb_ary_entry( vars, 0 ); > char *ivn; > StringValue( ivname ); >- ivn = S_ALLOC_N( char, RSTRING(ivname)->len + 2 ); >+ ivn = S_ALLOCA_N( char, RSTRING(ivname)->len + 2 ); > ivn[0] = '@'; > ivn[1] = '\0'; > strncat( ivn, RSTRING(ivname)->ptr, RSTRING(ivname)->len ); > rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) ); >- S_FREE( ivn ); > return Qnil; > } > > /* >@@ -1134,8 +1133,12 @@ > target_class = cYObject; > type = subclass; > subclass = cYObject; > } >+ else /* workaround for SEGV. real fix please */ >+ { >+ rb_raise( rb_eTypeError, "invalid subclass" ); >+ } > } > break; > } > } >@@ -1156,8 +1159,16 @@ > obj = rb_funcall( target_class, s_yaml_new, 3, subclass, type, val ); > } > else if ( !NIL_P( target_class ) ) > { >+ if ( subclass == rb_cBignum ) >+ { >+ obj = rb_str2inum( val, 10 ); /* for yaml dumped by 1.8.3 [ruby-core:6159] */ >+ } >+ else >+ { > obj = rb_obj_alloc( subclass ); >+ } >+ > if ( rb_respond_to( obj, s_yaml_initialize ) ) > { > rb_funcall( obj, s_yaml_initialize, 2, type, val ); > } >diff -Nbr -U4 ruby-1.8.4/ext/syck/syck.c yarv-0.4.0/ext/syck/syck.c >--- ruby-1.8.4/ext/syck/syck.c 2005-09-13 05:58:32.000000000 +0200 >+++ yarv-0.4.0/ext/syck/syck.c 2006-02-20 07:16:38.000000000 +0100 >@@ -1,9 +1,9 @@ > /* > * syck.c > * >- * $Author: why $ >- * $Date: 2005/09/13 03:58:32 $ >+ * $Author: ocean $ >+ * $Date: 2006/02/03 06:10:21 $ > * > * Copyright (C) 2003 why the lucky stiff > */ > #include "ruby.h" >@@ -409,11 +409,8 @@ > if ( p->token == NULL ) > return 0; > > skip = p->limit - p->token; >- if ( skip < 1 ) >- return 0; >- > if ( ( count = p->token - p->buffer ) ) > { > S_MEMMOVE( p->buffer, p->token, char, skip ); > p->token = p->buffer; >diff -Nbr -U4 ruby-1.8.4/lib/yaml/emitter.rb yarv-0.4.0/lib/yaml/emitter.rb >--- ruby-1.8.4/lib/yaml/emitter.rb 1970-01-01 01:00:00.000000000 +0100 >+++ yarv-0.4.0/lib/yaml/emitter.rb 2006-02-20 07:15:42.000000000 +0100 >@@ -0,0 +1,107 @@ >+# >+# Output classes and methods >+# >+ >+require 'yaml/baseemitter' >+require 'yaml/encoding' >+ >+module YAML >+ >+ # >+ # Emit a set of values >+ # >+ >+ class Emitter >+ >+ include BaseEmitter >+ >+ attr_accessor :options >+ >+ def initialize( opts ) >+ opts = {} if opts.class != Hash >+ @options = YAML::DEFAULTS.dup.update( opts ) >+ @headless = 0 >+ @seq_map = false >+ @anchors = {} >+ @anchor_extras = {} >+ @active_anchors = [] >+ @level = -1 >+ self.clear >+ end >+ >+ def clear >+ @buffer = [] >+ end >+ >+ def level >+ @level >+ end >+ >+ # >+ # Version string >+ # >+ def version_s >+ " %YAML:#{@options[:Version]}" if @options[:UseVersion] >+ end >+ >+ # >+ # Header >+ # >+ def header >+ if @headless.nonzero? >+ "" >+ else >+ "---#{version_s} " >+ end >+ end >+ >+ # >+ # Concatenate to the buffer >+ # >+ def <<( str ) >+ #p [ self.id, @level, str ] >+ @buffer.last << str >+ end >+ >+ # >+ # Monitor objects and allow references >+ # >+ def start_object( oid ) >+ @level += 1 >+ @buffer.push( "" ) >+ #p [ self.id, @level, :OPEN ] >+ idx = nil >+ if oid >+ if @anchors.has_key?( oid ) >+ idx = @active_anchors.index( oid ) >+ unless idx >+ idx = @active_anchors.length >+ af_str = "&#{@options[:AnchorFormat]} " % [ idx + 1 ] >+ af_str += @anchor_extras[ @anchors[ oid ] ].to_s >+ @buffer[ @anchors[ oid ] ][0,0] = af_str >+ @headless = 0 if @anchors[ oid ].zero? >+ end >+ idx += 1 >+ @active_anchors.push( oid ) >+ else >+ @anchors[ oid ] = @buffer.length - 1 >+ end >+ end >+ return idx >+ end >+ >+ # >+ # Output method >+ # >+ def end_object >+ @level -= 1 >+ @buffer.push( "" ) >+ #p [ self.id, @level, :END ] >+ if @level < 0 >+ header + @buffer.to_s[@headless..-1].to_s >+ end >+ end >+ end >+ >+end >+ >diff -Nbr -U4 ruby-1.8.4/lib/yaml/rubytypes.rb yarv-0.4.0/lib/yaml/rubytypes.rb >--- ruby-1.8.4/lib/yaml/rubytypes.rb 2005-09-20 08:46:45.000000000 +0200 >+++ yarv-0.4.0/lib/yaml/rubytypes.rb 2006-02-20 07:16:38.000000000 +0100 >@@ -182,8 +182,9 @@ > yaml_as "tag:ruby.yaml.org,2002:symbol" > yaml_as "tag:ruby.yaml.org,2002:sym" > def Symbol.yaml_new( klass, tag, val ) > if String === val >+ val = YAML::load( val ) if val =~ /\A(["']).*\1\z/ > val.intern > else > raise YAML::TypeError, "Invalid Symbol: " + val.inspect > end >@@ -351,9 +352,19 @@ > end > end > end > >-class Numeric >+class Integer >+ yaml_as "tag:yaml.org,2002:int" >+ def to_yaml( opts = {} ) >+ YAML::quick_emit( nil, opts ) do |out| >+ out.scalar( "tag:yaml.org,2002:int", self.to_s, :plain ) >+ end >+ end >+end >+ >+class Float >+ yaml_as "tag:yaml.org,2002:float" > def to_yaml( opts = {} ) > YAML::quick_emit( nil, opts ) do |out| > str = self.to_s > if str == "Infinity" >@@ -362,21 +373,13 @@ > str = "-.Inf" > elsif str == "NaN" > str = ".NaN" > end >- out.scalar( taguri, str, :plain ) >+ out.scalar( "tag:yaml.org,2002:float", str, :plain ) > end > end > end > >-class Fixnum >- yaml_as "tag:yaml.org,2002:int" >-end >- >-class Float >- yaml_as "tag:yaml.org,2002:float" >-end >- > class TrueClass > yaml_as "tag:yaml.org,2002:bool#yes" > def to_yaml( opts = {} ) > YAML::quick_emit( nil, opts ) do |out|
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 123938
: 80603