@@ -2138,7 +2138,7 @@ prism_script(ruby_cmdline_options_t *opt, pm_parse_result_t *result)
2138
2138
const bool read_stdin = (strcmp (opt -> script , "-" ) == 0 );
2139
2139
2140
2140
if (read_stdin ) {
2141
- pm_options_encoding_set (options , rb_enc_name (rb_locale_encoding ()));
2141
+ pm_options_encoding_set (options , rb_enc_name (IF_UTF8_PATH ( rb_utf8_encoding (), rb_locale_encoding () )));
2142
2142
}
2143
2143
if (opt -> src .enc .name != 0 ) {
2144
2144
pm_options_encoding_set (options , StringValueCStr (opt -> src .enc .name ));
@@ -2408,14 +2408,8 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
2408
2408
#endif
2409
2409
}
2410
2410
rb_enc_associate (opt -> script_name , IF_UTF8_PATH (uenc , lenc ));
2411
- #if UTF8_PATH
2412
- if (uenc != lenc ) {
2413
- opt -> script_name = str_conv_enc (opt -> script_name , uenc , lenc );
2414
- opt -> script = RSTRING_PTR (opt -> script_name );
2415
- }
2416
- #endif
2417
2411
rb_obj_freeze (opt -> script_name );
2418
- if ( IF_UTF8_PATH ( uenc != lenc , 1 )) {
2412
+ {
2419
2413
long i ;
2420
2414
VALUE load_path = vm -> load_path ;
2421
2415
const ID id_initial_load_path_mark = INITIAL_LOAD_PATH_MARK ;
@@ -2425,13 +2419,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
2425
2419
for (i = 0 ; i < RARRAY_LEN (load_path ); ++ i ) {
2426
2420
VALUE path = RARRAY_AREF (load_path , i );
2427
2421
int mark = rb_attr_get (path , id_initial_load_path_mark ) == path ;
2428
- #if UTF8_PATH
2429
- VALUE newpath = rb_str_conv_enc (path , uenc , lenc );
2430
- if (newpath == path ) continue ;
2431
- path = newpath ;
2432
- #else
2433
- if (!(path = copy_str (path , lenc , !mark ))) continue ;
2434
- #endif
2422
+ if (!(path = copy_str (path , IF_UTF8_PATH (uenc , lenc ), !mark ))) continue ;
2435
2423
if (mark ) rb_ivar_set (path , id_initial_load_path_mark , path );
2436
2424
if (!modifiable ) {
2437
2425
rb_ary_modify (load_path );
@@ -2559,11 +2547,6 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
2559
2547
VALUE path = Qnil ;
2560
2548
if (!opt -> e_script && strcmp (opt -> script , "-" )) {
2561
2549
path = rb_realpath_internal (Qnil , opt -> script_name , 1 );
2562
- #if UTF8_PATH
2563
- if (uenc != lenc ) {
2564
- path = str_conv_enc (path , uenc , lenc );
2565
- }
2566
- #endif
2567
2550
if (!ENCODING_GET (path )) { /* ASCII-8BIT */
2568
2551
rb_enc_copy (path , opt -> script_name );
2569
2552
}
@@ -2725,7 +2708,7 @@ load_file_internal(VALUE argp_v)
2725
2708
enc = rb_enc_from_index (opt -> src .enc .index );
2726
2709
}
2727
2710
else if (f == rb_stdin ) {
2728
- enc = rb_locale_encoding ();
2711
+ enc = IF_UTF8_PATH ( rb_utf8_encoding (), rb_locale_encoding () );
2729
2712
}
2730
2713
else {
2731
2714
enc = rb_utf8_encoding ();
0 commit comments