diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-12 09:09:15 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-12 09:09:15 +0000 |
commit | 080525aa68c68df1fd4c1484bea1de88e3c1f79f (patch) | |
tree | f985490507f159db8cdc564a258bbd33c4724fa0 /marshal.c | |
parent | 1c6ca1eec5c35e1665273b891ecc05e2daf0e063 (diff) |
* marshal.c (div0), numeric.c (infinite_value): new functions to
get rid of VC divion by 0 warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r-- | marshal.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -1201,6 +1201,20 @@ obj_alloc_by_path(const char *path, struct load_arg *arg) return rb_obj_alloc(klass); } +#if defined _MSC_VER && _MSC_VER >= 1300 +#pragma warning(push) +#pragma warning(disable:4723) +#endif +static double +div0(double x) +{ + double t = 0.0; + return x / t; +} +#if defined _MSC_VER && _MSC_VER >= 1300 +#pragma warning(pop) +#endif + static VALUE r_object0(struct load_arg *arg, int *ivp, VALUE extmod) { @@ -1292,18 +1306,18 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) case TYPE_FLOAT: { - double d, t = 0.0; + double d; VALUE str = r_bytes(arg); const char *ptr = RSTRING_PTR(str); if (strcmp(ptr, "nan") == 0) { - d = t / t; + d = div0(0.0); } else if (strcmp(ptr, "inf") == 0) { - d = 1.0 / t; + d = div0(+1.0); } else if (strcmp(ptr, "-inf") == 0) { - d = -1.0 / t; + d = div0(-1.0); } else { char *e; |