version 1.54, 2010/03/24 20:10:53 |
version 1.60, 2010/04/08 07:53:01 |
Line 51 const char *const __man_merrnames[WERRMAX] = { |
|
Line 51 const char *const __man_merrnames[WERRMAX] = { |
|
"literal context already open", /* WOLITERAL */ |
"literal context already open", /* WOLITERAL */ |
"no literal context open", /* WNLITERAL */ |
"no literal context open", /* WNLITERAL */ |
"invalid nesting of roff declarations", /* WROFFNEST */ |
"invalid nesting of roff declarations", /* WROFFNEST */ |
|
"scope in roff instructions broken", /* WROFFSCOPE */ |
|
"document title should be uppercase", /* WTITLECASE */ |
|
"deprecated comment style", /* WBADCOMMENT */ |
}; |
}; |
|
|
const char *const __man_macronames[MAN_MAX] = { |
const char *const __man_macronames[MAN_MAX] = { |
|
|
man_parseln(struct man *m, int ln, char *buf) |
man_parseln(struct man *m, int ln, char *buf) |
{ |
{ |
|
|
return('.' == *buf ? |
return('.' == *buf || '\'' == *buf ? |
man_pmacro(m, ln, buf) : |
man_pmacro(m, ln, buf) : |
man_ptext(m, ln, buf)); |
man_ptext(m, ln, buf)); |
} |
} |
Line 376 man_ptext(struct man *m, int line, char *buf) |
|
Line 379 man_ptext(struct man *m, int line, char *buf) |
|
int i, j; |
int i, j; |
char sv; |
char sv; |
|
|
|
/* Ignore bogus comments. */ |
|
|
|
if ('\\' == buf[0] && '.' == buf[1] && '\"' == buf[2]) |
|
return(man_pwarn(m, line, 0, WBADCOMMENT)); |
|
|
/* Literal free-form text whitespace is preserved. */ |
/* Literal free-form text whitespace is preserved. */ |
|
|
if (MAN_LITERAL & m->flags) { |
if (MAN_LITERAL & m->flags) { |
|
|
|
|
if (MAN_ELINE & m->flags) { |
if (MAN_ELINE & m->flags) { |
m->flags &= ~MAN_ELINE; |
m->flags &= ~MAN_ELINE; |
if ( ! man_unscope(m, m->last->parent)) |
if ( ! man_unscope(m, m->last->parent, WERRMAX)) |
return(0); |
return(0); |
} |
} |
|
|
|
|
return(1); |
return(1); |
m->flags &= ~MAN_BLINE; |
m->flags &= ~MAN_BLINE; |
|
|
if ( ! man_unscope(m, m->last->parent)) |
if ( ! man_unscope(m, m->last->parent, WERRMAX)) |
return(0); |
return(0); |
return(man_body_alloc(m, line, 0, m->last->tok)); |
return(man_body_alloc(m, line, 0, m->last->tok)); |
} |
} |
Line 476 macrowarn(struct man *m, int ln, const char *buf) |
|
Line 484 macrowarn(struct man *m, int ln, const char *buf) |
|
int |
int |
man_pmacro(struct man *m, int ln, char *buf) |
man_pmacro(struct man *m, int ln, char *buf) |
{ |
{ |
int i, j, ppos, fl; |
int i, j, ppos; |
enum mant tok; |
enum mant tok; |
char mac[5]; |
char mac[5]; |
struct man_node *n; |
struct man_node *n; |
|
|
/* Comments and empties are quickly ignored. */ |
/* Comments and empties are quickly ignored. */ |
|
|
fl = m->flags; |
|
|
|
if ('\0' == buf[1]) |
if ('\0' == buf[1]) |
return(1); |
return(1); |
|
|
i = 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++; |
i++; |
while (buf[i] && ' ' == buf[i]) |
while (buf[i] && (' ' == buf[i] || '\t' == buf[i])) |
i++; |
i++; |
if ('\0' == buf[i]) |
if ('\0' == buf[i]) |
goto out; |
goto out; |
Line 548 man_pmacro(struct man *m, int ln, char *buf) |
|
Line 558 man_pmacro(struct man *m, int ln, char *buf) |
|
* Remove prior ELINE macro, as it's being clobbering by a new |
* Remove prior ELINE macro, as it's being clobbering by a new |
* macro. Note that NSCOPED macros do not close out ELINE |
* macro. Note that NSCOPED macros do not close out ELINE |
* macros---they don't print text---so we let those slip by. |
* macros---they don't print text---so we let those slip by. |
|
* NOTE: we don't allow roff blocks (NOCLOSE) to be embedded |
|
* here because that would stipulate blocks as children of |
|
* elements! |
*/ |
*/ |
|
|
if ( ! (MAN_NSCOPED & man_macros[tok].flags) && |
if ( ! (MAN_NSCOPED & man_macros[tok].flags) && |
Line 579 man_pmacro(struct man *m, int ln, char *buf) |
|
Line 592 man_pmacro(struct man *m, int ln, char *buf) |
|
m->flags &= ~MAN_ELINE; |
m->flags &= ~MAN_ELINE; |
} |
} |
|
|
/* Begin recursive parse sequence. */ |
/* |
|
* Save the fact that we're in the next-line for a block. In |
|
* this way, embedded roff instructions can "remember" state |
|
* when they exit. |
|
*/ |
|
|
assert(man_macros[tok].fp); |
if (MAN_BLINE & m->flags) |
|
m->flags |= MAN_BPLINE; |
|
|
|
/* Call to handler... */ |
|
|
|
assert(man_macros[tok].fp); |
if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf)) |
if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf)) |
goto err; |
goto err; |
|
|
|
|
/* |
/* |
* We weren't in a block-line scope when entering the |
* We weren't in a block-line scope when entering the |
* above-parsed macro, so return. |
* above-parsed macro, so return. |
* |
|
* FIXME: this prohibits the nesting of blocks (e.g., `de' and |
|
* family) within BLINE or ELINE systems. This is annoying. |
|
*/ |
*/ |
|
|
if ( ! (MAN_BLINE & fl)) { |
if ( ! (MAN_BPLINE & m->flags)) { |
m->flags &= ~MAN_ILINE; |
m->flags &= ~MAN_ILINE; |
return(1); |
return(1); |
} |
} |
|
m->flags &= ~MAN_BPLINE; |
|
|
/* |
/* |
* If we're in a block scope, then allow this macro to slip by |
* If we're in a block scope, then allow this macro to slip by |
|
|
assert(MAN_BLINE & m->flags); |
assert(MAN_BLINE & m->flags); |
m->flags &= ~MAN_BLINE; |
m->flags &= ~MAN_BLINE; |
|
|
if ( ! man_unscope(m, m->last->parent)) |
if ( ! man_unscope(m, m->last->parent, WERRMAX)) |
return(0); |
return(0); |
return(man_body_alloc(m, ln, 0, m->last->tok)); |
return(man_body_alloc(m, ln, 0, m->last->tok)); |
|
|