[ruby/irb] Remove encoding_aliases.rb

(https://github.com/ruby/irb/pull/569)

We don't have to load another file to define the legacy encoding aliases
map because there's only one definition of it. We can define it in
locale.rb directly.
This commit is contained in:
Stan Lo 2023-04-26 16:05:59 +01:00 committed by git
parent 6339cb70c3
commit fe0b23b42f
2 changed files with 6 additions and 16 deletions

View File

@ -1,13 +0,0 @@
# frozen_string_literal: false
module IRB
# :stopdoc:
class Locale
@@legacy_encoding_alias_map = {
'ujis' => Encoding::EUC_JP,
'euc' => Encoding::EUC_JP
}.freeze
end
# :startdoc:
end

View File

@ -15,7 +15,11 @@ module IRB # :nodoc:
]x
LOCALE_DIR = "/lc/"
@@legacy_encoding_alias_map = {}.freeze
LEGACY_ENCODING_ALIAS_MAP = {
'ujis' => Encoding::EUC_JP,
'euc' => Encoding::EUC_JP
}
@@loaded = []
def initialize(locale = nil)
@ -26,8 +30,7 @@ module IRB # :nodoc:
@lang, @territory, @encoding_name, @modifier = m[:language], m[:territory], m[:codeset], m[:modifier]
if @encoding_name
begin load 'irb/encoding_aliases.rb'; rescue LoadError; end
if @encoding = @@legacy_encoding_alias_map[@encoding_name]
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