diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-12-31 15:28:11 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-31 15:28:11 +0900 |
| commit | 9fc26eacd17394a20c49315b9996dbfbd73ce238 (patch) | |
| tree | 9f2cfa4d057831d443afb7faedae2ec1acbc4814 /mrbgems/mruby-array-ext/src/array.c | |
| parent | b9e1b9b32852e2fb5836c1d4fd622a5a9a41119e (diff) | |
| parent | a137ef12f981b517f1e6b64e39edc7ac15d7e1eb (diff) | |
| download | mruby-9fc26eacd17394a20c49315b9996dbfbd73ce238.tar.gz mruby-9fc26eacd17394a20c49315b9996dbfbd73ce238.zip | |
Merge pull request #5619 from dearblue/properties
Get object properties after `mrb_get_args()`
Diffstat (limited to 'mrbgems/mruby-array-ext/src/array.c')
| -rw-r--r-- | mrbgems/mruby-array-ext/src/array.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/mrbgems/mruby-array-ext/src/array.c b/mrbgems/mruby-array-ext/src/array.c index d97778642..ae8a55d4d 100644 --- a/mrbgems/mruby-array-ext/src/array.c +++ b/mrbgems/mruby-array-ext/src/array.c @@ -264,12 +264,14 @@ mrb_ary_compact_bang(mrb_state *mrb, mrb_value self) static mrb_value mrb_ary_rotate(mrb_state *mrb, mrb_value self) { + mrb_int count=1; + mrb_get_args(mrb, "|i", &count); + mrb_value ary = mrb_ary_new(mrb); mrb_int len = RARRAY_LEN(self); mrb_value *p = RARRAY_PTR(self); - mrb_int count=1, idx; + mrb_int idx; - mrb_get_args(mrb, "|i", &count); if (len <= 0) return ary; if (count < 0) { idx = len - (~count % len) - 1; @@ -313,12 +315,14 @@ rev(mrb_value *p, mrb_int beg, mrb_int end) static mrb_value mrb_ary_rotate_bang(mrb_state *mrb, mrb_value self) { + mrb_int count=1; + mrb_get_args(mrb, "|i", &count); + struct RArray *a = mrb_ary_ptr(self); mrb_int len = ARY_LEN(a); mrb_value *p = ARY_PTR(a); - mrb_int count=1, idx; + mrb_int idx; - mrb_get_args(mrb, "|i", &count); mrb_ary_modify(mrb, a); if (len == 0 || count == 0) return self; if (count == 1) { |
