printf: Fix octal escapes with leading zeroes

Octal escapes can be written as `\057` or as `\0057`.

Simply ported wrong initially.
This commit is contained in:
Fabian Boehm 2023-10-05 15:39:50 +02:00
parent 8cc0bdeed8
commit 3ce67ecbd2
2 changed files with 5 additions and 1 deletions

View File

@ -698,7 +698,7 @@ impl<'a> builtin_printf_state_t<'a> {
while !str.is_empty() {
let c = str.char_at(0);
if c == '\\' {
let consumed_minus_1 = self.print_esc(str, false);
let consumed_minus_1 = self.print_esc(str, true);
str = &str[consumed_minus_1..];
} else {
self.append_output(c);

View File

@ -147,3 +147,7 @@ echo
printf --help
echo
# CHECK: --help
# This is how mc likes to encode the directory we should cd to.
printf '%b\n' '\0057foo\0057bar\0057'
# CHECK: /foo/bar/