Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions src/uu/stty/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub const INPUT_FLAGS: &[Flag<I>] = &[
// 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),
Expand Down Expand Up @@ -245,7 +245,7 @@ pub const LOCAL_FLAGS: &[Flag<L>] = &[
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),
];

Expand Down Expand Up @@ -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"
)))]
Comment on lines 275 to 281

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what this is. But I'd like to have cfg_aliase for them.

Expand All @@ -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"
)))]
Expand Down Expand Up @@ -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),
];

Expand Down
45 changes: 24 additions & 21 deletions src/uu/stty/src/stty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
];

Expand Down Expand Up @@ -1026,9 +1030,13 @@ fn combo_to_flags(combo: &str) -> Vec<ArgOptions<'_>> {
(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"),
],
_ => &[],
Expand Down Expand Up @@ -1084,16 +1092,11 @@ fn combo_to_flags(combo: &str) -> Vec<ArgOptions<'_>> {
}

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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about splitting this which does not conflict?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_sane_control_char doesn't seem to conflict when rebased onto your PR; there's only a minor conflict elsewhere. I just wanted to keep you informed of the conflict.

That said, I think do think it would be preferable to merge this before the more substantial changes in #15299.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where? cfg gate?

}

pub fn uu_app() -> Command {
Expand Down
Loading