Skip to content

Commit

Permalink
Ensure compatibility with frozen string literals (#643)
Browse files Browse the repository at this point in the history
Ref: https://bugs.ruby-lang.org/issues/20205

Ruby is moving forward with enabling frozen string literals
in the future.

Reline being part of the ruby-core test suite should work when
ruby is ran with `--enable-frozen-string-literal`.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
  • Loading branch information
casperisfine and byroot authored Mar 14, 2024
1 parent 5137a3f commit 7e2de64
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/reline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
env:
TERM: xterm-256color
run: bundle exec rake test
- name: rake test (frozen string literal)
env:
TERM: xterm-256color
run: bundle exec rake test RUBYOPT="--enable-frozen-string-literal"

readline:
name: >-
Expand Down
2 changes: 1 addition & 1 deletion lib/reline/kill_ring.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def initialize(max = 1024)
def append(string, before_p = false)
case @state
when State::FRESH, State::YANK
@ring << RingPoint.new(string)
@ring << RingPoint.new(+string)
@state = State::CONTINUED
when State::CONTINUED, State::PROCESSED
if before_p
Expand Down
4 changes: 2 additions & 2 deletions lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ def editing_mode
item_mbchars = item.grapheme_clusters
end
size = [memo_mbchars.size, item_mbchars.size].min
result = ''
result = +''
size.times do |i|
if @config.completion_ignore_case
if memo_mbchars[i].casecmp?(item_mbchars[i])
Expand Down Expand Up @@ -2935,7 +2935,7 @@ def finish
end

private def ed_delete_prev_char(key, arg: 1)
deleted = ''
deleted = +''
arg.times do
if @cursor > 0
byte_size = Reline::Unicode.get_prev_mbchar_size(@line, @byte_pointer)
Expand Down
2 changes: 1 addition & 1 deletion lib/reline/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def initialize(dllname, func, import, export = "0", calltype = :stdcall)
def call(*args)
import = @proto.split("")
args.each_with_index do |x, i|
args[i], = [x == 0 ? nil : x].pack("p").unpack(POINTER_TYPE) if import[i] == "S"
args[i], = [x == 0 ? nil : +x].pack("p").unpack(POINTER_TYPE) if import[i] == "S"
args[i], = [x].pack("I").unpack("i") if import[i] == "I"
end
ret, = @func.call(*args)
Expand Down

0 comments on commit 7e2de64

Please sign in to comment.