=================================================================== RCS file: /cvs/mandoc/man.c,v retrieving revision 1.18 retrieving revision 1.24 diff -u -p -r1.18 -r1.24 --- mandoc/man.c 2009/04/12 19:45:26 1.18 +++ mandoc/man.c 2009/06/18 20:46:19 1.24 @@ -1,6 +1,6 @@ -/* $Id: man.c,v 1.18 2009/04/12 19:45:26 kristaps Exp $ */ +/* $Id: man.c,v 1.24 2009/06/18 20:46:19 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 @@ -24,12 +24,12 @@ #include "libman.h" 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; @@ -182,6 +182,8 @@ man_node_append(struct man *man, struct man_node *p) abort(); /* NOTREACHED */ } + + p->parent->nchild++; man->last = p; @@ -250,6 +252,8 @@ man_node_free(struct man_node *p) if (p->string) free(p->string); + if (p->parent) + p->parent->nchild--; free(p); } @@ -263,6 +267,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 +329,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 +437,40 @@ 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 = NULL; + switch (type) { + case (WNPRINT): + p = "invalid character"; + break; + case (WNMEM): + p = "memory exhausted"; + break; + case (WMSEC): + p = "invalid manual section"; + break; + case (WDATE): + p = "invalid date format"; + break; + case (WLNSCOPE): + p = "scope of prior line violated"; + break; + case (WTSPACE): + p = "trailing whitespace at end of line"; + break; + case (WTQUOTE): + p = "unterminated quotation"; + break; + } + assert(p); + + if (iserr) + return(man_verr(m, line, pos, p)); + + return(man_vwarn(m, line, pos, p)); +}