Fix Ruby 2.2 compatibility.

This commit is contained in:
Vít Ondruch 2015-09-02 18:38:45 +02:00
parent c69e485703
commit 4fa3d5e3dc
2 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,57 @@
From 809e549408bfdf7cab4b98a73f6e78dd3ad81d86 Mon Sep 17 00:00:00 2001
From: Gaute Hope <eg@gaute.vetsj.com>
Date: Wed, 1 May 2013 15:10:26 +0200
Subject: [PATCH] ncurses_wrap.c: use new rb_thread_fd_select avoiding
deprecated functions
---
ncurses_wrap.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index 7793fcb..ba1e921 100755
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -836,20 +836,28 @@ static int rbncurshelper_nonblocking_wgetch(WINDOW *c_win) {
c_win->_delay = 0;
#endif
while (doupdate() /* detects resize */, (result = wgetch(c_win)) == ERR) {
- gettimeofday(&tv, &tz);
- nowtime = tv.tv_sec + tv.tv_usec * 1e-6;
- delay = finishtime - nowtime;
- if (delay <= 0) break;
-
- /* Check for terminal size change every resize_delay seconds */
- if (resize_delay > delay) resize_delay = delay;
- tv.tv_sec = (time_t)resize_delay;
- tv.tv_usec = (unsigned)( (resize_delay - tv.tv_sec) * 1e6 );
-
- /* sleep on infd until input is available or tv reaches timeout */
- FD_ZERO(&in_fds);
- FD_SET(infd, &in_fds);
- rb_thread_select(infd + 1, &in_fds, NULL, NULL, &tv);
+ rb_fdset_t fdsets[3];
+ rb_fdset_t *rfds = NULL;
+ gettimeofday(&tv, &tz);
+ nowtime = tv.tv_sec + tv.tv_usec * 1e-6;
+ delay = finishtime - nowtime;
+ if (delay <= 0) break;
+
+ /* Check for terminal size change every resize_delay seconds */
+ if (resize_delay > delay) resize_delay = delay;
+ tv.tv_sec = (time_t)resize_delay;
+ tv.tv_usec = (unsigned)( (resize_delay - tv.tv_sec) * 1e6 );
+
+ /* sleep on infd until input is available or tv reaches timeout */
+ FD_ZERO(&in_fds);
+ FD_SET(infd, &in_fds);
+ //rb_thread_fd_select(infd + 1, &in_fds, NULL, NULL, &tv);
+
+ rfds = &fdsets[0];
+ rb_fd_init(rfds);
+ rb_fd_copy(rfds, &in_fds, infd +1);
+
+ rb_thread_fd_select(infd + 1, rfds, NULL, NULL, &tv);
}
#ifdef NCURSES_VERSION
c_win->_delay = windelay;

View File

@ -3,7 +3,7 @@
Name: %distname
Version: 1.3.1
Release: 15%{?dist}
Release: 16%{?dist}
Summary: A module for ruby applications for using ncurses interfaces
Group: System Environment/Libraries
License: LGPLv2+
@ -14,6 +14,10 @@ Patch1: 0002-Werror-format-security.patch
# Fixes "ncurses_wrap.c:827:12: error: variable 'tz' has initializer but incomplete type"
# https://github.com/eclubb/ncurses-ruby/commit/0f7decd5e5a205444c9d31f19b0599a7e42b0fd8
Patch2: ruby-ncurses-fix-missing-tz-prototypes.patch
# rb_thread_select was removed from Ruby 2.2.
# https://bugs.ruby-lang.org/issues/9502#change-45212
# https://github.com/sup-heliotrope/ncursesw-ruby/commit/809e549408bfdf7cab4b98a73f6e78dd3ad81d86
Patch3: ruby-ncurses-1.3.1-use-new-rb_thread_fd_select-avoiding-deprecated-functions.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ruby(release)
BuildRequires: ruby
@ -32,6 +36,7 @@ of the C library ncurses accessible from the Ruby programming language.
%patch0 -p1 -b .p
%patch1 -p1 -b .format
%patch2 -p1 -b .systime
%patch3 -p1 -b .ruby22
%{__chmod} 0644 ncurses_wrap.c
find examples/ -type f | xargs %{__chmod} 0644
@ -57,6 +62,9 @@ ruby extconf.rb --vendor
%{ruby_vendorlibdir}/ncurses_sugar.rb
%changelog
* Wed Sep 02 2015 Vít Ondruch <vondruch@redhat.com> - 1.3.1-16
- Fix Ruby 2.2 compatibility.
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.3.1-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild