mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add MRB_WITHOUT_FLOAT
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#ifndef MRB_WITHOUT_FLOAT
|
||||
#include <float.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@@ -2284,6 +2286,7 @@ mrb_str_to_i(mrb_state *mrb, mrb_value self)
|
||||
return mrb_str_to_inum(mrb, self, base, FALSE);
|
||||
}
|
||||
|
||||
#ifndef MRB_WITHOUT_FLOAT
|
||||
MRB_API double
|
||||
mrb_cstr_to_dbl(mrb_state *mrb, const char * p, mrb_bool badcheck)
|
||||
{
|
||||
@@ -2387,6 +2390,7 @@ mrb_str_to_f(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
return mrb_float_value(mrb, mrb_str_to_dbl(mrb, self, FALSE));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 15.2.10.5.40 */
|
||||
/*
|
||||
@@ -2788,7 +2792,9 @@ mrb_init_string(mrb_state *mrb)
|
||||
mrb_define_method(mrb, s, "slice", mrb_str_aref_m, MRB_ARGS_ANY()); /* 15.2.10.5.34 */
|
||||
mrb_define_method(mrb, s, "split", mrb_str_split_m, MRB_ARGS_ANY()); /* 15.2.10.5.35 */
|
||||
|
||||
#ifndef MRB_WITHOUT_FLOAT
|
||||
mrb_define_method(mrb, s, "to_f", mrb_str_to_f, MRB_ARGS_NONE()); /* 15.2.10.5.38 */
|
||||
#endif
|
||||
mrb_define_method(mrb, s, "to_i", mrb_str_to_i, MRB_ARGS_ANY()); /* 15.2.10.5.39 */
|
||||
mrb_define_method(mrb, s, "to_s", mrb_str_to_s, MRB_ARGS_NONE()); /* 15.2.10.5.40 */
|
||||
mrb_define_method(mrb, s, "to_str", mrb_str_to_s, MRB_ARGS_NONE());
|
||||
@@ -2799,6 +2805,7 @@ mrb_init_string(mrb_state *mrb)
|
||||
mrb_define_method(mrb, s, "bytes", mrb_str_bytes, MRB_ARGS_NONE());
|
||||
}
|
||||
|
||||
#ifndef MRB_WITHOUT_FLOAT
|
||||
/*
|
||||
* Source code for the "strtod" library procedure.
|
||||
*
|
||||
@@ -3043,3 +3050,4 @@ done:
|
||||
}
|
||||
return fraction;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user