summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/class.c15
-rw-r--r--src/numeric.c5
2 files changed, 19 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c
index 11a21f7a7..2c1145ed3 100644
--- a/src/class.c
+++ b/src/class.c
@@ -14,6 +14,7 @@
#include "mruby/string.h"
#include "mruby/variable.h"
#include "mruby/error.h"
+#include "mruby/data.h"
KHASH_DEFINE(mt, mrb_sym, struct RProc*, 1, kh_int_hash_func, kh_int_hash_equal)
@@ -406,6 +407,7 @@ to_hash(mrb_state *mrb, mrb_value val)
i: Integer [mrb_int]
b: Boolean [mrb_bool]
n: Symbol [mrb_sym]
+ d: Data [void*,mrb_data_type const] 2nd argument will be used to check data type so it won't be modified
&: Block [mrb_value]
*: rest argument [mrb_value*,int] Receive the rest of the arguments as an array.
|: optional Next argument of '|' and later are optional.
@@ -658,6 +660,19 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
}
}
break;
+ case 'd':
+ {
+ void** datap;
+ struct mrb_data_type const* type;
+
+ datap = va_arg(ap, void**);
+ type = va_arg(ap, struct mrb_data_type const*);
+ if (i < argc) {
+ *datap = mrb_data_get_ptr(mrb, *sp++, type);
+ ++i;
+ }
+ }
+ break;
case '&':
{
diff --git a/src/numeric.c b/src/numeric.c
index ec7f05b97..e081cf80a 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -19,9 +19,11 @@
#define ceil(f) ceilf(f)
#define fmod(x,y) fmodf(x,y)
#define FLO_MAX_DIGITS 7
+#define FLO_MAX_SIGN_LENGTH 3
#define FLO_EPSILON FLT_EPSILON
#else
#define FLO_MAX_DIGITS 14
+#define FLO_MAX_SIGN_LENGTH 10
#define FLO_EPSILON DBL_EPSILON
#endif
@@ -159,6 +161,7 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo)
}
}
if (beg >= 0) length = end - beg;
+ if (length > FLO_MAX_SIGN_LENGTH) length = FLO_MAX_SIGN_LENGTH;
}
if (abs(exp) + length >= FLO_MAX_DIGITS) {
@@ -166,7 +169,7 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo)
e = TRUE;
n = n / pow(10.0, exp);
if (isinf(n)) {
- if (s[0] == '-') {
+ if (s < c) { /* s[0] == '-' */
return mrb_str_new_lit(mrb, "-0.0");
}
else {