@@ -175,7 +175,6 @@ pub fn glob_with<S: AsRef<OsStr> + ?Sized>(pattern: &S, options: &MatchOptions)
175175
176176 #[ cfg( windows) ]
177177 fn check_windows_verbatim ( p : & Path ) -> bool {
178- use std:: path:: Prefix ;
179178 match p. components ( ) . next ( ) {
180179 Some ( Component :: Prefix ( ref p) ) => p. kind ( ) . is_verbatim ( ) ,
181180 _ => false ,
@@ -405,10 +404,7 @@ impl Iterator for Paths {
405404
406405 // not recursive, so match normally
407406 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 ( ) {
412408 None => continue ,
413409 Some ( x) => x
414410 }
@@ -579,15 +575,15 @@ impl PlatformCharset<u16> for PatternCharset {
579575 fn period ( & self ) -> u16 { b'.' as _ }
580576
581577 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 ( )
583579 }
584580
585581 fn to_ascii_lowercase ( & self , ch : u16 ) -> u8 {
586582 ( ch as u8 ) . to_ascii_lowercase ( )
587583 }
588584
589585 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 ( ) )
591587 }
592588}
593589
@@ -612,7 +608,7 @@ impl Pattern {
612608 let helper = || {
613609 use std:: os:: windows:: ffi:: OsStrExt ;
614610
615- Self :: create_pattern ( pattern. encode_wide ( ) . peek ( ) , pattern. len ( ) , PatternCharset )
611+ Self :: create_pattern ( pattern. encode_wide ( ) . peekable ( ) , pattern. len ( ) , PatternCharset )
616612 } ;
617613
618614 #[ cfg( not( windows) ) ]
@@ -725,13 +721,10 @@ impl Pattern {
725721 match iter. clone ( ) . skip ( 2 ) . position ( |x| x == rbrack) {
726722 None => ( ) ,
727723 Some ( j) => {
728- // XXX: 1 + j? 2 + j?
729724 iter. next ( ) ;
730725 let niter = iter. clone ( ) . take ( j + 1 ) ;
731726 let cs = parse_char_specifiers ( niter, & charset) ;
732727 tokens. push ( AnyExcept ( cs) ) ;
733- // XXX: numbers
734- // XXX: maybe can just give &mut iter?
735728 for _ in 0 ..j + 2 {
736729 iter. next ( ) ;
737730 }
@@ -743,7 +736,6 @@ impl Pattern {
743736 match iter. clone ( ) . skip ( 1 ) . position ( |x| x == rbrack) {
744737 None => ( ) ,
745738 Some ( j) => {
746- // XXX: 1 + j?
747739 let niter = iter. clone ( ) . take ( j + 1 ) ;
748740 let cs = parse_char_specifiers ( niter, & charset) ;
749741 tokens. push ( AnyWithin ( cs) ) ;
@@ -814,20 +806,20 @@ impl Pattern {
814806
815807 /// Return if the given `str` matches this `Pattern` using the specified
816808 /// match options.
817- #[ cfg( not( windows) ) ]
818809 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 ;
820813
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+ }
823816
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 ;
829820
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+ }
831823 }
832824
833825 /// Access the original glob pattern.
@@ -1225,15 +1217,17 @@ mod test {
12251217 #[ cfg( windows) ]
12261218 fn win ( ) {
12271219 use std:: env:: current_dir;
1228- use std:: ffi :: AsOsStr ;
1220+ use std:: path :: { Component , Path } ;
12291221
12301222 // check windows absolute paths with host/device components
12311223 let root_with_device = current_dir ( )
12321224 . 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+ } )
12341229 . 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( ) ) ;
12371231 }
12381232 win ( )
12391233 }
0 commit comments