summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2012-02-26 21:01:44 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2012-02-26 21:01:44 +0000
commit628c511979cd7df4036d99ea9e46b4501b2a3027 (patch)
tree3d92ad535571c3405fff194923a7e6cd7227f94e
parent1b36e6b700e478eecfbc307913f4ce71da84a398 (diff)
Don't silently skip non-ASCII characters, but replace them with ``?''.
This is less likely to break the syntax of macros. Patch provided by joerg@.
-rw-r--r--usr.bin/mandoc/read.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 11862ac6120..d5d36ea11fe 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.5 2011/11/05 16:02:18 schwarze Exp $ */
+/* $Id: read.c,v 1.6 2012/02/26 21:01:43 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -315,9 +315,9 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int start)
* Warn about bogus characters. If you're using
* non-ASCII encoding, you're screwing your
* readers. Since I'd rather this not happen,
- * I'll be helpful and drop these characters so
- * we don't display gibberish. Note to manual
- * writers: use special characters.
+ * I'll be helpful and replace these characters
+ * with "?", so we don't display gibberish.
+ * Note to manual writers: use special characters.
*/
c = (unsigned char) blk.buf[i];
@@ -325,8 +325,11 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int start)
if ( ! (isascii(c) &&
(isgraph(c) || isblank(c)))) {
mandoc_msg(MANDOCERR_BADCHAR, curp,
- curp->line, pos, "ignoring byte");
+ curp->line, pos, NULL);
i++;
+ if (pos >= (int)ln.sz)
+ resize_buf(&ln, 256);
+ ln.buf[pos++] = '?';
continue;
}