ed

[hare] The standard editor
Log | Files | Refs | README | LICENSE

commit 8c30c8b01d98d352e289c0167f6a5089427076e3
parent 851cf0c7d42d4b065cdbe996898cd339ec0984f6
Author: Byron Torres <b@torresjrjr.com>
Date:   Wed, 10 Jan 2024 02:07:29 +0000

printlistline(): print octal non-printable chars

Diffstat:
Mprint.ha | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/print.ha b/print.ha @@ -1,3 +1,4 @@ +use ascii; use fmt; use io; use strings; @@ -73,7 +74,11 @@ fn printlistline(text: str) (size | io::error) = { case '$' => yield fmt::print("\\$")?; case => - yield fmt::print(r)?; + if (!ascii::isprint(r)) + // XXX: assuming r is ascii + yield fmt::printf("\\{:o_03}", r: u32)? + else + yield fmt::print(r)?; }; };