-/* $Id: man.c,v 1.20 2009/06/16 19:13:28 kristaps Exp $ */
+/* $Id: man.c,v 1.27 2009/07/07 09:35:40 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
#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 */
+};
+
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"
};
const char * const *man_macronames = __man_macronames;
abort();
/* NOTREACHED */
}
+
+ p->parent->nchild++;
man->last = p;
if (p->string)
free(p->string);
+ if (p->parent)
+ p->parent->nchild--;
free(p);
}
if (p->next)
man_node_freelist(p->next);
+ assert(0 == p->nchild);
man_node_free(p);
}
}
+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));
+}