diff --git a/src/uu/tr/src/operation.rs b/src/uu/tr/src/operation.rs index eae348370..f440487c8 100644 --- a/src/uu/tr/src/operation.rs +++ b/src/uu/tr/src/operation.rs @@ -45,6 +45,7 @@ impl Sequence { Sequence::parse_upper, Sequence::parse_xdigit, Sequence::parse_char_equal, + // NOTE: This must be the last one Sequence::parse_char, )), )))(input) @@ -110,6 +111,7 @@ impl Sequence { tag("["), anychar, tag("*"), + // TODO: Extend this to support octal as well. Octal starts with 0. take_while1(|c: char| c.is_digit(10)), tag("]"), ))(input) @@ -440,7 +442,7 @@ impl SymbolTranslator for SqueezeOperation { } } -pub fn translate_input_new(input: &mut R, output: &mut W, mut translator: T) +pub fn translate_input(input: &mut R, output: &mut W, mut translator: T) where T: SymbolTranslator, R: BufRead, diff --git a/src/uu/tr/src/tr.rs b/src/uu/tr/src/tr.rs index 581595385..3ba06920a 100644 --- a/src/uu/tr/src/tr.rs +++ b/src/uu/tr/src/tr.rs @@ -19,7 +19,7 @@ mod unicode_table; use clap::{crate_version, App, Arg}; use nom::AsBytes; -use operation::{translate_input_new, Sequence, SqueezeOperation, TranslateOperation}; +use operation::{translate_input, Sequence, SqueezeOperation, TranslateOperation}; use std::io::{stdin, stdout, BufReader, BufWriter}; use crate::operation::DeleteOperation; @@ -98,22 +98,22 @@ pub fn uumain(args: impl uucore::Args) -> i32 { let mut delete_writer = BufWriter::new(&mut delete_buffer); let delete_op = DeleteOperation::new(Sequence::parse_set_string(&sets[0]), complement_flag); - translate_input_new(&mut locked_stdin, &mut delete_writer, delete_op); + translate_input(&mut locked_stdin, &mut delete_writer, delete_op); } { let mut squeeze_reader = BufReader::new(delete_buffer.as_bytes()); let squeeze_op = SqueezeOperation::new(Sequence::parse_set_string(&sets[1]), complement_flag); - translate_input_new(&mut squeeze_reader, &mut buffered_stdout, squeeze_op); + translate_input(&mut squeeze_reader, &mut buffered_stdout, squeeze_op); } } else { let op = DeleteOperation::new(Sequence::parse_set_string(&sets[0]), complement_flag); - translate_input_new(&mut locked_stdin, &mut buffered_stdout, op); + translate_input(&mut locked_stdin, &mut buffered_stdout, op); } } else if squeeze_flag { if sets.len() < 2 { let op = SqueezeOperation::new(Sequence::parse_set_string(&sets[0]), complement_flag); - translate_input_new(&mut locked_stdin, &mut buffered_stdout, op); + translate_input(&mut locked_stdin, &mut buffered_stdout, op); } else { let mut translate_buffer = vec![]; { @@ -124,12 +124,12 @@ pub fn uumain(args: impl uucore::Args) -> i32 { truncate_set1_flag, complement_flag, ); - translate_input_new(&mut locked_stdin, &mut writer, translate_op); + translate_input(&mut locked_stdin, &mut writer, translate_op); } { let mut reader = BufReader::new(translate_buffer.as_bytes()); let squeeze_op = SqueezeOperation::new(Sequence::parse_set_string(&sets[1]), false); - translate_input_new(&mut reader, &mut buffered_stdout, squeeze_op); + translate_input(&mut reader, &mut buffered_stdout, squeeze_op); } } } else { @@ -139,7 +139,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { truncate_set1_flag, complement_flag, ); - translate_input_new(&mut locked_stdin, &mut buffered_stdout, op); + translate_input(&mut locked_stdin, &mut buffered_stdout, op); } 0