summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-17 02:21:39 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-02-17 02:21:39 +0000
commitd0a3c64fb4af21a911f2b7553bbddb45dd9e4484 (patch)
treea13f61d930df2858bf8da602ec0128910bec4582
parentdd0fa838d94ad91b1ab993e41b7ad113aac3b3f5 (diff)
* util.c (ruby_strtod): Float("1e") should fail. [ruby-core:7330]
* pack.c (EXTEND32): unpack("l") did not work where sizeof(long) != 4. [ruby-talk:180024] * pack.c (pack_unpack): fixed integer overflow on template "w". [ruby-talk:180126] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--pack.c6
-rw-r--r--test/ruby/test_float.rb1
-rw-r--r--test/ruby/test_pack.rb3
-rw-r--r--util.c12
5 files changed, 26 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 54b20f24c6..814985bc24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri Feb 17 11:20:53 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
+
+ * util.c (ruby_strtod): Float("1e") should fail. [ruby-core:7330]
+
+ * pack.c (EXTEND32): unpack("l") did not work where sizeof(long) != 4.
+ [ruby-talk:180024]
+
+ * pack.c (pack_unpack): fixed integer overflow on template "w".
+ [ruby-talk:180126]
+
Fri Feb 17 09:39:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_wait_for): sleep should always sleep for
diff --git a/pack.c b/pack.c
index f475f26f9b..b98a1209e3 100644
--- a/pack.c
+++ b/pack.c
@@ -345,11 +345,11 @@ num2i32(VALUE x)
return 0; /* not reached */
}
-#if SIZEOF_LONG == SIZE32 || SIZEOF_INT == SIZE32
+#if SIZEOF_LONG == SIZE32
# define EXTEND32(x)
#else
/* invariant in modulo 1<<31 */
-# define EXTEND32(x) do {if (!natint) {(x) = (I32)(((1<<31)-1-(x))^~(~0<<31));}} while(0)
+# define EXTEND32(x) do { if (!natint) {(x) = (((1L<<31)-1-(x))^~(~0L<<31));}} while(0)
#endif
#if SIZEOF_SHORT == SIZE16
# define EXTEND16(x)
@@ -1937,7 +1937,7 @@ pack_unpack(VALUE str, VALUE fmt)
case 'w':
{
unsigned long ul = 0;
- unsigned long ulmask = 0xfeL << ((sizeof(unsigned long) - 1) * 8);
+ unsigned long ulmask = 0xfeUL << ((sizeof(unsigned long) - 1) * 8);
while (len > 0 && s < send) {
ul <<= 7;
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
index fb180ff81b..63979b5be0 100644
--- a/test/ruby/test_float.rb
+++ b/test/ruby/test_float.rb
@@ -84,6 +84,7 @@ class TestFloat < Test::Unit::TestCase
assert_raise(ArgumentError){Float("+.")}
assert_raise(ArgumentError){Float("-")}
assert_raise(ArgumentError){Float("-.")}
+ assert_raise(ArgumentError){Float("1e")}
# add expected behaviour here.
end
end
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index a9f15599e4..e67465b33a 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -15,6 +15,9 @@ class TestPack < Test::Unit::TestCase
$x = [-1073741825]
assert_equal($x, $x.pack("q").unpack("q"))
+
+ $x = [-1]
+ assert_equal($x, $x.pack("l").unpack("l"))
end
def test_pack_N
diff --git a/util.c b/util.c
index 5eaee4cb0b..953927d145 100644
--- a/util.c
+++ b/util.c
@@ -848,9 +848,15 @@ ruby_strtod(
}
expSign = FALSE;
}
- while (ISDIGIT(*p)) {
- exp = exp * 10 + (*p - '0');
- p += 1;
+ if (ISDIGIT(*p)) {
+ do {
+ exp = exp * 10 + (*p - '0');
+ p += 1;
+ }
+ while (ISDIGIT(*p));
+ }
+ else {
+ p = pExp;
}
}
if (expSign) {