=================================================================== RCS file: /cvs/mandoc/read.c,v retrieving revision 1.24 retrieving revision 1.27 diff -u -p -r1.24 -r1.27 --- mandoc/read.c 2011/10/06 22:29:12 1.24 +++ mandoc/read.c 2012/02/05 16:46:15 1.27 @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.24 2011/10/06 22:29:12 kristaps Exp $ */ +/* $Id: read.c,v 1.27 2012/02/05 16:46:15 joerg Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -192,7 +192,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = "not a manual", "column syntax is inconsistent", "NOT IMPLEMENTED: .Bd -file", - "line scope broken, syntax violated", "argument count wrong, violates syntax", "child violates parent syntax", "argument count wrong, violates syntax", @@ -326,9 +325,9 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int * 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]; @@ -336,8 +335,11 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int 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; } @@ -464,7 +466,8 @@ rerun: * buffer because we're going to descend into * the file recursively. */ - curp->secondary->sz -= pos + 1; + if (curp->secondary) + curp->secondary->sz -= pos + 1; mparse_readfd_r(curp, -1, ln.buf + of, 1); if (MANDOCLEVEL_FATAL <= curp->file_status) break;