From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id A317C1F405 for ; Fri, 2 Feb 2024 07:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yhbt.net; s=selector1; t=1706860015; bh=JqR6U+JvLZ3aIqa08a+Kb6RyuI1THF7Wc10qQepQYOU=; h=From:To:Subject:Date:From; b=NqeK0T5vpm/o44VWxwtsdEs7XHYr0rJiBfAmNLwANlMDIzBlN9xrCcujxdfVuOzYu JyCLj+hvn4W/kNp+A4Sb6gX/Gf+6GYMtES3/fMROOP23QPyKbRLfko7C/5MFi8WPS7 CAyU/2vEJ0vzw5DxkNtTEsaEL8Uu0+4F7CHbxQf0= From: Eric Wong To: clogger-public@yhbt.net Subject: [PATCH] replace deprecated rb_iterate with rb_block_call Date: Fri, 2 Feb 2024 07:46:55 +0000 Message-ID: <20240202074655.1432299-1-bofh@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While rb_block_call appeared in Ruby 1.9, RB_BLOCK_CALL_FUNC_ARGLIST only appeared in 2.1 --- clogger.gemspec | 1 + ext/clogger_ext/clogger.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clogger.gemspec b/clogger.gemspec index 7a08dc5..306ed3b 100644 --- a/clogger.gemspec +++ b/clogger.gemspec @@ -5,6 +5,7 @@ s.name = %q{clogger} s.version = (ENV['VERSION'] || '2.4.0').dup s.homepage = 'https://YHBT.net/clogger/' + s.required_ruby_version = ">= 2.1.0" s.authors = ["cloggers"] s.summary = 'configurable request logging for Rack' s.description = File.read('README').split("\n\n")[1] diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c index cea4072..29c23b4 100644 --- a/ext/clogger_ext/clogger.c +++ b/ext/clogger_ext/clogger.c @@ -134,6 +134,7 @@ static ID sq_brace_id; static ID new_id; static ID to_path_id; static ID respond_to_id; +static ID each_id; static VALUE cClogger; static VALUE mFormat; static VALUE cRackHeaders; @@ -840,7 +841,7 @@ static VALUE clogger_init(int argc, VALUE *argv, VALUE self) return self; } -static VALUE body_iter_i(VALUE str, VALUE self) +static VALUE body_iter_i(RB_BLOCK_CALL_FUNC_ARGLIST(str, self)) { struct clogger *c = clogger_get(self); @@ -873,7 +874,7 @@ static VALUE clogger_each(VALUE self) rb_need_block(); c->body_bytes_sent = 0; - rb_iterate(rb_each, c->body, body_iter_i, self); + rb_block_call(c->body, each_id, 0, NULL, body_iter_i, self); return self; } @@ -1098,6 +1099,7 @@ void Init_clogger_ext(void) new_id = rb_intern("new"); to_path_id = rb_intern("to_path"); respond_to_id = rb_intern("respond_to?"); + each_id = rb_intern("each"); cClogger = rb_define_class("Clogger", rb_cObject); mFormat = rb_define_module_under(cClogger, "Format"); rb_define_alloc_func(cClogger, clogger_alloc);