ruby-ncurses/ruby-ncurses-1.3.1-use-new-rb_thread_fd_select-avoiding-deprecated-functions.patch
2015-09-02 18:39:14 +02:00

58 lines
2.0 KiB
Diff

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;