@@ -36,8 +36,11 @@ fn main() {
3636 let ok = tmpdir. join ( "ok" ) ;
3737 let not_ok = tmpdir. join ( "not_ok" ) ;
3838 if env:: var ( "YOU_ARE_A_LINKER" ) . is_ok ( ) {
39- match env:: args ( ) . find ( |a| a. contains ( "@" ) ) {
40- Some ( file) => { fs:: copy ( & file[ 1 ..] , & ok) . unwrap ( ) ; }
39+ match env:: args_os ( ) . find ( |a| a. to_string_lossy ( ) . contains ( "@" ) ) {
40+ Some ( file) => {
41+ let file = file. to_str ( ) . unwrap ( ) ;
42+ fs:: copy ( & file[ 1 ..] , & ok) . unwrap ( ) ;
43+ }
4144 None => { File :: create ( & not_ok) . unwrap ( ) ; }
4245 }
4346 return
@@ -84,11 +87,23 @@ fn main() {
8487 continue
8588 }
8689
87- let mut contents = String :: new ( ) ;
88- File :: open ( & ok) . unwrap ( ) . read_to_string ( & mut contents) . unwrap ( ) ;
90+ let mut contents = Vec :: new ( ) ;
91+ File :: open ( & ok) . unwrap ( ) . read_to_end ( & mut contents) . unwrap ( ) ;
8992
9093 for j in 0 ..i {
91- assert ! ( contents. contains( & format!( "{}{}" , lib_name, j) ) ) ;
94+ let exp = format ! ( "{}{}" , lib_name, j) ;
95+ let exp = if cfg ! ( target_env = "msvc" ) {
96+ let mut out = Vec :: with_capacity ( exp. len ( ) * 2 ) ;
97+ for c in exp. encode_utf16 ( ) {
98+ // encode in little endian
99+ out. push ( c as u8 ) ;
100+ out. push ( ( c >> 8 ) as u8 ) ;
101+ }
102+ out
103+ } else {
104+ exp. into_bytes ( )
105+ } ;
106+ assert ! ( contents. windows( exp. len( ) ) . any( |w| w == & exp[ ..] ) ) ;
92107 }
93108
94109 break
0 commit comments