Permalink
Browse files

Merge branch 'master' of github.com:mruby/mruby

  • Loading branch information...
2 parents 6423011 + bc66354 commit 4f27089b4ad915b7bda151a49694dcc8fbb4a2fc @matz matz committed Mar 8, 2014
Showing with 14 additions and 12 deletions.
  1. +2 −0 include/mruby/value.h
  2. +1 −1 src/codegen.c
  3. +2 −2 src/hash.c
  4. +5 −5 src/numeric.c
  5. +2 −2 src/object.c
  6. +1 −1 src/string.c
  7. +1 −1 src/variable.c
View
@@ -72,6 +72,8 @@ typedef short mrb_sym;
# define PRIo64 "I64o"
# define PRIx64 "I64x"
# define PRIX64 "I64X"
+# define INFINITY ((float)(DBL_MAX * DBL_MAX))
+# define NAN ((float)(INFINITY - INFINITY))
# else
# include <inttypes.h>
# endif
View
@@ -1915,7 +1915,7 @@ codegen(codegen_scope *s, node *tree, int val)
mrb_value fix = mrb_fixnum_value((intptr_t)tree);
mrb_value str = mrb_str_buf_new(mrb, 4);
- mrb_str_buf_cat(mrb, str, "$", 1);
+ mrb_str_cat_lit(mrb, str, "$");
mrb_str_buf_append(mrb, str, mrb_fixnum_to_str(mrb, fix, 10));
sym = new_sym(s, mrb_intern_str(mrb, str));
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
View
@@ -676,14 +676,14 @@ inspect_hash(mrb_state *mrb, mrb_value hash, int recur)
str2 = mrb_inspect(mrb, kh_key(h,k));
mrb_str_append(mrb, str, str2);
- mrb_str_buf_cat(mrb, str, "=>", 2);
+ mrb_str_cat_lit(mrb, str, "=>");
str2 = mrb_inspect(mrb, kh_value(h,k));
mrb_str_append(mrb, str, str2);
mrb_gc_arena_restore(mrb, ai);
}
}
- mrb_str_buf_cat(mrb, str, "}", 1);
+ mrb_str_cat_lit(mrb, str, "}");
return str;
}
View
@@ -304,8 +304,8 @@ flodivmod(mrb_state *mrb, mrb_float x, mrb_float y, mrb_float *divp, mrb_float *
mrb_float mod;
if (y == 0.0) {
- div = str_to_mrb_float("inf");
- mod = str_to_mrb_float("nan");
+ div = INFINITY;
+ mod = NAN;
}
else {
mod = fmod(x, y);
@@ -775,7 +775,7 @@ fix_mod(mrb_state *mrb, mrb_value x)
mrb_int mod;
if (mrb_fixnum(y) == 0) {
- return mrb_float_value(mrb, str_to_mrb_float("nan"));
+ return mrb_float_value(mrb, NAN);
}
fixdivmod(mrb, a, mrb_fixnum(y), 0, &mod);
return mrb_fixnum_value(mod);
@@ -805,8 +805,8 @@ fix_divmod(mrb_state *mrb, mrb_value x)
mrb_int div, mod;
if (mrb_fixnum(y) == 0) {
- return mrb_assoc_new(mrb, mrb_float_value(mrb, str_to_mrb_float("inf")),
- mrb_float_value(mrb, str_to_mrb_float("nan")));
+ return mrb_assoc_new(mrb, mrb_float_value(mrb, INFINITY),
+ mrb_float_value(mrb, NAN));
}
fixdivmod(mrb, mrb_fixnum(x), mrb_fixnum(y), &div, &mod);
return mrb_assoc_new(mrb, mrb_fixnum_value(div), mrb_fixnum_value(mod));
View
@@ -440,11 +440,11 @@ mrb_any_to_s(mrb_state *mrb, mrb_value obj)
mrb_value str = mrb_str_buf_new(mrb, 20);
const char *cname = mrb_obj_classname(mrb, obj);
- mrb_str_buf_cat(mrb, str, "#<", 2);
+ mrb_str_cat_lit(mrb, str, "#<");
mrb_str_cat_cstr(mrb, str, cname);
mrb_str_cat_lit(mrb, str, ":");
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_cptr(obj)));
- mrb_str_buf_cat(mrb, str, ">", 1);
+ mrb_str_cat_lit(mrb, str, ">");
return str;
}
View
@@ -2535,7 +2535,7 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str)
continue;
}
}
- mrb_str_buf_cat(mrb, result, "\"", 1);
+ mrb_str_cat_lit(mrb, result, "\"");
return result;
}
View
@@ -596,7 +596,7 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
const char *cn = mrb_obj_classname(mrb, mrb_obj_value(obj));
mrb_value str = mrb_str_buf_new(mrb, 30);
- mrb_str_buf_cat(mrb, str, "-<", 2);
+ mrb_str_cat_lit(mrb, str, "-<");
mrb_str_cat_cstr(mrb, str, cn);
mrb_str_cat_lit(mrb, str, ":");
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, obj));

0 comments on commit 4f27089

Please sign in to comment.