summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-08-29 23:55:54 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-08-29 23:55:54 +0000
commit9ac58df6bfbd908aa80137bb6bb51df7f9d5308e (patch)
tree7bca3f3909b380ef1c32d630e60a8f28351729c9
parente3430b38f830e9fa001b214615ea81090184b962 (diff)
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--usr.bin/mandoc/roff.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 534a4ef847f..7d67d434ded 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.146 2015/08/29 21:37:11 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.147 2015/08/29 23:55:53 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -1482,9 +1482,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)
@@ -1495,6 +1493,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') {
@@ -1523,19 +1537,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);
}