mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
tr: fix graph/print character class mapping (#11405)
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
@@ -185,8 +185,7 @@ impl Sequence {
|
||||
.chain(33..=47)
|
||||
.chain(58..=64)
|
||||
.chain(91..=96)
|
||||
.chain(123..=126)
|
||||
.chain(std::iter::once(32)), // space
|
||||
.chain(123..=126),
|
||||
),
|
||||
Class::Print => Box::new(
|
||||
(48..=57) // digit
|
||||
@@ -196,7 +195,8 @@ impl Sequence {
|
||||
.chain(33..=47)
|
||||
.chain(58..=64)
|
||||
.chain(91..=96)
|
||||
.chain(123..=126),
|
||||
.chain(123..=126)
|
||||
.chain(std::iter::once(32)), // space
|
||||
),
|
||||
Class::Punct => Box::new((33..=47).chain(58..=64).chain(91..=96).chain(123..=126)),
|
||||
Class::Space => Box::new(unicode_table::SPACES.iter().copied()),
|
||||
|
||||
@@ -65,6 +65,38 @@ fn test_delete() {
|
||||
.stdout_is("BD");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_graph_and_print_match_gnu() {
|
||||
let input = [b' ', b'A', b'!', b'\t', b'\n'];
|
||||
new_ucmd!()
|
||||
.args(&["-d", "[:graph:]"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_is_bytes([b' ', b'\t', b'\n']);
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["-d", "[:print:]"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_is_bytes([b'\t', b'\n']);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_complement_graph_and_print_match_gnu() {
|
||||
let input = [b' ', b'A', b'!', b'\t', b'\n'];
|
||||
new_ucmd!()
|
||||
.args(&["-d", "-c", "[:graph:]"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_is_bytes([b'A', b'!']);
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["-d", "-c", "[:print:]"])
|
||||
.pipe_in(input)
|
||||
.succeeds()
|
||||
.stdout_is_bytes([b' ', b'A', b'!']);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_afterwards_is_not_flag() {
|
||||
new_ucmd!()
|
||||
|
||||
Reference in New Issue
Block a user