зеркало из https://github.com/github/ruby.git
Fix encoding switches when RUBYOPT is empty or only spaces
* Follow-up of dbbc3583ba
which broke this.
This commit is contained in:
Родитель
a502cd80a5
Коммит
3c41a04b6c
5
ruby.c
5
ruby.c
|
@ -895,10 +895,11 @@ moreswitches(const char *s, ruby_cmdline_options_t *opt, int envopt)
|
|||
ruby_features_t warn = opt->warn;
|
||||
int backtrace_length_limit = opt->backtrace_length_limit;
|
||||
|
||||
opt->src.enc.name = opt->ext.enc.name = opt->intern.enc.name = 0;
|
||||
|
||||
while (ISSPACE(*s)) s++;
|
||||
if (!*s) return;
|
||||
|
||||
opt->src.enc.name = opt->ext.enc.name = opt->intern.enc.name = 0;
|
||||
|
||||
argstr = rb_str_tmp_new((len = strlen(s)) + (envopt!=0));
|
||||
argary = rb_str_tmp_new(0);
|
||||
|
||||
|
|
|
@ -6,6 +6,13 @@ describe "ruby -U" do
|
|||
options: '-U').should == 'UTF-8'
|
||||
end
|
||||
|
||||
it "sets Encoding.default_internal to UTF-8 when RUBYOPT is empty or only spaces" do
|
||||
ruby_exe('p Encoding.default_internal',
|
||||
options: '-U', env: { 'RUBYOPT' => '' }).should == "#<Encoding:UTF-8>\n"
|
||||
ruby_exe('p Encoding.default_internal',
|
||||
options: '-U', env: { 'RUBYOPT' => ' ' }).should == "#<Encoding:UTF-8>\n"
|
||||
end
|
||||
|
||||
it "does nothing different if specified multiple times" do
|
||||
ruby_exe('print Encoding.default_internal.name',
|
||||
options: '-U -U').should == 'UTF-8'
|
||||
|
|
Загрузка…
Ссылка в новой задаче