X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/2cc9df49aa3cd600a0b05463454254f8b25ef6c3..138483e8c7e6cccb5209979e94fec1fd87d0c343:/mdoc.c diff --git a/mdoc.c b/mdoc.c index 3dc159e6..96b4bffd 100644 --- a/mdoc.c +++ b/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.115 2010/01/07 10:05:24 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.116 2010/01/07 10:24:43 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -581,6 +581,7 @@ static int parsetext(struct mdoc *m, int line, char *buf) { int i, j; + char sv; if (SEC_NONE == m->lastnamed) return(mdoc_perr(m, line, 0, ETEXTPROL)); @@ -614,15 +615,29 @@ parsetext(struct mdoc *m, int line, char *buf) if (i && ' ' == buf[i] && '\\' == buf[i - 1]) continue; + 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 ( ! mdoc_pwarn(m, line, i - 1, ETAILWS)) + return(0); + for ( ; ' ' == buf[i]; i++) /* Skip trailing whitespace. */ ; j = i; + + /* Trailing whitespace? */ + + if (' ' == buf[i - 1] && '\0' == buf[i]) + if ( ! mdoc_pwarn(m, line, i - 1, ETAILWS)) + return(0); + if ('\0' == buf[i]) break; }