mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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/branches/ruby_1_8@9947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
26899051a0
commit
386352b474
5 changed files with 26 additions and 6 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Fri Feb 17 11:18:42 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>
|
Fri Feb 17 09:39:29 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (rb_thread_wait_for): sleep should always sleep for
|
* eval.c (rb_thread_wait_for): sleep should always sleep for
|
||||||
|
|
6
pack.c
6
pack.c
|
@ -347,11 +347,11 @@ num2i32(x)
|
||||||
return 0; /* not reached */
|
return 0; /* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SIZEOF_LONG == SIZE32 || SIZEOF_INT == SIZE32
|
#if SIZEOF_LONG == SIZE32
|
||||||
# define EXTEND32(x)
|
# define EXTEND32(x)
|
||||||
#else
|
#else
|
||||||
/* invariant in modulo 1<<31 */
|
/* 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
|
#endif
|
||||||
#if SIZEOF_SHORT == SIZE16
|
#if SIZEOF_SHORT == SIZE16
|
||||||
# define EXTEND16(x)
|
# define EXTEND16(x)
|
||||||
|
@ -1951,7 +1951,7 @@ pack_unpack(str, fmt)
|
||||||
case 'w':
|
case 'w':
|
||||||
{
|
{
|
||||||
unsigned long ul = 0;
|
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) {
|
while (len > 0 && s < send) {
|
||||||
ul <<= 7;
|
ul <<= 7;
|
||||||
|
|
|
@ -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("-")}
|
||||||
assert_raise(ArgumentError){Float("-.")}
|
assert_raise(ArgumentError){Float("-.")}
|
||||||
|
assert_raise(ArgumentError){Float("1e")}
|
||||||
# add expected behaviour here.
|
# add expected behaviour here.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,9 @@ class TestPack < Test::Unit::TestCase
|
||||||
|
|
||||||
$x = [-1073741825]
|
$x = [-1073741825]
|
||||||
assert_equal($x, $x.pack("q").unpack("q"))
|
assert_equal($x, $x.pack("q").unpack("q"))
|
||||||
|
|
||||||
|
$x = [-1]
|
||||||
|
assert_equal($x, $x.pack("l").unpack("l"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_pack_N
|
def test_pack_N
|
||||||
|
|
8
util.c
8
util.c
|
@ -863,10 +863,16 @@ ruby_strtod(string, endPtr)
|
||||||
}
|
}
|
||||||
expSign = FALSE;
|
expSign = FALSE;
|
||||||
}
|
}
|
||||||
while (ISDIGIT(*p)) {
|
if (ISDIGIT(*p)) {
|
||||||
|
do {
|
||||||
exp = exp * 10 + (*p - '0');
|
exp = exp * 10 + (*p - '0');
|
||||||
p += 1;
|
p += 1;
|
||||||
}
|
}
|
||||||
|
while (ISDIGIT(*p));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
p = pExp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (expSign) {
|
if (expSign) {
|
||||||
exp = fracExp - exp;
|
exp = fracExp - exp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue