@@ -472,15 +472,6 @@ static const rb_data_type_t dir_data_type = {
472
472
473
473
static VALUE dir_close (VALUE );
474
474
475
- #define GlobPathValue (str , safe ) \
476
- /* can contain null bytes as separators */ \
477
- (!RB_TYPE_P((str), T_STRING) ? \
478
- (void)FilePathValue(str) : \
479
- (void)(check_safe_glob((str), (safe)), \
480
- check_glob_encoding(str), (str)))
481
- #define check_safe_glob (str , safe ) ((safe) ? rb_check_safe_obj(str) : (void)0)
482
- #define check_glob_encoding (str ) rb_enc_check((str), rb_enc_from_encoding(rb_usascii_encoding()))
483
-
484
475
static VALUE
485
476
dir_s_alloc (VALUE klass )
486
477
{
@@ -551,7 +542,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir)
551
542
}
552
543
}
553
544
554
- GlobPathValue (dirname , FALSE );
545
+ FilePathValue (dirname );
555
546
orig = rb_str_dup_frozen (dirname );
556
547
dirname = rb_str_encode_ospath (dirname );
557
548
dirname = rb_str_dup_frozen (dirname );
@@ -2545,7 +2536,14 @@ rb_push_glob(VALUE str, VALUE base, int flags) /* '\0' is delimiter */
2545
2536
long offset = 0 ;
2546
2537
VALUE ary ;
2547
2538
2548
- GlobPathValue (str , TRUE);
2539
+ /* can contain null bytes as separators */
2540
+ if (!RB_TYPE_P ((str ), T_STRING )) {
2541
+ FilePathValue (str );
2542
+ }
2543
+ else {
2544
+ rb_check_safe_obj (str );
2545
+ rb_enc_check (str , rb_enc_from_encoding (rb_usascii_encoding ()));
2546
+ }
2549
2547
ary = rb_ary_new ();
2550
2548
2551
2549
while (offset < RSTRING_LEN (str )) {
@@ -2575,7 +2573,7 @@ dir_globs(long argc, const VALUE *argv, VALUE base, int flags)
2575
2573
for (i = 0 ; i < argc ; ++ i ) {
2576
2574
int status ;
2577
2575
VALUE str = argv [i ];
2578
- GlobPathValue (str , TRUE );
2576
+ FilePathValue (str );
2579
2577
status = push_glob (ary , str , base , flags );
2580
2578
if (status ) GLOB_JUMP_TAG (status );
2581
2579
}
@@ -2600,7 +2598,7 @@ dir_glob_options(VALUE opt, VALUE *base, int *flags)
2600
2598
}
2601
2599
#endif
2602
2600
else {
2603
- GlobPathValue (args [0 ], TRUE );
2601
+ FilePathValue (args [0 ]);
2604
2602
if (!RSTRING_LEN (args [0 ])) args [0 ] = Qnil ;
2605
2603
* base = args [0 ];
2606
2604
}
@@ -3185,7 +3183,7 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
3185
3183
const char * path ;
3186
3184
enum {false_on_notdir = 1 };
3187
3185
3188
- GlobPathValue (dirname , FALSE );
3186
+ FilePathValue (dirname );
3189
3187
orig = rb_str_dup_frozen (dirname );
3190
3188
dirname = rb_str_encode_ospath (dirname );
3191
3189
dirname = rb_str_dup_frozen (dirname );
0 commit comments