=================================================================== RCS file: /cvs/mandoc/man.c,v retrieving revision 1.40 retrieving revision 1.44 diff -u -p -r1.40 -r1.44 --- mandoc/man.c 2009/09/16 14:40:56 1.40 +++ mandoc/man.c 2009/10/27 08:26:12 1.44 @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.40 2009/09/16 14:40:56 kristaps Exp $ */ +/* $Id: man.c,v 1.44 2009/10/27 08:26:12 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -14,6 +14,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include #include #include @@ -38,7 +40,6 @@ const char *const __man_merrnames[WERRMAX] = { "expected block head arguments", /* WHEADARGS */ "expected block body arguments", /* WBODYARGS */ "expected empty block head", /* WNHEADARGS */ - "unknown macro", /* WMACRO */ "ill-formed macro", /* WMACROFORM */ "scope open on exit", /* WEXITSCOPE */ "no scope context", /* WNOSCOPE */ @@ -54,7 +55,7 @@ const char *const __man_macronames[MAN_MAX] = { "R", "B", "I", "IR", "RI", "na", "i", "sp", "nf", "fi", "r", "RE", - "RS", "DT", "UC" + "RS", "DT", "UC", "PD" }; const char * const *man_macronames = __man_macronames; @@ -69,6 +70,7 @@ static void man_free1(struct man *); static int man_alloc1(struct man *); 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); @@ -173,7 +175,7 @@ static int man_alloc1(struct man *m) { - bzero(&m->meta, sizeof(struct man_meta)); + memset(&m->meta, 0, sizeof(struct man_meta)); m->flags = 0; m->last = calloc(1, sizeof(struct man_node)); if (NULL == m->last) @@ -454,6 +456,18 @@ descope: } +static int +macrowarn(struct man *m, int ln, const char *buf) +{ + if ( ! (MAN_IGN_MACRO & m->pflags)) + return(man_verr(m, ln, 0, + "unknown macro: %s%s", + buf, strlen(buf) > 3 ? "..." : "")); + return(man_vwarn(m, ln, 0, "unknown macro: %s%s", + buf, strlen(buf) > 3 ? "..." : "")); +} + + int man_pmacro(struct man *m, int ln, char *buf) { @@ -508,11 +522,7 @@ man_pmacro(struct man *m, int ln, char *buf) } if (MAN_MAX == (c = man_hash_find(mac))) { - if ( ! (MAN_IGN_MACRO & m->pflags)) { - (void)man_perr(m, ln, ppos, WMACRO); - goto err; - } - if ( ! man_pwarn(m, ln, ppos, WMACRO)) + if ( ! macrowarn(m, ln, mac)) goto err; return(1); }