readline-ext 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58f52b39a9287ece2a0c2b5e2c53bfab5445616011f7f36dc5abf0d23c9bfa25
4
- data.tar.gz: 2550a9aab2ac93fe25a1af0764bd04285bb6820dc9e157cabacb3f4daea488b3
3
+ metadata.gz: aee9c6dfd2619ad2f975738c3cd0f8f142996637ca21d788acb5e8d695c3c2e9
4
+ data.tar.gz: 1228d841d7bf7c1b606f766fb6c37a3cb2d60ea4fdbd7bfeea85ba8782fd9b3c
5
5
  SHA512:
6
- metadata.gz: '0118bb153949cdc9450007bd945cd3dd39aa0681cf043a361c647e560425969fa7e3457d2b394a78707f5152b7c0d5d690be14f183a944a9342f6f5534574d23'
7
- data.tar.gz: 23f6db65adddff7053d9331b90712a7439ba2b4e77a54984965055355d32c1918f4e92a2f24eeb5f4dd4df1cde9e7af3cd2773392cc747854230a758317b6778
6
+ metadata.gz: 625852ad1adfe1a8e61f5d243754bf112764cb4a37a7975d5871d1f267856c083f3fd5bccbe9ab077d3928b02bf004c6bfda6a35ee22275a9710919ddb6c744b
7
+ data.tar.gz: 95f3ae47e17404fbd40041f3d3396a4b9aa86d44e56e7796c73631fc4379f8190e2e5e202a8b14cf1ed18c4cf3eaff8b0f8a435691946570a8e2bdeea061092c
@@ -1,17 +1,24 @@
1
- name: build
1
+ name: test
2
2
 
3
3
  on: [push, pull_request]
4
4
 
5
5
  jobs:
6
- build:
6
+ ruby-versions:
7
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
+ with:
9
+ min_version: 2.6
10
+ engine: cruby
11
+
12
+ test:
13
+ needs: ruby-versions
7
14
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
15
  strategy:
9
16
  matrix:
10
- ruby: [ 3.1, '3.0', 2.7, 2.6, head ]
17
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
11
18
  os: [ ubuntu-latest, macos-latest ]
12
19
  runs-on: ${{ matrix.os }}
13
20
  steps:
14
- - uses: actions/checkout@v3
21
+ - uses: actions/checkout@v4
15
22
  - name: Install libedit
16
23
  run: sudo apt-get install -q libedit-dev libedit2
17
24
  if: startsWith(matrix.os, 'ubuntu')
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ group :development do
7
7
  gem "rake"
8
8
  gem "rake-compiler"
9
9
  gem "test-unit"
10
+ gem "test-unit-ruby-core"
10
11
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: false
2
2
  require "mkmf"
3
3
 
4
+ have_func("rb_io_descriptor")
5
+
4
6
  readline = Struct.new(:headers, :extra_check).new(["stdio.h"])
5
7
 
6
8
  def readline.have_header(header)
@@ -15,6 +15,8 @@
15
15
 
16
16
  ************************************************/
17
17
 
18
+ #define READLINE_VERSION "0.2.0"
19
+
18
20
  #ifdef RUBY_EXTCONF_H
19
21
  #include RUBY_EXTCONF_H
20
22
  #endif
@@ -44,6 +46,15 @@
44
46
  #include <sys/stat.h>
45
47
  #endif
46
48
 
49
+ #ifndef HAVE_RB_IO_DESCRIPTOR
50
+ int io_descriptor_fallback(VALUE io) {
51
+ rb_io_t *fptr;
52
+ GetOpenFile(io, fptr);
53
+ return fptr->fd;
54
+ }
55
+ #define rb_io_descriptor io_descriptor_fallback
56
+ #endif
57
+
47
58
  static VALUE mReadline;
48
59
 
49
60
  #define EDIT_LINE_LIBRARY_VERSION "EditLine wrapper"
@@ -371,30 +382,36 @@ clear_rl_outstream(void)
371
382
  readline_outstream = Qfalse;
372
383
  }
373
384
 
385
+ VALUE io_descriptor(VALUE io) {
386
+ return RB_INT2NUM(rb_io_descriptor(io));
387
+ }
388
+
374
389
  static void
375
390
  prepare_readline(void)
