diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-11-17 16:27:20 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-11-17 16:27:20 -0800 |
commit | a9b23a145709f2f8fac65964f363da3829ee6745 (patch) | |
tree | 6a43bce11de793be814ffe9589d20be3ae7b0dd8 /lib.c | |
parent | ba889a439e4f7b5a2f03dc0dbd9795f079674fae (diff) | |
download | txr-a9b23a145709f2f8fac65964f363da3829ee6745.tar.gz txr-a9b23a145709f2f8fac65964f363da3829ee6745.tar.bz2 txr-a9b23a145709f2f8fac65964f363da3829ee6745.zip |
printer: no leading zeros in hex chars.
* lib.c (obj_print_impl): Drop the complicated logic for
printing a character as 2, 4 or 6 hex digits. All characters
that must print using the #\x notation are jus printed using
the ~X format specifier with no precision or leading zeros,
which will use just as many digits as are required.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -12562,7 +12562,6 @@ dot: put_char(obj, out); } else { wchar_t ch = c_chr(obj); - val fmt = nil; put_string(lit("#\\"), out); switch (ch) { @@ -12578,20 +12577,18 @@ dot: case ' ': put_string(lit("space"), out); break; case 0xDC00: put_string(lit("pnul"), out); break; case 0xFEFF: case 0xFFFE: case 0xFFFF: - goto fourhex; + hex: + format(out, lit("x~X"), num(ch), nao); + break; default: if ((ch < 0x20) || (ch >= 0x7F && ch < 0xA0)) - fmt = lit("x~,02X"); + goto hex; else if (ch >= 0xD800 && ch < 0xE000) - fourhex: - fmt = lit("x~,04X"); + goto hex; else if (ch >= 0xFFFF) - fmt = lit("x~,06X"); + goto hex; else put_char(chr(ch), out); - - if (fmt) - format(out, fmt, num(ch), nao); } } break; |