readline-ext 0.1.4 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56227f779fa87781e2c47322cf5350a253fc1ddf957b881689c0e35978e7e8b1
4
- data.tar.gz: a7a646daa7b7876a3cf486e24c1e034b28f147580ccb326146aa21175e106a5e
3
+ metadata.gz: aee9c6dfd2619ad2f975738c3cd0f8f142996637ca21d788acb5e8d695c3c2e9
4
+ data.tar.gz: 1228d841d7bf7c1b606f766fb6c37a3cb2d60ea4fdbd7bfeea85ba8782fd9b3c
5
5
  SHA512:
6
- metadata.gz: 06c1d284870cdc606ccc553d52f44b237595c31563d2a4b411f25c23eb2b022c726c04b1614ce9b25dab56dbee0110aadade6aa5b4ef8fa342020a61b2de6ef2
7
- data.tar.gz: 9eb01c2e2f76c3bbd2dafbda1bd10f384d89312adeb66b59f30524b4c33e92578be5447d8e74a7530eadf4343596d3fa291604e3d599b2644220d450f2f41d1f
6
+ metadata.gz: 625852ad1adfe1a8e61f5d243754bf112764cb4a37a7975d5871d1f267856c083f3fd5bccbe9ab077d3928b02bf004c6bfda6a35ee22275a9710919ddb6c744b
7
+ data.tar.gz: 95f3ae47e17404fbd40041f3d3396a4b9aa86d44e56e7796c73631fc4379f8190e2e5e202a8b14cf1ed18c4cf3eaff8b0f8a435691946570a8e2bdeea061092c
@@ -0,0 +1,7 @@
1
+ # This is a file used by GitHub to ignore the following commits on `git blame`.
2
+ #
3
+ # You can also do the same thing in your local repository with:
4
+ # $ git config --local blame.ignoreRevsFile .git-blame-ignore-revs
5
+
6
+ # Expand tabs
7
+ aeae109dcf365df8c403bb53c5c39d6e08f5772c
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -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.0', 2.7, 2.6, 2.5, 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@v2
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
- rl_initialize();
380
- initialized = 1;
396
+ rl_initialize();
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.4"
13
+ spec.version = source_version
4
14
  spec.authors = ["Yukihiro Matsumoto"]
5
15
  spec.email = ["matz@ruby-lang.org"]
6
16
 
@@ -14,13 +24,9 @@ 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) }
21
31
  spec.require_paths = ["lib"]
22
-
23
- spec.add_development_dependency "bundler"
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rake-compiler"
26
32
  end
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readline-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
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: 2021-12-24 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake-compiler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
11
+ date: 2023-12-07 00:00:00.000000000 Z
12
+ dependencies: []
55
13
  description: Provides an interface for GNU Readline and Edit Line (libedit).
56
14
  email:
57
15
  - matz@ruby-lang.org
@@ -60,6 +18,8 @@ extensions:
60
18
  - ext/readline/extconf.rb
61
19
  extra_rdoc_files: []
62
20
  files:
21
+ - ".git-blame-ignore-revs"
22
+ - ".github/dependabot.yml"
63
23
  - ".github/workflows/test.yml"
64
24
  - ".gitignore"
65
25
  - Gemfile
@@ -97,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
57
  - !ruby/object:Gem::Version
98
58
  version: '0'
99
59
  requirements: []
100
- rubygems_version: 3.3.2
60
+ rubygems_version: 3.5.0.dev
101
61
  signing_key:
102
62
  specification_version: 4
103
63
  summary: Provides an interface for GNU Readline and Edit Line (libedit).