376
391
  {
377
392
  static int initialized = 0;
393
+ int state;
394
+
378
395
  if (!initialized) {
379
396
  rl_initialize();
380
397
  initialized = 1;
381
398
  }
382
399
 
383
400
  if (readline_instream) {
384
- rb_io_t *ifp;
385
- rb_io_check_initialized(ifp = RFILE(rb_io_taint_check(readline_instream))->fptr);
386
- if (ifp->fd < 0) {
401
+ rb_protect(io_descriptor, readline_instream, &state);
402
+
403
+ if (state) {
387
404
  clear_rl_instream();
388
- rb_raise(rb_eIOError, "closed readline input");
405
+ rb_jump_tag(state);
389
406
  }
390
407
  }
391
408
 
392
409
  if (readline_outstream) {
393
- rb_io_t *ofp;
394
- rb_io_check_initialized(ofp = RFILE(rb_io_taint_check(readline_outstream))->fptr);
395
- if (ofp->fd < 0) {
410
+ rb_protect(io_descriptor, readline_outstream, &state);
411
+
412
+ if (state) {
396
413
  clear_rl_outstream();
397
- rb_raise(rb_eIOError, "closed readline output");
414
+ rb_jump_tag(state);
398
415
  }
399
416
  }
400
417
  }
@@ -551,7 +568,6 @@ readline_readline(int argc, VALUE *argv, VALUE self)
551
568
  static VALUE
552
569
  readline_s_set_input(VALUE self, VALUE input)
553
570
  {
554
- rb_io_t *ifp;
555
571
  int fd;
556
572
  FILE *f;
557
573
 
@@ -560,9 +576,9 @@ readline_s_set_input(VALUE self, VALUE input)
560
576
  }
561
577
  else {
562
578
  Check_Type(input, T_FILE);
563
- GetOpenFile(input, ifp);
579
+ fd = rb_io_descriptor(input);
564
580
  clear_rl_instream();
565
- fd = rb_cloexec_dup(ifp->fd);
581
+ fd = rb_cloexec_dup(fd);
566
582
  if (fd == -1)
567
583
  rb_sys_fail("dup");
568
584
  f = fdopen(fd, "r");
@@ -587,7 +603,6 @@ readline_s_set_input(VALUE self, VALUE input)
587
603
  static VALUE
588
604
  readline_s_set_output(VALUE self, VALUE output)
589
605
  {
590
- rb_io_t *ofp;
591
606
  int fd;
592
607
  FILE *f;
593
608
 
@@ -596,9 +611,9 @@ readline_s_set_output(VALUE self, VALUE output)
596
611
  }
597
612
  else {
598
613
  Check_Type(output, T_FILE);
599
- GetOpenFile(output, ofp);
614
+ fd = rb_io_descriptor(output);
600
615
  clear_rl_outstream();
601
- fd = rb_cloexec_dup(ofp->fd);
616
+ fd = rb_cloexec_dup(fd);
602
617
  if (fd == -1)
603
618
  rb_sys_fail("dup");
604
619
  f = fdopen(fd, "w");
@@ -2119,6 +2134,8 @@ Init_readline(void)
2119
2134
  /* Version string of GNU Readline or libedit. */
2120
2135
  rb_define_const(mReadline, "VERSION", version);
2121
2136
 
2137
+ rb_define_const(mReadline, "GEM_VERSION", rb_str_new_cstr(READLINE_VERSION));
2138
+
2122
2139
  rl_attempted_completion_function = readline_attempted_completion_function;
2123
2140
  #if defined(HAVE_RL_PRE_INPUT_HOOK)
2124
2141
  rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
data/readline-ext.gemspec CHANGED
@@ -1,6 +1,16 @@
1
+ source_version = ["", "ext/readline/"].find do |dir|
2
+ begin
3
+ break File.open(File.join(__dir__, "#{dir}readline.c")) {|f|
4
+ f.gets("\n#define READLINE_VERSION ")
5
+ f.gets[/\s*"(.+)"/, 1]
6
+ }
7
+ rescue Errno::ENOENT
8
+ end
9
+ end
10
+
1
11
  Gem::Specification.new do |spec|
2
12
  spec.name = "readline-ext"
3
- spec.version = "0.1.5"
13
+ spec.version = source_version
4
14
  spec.authors = ["Yukihiro Matsumoto"]
5
15
  spec.email = ["matz@ruby-lang.org"]
6
16
 
@@ -14,7 +24,7 @@ Gem::Specification.new do |spec|
14
24
  spec.metadata["source_code_uri"] = spec.homepage
15
25
 
16
26
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
28
  end
19
29
  spec.bindir = "exe"
20
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readline-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yukihiro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-14 00:00:00.000000000 Z
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Provides an interface for GNU Readline and Edit Line (libedit).
14
14
  email:
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  requirements: []
60
- rubygems_version: 3.4.0.dev
60
+ rubygems_version: 3.5.0.dev
61
61
  signing_key:
62
62
  specification_version: 4
63
63
  summary: Provides an interface for GNU Readline and Edit Line (libedit).