1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

stat: Support \t in --printf format

This commit is contained in:
Tuomas Tynkkynen 2021-07-23 19:04:18 +03:00
parent eae8c72793
commit 46a2491727
2 changed files with 3 additions and 1 deletions

View file

@ -436,6 +436,7 @@ impl Stater {
'f' => tokens.push(Token::Char('\x0C')), 'f' => tokens.push(Token::Char('\x0C')),
'n' => tokens.push(Token::Char('\n')), 'n' => tokens.push(Token::Char('\n')),
'r' => tokens.push(Token::Char('\r')), 'r' => tokens.push(Token::Char('\r')),
't' => tokens.push(Token::Char('\t')),
'v' => tokens.push(Token::Char('\x0B')), 'v' => tokens.push(Token::Char('\x0B')),
c => { c => {
show_warning!("unrecognized escape '\\{}'", c); show_warning!("unrecognized escape '\\{}'", c);

View file

@ -64,7 +64,7 @@ mod test_generate_tokens {
#[test] #[test]
fn printf_format() { fn printf_format() {
let s = "%-# 15a\\r\\\"\\\\\\a\\b\\e\\f\\v%+020.-23w\\x12\\167\\132\\112\\n"; let s = "%-# 15a\\t\\r\\\"\\\\\\a\\b\\e\\f\\v%+020.-23w\\x12\\167\\132\\112\\n";
let expected = vec![ let expected = vec![
Token::Directive { Token::Directive {
flag: F_LEFT | F_ALTER | F_SPACE, flag: F_LEFT | F_ALTER | F_SPACE,
@ -72,6 +72,7 @@ mod test_generate_tokens {
precision: -1, precision: -1,
format: 'a', format: 'a',
}, },
Token::Char('\t'),
Token::Char('\r'), Token::Char('\r'),
Token::Char('"'), Token::Char('"'),
Token::Char('\\'), Token::Char('\\'),