diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-29 12:50:42 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-03-29 12:50:42 +0900 |
| commit | 905f46a129de65098b3130789bb9c412201f4cb4 (patch) | |
| tree | f28332dc68c91263ce1371ce912b3f4b6a449f5b /mrbgems | |
| parent | 1f6bf0e14f57afca0c5254cc1a0893d11b3303e2 (diff) | |
| parent | db3573e0bf45bc3653d49a7dee90458df09005c8 (diff) | |
| download | mruby-905f46a129de65098b3130789bb9c412201f4cb4.tar.gz mruby-905f46a129de65098b3130789bb9c412201f4cb4.zip | |
Merge pull request #3558 from ksss/domain
Should raise FloatDomainError
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-time/src/time.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c index 7e5f68f43..908fe77f8 100644 --- a/mrbgems/mruby-time/src/time.c +++ b/mrbgems/mruby-time/src/time.c @@ -211,16 +211,7 @@ mrb_time_wrap(mrb_state *mrb, struct RClass *tc, struct mrb_time *tm) return mrb_obj_value(Data_Wrap_Struct(mrb, tc, &mrb_time_type, tm)); } -static void -check_num_exact(mrb_state *mrb, double num) -{ - if (isinf(num)) { - mrb_raise(mrb, E_FLOATDOMAIN_ERROR, num < 0 ? "-Infinity" : "Infinity"); - } - if (isnan(num)) { - mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN"); - } -} +void mrb_check_num_exact(mrb_state *mrb, mrb_float num); /* Allocates a mrb_time object and initializes it. */ static struct mrb_time* @@ -229,8 +220,8 @@ time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezone) struct mrb_time *tm; time_t tsec = 0; - check_num_exact(mrb, sec); - check_num_exact(mrb, usec); + mrb_check_num_exact(mrb, (mrb_float)sec); + mrb_check_num_exact(mrb, (mrb_float)usec); if (sizeof(time_t) == 4 && (sec > (double)INT32_MAX || (double)INT32_MIN > sec)) { goto out_of_range; |
