summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-13 15:43:02 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-13 15:43:02 +0000
commitb268c7309e3f17c73a89defb56754e29c206f151 (patch)
tree5ba7806e9888994ea744e2be5b47bb3b0f401913 /ext
parent3f6444f71d8b98b455712030b3c5f52b13e9d64b (diff)
* array.c (rb_ary_pop): may cause realloc oscillation. a patch
from MORITA Naoyuki <mlgetter at kidou.sakura.ne.jp>. [ruby-dev:29028] * parse.y (then): we'd like to reserve colon here for the future. warning added. * ruby.h: export rb_cMethod. [ruby-talk:201259] * ext/bigdecimal/bigdecimal.c: Allows '_' to appear within digits. [ruby-dev:28872] * ext/bigdecimal/lib/bigdecimal/util.rb: Bug in to_r reported by [ruby-list:42533] fixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/bigdecimal/bigdecimal.c15
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb5
2 files changed, 15 insertions, 5 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index d2d052fcf0..0abd20546a 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2496,14 +2496,25 @@ VpAlloc(U_LONG mx, char *szVal)
return vp;
}
- /* Skip all spaces */
+ /* Skip all '_' after digit: 2006-6-30 */
+ ni = 0;
psz = ALLOCA_N(char,strlen(szVal)+1);
i = 0;
ipn = 0;
while(psz[i]=szVal[ipn]) {
- if(ISSPACE(szVal[ipn])) {ipn++;continue;}
+ if(ISDIGIT(psz[i])) ++ni;
+ if(psz[i]=='_') {
+ if(ni>0) {ipn++;continue;}
+ psz[i]=0;
+ break;
+ }
++i; ++ipn;
}
+ /* Skip trailing spaces */
+ while((--i)>0) {
+ if(ISSPACE(psz[i])) psz[i] = 0;
+ else break;
+ }
szVal = psz;
/* Check on Inf & NaN */
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
index 2c17aa6b8e..09e926acd5 100644
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -46,11 +46,10 @@ class BigDecimal < Numeric
numerator = sign*digits.to_i
denomi_power = power - digits.size # base is always 10
if denomi_power < 0
- denominator = base ** (-denomi_power)
+ Rational(numerator,base ** (-denomi_power))
else
- denominator = base ** denomi_power
+ Rational(numerator * (base ** denomi_power),1)
end
- Rational(numerator,denominator)
end
end