aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@netbsd.org>2012-02-05 16:46:15 +0000
committerJoerg Sonnenberger <joerg@netbsd.org>2012-02-05 16:46:15 +0000
commitc52306308535a3ccd6b1bc672343ef135db23988 (patch)
treee06b11f2f7e8864b82525be959db783be47da3c2 /read.c
parent2cf4883bf9e6c647f1db66bc58b98ba2fa62da88 (diff)
downloadmandoc-c52306308535a3ccd6b1bc672343ef135db23988.tar.gz
mandoc-c52306308535a3ccd6b1bc672343ef135db23988.tar.zst
mandoc-c52306308535a3ccd6b1bc672343ef135db23988.zip
Don't silently skip non-ASCII characters, but replace them with ``?''.
This is less likely to break the syntax of macros.
Diffstat (limited to 'read.c')
-rw-r--r--read.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/read.c b/read.c
index 2e66757b..6dab8e0a 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.26 2011/11/07 01:24:40 schwarze Exp $ */
+/* $Id: read.c,v 1.27 2012/02/05 16:46:15 joerg Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -325,9 +325,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];
@@ -335,8 +335,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;
}