clogger RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <bofh@yhbt.net>
To: clogger-public@yhbt.net
Subject: [PATCH] replace deprecated rb_iterate with rb_block_call
Date: Fri,  2 Feb 2024 07:46:55 +0000	[thread overview]
Message-ID: <20240202074655.1432299-1-bofh@yhbt.net> (raw)

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);

                 reply	other threads:[~2024-02-02  7:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/clogger/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240202074655.1432299-1-bofh@yhbt.net \
    --to=bofh@yhbt.net \
    --cc=clogger-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/clogger.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).