Skip to content

Commit e6e285a

Browse files
3v1n0sylvestre
authored andcommitted
stty: Use c_line (as line_discipline) from nix
Nix now supports the line discipline parameter in various platforms, so use upstream definition instead of going through libc See: nix-rust/nix#1802
1 parent 4d3b4b9 commit e6e285a

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/uu/stty/src/stty.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,9 @@ fn print_terminal_size(
636636
);
637637
}
638638

639-
#[cfg(any(target_os = "linux", target_os = "redox"))]
639+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "haiku"))]
640640
{
641-
// For some reason the normal nix Termios struct does not expose the line,
642-
// so we get the underlying libc::termios struct to get that information.
643-
let libc_termios: nix::libc::termios = termios.clone().into();
644-
let line = libc_termios.c_line;
641+
let line = termios.line_discipline;
645642
printer.print(&translate!("stty-output-line", "line" => line));
646643
}
647644
printer.flush();
@@ -1030,7 +1027,7 @@ fn apply_special_setting(
10301027
SpecialSetting::Cols(n) => size.columns = *n,
10311028
SpecialSetting::Line(_n) => {
10321029
// nix only defines Termios's `line_discipline` field on these platforms
1033-
#[cfg(any(target_os = "linux", target_os = "android"))]
1030+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "haiku"))]
10341031
{
10351032
_termios.line_discipline = *_n;
10361033
}

0 commit comments

Comments
 (0)