=================================================================== RCS file: /cvs/mandoc/man.c,v retrieving revision 1.18 retrieving revision 1.28 diff -u -p -r1.18 -r1.28 --- mandoc/man.c 2009/04/12 19:45:26 1.18 +++ mandoc/man.c 2009/07/24 20:22:24 1.28 @@ -1,6 +1,6 @@ -/* $Id: man.c,v 1.18 2009/04/12 19:45:26 kristaps Exp $ */ +/* $Id: man.c,v 1.28 2009/07/24 20:22:24 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -23,13 +23,27 @@ #include "libman.h" +const char *const __man_merrnames[WERRMAX] = { + "invalid character", /* WNPRINT */ + "system: malloc error", /* WNMEM */ + "invalid manual section", /* WMSEC */ + "invalid date format", /* WDATE */ + "scope of prior line violated", /* WLNSCOPE */ + "trailing whitespace", /* WTSPACE */ + "unterminated quoted parameter", /* WTQUOTE */ + "document has no body", /* WNODATA */ + "document has no title/section", /* WNOTITLE */ + "invalid escape sequence", /* WESCAPE */ + "invalid number format", /* WNUMFMT */ +}; + const char *const __man_macronames[MAN_MAX] = { - "\\\"", "TH", "SH", "SS", + "br", "TH", "SH", "SS", "TP", "LP", "PP", "P", "IP", "HP", "SM", "SB", "BI", "IB", "BR", "RB", "R", "B", "I", "IR", - "RI", "br", "na", "i" + "RI", "na", "i", "sp" }; const char * const *man_macronames = __man_macronames; @@ -182,6 +196,8 @@ man_node_append(struct man *man, struct man_node *p) abort(); /* NOTREACHED */ } + + p->parent->nchild++; man->last = p; @@ -250,6 +266,8 @@ man_node_free(struct man_node *p) if (p->string) free(p->string); + if (p->parent) + p->parent->nchild--; free(p); } @@ -263,6 +281,7 @@ man_node_freelist(struct man_node *p) if (p->next) man_node_freelist(p->next); + assert(0 == p->nchild); man_node_free(p); } @@ -324,10 +343,6 @@ man_pmacro(struct man *m, int ln, char *buf) ppos = i; - if (buf[i] && '\\' == buf[i]) - if (buf[i + 1] && '\"' == buf[i + 1]) - goto out; - /* Copy the first word into a nil-terminated buffer. */ for (j = 0; j < 4; j++, i++) { @@ -436,3 +451,16 @@ man_vwarn(struct man *man, int ln, int pos, const char } +int +man_err(struct man *m, int line, int pos, int iserr, enum merr type) +{ + const char *p; + + p = __man_merrnames[(int)type]; + assert(p); + + if (iserr) + return(man_verr(m, line, pos, p)); + + return(man_vwarn(m, line, pos, p)); +}