diff options
author | Stan Lo <stan001212@gmail.com> | 2023-04-25 12:00:05 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-04-26 13:13:25 +0900 |
commit | 299d17a2f1ebda4efba7e634b9a5f7196f5274a8 (patch) | |
tree | aa36e2fb0eae56e3c35f176068f1dd06b8248c07 /lib/irb | |
parent | 5154d6beededf9d018c85316b982deb2babf40bb (diff) | |
download | ruby-299d17a2f1ebda4efba7e634b9a5f7196f5274a8.tar.gz |
[ruby/irb] Fix Locale's encoding lookup for Japanese encodings
(https://github.com/ruby/irb/pull/568)
In https://github.com/ruby/irb/commit/3ee79e89adb8e21b63d796e53bcc86281685076d,
`encoding_aliases.rb` was introduced to return the correct encoding object for
`ujis` and `euc` encodings.
However, the return value of `@@legacy_encoding_alias_map[@encoding_name]`
is always overridden by a second look up with `Encoding.find(@encoding_name)`.
So the logic didn't work as expected.
This commit fixes the problem.
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/locale.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb index eb3028616d..d7019039ea 100644 --- a/lib/irb/locale.rb +++ b/lib/irb/locale.rb @@ -29,8 +29,9 @@ module IRB # :nodoc: begin load 'irb/encoding_aliases.rb'; rescue LoadError; end if @encoding = @@legacy_encoding_alias_map[@encoding_name] warn(("%s is obsolete. use %s" % ["#{@lang}_#{@territory}.#{@encoding_name}", "#{@lang}_#{@territory}.#{@encoding.name}"]), uplevel: 1) + else + @encoding = Encoding.find(@encoding_name) rescue nil end - @encoding = Encoding.find(@encoding_name) rescue nil end end @encoding ||= (Encoding.find('locale') rescue Encoding::ASCII_8BIT) |