From 8cbc1d00bea445ad39a8f370653673b2cc16457b Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sat, 10 Oct 2026 03:53:36 +0900 Subject: [PATCH] Use rb_len_t for the length of the winsize array Fall back to long when the Ruby headers do not provide rb_len_t, so nothing changes on the existing Rubies. https://bugs.ruby-lang.org/issues/22400 Co-Authored-By: Claude Opus 5.5 --- ext/io/console/console.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 0548d08..b85dbd3 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -10,6 +10,11 @@ IO_CONSOLE_VERSION = "0.9.4"; #include "ruby/io.h" #include "ruby/thread.h" +#ifndef HAVE_RB_LEN_T +typedef long rb_len_t; +# define PRIdLEN "ld" +#endif + #ifdef HAVE_UNISTD_H #include #endif @@ -1033,12 +1038,12 @@ console_set_winsize(VALUE io, VALUE size) #endif VALUE row, col, xpixel, ypixel; const VALUE *sz; - long sizelen; + rb_len_t sizelen; int fd; size = rb_Array(size); if ((sizelen = RARRAY_LEN(size)) != 2 && sizelen != 4) { - rb_raise(rb_eArgError, "wrong number of arguments (given %ld, expected 2 or 4)", sizelen); + rb_raise(rb_eArgError, "wrong number of arguments (given %"PRIdLEN", expected 2 or 4)", sizelen); } sz = RARRAY_CONST_PTR(size); row = sz[0], col = sz[1], xpixel = ypixel = Qnil;