mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 05:25:34 +02:00

Instead, prefer `scan_byte` over `get_byte` since that already returns the byte as an integer, sidestepping conversion issues.
Fixes https://github.com/ruby/prism/issues/3582
7f3008b2b5
14 lines
304 B
Ruby
14 lines
304 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "strscan"
|
|
|
|
# Polyfill for StringScanner#scan_byte, which didn't exist until Ruby 3.4.
|
|
if !(StringScanner.instance_methods.include?(:scan_byte))
|
|
StringScanner.include(
|
|
Module.new {
|
|
def scan_byte # :nodoc:
|
|
get_byte&.b&.ord
|
|
end
|
|
}
|
|
)
|
|
end
|