diff options
author | 2010-02-18 02:11:25 +0000 | |
---|---|---|
committer | 2010-02-18 02:11:25 +0000 | |
commit | 8521b0bc6a75dbf2d60be65720832c7020cebee4 (patch) | |
tree | 8ab758f039cdac98a59ee9d190ce4bb9b9617f2d /usr.bin/mandoc/man.c | |
parent | The .TP man(7) macro requires text on the following line, to be used as (diff) | |
download | wireguard-openbsd-8521b0bc6a75dbf2d60be65720832c7020cebee4.tar.xz wireguard-openbsd-8521b0bc6a75dbf2d60be65720832c7020cebee4.zip |
sync to release 1.9.15:
* corrected .Vt handling (spotted by Joerg Sonnenberger)
* corrected .Xr argument handling (based on my patch)
* removed \\ escape sequence (because it is for low-level roff only)
* warn about trailing whitespace (suggested by jmc@)
* -Txhtml support
* and some general cleanup and doc improvements
Diffstat (limited to 'usr.bin/mandoc/man.c')
-rw-r--r-- | usr.bin/mandoc/man.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c index ebbf4ccdb35..d9a88f7b648 100644 --- a/usr.bin/mandoc/man.c +++ b/usr.bin/mandoc/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.17 2009/12/23 22:30:17 schwarze Exp $ */ +/* $Id: man.c,v 1.18 2010/02/18 02:11:26 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -361,6 +361,7 @@ static int man_ptext(struct man *m, int line, char *buf) { int i, j; + char sv; /* Literal free-form text whitespace is preserved. */ @@ -374,7 +375,12 @@ man_ptext(struct man *m, int line, char *buf) for (i = 0; ' ' == buf[i]; i++) /* Skip leading whitespace. */ ; - if (0 == buf[i]) { + + if ('\0' == buf[i]) { + /* Trailing whitespace? */ + if (i && ' ' == buf[i - 1]) + if ( ! man_pwarn(m, line, i - 1, WTSPACE)) + return(0); if ( ! pstring(m, line, 0, &buf[i], 0)) return(0); goto descope; @@ -388,15 +394,30 @@ man_ptext(struct man *m, int line, char *buf) if (i && ' ' == buf[i] && '\\' == buf[i - 1]) continue; - buf[i++] = 0; + sv = buf[i]; + buf[i++] = '\0'; + if ( ! pstring(m, line, j, &buf[j], (size_t)(i - j))) return(0); + /* Trailing whitespace? Check at overwritten byte. */ + + if (' ' == sv && '\0' == buf[i]) + if ( ! man_pwarn(m, line, i - 1, WTSPACE)) + return(0); + for ( ; ' ' == buf[i]; i++) /* Skip trailing whitespace. */ ; j = i; - if (0 == buf[i]) + + /* Trailing whitespace? */ + + if (' ' == buf[i - 1] && '\0' == buf[i]) + if ( ! man_pwarn(m, line, i - 1, WTSPACE)) + return(0); + + if ('\0' == buf[i]) break; } @@ -459,7 +480,7 @@ man_pmacro(struct man *m, int ln, char *buf) i++; while (buf[i] && ' ' == buf[i]) i++; - if (0 == buf[i]) + if ('\0' == buf[i]) goto out; } @@ -468,7 +489,7 @@ man_pmacro(struct man *m, int ln, char *buf) /* Copy the first word into a nil-terminated buffer. */ for (j = 0; j < 4; j++, i++) { - if (0 == (mac[j] = buf[i])) + if ('\0' == (mac[j] = buf[i])) break; else if (' ' == buf[i]) break; @@ -503,6 +524,12 @@ man_pmacro(struct man *m, int ln, char *buf) while (buf[i] && ' ' == buf[i]) i++; + /* Trailing whitespace? */ + + if ('\0' == buf[i] && ' ' == buf[i - 1]) + if ( ! man_pwarn(m, ln, i - 1, WTSPACE)) + goto err; + /* Remove prior ELINE macro, if applicable. */ if (m->flags & MAN_ELINE) { |