diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-07-17 10:35:41 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-17 10:35:41 +0900 |
| commit | d605b72c1d6fa4564a0a5e88535504b6850463b5 (patch) | |
| tree | 774fc0de56002abb3bb2b1c3387ff08f91876d17 /src/fmt_fp.c | |
| parent | 2af92d0ebcbeca6d3d85a27c8193273080a63090 (diff) | |
| parent | 9af3b7c6258de327218dd04e69d76ae68caf17b1 (diff) | |
| download | mruby-d605b72c1d6fa4564a0a5e88535504b6850463b5.tar.gz mruby-d605b72c1d6fa4564a0a5e88535504b6850463b5.zip | |
Merge branch 'master' into i110/inspect-recursion
Diffstat (limited to 'src/fmt_fp.c')
| -rw-r--r-- | src/fmt_fp.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fmt_fp.c b/src/fmt_fp.c index f8a8f7904..1f1af6764 100644 --- a/src/fmt_fp.c +++ b/src/fmt_fp.c @@ -1,3 +1,5 @@ +#ifndef MRB_WITHOUT_FLOAT +#if defined(MRB_DISABLE_STDIO) || defined(_WIN32) || defined(_WIN64) /* Most code in this file originates from musl (src/stdio/vfprintf.c) @@ -36,7 +38,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <mruby.h> #include <mruby/string.h> -#ifndef MRB_WITHOUT_FLOAT struct fmt_args { mrb_state *mrb; mrb_value str; @@ -371,4 +372,17 @@ mrb_float_to_str(mrb_state *mrb, mrb_value flo, const char *fmt) } return f.str; } +#else /* MRB_DISABLE_STDIO || _WIN32 || _WIN64 */ +#include <mruby.h> +#include <stdio.h> + +mrb_value +mrb_float_to_str(mrb_state *mrb, mrb_value flo, const char *fmt) +{ + char buf[25]; + + snprintf(buf, sizeof(buf), fmt, mrb_float(flo)); + return mrb_str_new_cstr(mrb, buf); +} +#endif /* MRB_DISABLE_STDIO || _WIN32 || _WIN64 */ #endif |
