@@ -33,14 +33,9 @@ mod options {
3333
3434#[ cfg( all(
3535 not( feature = "feat_external_libstdbuf" ) ,
36- any(
37- target_os = "linux" ,
38- target_os = "android" ,
39- target_os = "freebsd" ,
40- target_os = "netbsd" ,
41- target_os = "openbsd" ,
42- target_os = "dragonfly"
43- )
36+ unix,
37+ not( target_vendor = "apple" ) ,
38+ not( target_os = "cygwin" )
4439) ) ]
4540const STDBUF_INJECT : & [ u8 ] = include_bytes ! ( concat!( env!( "OUT_DIR" ) , "/libstdbuf.so" ) ) ;
4641
@@ -84,29 +79,19 @@ enum ProgramOptionsError {
8479 ValueTooLarge ( String ) ,
8580}
8681
87- #[ cfg( any(
88- target_os = "linux" ,
89- target_os = "android" ,
90- target_os = "freebsd" ,
91- target_os = "netbsd" ,
92- target_os = "openbsd" ,
93- target_os = "dragonfly"
94- ) ) ]
95- #[ expect(
96- clippy:: unnecessary_wraps,
97- reason = "fn sig must match on all platforms"
98- ) ]
99- fn preload_strings ( ) -> UResult < ( & ' static str , & ' static str ) > {
100- Ok ( ( "LD_PRELOAD" , "so" ) )
82+ #[ cfg( all( unix, not( target_vendor = "apple" ) , not( target_os = "cygwin" ) ) ) ]
83+ fn preload_strings ( ) -> ( & ' static str , & ' static str ) {
84+ ( "LD_PRELOAD" , "so" )
10185}
10286
10387#[ cfg( target_vendor = "apple" ) ]
104- #[ expect(
105- clippy:: unnecessary_wraps,
106- reason = "fn sig must match on all platforms"
107- ) ]
108- fn preload_strings ( ) -> UResult < ( & ' static str , & ' static str ) > {
109- Ok ( ( "DYLD_LIBRARY_PATH" , "dylib" ) )
88+ fn preload_strings ( ) -> ( & ' static str , & ' static str ) {
89+ ( "DYLD_LIBRARY_PATH" , "dylib" )
90+ }
91+
92+ #[ cfg( target_os = "cygwin" ) ]
93+ fn preload_strings ( ) -> ( & ' static str , & ' static str ) {
94+ ( "LD_PRELOAD" , "dll" )
11095}
11196
11297fn check_option ( matches : & ArgMatches , name : & str ) -> Result < BufferType , ProgramOptionsError > {
@@ -149,7 +134,7 @@ fn get_preload_env(tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
149134 use std:: fs:: File ;
150135 use std:: io:: Write ;
151136
152- let ( preload, extension) = preload_strings ( ) ? ;
137+ let ( preload, extension) = preload_strings ( ) ;
153138 let inject_path = tmp_dir. path ( ) . join ( "libstdbuf" ) . with_extension ( extension) ;
154139
155140 let mut file = File :: create ( & inject_path) ?;
@@ -160,7 +145,7 @@ fn get_preload_env(tmp_dir: &TempDir) -> UResult<(String, PathBuf)> {
160145
161146#[ cfg( feature = "feat_external_libstdbuf" ) ]
162147fn get_preload_env ( _tmp_dir : & TempDir ) -> UResult < ( String , PathBuf ) > {
163- let ( preload, extension) = preload_strings ( ) ? ;
148+ let ( preload, extension) = preload_strings ( ) ;
164149
165150 // Use the directory provided at compile time via LIBSTDBUF_DIR environment variable
166151 // This will fail to compile if LIBSTDBUF_DIR is not set, which is the desired behavior
0 commit comments