=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.113 retrieving revision 1.115 diff -u -p -r1.113 -r1.115 --- mandoc/mdoc.c 2009/10/30 05:58:38 1.113 +++ mandoc/mdoc.c 2010/01/07 10:05:24 1.115 @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.113 2009/10/30 05:58:38 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.115 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 @@ -93,11 +97,11 @@ const char *const __mdoc_macronames[MDOC_MAX] = { "Nm", "Op", "Ot", "Pa", "Rv", "St", "Va", "Vt", /* LINTED */ - "Xr", "\%A", "\%B", "\%D", + "Xr", "%A", "%B", "%D", /* LINTED */ - "\%I", "\%J", "\%N", "\%O", + "%I", "%J", "%N", "%O", /* LINTED */ - "\%P", "\%R", "\%T", "\%V", + "%P", "%R", "%T", "%V", "Ac", "Ao", "Aq", "At", "Bc", "Bf", "Bo", "Bq", "Bsx", "Bx", "Db", "Dc", @@ -114,11 +118,11 @@ const char *const __mdoc_macronames[MDOC_MAX] = { "Fr", "Ud", "Lb", "Lp", "Lk", "Mt", "Brq", "Bro", /* LINTED */ - "Brc", "\%C", "Es", "En", + "Brc", "%C", "Es", "En", /* LINTED */ - "Dx", "\%Q", "br", "sp", + "Dx", "%Q", "br", "sp", /* LINTED */ - "\%U" + "%U" }; const char *const __mdoc_argnames[MDOC_ARG_MAX] = { @@ -148,11 +152,6 @@ static int macrowarn(struct mdoc *, int, const char static int pstring(struct mdoc *, int, int, const char *, size_t); -#ifdef __linux__ -extern size_t strlcpy(char *, const char *, size_t); -#endif - - const struct mdoc_node * mdoc_node(const struct mdoc *m) { @@ -598,7 +597,8 @@ parsetext(struct mdoc *m, int line, char *buf) for (i = 0; ' ' == buf[i]; i++) /* Skip leading whitespace. */ ; - if (0 == buf[i]) + + if ('\0' == buf[i]) return(mdoc_perr(m, line, 0, ENOBLANK)); /* @@ -614,7 +614,8 @@ parsetext(struct mdoc *m, int line, char *buf) if (i && ' ' == buf[i] && '\\' == buf[i - 1]) continue; - buf[i++] = 0; + buf[i++] = '\0'; + if ( ! pstring(m, line, j, &buf[j], (size_t)(i - j))) return(0); @@ -622,7 +623,7 @@ parsetext(struct mdoc *m, int line, char *buf) /* Skip trailing whitespace. */ ; j = i; - if (0 == buf[i]) + if ('\0' == buf[i]) break; } @@ -659,7 +660,7 @@ parsemacro(struct mdoc *m, int ln, char *buf) /* Empty lines are ignored. */ - if (0 == buf[1]) + if ('\0' == buf[1]) return(1); i = 1; @@ -670,14 +671,14 @@ parsemacro(struct mdoc *m, int ln, char *buf) i++; while (buf[i] && ' ' == buf[i]) i++; - if (0 == buf[i]) + if ('\0' == buf[i]) return(1); } /* 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; @@ -707,6 +708,12 @@ parsemacro(struct mdoc *m, int ln, char *buf) while (buf[i] && ' ' == buf[i]) i++; + + /* Trailing whitespace? */ + + if ('\0' == buf[i] && ' ' == buf[i - 1]) + if ( ! mdoc_pwarn(m, ln, i - 1, ETAILWS)) + goto err; /* * Begin recursive parse sequence. Since we're at the start of