summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-01 10:23:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-01 10:23:22 +0000
commitc2269d5b4f60829a523f3479492267ef99e1c5fb (patch)
tree1b0a0b035dbca831b168c86d833de524b5cf7848 /string.c
parentd9b49e39b2f3380cb6c4bb68a175a230c4702b58 (diff)
* intern.h: prototypes for new functions; rb_cstr_to_inum(),
rb_str_to_inum(), rb_cstr_to_dbl(), rb_str_to_dbl() * bignum.c (rb_cstr_to_inum): changed from rb_cstr2inum(), and added argument badcheck to be consistent with parser. [new] * bignum.c (rb_str_to_inum): ditto. * bignum.c (rb_cstr2inum): wapper of rb_cstr_to_inum() now. * bignum.c (rb_str2inum): ditto. * object.c (rb_cstr_to_dbl): float number parser. [new] * object.c (rb_str_to_dbl): ditto. * object.c (rb_Float): use rb_cstr_to_dbl() for strict check. * object.c (rb_Integer): use rb_str_to_inum() for strict check. * string.c (rb_str_to_f): use rb_str_to_dbl() with less check. * string.c (rb_str_to_i): use rb_str_to_inum() with less check. * string.c (rb_str_hex): ditto. * string.c (rb_str_oct): ditto. * sprintf.c (rb_f_sprintf): ditto. * time.c (obj2long): ditto. * parse.y (yylex): use rb_cstr_to_inum() for strict check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/string.c b/string.c
index 87411a5..25fd851 100644
--- a/string.c
+++ b/string.c
@@ -1766,16 +1766,14 @@ rb_str_to_i(argc, argv, str)
default:
rb_raise(rb_eArgError, "illegal radix %d", base);
}
- return rb_str2inum(str, base);
+ return rb_str_to_inum(str, base, Qfalse);
}
static VALUE
rb_str_to_f(str)
VALUE str;
{
- double f = strtod(RSTRING(str)->ptr, 0);
-
- return rb_float_new(f);
+ return rb_float_new(rb_str_to_dbl(str, Qfalse));
}
static VALUE
@@ -2963,28 +2961,14 @@ static VALUE
rb_str_hex(str)
VALUE str;
{
- return rb_str2inum(str, 16);
+ return rb_str_to_inum(str, 16, Qfalse);
}
static VALUE
rb_str_oct(str)
VALUE str;
{
- int base = 8;
-
- if (RSTRING(str)->len > 2 && RSTRING(str)->ptr[0] == '0') {
- switch (RSTRING(str)->ptr[1]) {
- case 'x':
- case 'X':
- base = 16;
- break;
- case 'b':
- case 'B':
- base = 2;
- break;
- }
- }
- return rb_str2inum(str, base);
+ return rb_str_to_inum(str, -8, Qfalse);
}
static VALUE