diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index d25936628d2..ed38c067de1 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -78,7 +78,7 @@ pub const INPUT_FLAGS: &[Flag] = &[ // Flag::new("iuclc", I::IUCLC), #[cfg(not(target_os = "redox"))] Flag::new("ixany", I::IXANY), - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "haiku", target_os = "redox")))] Flag::new("imaxbel", I::IMAXBEL).sane(), #[cfg(any(target_vendor = "apple", target_os = "android", target_os = "linux"))] Flag::new("iutf8", I::IUTF8), @@ -245,7 +245,7 @@ pub const LOCAL_FLAGS: &[Flag] = &[ Flag::new("crtkill", L::ECHOKE).sane().hidden(), #[cfg(not(target_os = "redox"))] Flag::new("flusho", L::FLUSHO), - #[cfg(not(any(target_os = "cygwin", target_os = "redox")))] + #[cfg(not(any(target_os = "cygwin", target_os = "haiku", target_os = "redox")))] Flag::new("extproc", L::EXTPROC), ]; @@ -275,6 +275,7 @@ pub const BAUD_RATES: &[(&str, BaudRate)] = &[ #[cfg(not(any( target_os = "cygwin", target_os = "fuchsia", + target_os = "haiku", target_os = "hurd", target_os = "redox" )))] @@ -287,6 +288,7 @@ pub const BAUD_RATES: &[(&str, BaudRate)] = &[ #[cfg(not(any( target_os = "cygwin", target_os = "fuchsia", + target_os = "haiku", target_os = "hurd", target_os = "redox" )))] @@ -349,12 +351,16 @@ pub const CONTROL_CHARS: &[(&str, S)] = &[ // Sends a suspend signal (SIGTSTP). ("susp", S::VSUSP), // Reprints the current line. + #[cfg(not(target_os = "haiku"))] ("rprnt", S::VREPRINT), // Deletes the last word typed. + #[cfg(not(target_os = "haiku"))] ("werase", S::VWERASE), // Enters literal mode (next character is taken literally). + #[cfg(not(target_os = "haiku"))] ("lnext", S::VLNEXT), // Discards the current line. + #[cfg(not(target_os = "haiku"))] ("discard", S::VDISCARD), ]; diff --git a/src/uu/stty/src/stty.rs b/src/uu/stty/src/stty.rs index 4a54d7d4de2..ed96c8b902d 100644 --- a/src/uu/stty/src/stty.rs +++ b/src/uu/stty/src/stty.rs @@ -45,18 +45,22 @@ use flags::{CONTROL_CHARS, CONTROL_FLAGS, INPUT_FLAGS, LOCAL_FLAGS, OUTPUT_FLAGS const ASCII_DEL: u8 = 127; // Sane defaults for control characters. -const SANE_CONTROL_CHARS: [(S, u8); 12] = [ - (S::VINTR, 3), // ^C - (S::VQUIT, 28), // ^\ - (S::VERASE, 127), // DEL - (S::VKILL, 21), // ^U - (S::VEOF, 4), // ^D - (S::VSTART, 17), // ^Q - (S::VSTOP, 19), // ^S - (S::VSUSP, 26), // ^Z +const SANE_CONTROL_CHARS: &[(S, u8)] = &[ + (S::VINTR, 3), // ^C + (S::VQUIT, 28), // ^\ + (S::VERASE, 127), // DEL + (S::VKILL, 21), // ^U + (S::VEOF, 4), // ^D + (S::VSTART, 17), // ^Q + (S::VSTOP, 19), // ^S + (S::VSUSP, 26), // ^Z + #[cfg(not(target_os = "haiku"))] (S::VREPRINT, 18), // ^R - (S::VWERASE, 23), // ^W - (S::VLNEXT, 22), // ^V + #[cfg(not(target_os = "haiku"))] + (S::VWERASE, 23), // ^W + #[cfg(not(target_os = "haiku"))] + (S::VLNEXT, 22), // ^V + #[cfg(not(target_os = "haiku"))] (S::VDISCARD, 15), // ^O ]; @@ -1026,9 +1030,13 @@ fn combo_to_flags(combo: &str) -> Vec> { (S::VSTART, "^Q"), (S::VSTOP, "^S"), (S::VSUSP, "^Z"), + #[cfg(not(target_os = "haiku"))] (S::VREPRINT, "^R"), + #[cfg(not(target_os = "haiku"))] (S::VWERASE, "^W"), + #[cfg(not(target_os = "haiku"))] (S::VLNEXT, "^V"), + #[cfg(not(target_os = "haiku"))] (S::VDISCARD, "^O"), ], _ => &[], @@ -1084,16 +1092,11 @@ fn combo_to_flags(combo: &str) -> Vec> { } fn get_sane_control_char(cc_index: S) -> u8 { - for (sane_index, sane_val) in SANE_CONTROL_CHARS { - if sane_index == cc_index { - return sane_val; - } - } - // Default values for control chars not in the sane list - match cc_index { - S::VMIN => 1, - _ => 0, - } + SANE_CONTROL_CHARS + .iter() + .copied() + .find_map(|(i, v)| (i == cc_index).then_some(v)) + .unwrap_or(u8::from(cc_index == S::VMIN)) } pub fn uu_app() -> Command {