console.c in io-console-0.4.5 vs console.c in io-console-0.4.6
- old
+ new
@@ -12,10 +12,16 @@
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#ifndef RARRAY_CONST_PTR
+# define RARRAY_CONST_PTR(ary) RARRAY_PTR(ary)
+#endif
+#ifndef HAVE_RB_FUNCALLV
+# define rb_funcallv rb_funcall2
+#endif
#if defined HAVE_TERMIOS_H
# include <termios.h>
typedef struct termios conmode;
@@ -95,10 +101,14 @@
}
return rb_funcallv(recv, vid, argc, argv);
}
#endif
+#ifndef HAVE_RB_SYM2STR
+# define rb_sym2str(sym) rb_id2str(SYM2ID(sym))
+#endif
+
typedef struct {
int vmin;
int vtime;
} rawmode_arg_t;
@@ -376,11 +386,11 @@
}
static VALUE
getc_call(VALUE io)
{
- return rb_funcall2(io, id_getc, 0, 0);
+ return rb_funcallv(io, id_getc, 0, 0);
}
/*
* call-seq:
* io.getch(min: nil, time: nil) -> char
@@ -716,19 +726,21 @@
if (FIXNUM_P(k)) {
vk = NUM2UINT(k);
}
else {
const struct vktable *t;
+ const char *kn;
if (SYMBOL_P(k)) {
k = rb_sym2str(k);
+ kn = RSTRING_PTR(k);
}
else {
- StringValueCStr(k);
+ kn = StringValuePtr(k);
}
- t = console_win32_vk(RSTRING_PTR(k), RSTRING_LEN(k));
+ t = console_win32_vk(kn, RSTRING_LEN(k));
if (!t || (vk = (short)t->vk) == -1) {
- rb_raise(rb_eArgError, "unknown virtual key code: %"PRIsVALUE, k);
+ rb_raise(rb_eArgError, "unknown virtual key code: % "PRIsVALUE, k);
}
}
return GetKeyState(vk) & 0x80 ? Qtrue : Qfalse;
}
#else
@@ -842,10 +854,10 @@
* See IO#getch.
*/
static VALUE
io_getch(int argc, VALUE *argv, VALUE io)
{
- return rb_funcall2(io, id_getc, argc, argv);
+ return rb_funcallv(io, id_getc, argc, argv);
}
#if ENABLE_IO_GETPASS
static VALUE
puts_call(VALUE io)