Commit 2e49a131 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #3084 from syohex/all-zeros

Fix passing all zero string to Kernel#Integer
parents 49248569 787685a0
...@@ -22,6 +22,8 @@ assert('Kernel#Integer') do ...@@ -22,6 +22,8 @@ assert('Kernel#Integer') do
assert_equal(26, Integer("0x1a")) assert_equal(26, Integer("0x1a"))
assert_equal(930, Integer("0930", 10)) assert_equal(930, Integer("0930", 10))
assert_equal(7, Integer("111", 2)) assert_equal(7, Integer("111", 2))
assert_equal(0, Integer("0"))
assert_equal(0, Integer("00000"))
assert_raise(TypeError) { Integer(nil) } assert_raise(TypeError) { Integer(nil) }
end end
......
...@@ -2153,6 +2153,8 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b ...@@ -2153,6 +2153,8 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
break; break;
} }
} }
if (*(p - 1) == '0')
p--;
} }
if (p == pend) { if (p == pend) {
if (badcheck) goto bad; if (badcheck) goto bad;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment