summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-29 00:17:02 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-29 00:17:02 +0000
commita5ff6d8934e26bc098d34918dc831ee2981b5e64 (patch)
treeca0cd36f68f76f67819ea5aa07e11c881fb0e612 /usr.bin/mandoc/html.c
parent39a2da78dc8188292b51da7da1bcb4fadaa7f50f (diff)
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.
Diffstat (limited to 'usr.bin/mandoc/html.c')
-rw-r--r--usr.bin/mandoc/html.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/mandoc/html.c b/usr.bin/mandoc/html.c
index 14fe83c629b..1e199ef807a 100644
--- a/usr.bin/mandoc/html.c
+++ b/usr.bin/mandoc/html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.50 2014/10/28 17:35:42 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.51 2014/10/29 00:17:01 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -420,9 +420,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)
@@ -431,9 +435,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);