Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
// spell-checker:ignore (ToDO) getreent reent IOFBF IOLBF IONBF setvbuf stderrp stdinp stdoutp
// spell-checker:ignore (ToDO) getreent reent IOFBF IOLBF IONBF setvbuf stderrp stdinp stdoutp fdopen

use ctor::ctor;
use libc::{_IOFBF, _IOLBF, _IONBF, FILE, c_char, c_int, fileno, size_t};
Expand Down Expand Up @@ -35,6 +35,11 @@ pub unsafe extern "C" fn __stdbuf_get_stdin() -> *mut FILE {
unsafe { __stdin }
}

#[cfg(target_os = "netbsd")]
{
unsafe { libc::fdopen(0, c"r".as_ptr()) }
}

#[cfg(target_os = "cygwin")]
{
// _getreent()->_std{in,out,err}
Expand All @@ -61,6 +66,7 @@ pub unsafe extern "C" fn __stdbuf_get_stdin() -> *mut FILE {
#[cfg(not(any(
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin"
)))]
Expand Down Expand Up @@ -92,6 +98,11 @@ pub unsafe extern "C" fn __stdbuf_get_stdout() -> *mut FILE {
unsafe { __stdout }
}

#[cfg(target_os = "netbsd")]
{
unsafe { libc::fdopen(1, c"w".as_ptr()) }
}

#[cfg(target_os = "cygwin")]
{
// _getreent()->_std{in,out,err}
Expand All @@ -118,6 +129,7 @@ pub unsafe extern "C" fn __stdbuf_get_stdout() -> *mut FILE {
#[cfg(not(any(
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin"
)))]
Expand Down Expand Up @@ -149,6 +161,11 @@ pub unsafe extern "C" fn __stdbuf_get_stderr() -> *mut FILE {
unsafe { __stderr }
}

#[cfg(target_os = "netbsd")]
{
unsafe { libc::fdopen(2, c"w".as_ptr()) }
}

#[cfg(target_os = "cygwin")]
{
// _getreent()->_std{in,out,err}
Expand All @@ -175,6 +192,7 @@ pub unsafe extern "C" fn __stdbuf_get_stderr() -> *mut FILE {
#[cfg(not(any(
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin"
)))]
Expand Down
Loading