summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-08-29 23:56:01 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-08-29 23:56:01 +0000
commit01c1e070bb9640567ef7f1b0e926135d634de07d (patch)
treed987d3be43dbfe29e9f474adf80b0bf3e3df7ddc
parent7db5146c651943cae039a73f4c2c3196cf08b086 (diff)
downloadmandoc-01c1e070bb9640567ef7f1b0e926135d634de07d.tar.gz
If we have to reparse the text line because we spring an input line trap,
we must not escape breakable hyphens yet, or mparse_buf_r() in read.c will complain and replace the escaped hyphens with question marks. Bug found in ocserv(8) following a report from Kurt Jaeger <pi at FreeBSD>.
-rw-r--r--roff.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/roff.c b/roff.c
index 24c0898a..0da8b963 100644
--- a/roff.c
+++ b/roff.c
@@ -1484,9 +1484,7 @@ roff_res(struct roff *r, struct buf *buf, int ln, int pos)
}
/*
- * Process text streams:
- * Convert all breakable hyphens into ASCII_HYPH.
- * Decrement and spring input line trap.
+ * Process text streams.
*/
static enum rofferr
roff_parsetext(struct buf *buf, int pos, int *offs)
@@ -1497,6 +1495,22 @@ roff_parsetext(struct buf *buf, int pos, int *offs)
int isz;
enum mandoc_esc esc;
+ /* Spring the input line trap. */
+
+ if (roffit_lines == 1) {
+ isz = mandoc_asprintf(&p, "%s\n.%s", buf->buf, roffit_macro);
+ free(buf->buf);
+ buf->buf = p;
+ buf->sz = isz + 1;
+ *offs = 0;
+ free(roffit_macro);
+ roffit_lines = 0;
+ return(ROFF_REPARSE);
+ } else if (roffit_lines > 1)
+ --roffit_lines;
+
+ /* Convert all breakable hyphens into ASCII_HYPH. */
+
start = p = buf->buf + pos;
while (*p != '\0') {
@@ -1525,19 +1539,6 @@ roff_parsetext(struct buf *buf, int pos, int *offs)
*p = ASCII_HYPH;
p++;
}
-
- /* Spring the input line trap. */
- if (roffit_lines == 1) {
- isz = mandoc_asprintf(&p, "%s\n.%s", buf->buf, roffit_macro);
- free(buf->buf);
- buf->buf = p;
- buf->sz = isz + 1;
- *offs = 0;
- free(roffit_macro);
- roffit_lines = 0;
- return(ROFF_REPARSE);
- } else if (roffit_lines > 1)
- --roffit_lines;
return(ROFF_CONT);
}