=================================================================== RCS file: /cvs/mandoc/man.c,v retrieving revision 1.54 retrieving revision 1.58 diff -u -p -r1.54 -r1.58 --- mandoc/man.c 2010/03/24 20:10:53 1.54 +++ mandoc/man.c 2010/03/29 04:52:14 1.58 @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.54 2010/03/24 20:10:53 kristaps Exp $ */ +/* $Id: man.c,v 1.58 2010/03/29 04:52:14 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -51,6 +51,8 @@ const char *const __man_merrnames[WERRMAX] = { "literal context already open", /* WOLITERAL */ "no literal context open", /* WNLITERAL */ "invalid nesting of roff declarations", /* WROFFNEST */ + "scope in roff instructions broken", /* WROFFSCOPE */ + "document title should be uppercase", /* WTITLECASE */ }; const char *const __man_macronames[MAN_MAX] = { @@ -155,7 +157,7 @@ int man_parseln(struct man *m, int ln, char *buf) { - return('.' == *buf ? + return('.' == *buf || '\'' == *buf ? man_pmacro(m, ln, buf) : man_ptext(m, ln, buf)); } @@ -447,7 +449,7 @@ descope: if (MAN_ELINE & m->flags) { m->flags &= ~MAN_ELINE; - if ( ! man_unscope(m, m->last->parent)) + if ( ! man_unscope(m, m->last->parent, WERRMAX)) return(0); } @@ -455,7 +457,7 @@ descope: return(1); m->flags &= ~MAN_BLINE; - if ( ! man_unscope(m, m->last->parent)) + if ( ! man_unscope(m, m->last->parent, WERRMAX)) return(0); return(man_body_alloc(m, line, 0, m->last->tok)); } @@ -476,23 +478,28 @@ macrowarn(struct man *m, int ln, const char *buf) int man_pmacro(struct man *m, int ln, char *buf) { - int i, j, ppos, fl; + int i, j, ppos; enum mant tok; char mac[5]; struct man_node *n; /* Comments and empties are quickly ignored. */ - fl = m->flags; + if (MAN_BLINE & m->flags) + m->flags |= MAN_BPLINE; if ('\0' == buf[1]) return(1); i = 1; - if (' ' == buf[i]) { + /* + * Skip whitespace between the control character and initial + * text. "Whitespace" is both spaces and tabs. + */ + if (' ' == buf[i] || '\t' == buf[i]) { i++; - while (buf[i] && ' ' == buf[i]) + while (buf[i] && (' ' == buf[i] || '\t' == buf[i])) i++; if ('\0' == buf[i]) goto out; @@ -595,10 +602,11 @@ out: * family) within BLINE or ELINE systems. This is annoying. */ - if ( ! (MAN_BLINE & fl)) { + if ( ! (MAN_BPLINE & m->flags)) { m->flags &= ~MAN_ILINE; return(1); } + m->flags &= ~MAN_BPLINE; /* * If we're in a block scope, then allow this macro to slip by @@ -623,7 +631,7 @@ out: assert(MAN_BLINE & m->flags); m->flags &= ~MAN_BLINE; - if ( ! man_unscope(m, m->last->parent)) + if ( ! man_unscope(m, m->last->parent, WERRMAX)) return(0); return(man_body_alloc(m, ln, 0, m->last->tok));