mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
------------------------------------------------------------------------
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ac1d9e7c2d
commit
8fd29e2019
8 changed files with 923 additions and 878 deletions
|
@ -146,6 +146,12 @@ module REXML
|
|||
def node_type
|
||||
:attribute
|
||||
end
|
||||
|
||||
def inspect
|
||||
rv = ""
|
||||
write( rv )
|
||||
rv
|
||||
end
|
||||
end
|
||||
end
|
||||
#vim:ts=2 sw=2 noexpandtab:
|
||||
|
|
|
@ -176,6 +176,7 @@ module REXML
|
|||
tag_stack = []
|
||||
in_doctype = false
|
||||
entities = nil
|
||||
begin
|
||||
while true
|
||||
event = parser.pull
|
||||
case event[0]
|
||||
|
@ -237,6 +238,9 @@ module REXML
|
|||
x = XMLDecl.new( event[1], event[2], event[3] )
|
||||
build_context.add( x )
|
||||
end
|
||||
end
|
||||
rescue
|
||||
raise ParseException.new( $!.message, parser.source, parser, $! )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -67,6 +67,22 @@ module REXML
|
|||
end
|
||||
end
|
||||
|
||||
def inspect
|
||||
rv = "<#@expanded_name"
|
||||
|
||||
@attributes.each_attribute do |attr|
|
||||
rv << " "
|
||||
attr.write( rv, 0 )
|
||||
end unless @attributes.empty?
|
||||
|
||||
if children.size > 0
|
||||
rv << " ... </>"
|
||||
else
|
||||
rv << "/>"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Creates a shallow copy of self.
|
||||
# d = Document.new "<a><b/><b/><c><d/></c></a>"
|
||||
# new_a = d.root.clone
|
||||
|
|
|
@ -6,7 +6,7 @@ module REXML
|
|||
array_utf8 = content.unpack('U*')
|
||||
array_enc = []
|
||||
array_utf8.each do |num|
|
||||
if num <= 0xFF
|
||||
if num <= 0x7F
|
||||
array_enc << num
|
||||
else
|
||||
# Numeric entity (&#nnnn;); shard by Stefan Scholl
|
||||
|
|
|
@ -331,11 +331,17 @@ module REXML
|
|||
elsif object == false
|
||||
Float(0)
|
||||
elsif object.kind_of? Array
|
||||
string( object ).to_f
|
||||
number(string( object ))
|
||||
elsif object.kind_of? Float
|
||||
object
|
||||
else
|
||||
str = string( object )
|
||||
#puts "STRING OF #{object.inspect} = #{str}"
|
||||
if str =~ /^\d+/
|
||||
object.to_s.to_f
|
||||
else
|
||||
(0.0 / 0.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -35,11 +35,13 @@ module REXML
|
|||
end
|
||||
|
||||
def position
|
||||
@source.current_line[0] if @source and @source.current_line
|
||||
@source.current_line[0] if @source and defined? @source.current_line and
|
||||
@source.current_line
|
||||
end
|
||||
|
||||
def line
|
||||
@source.current_line[2] if @source and @source.current_line
|
||||
@source.current_line[2] if @source and defined? @source.current_line and
|
||||
@source.current_line
|
||||
end
|
||||
|
||||
def context
|
||||
|
|
|
@ -100,6 +100,8 @@ module REXML
|
|||
self.stream = source
|
||||
end
|
||||
|
||||
attr_reader :source
|
||||
|
||||
def stream=( source )
|
||||
if source.kind_of? String
|
||||
@source = Source.new(source)
|
||||
|
|
|
@ -49,7 +49,7 @@ module REXML
|
|||
while ( path_stack.size > 0 and nodeset.size > 0 )
|
||||
#puts "PARSE: #{path_stack.inspect} '#{nodeset.collect{|n|n.class}.inspect}'"
|
||||
nodeset = internal_parse( path_stack, nodeset )
|
||||
#puts "NODESET: #{nodeset.size}"
|
||||
#puts "NODESET: #{nodeset}"
|
||||
#puts "PATH_STACK: #{path_stack.inspect}"
|
||||
end
|
||||
nodeset
|
||||
|
@ -136,7 +136,6 @@ module REXML
|
|||
return literal
|
||||
|
||||
when :attribute
|
||||
#puts ":ATTRIBUTE"
|
||||
new_nodeset = []
|
||||
case path_stack.shift
|
||||
when :qname
|
||||
|
@ -344,14 +343,20 @@ module REXML
|
|||
eq = predicate.shift
|
||||
left = Predicate( predicate.shift, node )
|
||||
right = Predicate( predicate.shift, node )
|
||||
#puts "LEFT = #{left.inspect}"
|
||||
#puts "RIGHT = #{right.inspect}"
|
||||
return equality_relational_compare( left, eq, right )
|
||||
|
||||
when :div, :mod, :mult, :plus, :minus
|
||||
op = predicate.shift
|
||||
left = Predicate( predicate.shift, node )
|
||||
right = Predicate( predicate.shift, node )
|
||||
#puts "LEFT = #{left.inspect}"
|
||||
#puts "RIGHT = #{right.inspect}"
|
||||
left = Functions::number( left )
|
||||
right = Functions::number( right )
|
||||
#puts "LEFT = #{left.inspect}"
|
||||
#puts "RIGHT = #{right.inspect}"
|
||||
case op
|
||||
when :div
|
||||
return left.to_f / right.to_f
|
||||
|
@ -472,8 +477,12 @@ module REXML
|
|||
end
|
||||
when /^\d+(\.\d+)?$/
|
||||
b = Functions::number( b )
|
||||
#puts "B = #{b.inspect}"
|
||||
for v in a
|
||||
#puts "v = #{v.inspect}"
|
||||
v = Functions::number(v)
|
||||
#puts "v = #{v.inspect}"
|
||||
#puts compare(v,op,b)
|
||||
return true if compare( v, op, b )
|
||||
end
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue