aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
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
commitc811b41609dc2a80154d0dec89ac310da527f301 (patch)
tree3d6e6477989c682f7e21928e27c996c6ffe2a850 /roff.c
parent7794af01645f7ec7af31393921bc662b4e970d47 (diff)
downloadmandoc-c811b41609dc2a80154d0dec89ac310da527f301.tar.gz
mandoc-c811b41609dc2a80154d0dec89ac310da527f301.tar.zst
mandoc-c811b41609dc2a80154d0dec89ac310da527f301.zip
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>.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/roff.c b/roff.c
index e72c965a..56259162 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.274 2015/08/29 21:37:20 schwarze Exp $ */
+/* $Id: roff.c,v 1.275 2015/08/29 23:56:01 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}