diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-08-03 11:54:45 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-08-03 11:54:45 +0900 |
| commit | a4243360a2f8248dbf23b46ca14a7a59c0479b32 (patch) | |
| tree | f1610224880c12bf374f11851c59d3f6474a6638 /src/error.c | |
| parent | c883f4e332f2385fc9c9df7162b336ea601ec459 (diff) | |
| download | mruby-a4243360a2f8248dbf23b46ca14a7a59c0479b32.tar.gz mruby-a4243360a2f8248dbf23b46ca14a7a59c0479b32.zip | |
Fix `mrb_vformat("%f")` with `MRB_USE_FLOAT`
It potentially not work when `mrb_float` is `float` because `float` variable
in variable length arguments is promoted to `double`.
Also I fixed build with `MRB_WITHOUT_FLOAT`.
Diffstat (limited to 'src/error.c')
| -rw-r--r-- | src/error.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/error.c b/src/error.c index 6e7c3763a..3ee137c95 100644 --- a/src/error.c +++ b/src/error.c @@ -328,9 +328,11 @@ mrb_vformat(mrb_state *mrb, const char *format, va_list ap) i = *p == 'd' ? (mrb_int)va_arg(ap, int) : va_arg(ap, mrb_int); obj = mrb_fixnum_value(i); goto L_cat_obj; +#ifndef MRB_WITHOUT_FLOAT case 'f': - obj = mrb_float_value(mrb, va_arg(ap, mrb_float)); + obj = mrb_float_value(mrb, (mrb_float)va_arg(ap, double)); goto L_cat_obj; +#endif case 'l': chars = va_arg(ap, char*); len = va_arg(ap, mrb_int); |
