From c9108e0385d2d2add77206e703bb2ede55fd1570 Mon Sep 17 00:00:00 2001 From: gogotanaka Date: Sun, 5 Oct 2014 15:37:44 -0700 Subject: [PATCH] Convert indent to spaces --- enumerator.c | 426 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 213 insertions(+), 213 deletions(-) diff --git a/enumerator.c b/enumerator.c index 75de8eb..25c3618 100644 --- a/enumerator.c +++ b/enumerator.c @@ -164,9 +164,9 @@ enumerator_memsize(const void *p) static const rb_data_type_t enumerator_data_type = { "enumerator", { - enumerator_mark, - enumerator_free, - enumerator_memsize, + enumerator_mark, + enumerator_free, + enumerator_memsize, }, NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY }; @@ -178,7 +178,7 @@ enumerator_ptr(VALUE obj) TypedData_Get_Struct(obj, struct enumerator, &enumerator_data_type, ptr); if (!ptr || ptr->obj == Qundef) { - rb_raise(rb_eArgError, "uninitialized enumerator"); + rb_raise(rb_eArgError, "uninitialized enumerator"); } return ptr; } @@ -244,12 +244,12 @@ obj_to_enum(int argc, VALUE *argv, VALUE obj) VALUE enumerator, meth = sym_each; if (argc > 0) { - --argc; - meth = *argv++; + --argc; + meth = *argv++; } enumerator = rb_enumeratorize_with_size(obj, meth, argc, argv, 0); if (rb_block_given_p()) { - enumerator_ptr(enumerator)->size = rb_block_proc(); + enumerator_ptr(enumerator)->size = rb_block_proc(); } return enumerator; } @@ -275,7 +275,7 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *ar TypedData_Get_Struct(enum_obj, struct enumerator, &enumerator_data_type, ptr); if (!ptr) { - rb_raise(rb_eArgError, "unallocated enumerator"); + rb_raise(rb_eArgError, "unallocated enumerator"); } ptr->obj = obj; @@ -337,9 +337,9 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj) VALUE size = Qnil; if (rb_block_given_p()) { - rb_check_arity(argc, 0, 1); - recv = generator_init(generator_allocate(rb_cGenerator), rb_block_proc()); - if (argc) { + rb_check_arity(argc, 0, 1); + recv = generator_init(generator_allocate(rb_cGenerator), rb_block_proc()); + if (argc) { if (NIL_P(argv[0]) || rb_respond_to(argv[0], id_call) || (RB_TYPE_P(argv[0], T_FLOAT) && RFLOAT_VALUE(argv[0]) == INFINITY)) { size = argv[0]; @@ -351,13 +351,13 @@ enumerator_initialize(int argc, VALUE *argv, VALUE obj) } } else { - rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); - rb_warn("Enumerator.new without a block is deprecated; use Object#to_enum"); - recv = *argv++; - if (--argc) { - meth = *argv++; - --argc; - } + rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS); + rb_warn("Enumerator.new without a block is deprecated; use Object#to_enum"); + recv = *argv++; + if (--argc) { + meth = *argv++; + --argc; + } } return enumerator_init(obj, recv, meth, argc, argv, 0, size); @@ -372,14 +372,14 @@ enumerator_init_copy(VALUE obj, VALUE orig) if (!OBJ_INIT_COPY(obj, orig)) return obj; ptr0 = enumerator_ptr(orig); if (ptr0->fib) { - /* Fibers cannot be copied */ - rb_raise(rb_eTypeError, "can't copy execution context"); + /* Fibers cannot be copied */ + rb_raise(rb_eTypeError, "can't copy execution context"); } TypedData_Get_Struct(obj, struct enumerator, &enumerator_data_type, ptr1); if (!ptr1) { - rb_raise(rb_eArgError, "unallocated enumerator"); + rb_raise(rb_eArgError, "unallocated enumerator"); } ptr1->obj = ptr0->obj; @@ -412,10 +412,10 @@ rb_enumeratorize_with_size(VALUE obj, VALUE meth, int argc, const VALUE *argv, r /* Similar effect as calling obj.to_enum, i.e. dispatching to either Kernel#to_enum vs Lazy#to_enum */ if (RTEST(rb_obj_is_kind_of(obj, rb_cLazy))) - return lazy_to_enum_i(obj, meth, argc, argv, size_fn); + return lazy_to_enum_i(obj, meth, argc, argv, size_fn); else - return enumerator_init(enumerator_allocate(rb_cEnumerator), - obj, meth, argc, argv, size_fn, Qnil); + return enumerator_init(enumerator_allocate(rb_cEnumerator), + obj, meth, argc, argv, size_fn, Qnil); } static VALUE @@ -427,8 +427,8 @@ enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg) ID meth = e->meth; if (e->args) { - argc = RARRAY_LENINT(e->args); - argv = RARRAY_CONST_PTR(e->args); + argc = RARRAY_LENINT(e->args); + argv = RARRAY_CONST_PTR(e->args); } return rb_block_call(e->obj, meth, argc, argv, func, arg); } @@ -473,20 +473,20 @@ static VALUE enumerator_each(int argc, VALUE *argv, VALUE obj) { if (argc > 0) { - struct enumerator *e = enumerator_ptr(obj = rb_obj_dup(obj)); - VALUE args = e->args; - if (args) { + struct enumerator *e = enumerator_ptr(obj = rb_obj_dup(obj)); + VALUE args = e->args; + if (args) { #if SIZEOF_INT < SIZEOF_LONG - /* check int range overflow */ - rb_long2int(RARRAY_LEN(args) + argc); + /* check int range overflow */ + rb_long2int(RARRAY_LEN(args) + argc); #endif - args = rb_ary_dup(args); - rb_ary_cat(args, argv, argc); - } - else { - args = rb_ary_new4(argc, argv); - } - e->args = args; + args = rb_ary_dup(args); + rb_ary_cat(args, argv, argc); + } + else { + args = rb_ary_new4(argc, argv); + } + e->args = args; } if (!rb_block_given_p()) return obj; return enumerator_block_call(obj, 0, obj); @@ -500,7 +500,7 @@ enumerator_with_index_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) memo->u1.value = rb_int_succ(idx); if (argc <= 1) - return rb_yield_values(2, val, idx); + return rb_yield_values(2, val, idx); return rb_yield_values(2, rb_ary_new4(argc, argv), idx); } @@ -534,9 +534,9 @@ enumerator_with_index(int argc, VALUE *argv, VALUE obj) rb_scan_args(argc, argv, "01", &memo); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_enum_size); if (NIL_P(memo)) - memo = INT2FIX(0); + memo = INT2FIX(0); else - memo = rb_to_int(memo); + memo = rb_to_int(memo); return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)NEW_MEMO(memo, 0, 0)); } @@ -560,7 +560,7 @@ static VALUE enumerator_with_object_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, memo)) { if (argc <= 1) - return rb_yield_values(2, val, memo); + return rb_yield_values(2, val, memo); return rb_yield_values(2, rb_ary_new4(argc, argv), memo); } @@ -645,21 +645,21 @@ get_next_values(VALUE obj, struct enumerator *e) VALUE curr, vs; if (e->stop_exc) - rb_exc_raise(e->stop_exc); + rb_exc_raise(e->stop_exc); curr = rb_fiber_current(); if (!e->fib || !rb_fiber_alive_p(e->fib)) { - next_init(obj, e); + next_init(obj, e); } vs = rb_fiber_resume(e->fib, 1, &curr); if (e->stop_exc) { - e->fib = 0; - e->dst = Qnil; - e->lookahead = Qundef; - e->feedvalue = Qundef; - rb_exc_raise(e->stop_exc); + e->fib = 0; + e->dst = Qnil; + e->lookahead = Qundef; + e->feedvalue = Qundef; + rb_exc_raise(e->stop_exc); } return vs; } @@ -901,7 +901,7 @@ enumerator_feed(VALUE obj, VALUE v) struct enumerator *e = enumerator_ptr(obj); if (e->feedvalue != Qundef) { - rb_raise(rb_eTypeError, "feed value already set"); + rb_raise(rb_eTypeError, "feed value already set"); } e->feedvalue = v; @@ -945,18 +945,18 @@ inspect_enumerator(VALUE obj, VALUE dummy, int recur) cname = rb_obj_class(obj); if (!e || e->obj == Qundef) { - return rb_sprintf("#<%"PRIsVALUE": uninitialized>", rb_class_path(cname)); + return rb_sprintf("#<%"PRIsVALUE": uninitialized>", rb_class_path(cname)); } if (recur) { - str = rb_sprintf("#<%"PRIsVALUE": ...>", rb_class_path(cname)); - OBJ_TAINT(str); - return str; + str = rb_sprintf("#<%"PRIsVALUE": ...>", rb_class_path(cname)); + OBJ_TAINT(str); + return str; } eobj = rb_attr_get(obj, id_receiver); if (NIL_P(eobj)) { - eobj = e->obj; + eobj = e->obj; } /* (1..100).each_cons(2) => "#" */ @@ -975,36 +975,36 @@ append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args) method = rb_attr_get(obj, id_method); if (method != Qfalse) { - if (!NIL_P(method)) { - Check_Type(method, T_SYMBOL); - method = rb_sym2str(method); - } - else { - method = rb_id2str(default_method); - } - rb_str_buf_cat2(str, ":"); - rb_str_buf_append(str, method); + if (!NIL_P(method)) { + Check_Type(method, T_SYMBOL); + method = rb_sym2str(method); + } + else { + method = rb_id2str(default_method); + } + rb_str_buf_cat2(str, ":"); + rb_str_buf_append(str, method); } eargs = rb_attr_get(obj, id_arguments); if (NIL_P(eargs)) { - eargs = default_args; + eargs = default_args; } if (eargs != Qfalse) { - long argc = RARRAY_LEN(eargs); - const VALUE *argv = RARRAY_CONST_PTR(eargs); /* WB: no new reference */ + long argc = RARRAY_LEN(eargs); + const VALUE *argv = RARRAY_CONST_PTR(eargs); /* WB: no new reference */ - if (argc > 0) { - rb_str_buf_cat2(str, "("); + if (argc > 0) { + rb_str_buf_cat2(str, "("); - while (argc--) { - VALUE arg = *argv++; + while (argc--) { + VALUE arg = *argv++; - rb_str_append(str, rb_inspect(arg)); - rb_str_buf_cat2(str, argc > 0 ? ", " : ")"); - OBJ_INFECT(str, arg); - } - } + rb_str_append(str, rb_inspect(arg)); + rb_str_buf_cat2(str, argc > 0 ? ", " : ")"); + OBJ_INFECT(str, arg); + } + } } return str; @@ -1043,11 +1043,11 @@ enumerator_size(VALUE obj) VALUE size; if (e->size_fn) { - return (*e->size_fn)(e->obj, e->args, obj); + return (*e->size_fn)(e->obj, e->args, obj); } if (e->args) { - argc = (int)RARRAY_LEN(e->args); - argv = RARRAY_CONST_PTR(e->args); + argc = (int)RARRAY_LEN(e->args); + argv = RARRAY_CONST_PTR(e->args); } size = rb_check_funcall(e->size, id_call, argc, argv); if (size != Qundef) return size; @@ -1075,9 +1075,9 @@ yielder_memsize(const void *p) static const rb_data_type_t yielder_data_type = { "yielder", { - yielder_mark, - yielder_free, - yielder_memsize, + yielder_mark, + yielder_free, + yielder_memsize, }, NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY }; @@ -1089,7 +1089,7 @@ yielder_ptr(VALUE obj) TypedData_Get_Struct(obj, struct yielder, &yielder_data_type, ptr); if (!ptr || ptr->proc == Qundef) { - rb_raise(rb_eArgError, "uninitialized yielder"); + rb_raise(rb_eArgError, "uninitialized yielder"); } return ptr; } @@ -1115,7 +1115,7 @@ yielder_init(VALUE obj, VALUE proc) TypedData_Get_Struct(obj, struct yielder, &yielder_data_type, ptr); if (!ptr) { - rb_raise(rb_eArgError, "unallocated yielder"); + rb_raise(rb_eArgError, "unallocated yielder"); } ptr->proc = proc; @@ -1182,9 +1182,9 @@ generator_memsize(const void *p) static const rb_data_type_t generator_data_type = { "generator", { - generator_mark, - generator_free, - generator_memsize, + generator_mark, + generator_free, + generator_memsize, }, NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY }; @@ -1196,7 +1196,7 @@ generator_ptr(VALUE obj) TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr); if (!ptr || ptr->proc == Qundef) { - rb_raise(rb_eArgError, "uninitialized generator"); + rb_raise(rb_eArgError, "uninitialized generator"); } return ptr; } @@ -1223,7 +1223,7 @@ generator_init(VALUE obj, VALUE proc) TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr); if (!ptr) { - rb_raise(rb_eArgError, "unallocated generator"); + rb_raise(rb_eArgError, "unallocated generator"); } ptr->proc = proc; @@ -1238,21 +1238,21 @@ generator_initialize(int argc, VALUE *argv, VALUE obj) VALUE proc; if (argc == 0) { - rb_need_block(); + rb_need_block(); - proc = rb_block_proc(); + proc = rb_block_proc(); } else { - rb_scan_args(argc, argv, "1", &proc); + rb_scan_args(argc, argv, "1", &proc); - if (!rb_obj_is_proc(proc)) - rb_raise(rb_eTypeError, - "wrong argument type %s (expected Proc)", - rb_obj_classname(proc)); + if (!rb_obj_is_proc(proc)) + rb_raise(rb_eTypeError, + "wrong argument type %s (expected Proc)", + rb_obj_classname(proc)); - if (rb_block_given_p()) { - rb_warn("given block not used"); - } + if (rb_block_given_p()) { + rb_warn("given block not used"); + } } return generator_init(obj, proc); @@ -1271,7 +1271,7 @@ generator_init_copy(VALUE obj, VALUE orig) TypedData_Get_Struct(obj, struct generator, &generator_data_type, ptr1); if (!ptr1) { - rb_raise(rb_eArgError, "unallocated generator"); + rb_raise(rb_eArgError, "unallocated generator"); } ptr1->proc = ptr0->proc; @@ -1288,7 +1288,7 @@ generator_each(int argc, VALUE *argv, VALUE obj) rb_ary_push(args, yielder_new()); if (argc > 0) { - rb_ary_cat(args, argv, argc); + rb_ary_cat(args, argv, argc); } return rb_proc_call(ptr->proc, args); @@ -1325,22 +1325,22 @@ lazy_init_iterator(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) { VALUE result; if (argc == 1) { - VALUE args[2]; - args[0] = m; - args[1] = val; - result = rb_yield_values2(2, args); + VALUE args[2]; + args[0] = m; + args[1] = val; + result = rb_yield_values2(2, args); } else { - VALUE args; - int len = rb_long2int((long)argc + 1); + VALUE args; + int len = rb_long2int((long)argc + 1); - args = rb_ary_tmp_new(len); - rb_ary_push(args, m); - if (argc > 0) { - rb_ary_cat(args, argv, argc); - } - result = rb_yield_values2(len, RARRAY_CONST_PTR(args)); - RB_GC_GUARD(args); + args = rb_ary_tmp_new(len); + rb_ary_push(args, m); + if (argc > 0) { + rb_ary_cat(args, argv, argc); + } + result = rb_yield_values2(len, RARRAY_CONST_PTR(args)); + RB_GC_GUARD(args); } if (result == Qundef) rb_iter_break(); return Qnil; @@ -1389,11 +1389,11 @@ lazy_initialize(int argc, VALUE *argv, VALUE self) rb_check_arity(argc, 1, 2); if (!rb_block_given_p()) { - rb_raise(rb_eArgError, "tried to call lazy new without a block"); + rb_raise(rb_eArgError, "tried to call lazy new without a block"); } obj = argv[0]; if (argc > 1) { - size = argv[1]; + size = argv[1]; } generator = generator_allocate(rb_cGenerator); rb_block_call(generator, id_initialize, 0, 0, lazy_init_block_i, obj); @@ -1410,11 +1410,11 @@ lazy_set_method(VALUE lazy, VALUE args, rb_enumerator_size_func *size_fn) struct enumerator *e = enumerator_ptr(lazy); rb_ivar_set(lazy, id_method, ID2SYM(id)); if (NIL_P(args)) { - /* Qfalse indicates that the arguments are empty */ - rb_ivar_set(lazy, id_arguments, Qfalse); + /* Qfalse indicates that the arguments are empty */ + rb_ivar_set(lazy, id_arguments, Qfalse); } else { - rb_ivar_set(lazy, id_arguments, args); + rb_ivar_set(lazy, id_arguments, args); } e->size_fn = size_fn; return lazy; @@ -1464,7 +1464,7 @@ static VALUE lazy_to_enum_i(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator_size_func *size_fn) { return enumerator_init(enumerator_allocate(rb_cLazy), - obj, meth, argc, argv, size_fn, Qnil); + obj, meth, argc, argv, size_fn, Qnil); } /* @@ -1496,12 +1496,12 @@ lazy_to_enum(int argc, VALUE *argv, VALUE self) VALUE lazy, meth = sym_each; if (argc > 0) { - --argc; - meth = *argv++; + --argc; + meth = *argv++; } lazy = lazy_to_enum_i(self, meth, argc, argv, 0); if (rb_block_given_p()) { - enumerator_ptr(lazy)->size = rb_block_proc(); + enumerator_ptr(lazy)->size = rb_block_proc(); } return lazy; } @@ -1519,12 +1519,12 @@ static VALUE lazy_map(VALUE obj) { if (!rb_block_given_p()) { - rb_raise(rb_eArgError, "tried to call lazy map without a block"); + rb_raise(rb_eArgError, "tried to call lazy map without a block"); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_map_func, 0), - Qnil, lazy_receiver_size); + lazy_map_func, 0), + Qnil, lazy_receiver_size); } static VALUE @@ -1545,13 +1545,13 @@ lazy_flat_map_to_ary(VALUE obj, VALUE yielder) { VALUE ary = rb_check_array_type(obj); if (NIL_P(ary)) { - rb_funcall(yielder, id_yield, 1, obj); + rb_funcall(yielder, id_yield, 1, obj); } else { - long i; - for (i = 0; i < RARRAY_LEN(ary); i++) { - rb_funcall(yielder, id_yield, 1, RARRAY_AREF(ary, i)); - } + long i; + for (i = 0; i < RARRAY_LEN(ary); i++) { + rb_funcall(yielder, id_yield, 1, RARRAY_AREF(ary, i)); + } } return Qnil; } @@ -1561,18 +1561,18 @@ lazy_flat_map_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) { VALUE result = rb_yield_values2(argc - 1, &argv[1]); if (RB_TYPE_P(result, T_ARRAY)) { - long i; - for (i = 0; i < RARRAY_LEN(result); i++) { - rb_funcall(argv[0], id_yield, 1, RARRAY_AREF(result, i)); - } + long i; + for (i = 0; i < RARRAY_LEN(result); i++) { + rb_funcall(argv[0], id_yield, 1, RARRAY_AREF(result, i)); + } } else { - if (rb_respond_to(result, id_force) && rb_respond_to(result, id_each)) { - lazy_flat_map_each(result, argv[0]); - } - else { - lazy_flat_map_to_ary(result, argv[0]); - } + if (rb_respond_to(result, id_force) && rb_respond_to(result, id_each)) { + lazy_flat_map_each(result, argv[0]); + } + else { + lazy_flat_map_to_ary(result, argv[0]); + } } return Qnil; } @@ -1604,12 +1604,12 @@ static VALUE lazy_flat_map(VALUE obj) { if (!rb_block_given_p()) { - rb_raise(rb_eArgError, "tried to call lazy flat_map without a block"); + rb_raise(rb_eArgError, "tried to call lazy flat_map without a block"); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_flat_map_func, 0), - Qnil, 0); + lazy_flat_map_func, 0), + Qnil, 0); } static VALUE @@ -1618,7 +1618,7 @@ lazy_select_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) VALUE element = rb_enum_values_pack(argc - 1, argv + 1); if (RTEST(rb_yield(element))) { - return rb_funcall(argv[0], id_yield, 1, element); + return rb_funcall(argv[0], id_yield, 1, element); } return Qnil; } @@ -1627,12 +1627,12 @@ static VALUE lazy_select(VALUE obj) { if (!rb_block_given_p()) { - rb_raise(rb_eArgError, "tried to call lazy select without a block"); + rb_raise(rb_eArgError, "tried to call lazy select without a block"); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_select_func, 0), - Qnil, 0); + lazy_select_func, 0), + Qnil, 0); } static VALUE @@ -1641,7 +1641,7 @@ lazy_reject_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) VALUE element = rb_enum_values_pack(argc - 1, argv + 1); if (!RTEST(rb_yield(element))) { - return rb_funcall(argv[0], id_yield, 1, element); + return rb_funcall(argv[0], id_yield, 1, element); } return Qnil; } @@ -1650,12 +1650,12 @@ static VALUE lazy_reject(VALUE obj) { if (!rb_block_given_p()) { - rb_raise(rb_eArgError, "tried to call lazy reject without a block"); + rb_raise(rb_eArgError, "tried to call lazy reject without a block"); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_reject_func, 0), - Qnil, 0); + lazy_reject_func, 0), + Qnil, 0); } static VALUE @@ -1665,7 +1665,7 @@ lazy_grep_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) VALUE result = rb_funcall(m, id_eqq, 1, i); if (RTEST(result)) { - rb_funcall(argv[0], id_yield, 1, i); + rb_funcall(argv[0], id_yield, 1, i); } return Qnil; } @@ -1677,7 +1677,7 @@ lazy_grep_iter(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) VALUE result = rb_funcall(m, id_eqq, 1, i); if (RTEST(result)) { - rb_funcall(argv[0], id_yield, 1, rb_yield(i)); + rb_funcall(argv[0], id_yield, 1, rb_yield(i)); } return Qnil; } @@ -1686,10 +1686,10 @@ static VALUE lazy_grep(VALUE obj, VALUE pattern) { return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - rb_block_given_p() ? - lazy_grep_iter : lazy_grep_func, - pattern), - rb_ary_new3(1, pattern), 0); + rb_block_given_p() ? + lazy_grep_iter : lazy_grep_func, + pattern), + rb_ary_new3(1, pattern), 0); } static VALUE @@ -1717,7 +1717,7 @@ lazy_zip_arrays_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, arrays)) ary = rb_ary_new2(RARRAY_LEN(arrays) + 1); rb_ary_push(ary, argv[1]); for (i = 0; i < RARRAY_LEN(arrays); i++) { - rb_ary_push(ary, rb_ary_entry(RARRAY_AREF(arrays, i), count)); + rb_ary_push(ary, rb_ary_entry(RARRAY_AREF(arrays, i), count)); } rb_funcall(yielder, id_yield, 1, ary); rb_ivar_set(yielder, id_memo, LONG2NUM(++count)); @@ -1733,24 +1733,24 @@ lazy_zip_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, zip_args)) yielder = argv[0]; arg = rb_attr_get(yielder, id_memo); if (NIL_P(arg)) { - arg = rb_ary_new2(RARRAY_LEN(zip_args)); - for (i = 0; i < RARRAY_LEN(zip_args); i++) { - rb_ary_push(arg, rb_funcall(RARRAY_AREF(zip_args, i), id_to_enum, 0)); - } - rb_ivar_set(yielder, id_memo, arg); + arg = rb_ary_new2(RARRAY_LEN(zip_args)); + for (i = 0; i < RARRAY_LEN(zip_args); i++) { + rb_ary_push(arg, rb_funcall(RARRAY_AREF(zip_args, i), id_to_enum, 0)); + } + rb_ivar_set(yielder, id_memo, arg); } ary = rb_ary_new2(RARRAY_LEN(arg) + 1); v = Qnil; if (--argc > 0) { - ++argv; - v = argc > 1 ? rb_ary_new_from_values(argc, argv) : *argv; + ++argv; + v = argc > 1 ? rb_ary_new_from_values(argc, argv) : *argv; } rb_ary_push(ary, v); for (i = 0; i < RARRAY_LEN(arg); i++) { - v = rb_rescue2(call_next, RARRAY_AREF(arg, i), next_stopped, 0, - rb_eStopIteration, (VALUE)0); - rb_ary_push(ary, v); + v = rb_rescue2(call_next, RARRAY_AREF(arg, i), next_stopped, 0, + rb_eStopIteration, (VALUE)0); + rb_ary_push(ary, v); } rb_funcall(yielder, id_yield, 1, ary); return Qnil; @@ -1764,29 +1764,29 @@ lazy_zip(int argc, VALUE *argv, VALUE obj) rb_block_call_func *func = lazy_zip_arrays_func; if (rb_block_given_p()) { - return rb_call_super(argc, argv); + return rb_call_super(argc, argv); } ary = rb_ary_new2(argc); for (i = 0; i < argc; i++) { - v = rb_check_array_type(argv[i]); - if (NIL_P(v)) { - for (; i < argc; i++) { - if (!rb_respond_to(argv[i], id_each)) { - rb_raise(rb_eTypeError, "wrong argument type %s (must respond to :each)", - rb_obj_classname(argv[i])); - } - } - ary = rb_ary_new4(argc, argv); - func = lazy_zip_func; - break; - } - rb_ary_push(ary, v); + v = rb_check_array_type(argv[i]); + if (NIL_P(v)) { + for (; i < argc; i++) { + if (!rb_respond_to(argv[i], id_each)) { + rb_raise(rb_eTypeError, "wrong argument type %s (must respond to :each)", + rb_obj_classname(argv[i])); + } + } + ary = rb_ary_new4(argc, argv); + func = lazy_zip_func; + break; + } + rb_ary_push(ary, v); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - func, ary), - ary, lazy_receiver_size); + func, ary), + ary, lazy_receiver_size); } static VALUE @@ -1795,16 +1795,16 @@ lazy_take_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, args)) long remain; VALUE memo = rb_attr_get(argv[0], id_memo); if (NIL_P(memo)) { - memo = args; + memo = args; } rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); if ((remain = NUM2LONG(memo)-1) == 0) { - return Qundef; + return Qundef; } else { - rb_ivar_set(argv[0], id_memo, LONG2NUM(remain)); - return Qnil; + rb_ivar_set(argv[0], id_memo, LONG2NUM(remain)); + return Qnil; } } @@ -1814,7 +1814,7 @@ lazy_take_size(VALUE generator, VALUE args, VALUE lazy) VALUE receiver = lazy_size(lazy); long len = NUM2LONG(RARRAY_AREF(rb_ivar_get(lazy, id_arguments), 0)); if (NIL_P(receiver) || (FIXNUM_P(receiver) && FIX2LONG(receiver) < len)) - return receiver; + return receiver; return LONG2NUM(len); } @@ -1825,15 +1825,15 @@ lazy_take(VALUE obj, VALUE n) VALUE lazy; if (len < 0) { - rb_raise(rb_eArgError, "attempt to take negative size"); + rb_raise(rb_eArgError, "attempt to take negative size"); } if (len == 0) { - VALUE len = INT2FIX(0); - lazy = lazy_to_enum_i(obj, sym_cycle, 1, &len, 0); + VALUE len = INT2FIX(0); + lazy = lazy_to_enum_i(obj, sym_cycle, 1, &len, 0); } else { - lazy = rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_take_func, n); + lazy = rb_block_call(rb_cLazy, id_new, 1, &obj, + lazy_take_func, n); } return lazy_set_method(lazy, rb_ary_new3(1, n), lazy_take_size); } @@ -1851,11 +1851,11 @@ static VALUE lazy_take_while(VALUE obj) { if (!rb_block_given_p()) { - rb_raise(rb_eArgError, "tried to call lazy take_while without a block"); + rb_raise(rb_eArgError, "tried to call lazy take_while without a block"); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_take_while_func, 0), - Qnil, 0); + lazy_take_while_func, 0), + Qnil, 0); } static VALUE @@ -1864,10 +1864,10 @@ lazy_drop_size(VALUE generator, VALUE args, VALUE lazy) long len = NUM2LONG(RARRAY_AREF(rb_ivar_get(lazy, id_arguments), 0)); VALUE receiver = lazy_size(lazy); if (NIL_P(receiver)) - return receiver; + return receiver; if (FIXNUM_P(receiver)) { - len = FIX2LONG(receiver) - len; - return LONG2FIX(len < 0 ? 0 : len); + len = FIX2LONG(receiver) - len; + return LONG2FIX(len < 0 ? 0 : len); } return rb_funcall(receiver, '-', 1, LONG2NUM(len)); } @@ -1878,13 +1878,13 @@ lazy_drop_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, args)) long remain; VALUE memo = rb_attr_get(argv[0], id_memo); if (NIL_P(memo)) { - memo = args; + memo = args; } if ((remain = NUM2LONG(memo)) == 0) { - rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); + rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); } else { - rb_ivar_set(argv[0], id_memo, LONG2NUM(--remain)); + rb_ivar_set(argv[0], id_memo, LONG2NUM(--remain)); } return Qnil; } @@ -1895,11 +1895,11 @@ lazy_drop(VALUE obj, VALUE n) long len = NUM2LONG(n); if (len < 0) { - rb_raise(rb_eArgError, "attempt to drop negative size"); + rb_raise(rb_eArgError, "attempt to drop negative size"); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_drop_func, n), - rb_ary_new3(1, n), lazy_drop_size); + lazy_drop_func, n), + rb_ary_new3(1, n), lazy_drop_size); } static VALUE @@ -1907,10 +1907,10 @@ lazy_drop_while_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, args)) { VALUE memo = rb_attr_get(argv[0], id_memo); if (NIL_P(memo) && !RTEST(rb_yield_values2(argc - 1, &argv[1]))) { - rb_ivar_set(argv[0], id_memo, memo = Qtrue); + rb_ivar_set(argv[0], id_memo, memo = Qtrue); } if (memo == Qtrue) { - rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); + rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); } return Qnil; } @@ -1919,11 +1919,11 @@ static VALUE lazy_drop_while(VALUE obj) { if (!rb_block_given_p()) { - rb_raise(rb_eArgError, "tried to call lazy drop_while without a block"); + rb_raise(rb_eArgError, "tried to call lazy drop_while without a block"); } return lazy_set_method(rb_block_call(rb_cLazy, id_new, 1, &obj, - lazy_drop_while_func, 0), - Qnil, 0); + lazy_drop_while_func, 0), + Qnil, 0); } static VALUE @@ -2062,7 +2062,7 @@ InitVM_Enumerator(void) rb_define_method(rb_cYielder, "yield", yielder_yield, -2); rb_define_method(rb_cYielder, "<<", yielder_yield_push, -2); - rb_provide("enumerator.so"); /* for backward compatibility */ + rb_provide("enumerator.so"); /* for backward compatibility */ } #undef rb_intern -- 1.8.5.2 (Apple Git-48)