aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 04:32:43 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 04:32:43 +0000
commit4d399f12d4354c17bbb1ea2b12de4c11c6ac03ff (patch)
tree996a9f52ab0cd10d044d0949116c276627caad02 /util.c
parent2067e4eb30eb78b36c252baff319c6d581700460 (diff)
downloadruby-4d399f12d4354c17bbb1ea2b12de4c11c6ac03ff.tar.gz
* object.c (rb_cstr_to_dbl): return 0.0 if hexadecimal and
baccheck is FALSE: Float("0x1p+0") works, but "0x1p+0".to_f doesn't. [ruby-dev:40650] * util.c (ruby_strtod): allow hexdecimal integers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r--util.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/util.c b/util.c
index 9cdb563040..11d0272e52 100644
--- a/util.c
+++ b/util.c
@@ -2124,24 +2124,21 @@ break2:
}
}
- if (*s != 'P' && *s != 'p') {
- s = s0;
- goto ret;
+ if (*s == 'P' || *s == 'p') {
+ dsign = 0x2C - *++s; /* +: 2B, -: 2D */
+ if (abs(dsign) == 1) s++;
+ else dsign = 1;
+
+ for (nd = 0; (c = *s) >= '0' && c <= '9'; s++) {
+ nd *= 10;
+ nd += c;
+ nd -= '0';
+ }
+ dval(rv) = ldexp(adj, nd * dsign);
}
-
- dsign = 0x2C - *++s; /* +: 2B, -: 2D */
- if (abs(dsign) != 1) {
- s = s0;
- goto ret;
+ else {
+ dval(rv) = adj;
}
-
- for (nd = 0, s++; (c = *s) >= '0' && c <= '9'; s++) {
- nd *= 10;
- nd += c;
- nd -= '0';
- }
-
- dval(rv) = ldexp(adj, nd * dsign);
goto ret;
}
nz0 = 1;