summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-11-13 16:29:16 -0800
committerYukihiro "Matz" Matsumoto <[email protected]>2013-11-13 16:29:16 -0800
commit2a5e0a4f6c90b95fd0f078b192b1cf152e47a1da (patch)
tree2c471cb54108fe16c35a94f18e18151746c6e0c7
parentedd6c17c1e21e8ecc65241625fecb60e8deb4455 (diff)
parent0cbdbd81cbc96637c7ba2e1e545ae8df45e0b3df (diff)
downloadmruby-2a5e0a4f6c90b95fd0f078b192b1cf152e47a1da.tar.gz
mruby-2a5e0a4f6c90b95fd0f078b192b1cf152e47a1da.zip
Merge pull request #1571 from bggd/patch-1
Changed a variable declaration to top of block
-rw-r--r--mrbgems/mruby-random/src/random.c5
-rw-r--r--src/codegen.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/mrbgems/mruby-random/src/random.c b/mrbgems/mruby-random/src/random.c
index d3f244910..4762d212b 100644
--- a/mrbgems/mruby-random/src/random.c
+++ b/mrbgems/mruby-random/src/random.c
@@ -265,6 +265,7 @@ mrb_ary_shuffle_bang(mrb_state *mrb, mrb_value ary)
for (i = RARRAY_LEN(ary) - 1; i > 0; i--) {
mrb_int j;
+ mrb_value tmp;
if (mrb_nil_p(random)) {
j = mrb_fixnum(mrb_random_mt_g_rand(mrb, mrb_fixnum_value(RARRAY_LEN(ary))));
@@ -273,9 +274,9 @@ mrb_ary_shuffle_bang(mrb_state *mrb, mrb_value ary)
j = mrb_fixnum(mrb_random_mt_rand(mrb, DATA_PTR(random), mrb_fixnum_value(RARRAY_LEN(ary))));
}
- mrb_value t = RARRAY_PTR(ary)[i];
+ tmp = RARRAY_PTR(ary)[i];
RARRAY_PTR(ary)[i] = RARRAY_PTR(ary)[j];
- RARRAY_PTR(ary)[j] = t;
+ RARRAY_PTR(ary)[j] = tmp;
}
}
diff --git a/src/codegen.c b/src/codegen.c
index bb8cece7d..a27bd612e 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -402,8 +402,8 @@ new_lit(codegen_scope *s, mrb_value val)
switch (mrb_type(val)) {
case MRB_TT_STRING:
for (i=0; i<s->irep->plen; i++) {
- pv = &s->irep->pool[i];
mrb_int len;
+ pv = &s->irep->pool[i];
if (pv->type != MRB_TT_STRING) continue;
if ((len = pv->value.s->len) != RSTRING_LEN(val)) continue;