diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-30 14:07:00 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-30 14:07:00 -0600 |
commit | 691d3fe7ff920e8113d174c2ce6c3126000a2f82 (patch) | |
tree | 827a1e09e6a7dfe1cf20277e95ec503f1e2fef80 /libmisc/fmt.c | |
parent | bf3667b8b76eefd95e33e32b4f5abbf2de0e2065 (diff) | |
parent | 9c0b5f1f0b2009ab628400e10c18ec64ede696d8 (diff) |
Merge branch 'lukeshu/more-coverage'
Diffstat (limited to 'libmisc/fmt.c')
-rw-r--r-- | libmisc/fmt.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/libmisc/fmt.c b/libmisc/fmt.c index a8baa84..7c18ef5 100644 --- a/libmisc/fmt.c +++ b/libmisc/fmt.c @@ -71,9 +71,33 @@ void fmt_print_ptr(lo_interface fmt_dest w, void *ptr) { */ void fmt_print_qbyte(lo_interface fmt_dest w, uint8_t b) { fmt_print_byte(w, '\''); - if (' ' <= b && b <= '~') { - if (b == '\'' || b == '\\') - fmt_print_byte(w, '\\'); + if (b == '\0' || + b == '\b' || + b == '\f' || + b == '\n' || + b == '\r' || + b == '\t' || + b == '\v' || + b == '\\' || + b == '\'' || + b == '"' || + b == '?') { + fmt_print_byte(w, '\\'); + switch (b) { + case '\0': fmt_print_byte(w, '0'); break; + case '\a': fmt_print_byte(w, 'a'); break; + case '\b': fmt_print_byte(w, 'b'); break; + case '\f': fmt_print_byte(w, 'f'); break; + case '\n': fmt_print_byte(w, 'n'); break; + case '\r': fmt_print_byte(w, 'r'); break; + case '\t': fmt_print_byte(w, 't'); break; + case '\v': fmt_print_byte(w, 'v'); break; + case '\\': fmt_print_byte(w, '\\'); break; + case '\'': fmt_print_byte(w, '\''); break; + case '"': fmt_print_byte(w, '"'); break; + case '?': fmt_print_byte(w, '?'); break; + } + } else if (' ' <= b && b <= '~') { fmt_print_byte(w, b); } else { fmt_print_byte(w, '\\'); |