@@ -175,7 +175,6 @@ pub fn glob_with<S: AsRef<OsStr> + ?Sized>(pattern: &S, options: &MatchOptions)
175
175
176
176
#[ cfg( windows) ]
177
177
fn check_windows_verbatim ( p : & Path ) -> bool {
178
- use std:: path:: Prefix ;
179
178
match p. components ( ) . next ( ) {
180
179
Some ( Component :: Prefix ( ref p) ) => p. kind ( ) . is_verbatim ( ) ,
181
180
_ => false ,
@@ -405,10 +404,7 @@ impl Iterator for Paths {
405
404
406
405
// not recursive, so match normally
407
406
if self . dir_patterns [ idx] . matches_with ( {
408
- match path. file_name ( ) . and_then ( |s| s. to_str ( ) ) {
409
- // FIXME (#9639): How do we handle non-utf8 filenames?
410
- // Ignore them for now; ideally we'd still match them
411
- // against a *
407
+ match path. file_name ( ) {
412
408
None => continue ,
413
409
Some ( x) => x
414
410
}
@@ -579,15 +575,15 @@ impl PlatformCharset<u16> for PatternCharset {
579
575
fn period ( & self ) -> u16 { b'.' as _ }
580
576
581
577
fn is_ascii ( & self , ch : u16 ) -> bool {
582
- ch <= u8:: max_value ( ) && ( ch as u8 ) . is_ascii ( )
578
+ ch <= u8:: max_value ( ) as u16 && ( ch as u8 ) . is_ascii ( )
583
579
}
584
580
585
581
fn to_ascii_lowercase ( & self , ch : u16 ) -> u8 {
586
582
( ch as u8 ) . to_ascii_lowercase ( )
587
583
}
588
584
589
585
fn is_separator ( & self , ch : u16 ) -> bool {
590
- ch <= u8:: max_value ( ) && path:: is_separator ( ( ch as u8 ) . into ( ) )
586
+ ch <= u8:: max_value ( ) as u16 && path:: is_separator ( ( ch as u8 ) . into ( ) )
591
587
}
592
588
}
593
589
@@ -612,7 +608,7 @@ impl Pattern {
612
608
let helper = || {
613
609
use std:: os:: windows:: ffi:: OsStrExt ;
614
610
615
- Self :: create_pattern ( pattern. encode_wide ( ) . peek ( ) , pattern. len ( ) , PatternCharset )
611
+ Self :: create_pattern ( pattern. encode_wide ( ) . peekable ( ) , pattern. len ( ) , PatternCharset )
616
612
} ;
617
613
618
614
#[ cfg( not( windows) ) ]
@@ -725,13 +721,10 @@ impl Pattern {
725
721
match iter. clone ( ) . skip ( 2 ) . position ( |x| x == rbrack) {
726
722
None => ( ) ,
727
723
Some ( j) => {
728
- // XXX: 1 + j? 2 + j?
729
724
iter. next ( ) ;
730
725
let niter = iter. clone ( ) . take ( j + 1 ) ;
731
726
let cs = parse_char_specifiers ( niter, & charset) ;
732
727
tokens. push ( AnyExcept ( cs) ) ;
733
- // XXX: numbers
734
- // XXX: maybe can just give &mut iter?
735
728
for _ in 0 ..j + 2 {
736
729
iter. next ( ) ;
737
730
}
@@ -743,7 +736,6 @@ impl Pattern {
743
736
match iter. clone ( ) . skip ( 1 ) . position ( |x| x == rbrack) {
744
737
None => ( ) ,
745
738
Some ( j) => {
746
- // XXX: 1 + j?
747
739
let niter = iter. clone ( ) . take ( j + 1 ) ;
748
740
let cs = parse_char_specifiers ( niter, & charset) ;
749
741
tokens. push ( AnyWithin ( cs) ) ;
@@ -814,20 +806,20 @@ impl Pattern {
814
806
815
807
/// Return if the given `str` matches this `Pattern` using the specified
816
808
/// match options.
817
- #[ cfg( not( windows) ) ]
818
809
pub fn matches_with < S : AsRef < OsStr > + ?Sized > ( & self , str : & S , options : & MatchOptions ) -> bool {
819
- use std:: os:: unix:: ffi:: OsStrExt ;
810
+ #[ cfg( not( windows) ) ]
811
+ {
812
+ use std:: os:: unix:: ffi:: OsStrExt ;
820
813
821
- self . matches_from ( true , str. as_ref ( ) . as_bytes ( ) . iter ( ) . map ( |& b| b) , 0 , options, & PatternCharset ) == Match
822
- }
814
+ self . matches_from ( true , str. as_ref ( ) . as_bytes ( ) . iter ( ) . map ( |& b| b) , 0 , options, & PatternCharset ) == Match
815
+ }
823
816
824
- /// Return if the given `str` matches this `Pattern` using the specified
825
- /// match options.
826
- #[ cfg( windows) ]
827
- pub fn matches_with < S : AsRef < OsStr > + ?Sized > ( & self , str : & S , option : & MatchOptions ) -> bool {
828
- use std:: os:: unix:: ffi:: OsStrExt ;
817
+ #[ cfg( windows) ]
818
+ {
819
+ use std:: os:: windows:: ffi:: OsStrExt ;
829
820
830
- self . matches_from ( true , str. as_ref ( ) . encode_wide ( ) , 0 , options, & PatternCharset ) == Match
821
+ self . matches_from ( true , str. as_ref ( ) . encode_wide ( ) , 0 , options, & PatternCharset ) == Match
822
+ }
831
823
}
832
824
833
825
/// Access the original glob pattern.
@@ -1225,15 +1217,17 @@ mod test {
1225
1217
#[ cfg( windows) ]
1226
1218
fn win ( ) {
1227
1219
use std:: env:: current_dir;
1228
- use std:: ffi :: AsOsStr ;
1220
+ use std:: path :: { Component , Path } ;
1229
1221
1230
1222
// check windows absolute paths with host/device components
1231
1223
let root_with_device = current_dir ( )
1232
1224
. ok ( )
1233
- . and_then ( |p| p. prefix ( ) . map ( |p| p. join ( "*" ) ) )
1225
+ . and_then ( |p| match p. components ( ) . next ( ) {
1226
+ Some ( Component :: Prefix ( prefix) ) => Some ( Path :: new ( prefix. as_os_str ( ) ) . join ( "*" ) ) ,
1227
+ _ => None ,
1228
+ } )
1234
1229
. unwrap ( ) ;
1235
- // FIXME (#9639): This needs to handle non-utf8 paths
1236
- assert ! ( glob( root_with_device. as_os_str( ) . to_str( ) . unwrap( ) ) . unwrap( ) . next( ) . is_some( ) ) ;
1230
+ assert ! ( glob( & root_with_device) . unwrap( ) . next( ) . is_some( ) ) ;
1237
1231
}
1238
1232
win ( )
1239
1233
}
0 commit comments