diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-01 11:02:34 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-04-01 11:02:34 +0000 |
commit | 68a12b55fca0e79e51b7c10c444cd926d5ff7a33 (patch) | |
tree | e890e8181d44868f0fc0472c26e0b22cd75d40fa /lib/xsd | |
parent | 86203a88aee76517c3c8862057e3315e0d479489 (diff) |
* lib/soap/mapping/{factory.rb,registry.rb}: fixed illegal mapped URI
object with soap/marshal.
added URIFactory class for URI mapping. BasetypeFactory checks
instance_variables when original mapping is not allowed (ivar must
be empty). Instance of URI have instance_variables but it must be
llowed whenever original mapping is allowed or not.
* lib/xsd/datatypes.rb: check the smallest positive non-zero
single-precision float exactly instead of packing with "f".
[ruby-talk:88822]
* lib/soap/mapping/rubytypeFactory.rb: should not dump singleton class.
[ruby-dev:22588]
c = class << Object.new; class C; self; end; end; SOAPMarshal.dump(c)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/xsd')
-rw-r--r-- | lib/xsd/datatypes.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/xsd/datatypes.rb b/lib/xsd/datatypes.rb index f318e612b1..7223632b04 100644 --- a/lib/xsd/datatypes.rb +++ b/lib/xsd/datatypes.rb @@ -268,8 +268,11 @@ end module FloatConstants NaN = 0.0/0.0 - POSITIVE_INF = 1.0/0.0 + POSITIVE_INF = +1.0/0.0 NEGATIVE_INF = -1.0/0.0 + POSITIVE_ZERO = +1.0/POSITIVE_INF + NEGATIVE_ZERO = -1.0/POSITIVE_INF + MIN_POSITIVE_SINGLE = 2 ** -149 end class XSDFloat < XSDAnySimpleType @@ -320,7 +323,7 @@ private elsif @data.infinite? == -1 '-INF' else - sign = (1 / @data > 0.0) ? '+' : '-' + sign = XSDFloat.positive?(@data) ? '+' : '-' sign + sprintf("%.10g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 } end end @@ -329,11 +332,16 @@ private def narrow32bit(f) if f.nan? || f.infinite? f + elsif f.abs < MIN_POSITIVE_SINGLE + XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO else - packed = [f].pack("f") - (/\A\0*\z/ =~ packed)? 0.0 : f + f end end + + def self.positive?(value) + (1 / value) > 0.0 + end end # Ruby's Float is double-precision 64-bit floating point value. |