diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-08-29 23:56:01 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-08-29 23:56:01 +0000 |
commit | 01c1e070bb9640567ef7f1b0e926135d634de07d (patch) | |
tree | d987d3be43dbfe29e9f474adf80b0bf3e3df7ddc | |
parent | 7db5146c651943cae039a73f4c2c3196cf08b086 (diff) | |
download | mandoc-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.c | 33 |
1 files changed, 17 insertions, 16 deletions
@@ -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); } |