summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-09-03 05:37:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-09-03 05:37:42 +0000
commit0f35b58a2fbae58a20979de77a3a642c42f41899 (patch)
treecab4099dba0fde8650c94226a1f9ce94549561c9 /pack.c
parentc9d1be6327640aa5bc01f8c6c8846e4e3fb31337 (diff)
* ruby.c (proc_options): should not alter origargv[].
* ruby.c (set_arg0): long strings for $0 dumped core. * ruby.c (set_arg0): use setprogtitle() if it's available. * io.c (rb_io_popen): accept integer flags as mode. * file.c (rb_find_file_ext): extension table can be supplied from outside. renamed. * eval.c (rb_f_require): replace rb_find_file_noext by rb_find_file_ext. * eval.c (rb_provided): should also check feature without extension. * numeric.c (flo_to_s): do not rely on decimal point to be '.' git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c66
1 files changed, 6 insertions, 60 deletions
diff --git a/pack.c b/pack.c
index 18de622..f5faf7e 100644
--- a/pack.c
+++ b/pack.c
@@ -656,16 +656,7 @@ pack_pack(ary, fmt)
float f;
from = NEXTFROM;
- switch (TYPE(from)) {
- case T_FLOAT:
- f = RFLOAT(from)->value;
- break;
- case T_STRING:
- f = strtod(RSTRING(from)->ptr, 0);
- default:
- f = (float)NUM2INT(from);
- break;
- }
+ f = RFLOAT(rb_Float(from))->value;
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
break;
@@ -676,16 +667,7 @@ pack_pack(ary, fmt)
FLOAT_CONVWITH(ftmp);
from = NEXTFROM;
- switch (TYPE(from)) {
- case T_FLOAT:
- f = RFLOAT(from)->value;
- break;
- case T_STRING:
- f = strtod(RSTRING(from)->ptr, 0);
- default:
- f = (float)NUM2INT(from);
- break;
- }
+ f = RFLOAT(rb_Float(from))->value;
f = HTOVF(f,ftmp);
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
@@ -697,16 +679,7 @@ pack_pack(ary, fmt)
DOUBLE_CONVWITH(dtmp);
from = NEXTFROM;
- switch (TYPE(from)) {
- case T_FLOAT:
- d = RFLOAT(from)->value;
- break;
- case T_STRING:
- d = strtod(RSTRING(from)->ptr, 0);
- default:
- d = (double)NUM2INT(from);
- break;
- }
+ d = RFLOAT(rb_Float(from))->value;
d = HTOVD(d,dtmp);
rb_str_buf_cat(res, (char*)&d, sizeof(double));
}
@@ -718,16 +691,7 @@ pack_pack(ary, fmt)
double d;
from = NEXTFROM;
- switch (TYPE(from)) {
- case T_FLOAT:
- d = RFLOAT(from)->value;
- break;
- case T_STRING:
- d = strtod(RSTRING(from)->ptr, 0);
- default:
- d = (double)NUM2INT(from);
- break;
- }
+ d = RFLOAT(rb_Float(from))->value;
rb_str_buf_cat(res, (char*)&d, sizeof(double));
}
break;
@@ -738,16 +702,7 @@ pack_pack(ary, fmt)
FLOAT_CONVWITH(ftmp);
from = NEXTFROM;
- switch (TYPE(from)) {
- case T_FLOAT:
- f = RFLOAT(from)->value;
- break;
- case T_STRING:
- f = strtod(RSTRING(from)->ptr, 0);
- default:
- f = (float)NUM2INT(from);
- break;
- }
+ f = RFLOAT(rb_Float(from))->value;
f = HTONF(f,ftmp);
rb_str_buf_cat(res, (char*)&f, sizeof(float));
}
@@ -759,16 +714,7 @@ pack_pack(ary, fmt)
DOUBLE_CONVWITH(dtmp);
from = NEXTFROM;
- switch (TYPE(from)) {
- case T_FLOAT:
- d = RFLOAT(from)->value;
- break;
- case T_STRING:
- d = strtod(RSTRING(from)->ptr, 0);
- default:
- d = (double)NUM2INT(from);
- break;
- }
+ d = RFLOAT(rb_Float(from))->value;
d = HTOND(d,dtmp);
rb_str_buf_cat(res, (char*)&d, sizeof(double));
}