version 1.21, 2008/12/15 01:54:58 |
version 1.24, 2008/12/23 05:30:49 |
|
|
print_node(const struct mdoc_node *n, int indent) |
print_node(const struct mdoc_node *n, int indent) |
{ |
{ |
const char *p, *t; |
const char *p, *t; |
int i; |
int i, j; |
|
size_t argc; |
|
struct mdoc_arg *argv; |
|
|
|
argv = NULL; |
|
argc = 0; |
|
|
switch (n->type) { |
switch (n->type) { |
case (MDOC_TEXT): |
case (MDOC_TEXT): |
assert(NULL == n->child); |
assert(NULL == n->child); |
Line 202 print_node(const struct mdoc_node *n, int indent) |
|
Line 207 print_node(const struct mdoc_node *n, int indent) |
|
assert(NULL == n->child); |
assert(NULL == n->child); |
p = mdoc_macronames[n->data.elem.tok]; |
p = mdoc_macronames[n->data.elem.tok]; |
t = "element"; |
t = "element"; |
|
argv = n->data.elem.argv; |
|
argc = n->data.elem.argc; |
break; |
break; |
case (MDOC_BLOCK): |
case (MDOC_BLOCK): |
p = mdoc_macronames[n->data.block.tok]; |
p = mdoc_macronames[n->data.block.tok]; |
t = "block"; |
t = "block"; |
|
argv = n->data.block.argv; |
|
argc = n->data.block.argc; |
break; |
break; |
|
default: |
|
abort(); |
|
/* NOTREACHED */ |
} |
} |
|
|
for (i = 0; i < indent; i++) |
for (i = 0; i < indent; i++) |
(void)printf(" "); |
(void)printf(" "); |
(void)printf("%s (%s)\n", p, t); |
(void)printf("%s (%s)", p, t); |
|
|
|
for (i = 0; i < (int)argc; i++) { |
|
(void)printf(" -%s", mdoc_argnames[argv[i].arg]); |
|
for (j = 0; j < (int)argv[i].sz; j++) |
|
(void)printf(" \"%s\"", argv[i].value[j]); |
|
} |
|
|
|
(void)printf("\n"); |
|
|
if (n->child) |
if (n->child) |
print_node(n->child, indent + 1); |
print_node(n->child, indent + 1); |
if (n->next) |
if (n->next) |
Line 262 parse_begin(struct md_parse *p) |
|
Line 282 parse_begin(struct md_parse *p) |
|
for (i = 0; i < sz; i++) { |
for (i = 0; i < sz; i++) { |
if ('\n' != p->buf[i]) { |
if ('\n' != p->buf[i]) { |
if (pos < sizeof(line)) { |
if (pos < sizeof(line)) { |
/* LINTED */ |
sv[(int)pos] = p->buf[(int)i]; |
sv[pos] = p->buf[i]; |
line[(int)pos++] = |
line[pos++] = p->buf[i]; |
p->buf[(int)i]; |
continue; |
continue; |
} |
} |
warnx("%s: line %d too long", |
warnx("%s: line %d too long", |
Line 298 msg_err(void *arg, int tok, int col, enum mdoc_err typ |
|
Line 318 msg_err(void *arg, int tok, int col, enum mdoc_err typ |
|
|
|
switch (type) { |
switch (type) { |
case (ERR_SYNTAX_QUOTE): |
case (ERR_SYNTAX_QUOTE): |
|
lit = "syntax: disallowed argument quotation"; |
|
break; |
|
case (ERR_SYNTAX_UNQUOTE): |
lit = "syntax: unterminated quotation"; |
lit = "syntax: unterminated quotation"; |
break; |
break; |
case (ERR_SYNTAX_WS): |
case (ERR_SYNTAX_WS): |
lit = "syntax: whitespace in argument"; |
lit = "syntax: whitespace in argument"; |
break; |
break; |
|
case (ERR_SYNTAX_ARGS): |
|
fmt = "syntax: macro `%s' arguments malformed"; |
|
break; |
|
case (ERR_SYNTAX_BADARG): |
|
fmt = "syntax: unknown argument for macro `%s'"; |
|
break; |
case (ERR_SCOPE_BREAK): |
case (ERR_SCOPE_BREAK): |
/* Which scope is broken? */ |
/* Which scope is broken? */ |
fmt = "macro `%s' breaks prior explicit scope"; |
fmt = "scope: macro `%s' breaks prior explicit scope"; |
break; |
break; |
|
case (ERR_SCOPE_NOCTX): |
|
fmt = "scope: closure macro `%s' has no context"; |
|
break; |
case (ERR_MACRO_NOTSUP): |
case (ERR_MACRO_NOTSUP): |
fmt = "macro `%s' not supported"; |
fmt = "macro `%s' not supported"; |
break; |
break; |
case (ERR_MACRO_NOTCALL): |
case (ERR_MACRO_NOTCALL): |
fmt = "macro `%s' not callable"; |
fmt = "macro `%s' not callable"; |
break; |
break; |
|
case (ERR_SEC_PROLOGUE): |
|
fmt = "macro `%s' cannot be called in the prologue"; |
|
break; |
|
case (ERR_SEC_NPROLOGUE): |
|
fmt = "macro `%s' called outside of prologue"; |
|
break; |
case (ERR_ARGS_GE1): |
case (ERR_ARGS_GE1): |
fmt = "macro `%s' expects one or more arguments"; |
fmt = "macro `%s' expects one or more arguments"; |
break; |
break; |
|
case (ERR_ARGS_MANY): |
|
fmt = "macro `%s' has too many arguments"; |
|
break; |
|
case (ERR_SEC_PROLOGUE_OO): |
|
fmt = "prologue macro `%s' is out-of-order"; |
|
break; |
|
case (ERR_SEC_PROLOGUE_REP): |
|
fmt = "prologue macro `%s' repeated"; |
|
break; |
|
case (ERR_SEC_NAME): |
|
lit = "`NAME' section must be first"; |
|
break; |
|
case (ERR_SYNTAX_ARGVAL): |
|
lit = "syntax: expected value for macro argument"; |
|
break; |
|
case (ERR_SYNTAX_ARGMANY): |
|
lit = "syntax: too many values for macro argument"; |
|
break; |
default: |
default: |
abort(); |
abort(); |
/* NOTREACHED */ |
/* NOTREACHED */ |
Line 330 msg_err(void *arg, int tok, int col, enum mdoc_err typ |
|
Line 386 msg_err(void *arg, int tok, int col, enum mdoc_err typ |
|
p->name, p->lnn, lit); |
p->name, p->lnn, lit); |
|
|
if (p->dbg < 1) { |
if (p->dbg < 1) { |
(void)fprintf(stderr, " (column %d)\n", col); |
if (-1 != col) |
|
(void)fprintf(stderr, " (column %d)\n", col); |
return(0); |
return(0); |
|
} else if (-1 == col) { |
|
(void)fprintf(stderr, "\nFrom: %s", p->line); |
|
return(0); |
} |
} |
|
|
(void)fprintf(stderr, "\nFrom: %s\n ", p->line); |
(void)fprintf(stderr, "\nFrom: %s\n ", p->line); |
Line 357 msg_msg(void *arg, int col, const char *msg) |
|
Line 417 msg_msg(void *arg, int col, const char *msg) |
|
(void)printf("%s:%d: %s", p->name, p->lnn, msg); |
(void)printf("%s:%d: %s", p->name, p->lnn, msg); |
|
|
if (p->dbg < 3) { |
if (p->dbg < 3) { |
(void)printf(" (column %d)\n", col); |
if (-1 != col) |
|
(void)printf(" (column %d)\n", col); |
return; |
return; |
|
} else if (-1 == col) { |
|
(void)printf("\nFrom %s\n", p->line); |
|
return; |
} |
} |
|
|
(void)printf("\nFrom: %s\n ", p->line); |
(void)printf("\nFrom: %s\n ", p->line); |
Line 389 msg_warn(void *arg, int tok, int col, enum mdoc_warn t |
|
Line 453 msg_warn(void *arg, int tok, int col, enum mdoc_warn t |
|
break; |
break; |
case (WARN_SYNTAX_MACLIKE): |
case (WARN_SYNTAX_MACLIKE): |
lit = "syntax: macro-like argument"; |
lit = "syntax: macro-like argument"; |
|
break; |
|
case (WARN_SYNTAX_ARGLIKE): |
|
lit = "syntax: argument-like value"; |
|
break; |
|
case (WARN_SEC_OO): |
|
lit = "section is out of conventional order"; |
break; |
break; |
case (WARN_ARGS_GE1): |
case (WARN_ARGS_GE1): |
fmt = "macro `%s' suggests one or more arguments"; |
fmt = "macro `%s' suggests one or more arguments"; |