io-console 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/console.c +45 -1
- data/extconf.rb +9 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f84c71a10c07466a96df3e243d33729d409b5983
|
4
|
+
data.tar.gz: 82ffd31d1858ed4d574efad6ef0ed86fb65636a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1125bd8d61efee82b4bfcdc2de73b5a4b075b622a19e911408e4262415b7e2707f9c643bf711f7ddc4b6e64c2861585f99b0a3cd21539f811197042d0de40a
|
7
|
+
data.tar.gz: 1748231bba6d1a9adb725424878d63562a8fae3dc6fb066651c4d4c56a59d103a34812b7b66fbd6abec1a2fdc13121fb0423b02bb3cf5e781d12851813e1d6f8
|
data/console.c
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
#include "ruby/io.h"
|
8
8
|
#else
|
9
9
|
#include "rubyio.h"
|
10
|
+
/* assumes rb_io_t doesn't have pathv */
|
11
|
+
#include "util.h" /* for ruby_strdup() */
|
10
12
|
#endif
|
11
13
|
|
12
14
|
#ifndef HAVE_RB_IO_T
|
@@ -23,6 +25,10 @@ typedef OpenFile rb_io_t;
|
|
23
25
|
#include <sys/ioctl.h>
|
24
26
|
#endif
|
25
27
|
|
28
|
+
#ifndef RB_TYPE_P
|
29
|
+
#define RB_TYPE_P(obj, type) (TYPE(obj) == type)
|
30
|
+
#endif
|
31
|
+
|
26
32
|
#if defined HAVE_TERMIOS_H
|
27
33
|
# include <termios.h>
|
28
34
|
typedef struct termios conmode;
|
@@ -101,11 +107,28 @@ rawmode_opt(int argc, VALUE *argv, rawmode_arg_t *opts)
|
|
101
107
|
{
|
102
108
|
rawmode_arg_t *optp = NULL;
|
103
109
|
VALUE vopts;
|
110
|
+
#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
|
104
111
|
rb_scan_args(argc, argv, "0:", &vopts);
|
112
|
+
#else
|
113
|
+
vopts = Qnil;
|
114
|
+
if (argc > 0) {
|
115
|
+
vopts = argv[--argc];
|
116
|
+
if (!NIL_P(vopts)) {
|
117
|
+
# ifdef HAVE_RB_CHECK_HASH_TYPE
|
118
|
+
vopts = rb_check_hash_type(vopts);
|
119
|
+
if (NIL_P(vopts)) ++argc;
|
120
|
+
# else
|
121
|
+
Check_Type(vopts, T_HASH);
|
122
|
+
# endif
|
123
|
+
}
|
124
|
+
}
|
125
|
+
rb_scan_args(argc, argv, "0");
|
126
|
+
#endif
|
105
127
|
if (!NIL_P(vopts)) {
|
106
128
|
VALUE vmin = rb_hash_aref(vopts, ID2SYM(rb_intern("min")));
|
107
129
|
VALUE vtime = rb_hash_aref(vopts, ID2SYM(rb_intern("time")));
|
108
|
-
|
130
|
+
/* default values by `stty raw` */
|
131
|
+
opts->vmin = 1;
|
109
132
|
opts->vtime = 0;
|
110
133
|
if (!NIL_P(vmin)) {
|
111
134
|
opts->vmin = NUM2INT(vmin);
|
@@ -643,6 +666,23 @@ console_ioflush(VALUE io)
|
|
643
666
|
return io;
|
644
667
|
}
|
645
668
|
|
669
|
+
#ifndef HAVE_RB_CLOEXEC_OPEN
|
670
|
+
static int
|
671
|
+
rb_cloexec_open(const char *pathname, int flags, mode_t mode)
|
672
|
+
{
|
673
|
+
int ret;
|
674
|
+
#ifdef O_CLOEXEC
|
675
|
+
/* O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
|
676
|
+
flags |= O_CLOEXEC;
|
677
|
+
#elif defined O_NOINHERIT
|
678
|
+
flags |= O_NOINHERIT;
|
679
|
+
#endif
|
680
|
+
return open(pathname, flags, mode);
|
681
|
+
}
|
682
|
+
|
683
|
+
#define rb_update_max_fd(fd) (void)(fd)
|
684
|
+
#endif
|
685
|
+
|
646
686
|
/*
|
647
687
|
* call-seq:
|
648
688
|
* IO.console -> #<File:/dev/tty>
|
@@ -704,7 +744,11 @@ console_dev(VALUE klass)
|
|
704
744
|
args[0] = INT2NUM(fd);
|
705
745
|
con = rb_class_new_instance(2, args, klass);
|
706
746
|
GetOpenFile(con, fptr);
|
747
|
+
#ifdef HAVE_RUBY_IO_H
|
707
748
|
fptr->pathv = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE));
|
749
|
+
#else
|
750
|
+
fptr->path = ruby_strdup(CONSOLE_DEVICE);
|
751
|
+
#endif
|
708
752
|
#ifdef CONSOLE_DEVICE_FOR_WRITING
|
709
753
|
GetOpenFile(out, ofptr);
|
710
754
|
# ifdef HAVE_RB_IO_GET_WRITE_IO
|
data/extconf.rb
CHANGED
@@ -12,9 +12,15 @@ when have_header(hdr = "sgtty.h")
|
|
12
12
|
else
|
13
13
|
ok = false
|
14
14
|
end
|
15
|
-
|
16
|
-
|
17
|
-
have_func("dup3", "unistd.h")
|
15
|
+
ok &&= enable_config("io-console-force-compatible-with-1.8") ||
|
16
|
+
macro_defined?("HAVE_RUBY_IO_H", cpp_include("ruby.h"))
|
18
17
|
if ok
|
18
|
+
have_header("sys/ioctl.h")
|
19
|
+
have_func("rb_check_hash_type", "ruby.h")
|
20
|
+
have_func("rb_io_get_write_io", "ruby/io.h")
|
21
|
+
have_func("rb_cloexec_open", "ruby/io.h")
|
22
|
+
if enable_config("io-console-rb_scan_args-optional-hash", true)
|
23
|
+
$defs << "-DHAVE_RB_SCAN_ARGS_OPTIONAL_HASH=1"
|
24
|
+
end
|
19
25
|
create_makefile("io/console")
|
20
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nobu Nakada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-02-
|
11
|
+
date: 2013-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: add console capabilities to IO instances.
|
14
14
|
email: nobu@ruby-lang.org
|
@@ -27,20 +27,20 @@ metadata: {}
|
|
27
27
|
post_install_message:
|
28
28
|
rdoc_options: []
|
29
29
|
require_paths:
|
30
|
-
-
|
30
|
+
- .
|
31
31
|
required_ruby_version: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - '>='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 1.9.3
|
36
36
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
requirements: []
|
42
42
|
rubyforge_project:
|
43
|
-
rubygems_version: 2.0.0
|
43
|
+
rubygems_version: 2.0.0
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: Console interface
|