ruby-changes:30440
From: kou <ko1@a...>
Date: Sun, 11 Aug 2013 18:42:44 +0900 (JST)
Subject: [ruby-changes:30440] kou:r42519 (trunk): * lib/rexml/parsers/sax2parser.rb
kou 2013-08-11 18:42:37 +0900 (Sun, 11 Aug 2013) New Revision: 42519 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42519 Log: * lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#handle_entitydecl): Extract. Modified files: trunk/ChangeLog trunk/lib/rexml/parsers/sax2parser.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42518) +++ ChangeLog (revision 42519) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Aug 11 18:42:13 2013 Kouhei Sutou <kou@c...> + + * lib/rexml/parsers/sax2parser.rb + (REXML::Parsers::SAX2Parser#handle_entitydecl): Extract. + Sun Aug 11 18:40:25 2013 Kouhei Sutou <kou@c...> * lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse): Index: lib/rexml/parsers/sax2parser.rb =================================================================== --- lib/rexml/parsers/sax2parser.rb (revision 42518) +++ lib/rexml/parsers/sax2parser.rb (revision 42519) @@ -176,30 +176,7 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/parsers/sax2parser.rb#L176 } handle( :characters, copy ) when :entitydecl - @entities[ event[1] ] = event[2] if event.size == 3 - parameter_reference_p = false - case event[2] - when "SYSTEM" - if event.size == 5 - if event.last == "%" - parameter_reference_p = true - else - event[4, 0] = "NDATA" - end - end - when "PUBLIC" - if event.size == 6 - if event.last == "%" - parameter_reference_p = true - else - event[5, 0] = "NDATA" - end - end - else - parameter_reference_p = (event.size == 4) - end - event[1, 0] = event.pop if parameter_reference_p - handle( event[0], event[1..-1] ) + handle_entitydecl( event ) when :processing_instruction, :comment, :attlistdecl, :elementdecl, :cdata, :notationdecl, :xmldecl handle( *event ) @@ -220,6 +197,33 @@ module REXML https://github.com/ruby/ruby/blob/trunk/lib/rexml/parsers/sax2parser.rb#L197 } if listeners end + def handle_entitydecl( event ) + @entities[ event[1] ] = event[2] if event.size == 3 + parameter_reference_p = false + case event[2] + when "SYSTEM" + if event.size == 5 + if event.last == "%" + parameter_reference_p = true + else + event[4, 0] = "NDATA" + end + end + when "PUBLIC" + if event.size == 6 + if event.last == "%" + parameter_reference_p = true + else + event[5, 0] = "NDATA" + end + end + else + parameter_reference_p = (event.size == 4) + end + event[1, 0] = event.pop if parameter_reference_p + handle( event[0], event[1..-1] ) + end + # The following methods are duplicates, but it is faster than using # a helper def get_procs( symbol, name ) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/