From 1b2b0a521e5fb13fb845879ff53b5201b76097f4 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 29 Oct 2014 00:17:43 +0000 Subject: In terminal output, unify handling of Unicode and numbered character escape sequences just like it was earlier implemented for -Thtml. Do not let control characters other than ASCII 9 (horizontal tab) propagate to the output, even though groff allows them; but that really doesn't look like a great idea. Let mchars_num2char() return int such that we can distinguish invalid \N syntax from \N'0'. This also reduces the danger of signed char issues popping up. --- html.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index 01514937..ff68e6e1 100644 --- a/html.c +++ b/html.c @@ -422,9 +422,13 @@ print_encode(struct html *h, const char *p, int norecurse) break; case ESCAPE_NUMBERED: c = mchars_num2char(seq, len); + if (c < 0) + continue; break; case ESCAPE_SPECIAL: c = mchars_spec2cp(h->symtab, seq, len); + if (c <= 0) + continue; break; case ESCAPE_NOSPACE: if ('\0' == *p) @@ -433,9 +437,8 @@ print_encode(struct html *h, const char *p, int norecurse) default: continue; } - if (c <= 0) - continue; - if (c < 0x20 || (c > 0x7E && c < 0xA0)) + if ((c < 0x20 && c != 0x09) || + (c > 0x7E && c < 0xA0)) c = 0xFFFD; if (c > 0x7E) printf("&#%d;", c); -- cgit