version 1.67, 2010/05/15 06:48:13 |
version 1.73, 2010/05/17 10:50:32 |
|
|
|
|
const char *const __man_merrnames[WERRMAX] = { |
const char *const __man_merrnames[WERRMAX] = { |
"invalid character", /* WNPRINT */ |
"invalid character", /* WNPRINT */ |
"invalid manual section", /* WMSEC */ |
|
"invalid date format", /* WDATE */ |
"invalid date format", /* WDATE */ |
"scope of prior line violated", /* WLNSCOPE */ |
"scope of prior line violated", /* WLNSCOPE */ |
"over-zealous prior line scope violation", /* WLNSCOPE2 */ |
"over-zealous prior line scope violation", /* WLNSCOPE2 */ |
Line 50 const char *const __man_merrnames[WERRMAX] = { |
|
Line 49 const char *const __man_merrnames[WERRMAX] = { |
|
"no scope context", /* WNOSCOPE */ |
"no scope context", /* WNOSCOPE */ |
"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 */ |
|
"scope in roff instructions broken", /* WROFFSCOPE */ |
|
"document title should be uppercase", /* WTITLECASE */ |
"document title should be uppercase", /* WTITLECASE */ |
"deprecated comment style", /* WBADCOMMENT */ |
"deprecated comment style", /* WBADCOMMENT */ |
}; |
}; |
Line 65 const char *const __man_macronames[MAN_MAX] = { |
|
Line 62 const char *const __man_macronames[MAN_MAX] = { |
|
"RI", "na", "i", "sp", |
"RI", "na", "i", "sp", |
"nf", "fi", "r", "RE", |
"nf", "fi", "r", "RE", |
"RS", "DT", "UC", "PD", |
"RS", "DT", "UC", "PD", |
"Sp", "Vb", "Ve", "de", |
"Sp", "Vb", "Ve", "AT", |
"dei", "am", "ami", "ig", |
|
".", |
|
}; |
}; |
|
|
const char * const *man_macronames = __man_macronames; |
const char * const *man_macronames = __man_macronames; |
Line 79 static int man_node_append(struct man *, |
|
Line 74 static int man_node_append(struct man *, |
|
static void man_node_free(struct man_node *); |
static void man_node_free(struct man_node *); |
static void man_node_unlink(struct man *, |
static void man_node_unlink(struct man *, |
struct man_node *); |
struct man_node *); |
static int man_ptext(struct man *, int, char *); |
static int man_ptext(struct man *, int, char *, int); |
static int man_pmacro(struct man *, int, char *); |
static int man_pmacro(struct man *, int, char *, int); |
static void man_free1(struct man *); |
static void man_free1(struct man *); |
static void man_alloc1(struct man *); |
static void man_alloc1(struct man *); |
static int macrowarn(struct man *, int, const char *); |
static int macrowarn(struct man *, int, const char *, int); |
|
|
|
|
const struct man_node * |
const struct man_node * |
Line 153 man_endparse(struct man *m) |
|
Line 148 man_endparse(struct man *m) |
|
|
|
|
|
int |
int |
man_parseln(struct man *m, int ln, char *buf) |
man_parseln(struct man *m, int ln, char *buf, int offs) |
{ |
{ |
|
|
return('.' == *buf || '\'' == *buf ? |
if (MAN_HALT & m->flags) |
man_pmacro(m, ln, buf) : |
return(0); |
man_ptext(m, ln, buf)); |
|
|
return(('.' == buf[offs] || '\'' == buf[offs]) ? |
|
man_pmacro(m, ln, buf, offs) : |
|
man_ptext(m, ln, buf, offs)); |
} |
} |
|
|
|
|
Line 174 man_free1(struct man *man) |
|
Line 172 man_free1(struct man *man) |
|
free(man->meta.source); |
free(man->meta.source); |
if (man->meta.vol) |
if (man->meta.vol) |
free(man->meta.vol); |
free(man->meta.vol); |
|
if (man->meta.msec) |
|
free(man->meta.msec); |
} |
} |
|
|
|
|
Line 366 man_node_delete(struct man *m, struct man_node *p) |
|
Line 366 man_node_delete(struct man *m, struct man_node *p) |
|
|
|
|
|
static int |
static int |
man_ptext(struct man *m, int line, char *buf) |
man_ptext(struct man *m, int line, char *buf, int offs) |
{ |
{ |
int i; |
int i; |
|
|
/* Ignore bogus comments. */ |
/* Ignore bogus comments. */ |
|
|
if ('\\' == buf[0] && '.' == buf[1] && '\"' == buf[2]) |
if ('\\' == buf[offs] && |
return(man_pwarn(m, line, 0, WBADCOMMENT)); |
'.' == buf[offs + 1] && |
|
'"' == buf[offs + 2]) |
|
return(man_pwarn(m, line, offs, 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_word_alloc(m, line, 0, buf)) |
if ( ! man_word_alloc(m, line, offs, buf + offs)) |
return(0); |
return(0); |
goto descope; |
goto descope; |
} |
} |
|
|
/* Pump blank lines directly into the backend. */ |
/* Pump blank lines directly into the backend. */ |
|
|
for (i = 0; ' ' == buf[i]; i++) |
for (i = offs; ' ' == buf[i]; i++) |
/* Skip leading whitespace. */ ; |
/* Skip leading whitespace. */ ; |
|
|
if ('\0' == buf[i]) { |
if ('\0' == buf[i]) { |
/* Allocate a blank entry. */ |
/* Allocate a blank entry. */ |
if ( ! man_word_alloc(m, line, 0, "")) |
if ( ! man_word_alloc(m, line, offs, "")) |
return(0); |
return(0); |
goto descope; |
goto descope; |
} |
} |
Line 417 man_ptext(struct man *m, int line, char *buf) |
|
Line 419 man_ptext(struct man *m, int line, char *buf) |
|
buf[i] = '\0'; |
buf[i] = '\0'; |
} |
} |
|
|
if ( ! man_word_alloc(m, line, 0, buf)) |
if ( ! man_word_alloc(m, line, offs, buf + offs)) |
return(0); |
return(0); |
|
|
/* |
/* |
Line 426 man_ptext(struct man *m, int line, char *buf) |
|
Line 428 man_ptext(struct man *m, int line, char *buf) |
|
* sentence. The front-end will know how to interpret this. |
* sentence. The front-end will know how to interpret this. |
*/ |
*/ |
|
|
/* FIXME: chain of close delims. */ |
|
|
|
assert(i); |
assert(i); |
|
|
if (mandoc_eos(buf, (size_t)i)) |
if (mandoc_eos(buf, (size_t)i)) |
m->last->flags |= MAN_EOS; |
m->last->flags |= MAN_EOS; |
|
|
|
|
|
|
if ( ! man_unscope(m, m->last->parent, WERRMAX)) |
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, offs, m->last->tok)); |
} |
} |
|
|
|
|
static int |
static int |
macrowarn(struct man *m, int ln, const char *buf) |
macrowarn(struct man *m, int ln, const char *buf, int offs) |
{ |
{ |
if ( ! (MAN_IGN_MACRO & m->pflags)) |
if ( ! (MAN_IGN_MACRO & m->pflags)) |
return(man_verr(m, ln, 0, "unknown macro: %s%s", |
return(man_verr(m, ln, offs, "unknown macro: %s%s", |
buf, strlen(buf) > 3 ? "..." : "")); |
buf, strlen(buf) > 3 ? "..." : "")); |
return(man_vwarn(m, ln, 0, "unknown macro: %s%s", |
return(man_vwarn(m, ln, offs, "unknown macro: %s%s", |
buf, strlen(buf) > 3 ? "..." : "")); |
buf, strlen(buf) > 3 ? "..." : "")); |
} |
} |
|
|
|
|
int |
int |
man_pmacro(struct man *m, int ln, char *buf) |
man_pmacro(struct man *m, int ln, char *buf, int offs) |
{ |
{ |
int i, j, ppos; |
int i, j, ppos; |
enum mant tok; |
enum mant tok; |
Line 477 man_pmacro(struct man *m, int ln, char *buf) |
|
Line 476 man_pmacro(struct man *m, int ln, char *buf) |
|
|
|
/* Comments and empties are quickly ignored. */ |
/* Comments and empties are quickly ignored. */ |
|
|
if ('\0' == buf[1]) |
offs++; |
|
|
|
if ('\0' == buf[offs]) |
return(1); |
return(1); |
|
|
i = 1; |
i = offs; |
|
|
/* |
/* |
* Skip whitespace between the control character and initial |
* Skip whitespace between the control character and initial |
Line 525 man_pmacro(struct man *m, int ln, char *buf) |
|
Line 526 man_pmacro(struct man *m, int ln, char *buf) |
|
} |
} |
|
|
if (MAN_MAX == (tok = man_hash_find(mac))) { |
if (MAN_MAX == (tok = man_hash_find(mac))) { |
if ( ! macrowarn(m, ln, mac)) |
if ( ! macrowarn(m, ln, mac, ppos)) |
goto err; |
goto err; |
return(1); |
return(1); |
} |
} |
Line 548 man_pmacro(struct man *m, int ln, char *buf) |
|
Line 549 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) && |
|
|
|
|
if ( ! man_unscope(m, m->last->parent, WERRMAX)) |
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, offs, m->last->tok)); |
|
|
err: /* Error out. */ |
err: /* Error out. */ |
|
|