ruby-changes:27216
From: nobu <ko1@a...>
Date: Sat, 16 Feb 2013 12:46:43 +0900 (JST)
Subject: [ruby-changes:27216] nobu:r39268 (trunk): io/console: compatibility with 1.9
nobu 2013-02-16 12:46:34 +0900 (Sat, 16 Feb 2013) New Revision: 39268 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39268 Log: io/console: compatibility with 1.9 * ext/io/console/console.c (rawmode_opt, console_dev): compatibility with ruby 1.9. [ruby-core:52220] [Bug #7847] Modified files: trunk/ChangeLog trunk/ext/io/console/console.c trunk/ext/io/console/extconf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39267) +++ ChangeLog (revision 39268) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Feb 16 12:46:32 2013 Nobuyoshi Nakada <nobu@r...> + + * ext/io/console/console.c (rawmode_opt, console_dev): compatibility + with ruby 1.9. [ruby-core:52220] [Bug #7847] + Sat Feb 16 12:45:50 2013 Nobuyoshi Nakada <nobu@r...> * configure.in: unexpand arch sitearch and exec_prefix values, so Index: ext/io/console/console.c =================================================================== --- ext/io/console/console.c (revision 39267) +++ ext/io/console/console.c (revision 39268) @@ -23,6 +23,10 @@ typedef OpenFile rb_io_t; https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L23 #include <sys/ioctl.h> #endif +#ifndef RB_TYPE_P +#define RB_TYPE_P(obj, type) (TYPE(obj) == type) +#endif + #if defined HAVE_TERMIOS_H # include <termios.h> typedef struct termios conmode; @@ -101,7 +105,23 @@ rawmode_opt(int argc, VALUE *argv, rawmo https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L105 { rawmode_arg_t *optp = NULL; VALUE vopts; +#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH rb_scan_args(argc, argv, "0:", &vopts); +#else + vopts = Qnil; + if (argc > 0) { + vopts = argv[--argc]; + if (!NIL_P(vopts)) { +# ifdef HAVE_RB_CHECK_HASH_TYPE + vopts = rb_check_hash_type(vopts); + if (NIL_P(vopts)) ++argc; +# else + Check_Type(vopts, T_HASH); +# endif + } + } + rb_scan_args(argc, argv, "0"); +#endif if (!NIL_P(vopts)) { VALUE vmin = rb_hash_aref(vopts, ID2SYM(rb_intern("min"))); VALUE vtime = rb_hash_aref(vopts, ID2SYM(rb_intern("time"))); @@ -644,6 +664,23 @@ console_ioflush(VALUE io) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L664 return io; } +#ifndef HAVE_RB_CLOEXEC_OPEN +static int +rb_cloexec_open(const char *pathname, int flags, mode_t mode) +{ + int ret; +#ifdef O_CLOEXEC + /* O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */ + flags |= O_CLOEXEC; +#elif defined O_NOINHERIT + flags |= O_NOINHERIT; +#endif + return open(pathname, flags, mode); +} + +#define rb_update_max_fd(fd) (void)(fd) +#endif + /* * call-seq: * IO.console -> #<File:/dev/tty> Index: ext/io/console/extconf.rb =================================================================== --- ext/io/console/extconf.rb (revision 39267) +++ ext/io/console/extconf.rb (revision 39268) @@ -12,9 +12,10 @@ when have_header(hdr = "sgtty.h") https://github.com/ruby/ruby/blob/trunk/ext/io/console/extconf.rb#L12 else ok = false end -have_header("sys/ioctl.h") -have_func("rb_io_get_write_io", "ruby/io.h") -have_func("dup3", "unistd.h") if ok + have_header("sys/ioctl.h") + have_func("rb_check_hash_type", "ruby.h") + have_func("rb_io_get_write_io", "ruby/io.h") + have_func("rb_cloexec_open", "ruby/io.h") create_makefile("io/console") end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/