From 403f943bb494b7bf1e29f8921ced304ca6ae1f22 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 23 Jul 2010 19:48:10 +0200 Subject: [PATCH] fix BigDecimal.new starting with underscores --- src/org/jruby/RubyBigDecimal.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/jruby/RubyBigDecimal.java b/src/org/jruby/RubyBigDecimal.java index 226a42a6957..1f838becb66 100644 --- a/src/org/jruby/RubyBigDecimal.java +++ b/src/org/jruby/RubyBigDecimal.java @@ -383,7 +383,10 @@ public static RubyBigDecimal newInstance(IRubyObject recv, IRubyObject[] args) { // by Java's BigDecimal. Not terribly efficient for now. // 1. MRI allows d and D as exponent separators strValue = strValue.replaceFirst("[dD]", "E"); - // 2. MRI allows underscores anywhere + // 2. MRI allows underscores anywhere but in the beginning + if (strValue.startsWith("_")) { + return newZero(runtime, 1); + } strValue = strValue.replaceAll("_", ""); // 3. MRI ignores the trailing junk strValue = NUMBER_PATTERN.matcher(strValue).replaceFirst("$1");