Author: jfearn Update of /cvs/pkgs/rpms/perl-XML-TreeBuilder/devel In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv20153 Modified Files: XML-TreeBuilder-NoExpand.patch perl-XML-TreeBuilder.spec Log Message: fix NoExpand and ErrorContext in output when undefined XML-TreeBuilder-NoExpand.patch: Index: XML-TreeBuilder-NoExpand.patch =================================================================== RCS file: /cvs/pkgs/rpms/perl-XML-TreeBuilder/devel/XML-TreeBuilder-NoExpand.patch,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XML-TreeBuilder-NoExpand.patch 15 Oct 2008 03:29:04 -0000 1.2 +++ XML-TreeBuilder-NoExpand.patch 16 Mar 2009 05:07:00 -0000 1.3 @@ -1,22 +1,23 @@ -diff -rubB --exclude=.svn XML-TreeBuilder-3.09/Changes XML-TreeBuilder-patched/Changes +Only in XML-TreeBuilder-patched: blib +diff -rubB --exclude=.svn --exclude='*.swp' XML-TreeBuilder-3.09/Changes XML-TreeBuilder-patched/Changes --- XML-TreeBuilder-3.09/Changes 2004-06-11 14:28:41.000000000 +1000 -+++ XML-TreeBuilder-patched/Changes 2008-10-15 12:17:13.000000000 +1000 -@@ -1,5 +1,11 @@ - # Time-stamp: "2004-06-10 20:28:41 ADT" ++++ XML-TreeBuilder-patched/Changes 2009-03-16 14:30:51.000000000 +1000 +@@ -1,5 +1,10 @@ +-# Time-stamp: "2004-06-10 20:28:41 ADT" ++2009-16-03 Jeff Fearn <jfearn@xxxxxxxxxx> -+2007-12-01 Jeff Fearn <jfearn@xxxxxxxxxx> -+ -+ Release 3.10 ++ Release 3.09.x + + Added NoExpand option to allow entities to be left untouched in xml. -+ ++ Added ErrorContext option to allow better reporting of error locations. ++ Expanded tests to test these options. 2004-06-10 Sean M. Burke <sburke@xxxxxxxx> -diff -rubB --exclude=.svn XML-TreeBuilder-3.09/lib/XML/TreeBuilder.pm XML-TreeBuilder-patched/lib/XML/TreeBuilder.pm +diff -rubB --exclude=.svn --exclude='*.swp' XML-TreeBuilder-3.09/lib/XML/TreeBuilder.pm XML-TreeBuilder-patched/lib/XML/TreeBuilder.pm --- XML-TreeBuilder-3.09/lib/XML/TreeBuilder.pm 2004-06-11 13:59:14.000000000 +1000 -+++ XML-TreeBuilder-patched/lib/XML/TreeBuilder.pm 2008-10-15 12:38:59.000000000 +1000 -@@ -5,6 +5,7 @@ ++++ XML-TreeBuilder-patched/lib/XML/TreeBuilder.pm 2009-03-16 13:55:57.000000000 +1000 +@@ -5,6 +7,7 @@ use strict; use XML::Element (); use XML::Parser (); @@ -24,81 +25,199 @@ use vars qw(@ISA $VERSION); $VERSION = '3.09'; -@@ -12,8 +13,15 @@ +@@ -12,8 +15,15 @@ #========================================================================== sub new { - my $class = ref($_[0]) || $_[0]; - # that's the only parameter it knows -+ my ($this, $arg) = @_; -+ my $class = ref($this) || $this; ++ my ( $this, $arg ) = @_; ++ my $class = ref($this) || $this; + -+ my $NoExpand = defined $arg->{'NoExpand'} ? delete $arg->{'NoExpand'} : 0; -+ my $ErrorContext = defined $arg->{'ErrorContext'} ? delete $arg->{'ErrorContext'} : 0; ++ my $NoExpand = ( delete $arg->{'NoExpand'} || undef ); ++ my $ErrorContext = ( delete $arg->{'ErrorContext'} || undef ); + -+ if ( %{$arg} ) { -+ croak "unknown args: " . join( ", ", keys %{$arg} ); -+ } ++ if ( %{$arg} ) { ++ croak "unknown args: " . join( ", ", keys %{$arg} ); ++ } my $self = XML::Element->new('NIL'); bless $self, $class; # and rebless -@@ -21,11 +29,19 @@ +@@ -21,44 +31,51 @@ $self->{'_store_comments'} = 0; $self->{'_store_pis'} = 0; $self->{'_store_declarations'} = 0; -+ $self->{'NoExpand'} = $NoExpand; -+ $self->{'ErrorContext'} = $ErrorContext; ++ $self->{'NoExpand'} = $NoExpand if ($NoExpand); ++ $self->{'ErrorContext'} = $ErrorContext if ($ErrorContext); my @stack; ++ # Compare the simplicity of this to the sheer nastiness of HTML::TreeBuilder! - $self->{'_xml_parser'} = XML::Parser->new( 'Handlers' => { -+ 'Default' => sub { -+ if ( ( $self->{'NoExpand'} ) && ( $_[1] =~ /&.*\;/ ) ) { -+ $stack[-1]->push_content( $_[1] ); -+ } -+ return; -+ }, +- $self->{'_xml_parser'} = XML::Parser->new( 'Handlers' => { ++ $self->{'_xml_parser'} = XML::Parser->new( ++ 'Handlers' => { ++ 'Default' => sub { ++ if ( ( $self->{'NoExpand'} ) && ( $_[1] =~ /&.*\;/ ) ) { ++ $stack[-1]->push_content( $_[1] ); ++ } ++ return; ++ }, 'Start' => sub { shift; - if(@stack) { -@@ -103,7 +119,22 @@ +- if(@stack) { ++ if (@stack) { + push @stack, $self->{'_element_class'}->new(@_); + $stack[-2]->push_content( $stack[-1] ); +- } else { ++ } ++ else { + $self->tag(shift); +- while(@_) { $self->attr(splice(@_,0,2)) }; ++ while (@_) { $self->attr( splice( @_, 0, 2 ) ) } + push @stack, $self; + } + }, + + 'End' => sub { pop @stack; return }, + +- 'Char' => sub { $stack[-1]->push_content($_[1]) }, ++ 'Char' => sub { $stack[-1]->push_content( $_[1] ) }, + + 'Comment' => sub { + return unless $self->{'_store_comments'}; +- ( +- @stack ? $stack[-1] : $self +- )->push_content( +- $self->{'_element_class'}->new('~comment', 'text' => $_[1]) +- ); ++ ( @stack ? $stack[-1] : $self ) ++ ->push_content( $self->{'_element_class'} ++ ->new( '~comment', 'text' => $_[1] ) ); + return; + }, + + 'Proc' => sub { + return unless $self->{'_store_pis'}; +- ( +- @stack ? $stack[-1] : $self +- )->push_content( +- $self->{'_element_class'}->new('~pi', 'text' => "$_[1] $_[2]") +- ); ++ ( @stack ? $stack[-1] : $self ) ++ ->push_content( $self->{'_element_class'} ++ ->new( '~pi', 'text' => "$_[1] $_[2]" ) ); + return; + }, + +@@ -67,11 +84,11 @@ + 'Attlist' => sub { + return unless $self->{'_store_declarations'}; + shift; +- ( +- @stack ? $stack[-1] : $self +- )->push_content( +- $self->{'_element_class'}->new('~declaration', +- 'text' => join ' ', 'ATTLIST', @_ ++ ( @stack ? $stack[-1] : $self )->push_content( ++ $self->{'_element_class'}->new( ++ '~declaration', ++ 'text' => join ' ', ++ 'ATTLIST', @_ + ) + ); + return; +@@ -80,11 +97,11 @@ + 'Element' => sub { + return unless $self->{'_store_declarations'}; + shift; +- ( +- @stack ? $stack[-1] : $self +- )->push_content( +- $self->{'_element_class'}->new('~declaration', +- 'text' => join ' ', 'ELEMENT', @_ ++ ( @stack ? $stack[-1] : $self )->push_content( ++ $self->{'_element_class'}->new( ++ '~declaration', ++ 'text' => join ' ', ++ 'ELEMENT', @_ + ) + ); + return; +@@ -93,17 +110,32 @@ + 'Doctype' => sub { + return unless $self->{'_store_declarations'}; + shift; +- ( +- @stack ? $stack[-1] : $self +- )->push_content( +- $self->{'_element_class'}->new('~declaration', +- 'text' => join ' ', 'DOCTYPE', @_ ++ ( @stack ? $stack[-1] : $self )->push_content( ++ $self->{'_element_class'}->new( ++ '~declaration', ++ 'text' => join ' ', ++ 'DOCTYPE', @_ + ) + ); return; }, - }); -+ 'Entity' => sub { -+ return unless $self->{'_store_declarations'}; -+ shift; -+ ( -+ @stack ? $stack[-1] : $self -+ )->push_content( -+ $self->{'_element_class'}->new('~declaration', -+ 'text' => join ' ', 'ENTITY', @_ -+ ) -+ ); -+ return; -+ }, -+ }, -+ 'NoExpand' => $self->{'NoExpand'}, -+ 'ErrorContext' => $self->{'ErrorContext'} -+ ); ++ 'Entity' => sub { ++ return unless $self->{'_store_declarations'}; ++ shift; ++ ( @stack ? $stack[-1] : $self )->push_content( ++ $self->{'_element_class'}->new( ++ '~declaration', ++ 'text' => join ' ', ++ 'ENTITY', @_ ++ ) ++ ); ++ return; ++ }, ++ }, ++ 'NoExpand' => $self->{'NoExpand'}, ++ 'ErrorContext' => $self->{'ErrorContext'} ++ ); return $self; } -Only in XML-TreeBuilder-patched/lib/XML: .TreeBuilder.pm.swp -diff -rubB --exclude=.svn XML-TreeBuilder-3.09/t/10main.t XML-TreeBuilder-patched/t/10main.t +@@ -110,15 +143,15 @@ + #========================================================================== + sub _elem # universal accessor... + { +- my($self, $elem, $val) = @_; ++ my ( $self, $elem, $val ) = @_; + my $old = $self->{$elem}; + $self->{$elem} = $val if defined $val; + return $old; + } + +-sub store_comments { shift->_elem('_store_comments', @_); } +-sub store_declarations { shift->_elem('_store_declarations', @_); } +-sub store_pis { shift->_elem('_store_pis', @_); } ++sub store_comments { shift->_elem( '_store_comments', @_ ); } ++sub store_declarations { shift->_elem( '_store_declarations', @_ ); } ++sub store_pis { shift->_elem( '_store_pis', @_ ); } + + #========================================================================== + +Only in XML-TreeBuilder-patched: Makefile +Only in XML-TreeBuilder-patched: pm_to_blib +diff -rubB --exclude=.svn --exclude='*.swp' XML-TreeBuilder-3.09/t/10main.t XML-TreeBuilder-patched/t/10main.t --- XML-TreeBuilder-3.09/t/10main.t 2004-06-11 14:22:53.000000000 +1000 -+++ XML-TreeBuilder-patched/t/10main.t 2008-10-15 12:17:13.000000000 +1000 -@@ -21,6 +21,7 @@ ++++ XML-TreeBuilder-patched/t/10main.t 2009-03-16 13:33:49.000000000 +1000 +@@ -2,7 +2,7 @@ + # Time-stamp: "2004-06-10 20:22:53 ADT" + + use Test; +-BEGIN { plan tests => 3 } ++BEGIN { plan tests => 4 } - my $y = XML::Element->new_from_lol( - ['Gee', -+ { 'NoExpand' => '0', 'ErrorContext' => '0'}, - ['~comment', {'text' => ' myorp '}], - ['foo', {'Id'=> 'me', 'xml:foo' => 'lal'}, 'Hello World'], - ['lor'], -@@ -29,8 +30,7 @@ + use XML::TreeBuilder; + +@@ -29,8 +29,7 @@ ] ); @@ -108,3 +227,32 @@ unless( $ENV{'HARNESS_ACTIVE'} ) { $x->dump; +@@ -45,6 +44,28 @@ + $x->delete; + $y->delete; + ++$x = XML::TreeBuilder->new({ 'NoExpand' => "1", 'ErrorContext' => "2" }); ++$x->store_comments(1); ++$x->store_pis(1); ++$x->store_declarations(1); ++$x->parse( ++ qq{<!-- myorp --><Gee><foo Id="me" xml:foo="lal">Hello World</foo>} . ++ qq{<lor/><!-- foo --></Gee><!-- glarg -->} ++); ++ ++$y = XML::Element->new_from_lol( ++ ['Gee', ++ { 'NoExpand' => "1", 'ErrorContext' => "2" }, ++ ['~comment', {'text' => ' myorp '}], ++ ['foo', {'Id'=> 'me', 'xml:foo' => 'lal'}, 'Hello World'], ++ ['lor'], ++ ['~comment', {'text' => ' foo '}], ++ ['~comment', {'text' => ' glarg '}], ++ ] ++); ++ ++ok($x->same_as($y)); ++ + ok 1; + print "# Bye from ", __FILE__, "\n"; + Index: perl-XML-TreeBuilder.spec =================================================================== RCS file: /cvs/pkgs/rpms/perl-XML-TreeBuilder/devel/perl-XML-TreeBuilder.spec,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- perl-XML-TreeBuilder.spec 27 Feb 2009 04:49:55 -0000 1.3 +++ perl-XML-TreeBuilder.spec 16 Mar 2009 05:07:00 -0000 1.4 @@ -50,8 +50,8 @@ %{perl_vendorlib}/XML/ %changelog -* Thu Feb 26 2009 Fedora Release Engineering <rel-eng@xxxxxxxxxxxxxxxxxxxxxxx> - 3.09-12 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild +* Mon Mar 16 2009 Jeff Fearn <jfearn@xxxxxxxxxx> - 3.09-12 +- Remove NoExpand and ErrorContext from output if they aren't set. * Wed Oct 15 2008 Jeff Fearn <jfearn@xxxxxxxxxx> - 3.09-11 - Add ErrorContext pass through -- Fedora Extras Perl SIG http://www.fedoraproject.org/wiki/Extras/SIGs/Perl Fedora-perl-devel-list mailing list Fedora-perl-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-perl-devel-list