summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-09-10 19:33:08 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-09-10 19:33:08 -0700
commita615af8eff76e33bb5bd4dcd591d2857096f6258 (patch)
tree8bfdd430d915b09bd8e3ee05d7f169845a02ad4b /lib.c
parent595c0bee41e0c7286c9779ab8f08ca6ec140c8d7 (diff)
downloadtxr-a615af8eff76e33bb5bd4dcd591d2857096f6258.tar.gz
txr-a615af8eff76e33bb5bd4dcd591d2857096f6258.tar.bz2
txr-a615af8eff76e33bb5bd4dcd591d2857096f6258.zip
printer: put out BOM character as #\xFEFF.
* lib.c (obj_print_impl): The Unicode BOM is also a zero width non-breaking space, which causes it to look like the incomplete #\ syntax. Let's instead render it as #\xFEFF. A few other hex cases are moved up into the surrounding switch, and a little goto takes care of avoiding code duplication.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 3b2aa4af..467b1785 100644
--- a/lib.c
+++ b/lib.c
@@ -11513,10 +11513,13 @@ dot:
case 27: put_string(lit("esc"), out); break;
case ' ': put_string(lit("space"), out); break;
case 0xDC00: put_string(lit("pnul"), out); break;
+ case 0xFEFF: case 0xFFFE: case 0xFFFF:
+ goto fourhex;
default:
if ((ch < 0x20) || (ch >= 0x7F && ch < 0xA0))
fmt = lit("x~,02X");
- else if ((ch >= 0xD800 && ch < 0xE000) || ch == 0xFFFE || ch == 0xFFFF)
+ else if (ch >= 0xD800 && ch < 0xE000)
+ fourhex:
fmt = lit("x~,04X");
else if (ch >= 0xFFFF)
fmt = lit("x~,06X");