Set encoding index correctly

This commit is contained in:
Alexander Momchilov 2024-08-26 09:19:22 -04:00 committed by Kevin Newton
parent b5646124b3
commit f93c27d86b
Notes: git 2024-08-28 12:48:01 +00:00

14
ruby.c
View File

@ -2121,13 +2121,25 @@ prism_script_shebang_callback(pm_options_t *options, const uint8_t *source, size
memcpy(switches, source, length);
switches[length] = '\0';
int no_src_enc = !opt->src.enc.name;
int no_ext_enc = !opt->ext.enc.name;
int no_int_enc = !opt->intern.enc.name;
moreswitches(switches, opt, 0);
free(switches);
pm_options_command_line_set(options, prism_script_command_line(opt));
if (opt->ext.enc.name != 0) {
if (no_src_enc && opt->src.enc.name) {
opt->src.enc.index = opt_enc_index(opt->src.enc.name);
pm_options_encoding_set(options, StringValueCStr(opt->ext.enc.name));
}
if (no_ext_enc && opt->ext.enc.name) {
opt->ext.enc.index = opt_enc_index(opt->ext.enc.name);
}
if (no_int_enc && opt->intern.enc.name) {
opt->intern.enc.index = opt_enc_index(opt->intern.enc.name);
}
}
/**