=================================================================== RCS file: /cvs/mandoc/man.c,v retrieving revision 1.46 retrieving revision 1.48 diff -u -p -r1.46 -r1.48 --- mandoc/man.c 2009/11/02 08:40:31 1.46 +++ mandoc/man.c 2010/01/07 10:05:24 1.48 @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.46 2009/11/02 08:40:31 kristaps Exp $ */ +/* $Id: man.c,v 1.48 2010/01/07 10:05:24 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -14,6 +14,10 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include @@ -72,11 +76,7 @@ static int pstring(struct man *, int, int, const char *, size_t); static int macrowarn(struct man *, int, const char *); -#ifdef __linux__ -extern size_t strlcpy(char *, const char *, size_t); -#endif - const struct man_node * man_node(const struct man *m) { @@ -378,6 +378,7 @@ man_ptext(struct man *m, int line, char *buf) for (i = 0; ' ' == buf[i]; i++) /* Skip leading whitespace. */ ; + if (0 == buf[i]) { if ( ! pstring(m, line, 0, &buf[i], 0)) return(0); @@ -463,7 +464,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; } @@ -472,7 +473,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; @@ -506,6 +507,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. */