summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2010-08-08 14:45:59 +0000
committerIngo Schwarze <schwarze@openbsd.org>2010-08-08 14:45:59 +0000
commit707c79c1b528a7fd9042ccdadadb8154470066e5 (patch)
treed5d1493da894a8794670afa36526ed49aa269315 /main.c
parent556aafc9aef6fb2d86a1cc5928f39267b81bc0a8 (diff)
downloadmandoc-707c79c1b528a7fd9042ccdadadb8154470066e5.tar.gz
Make sure we really throw away non-ASCII characters.
For example, on OpenBSD without locale settings, isgraph(3) returns true for some eight-bit characters. ok kristaps@
Diffstat (limited to 'main.c')
-rw-r--r--main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/main.c b/main.c
index 4501d241..d8df12a8 100644
--- a/main.c
+++ b/main.c
@@ -466,6 +466,7 @@ fdesc(struct curparse *curp)
struct buf ln, blk;
int i, pos, lnn, lnn_start, with_mmap, of;
enum rofferr re;
+ unsigned char c;
struct man *man;
struct mdoc *mdoc;
struct roff *roff;
@@ -508,8 +509,8 @@ fdesc(struct curparse *curp)
* writers: use special characters.
*/
- if ( ! isgraph((u_char)blk.buf[i]) &&
- ! isblank((u_char)blk.buf[i])) {
+ c = (unsigned char) blk.buf[i];
+ if ( ! (isascii(c) && (isgraph(c) || isblank(c)))) {
if ( ! mmsg(MANDOCERR_BADCHAR, curp,
lnn_start, pos,
"ignoring byte"))