diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-16 11:50:54 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-16 11:50:54 +0000 |
commit | c3f113eda71022f3ea3245ce53f3878057139149 (patch) | |
tree | e812fcd3245ade0fe206c0b6a2ee19191a2a6d77 | |
parent | 49aead8ab67de188578d52298d35707f7a62a695 (diff) | |
download | mandoc-c3f113eda71022f3ea3245ce53f3878057139149.tar.gz |
Finished re-fitting err/warn/msg routines.
Some minor bug-fixes.
-rw-r--r-- | action.c | 18 | ||||
-rw-r--r-- | argv.c | 24 | ||||
-rw-r--r-- | macro.c | 84 | ||||
-rw-r--r-- | mdocml.c | 4 | ||||
-rw-r--r-- | strings.c | 4 | ||||
-rw-r--r-- | validate.c | 64 |
6 files changed, 104 insertions, 94 deletions
@@ -203,12 +203,12 @@ post_dt(struct mdoc *mdoc) case (0): if (xstrlcpy(mdoc->meta.title, p, sz)) break; - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_nerr(mdoc, n, "badly-formed manual title parameter")); case (1): mdoc->meta.msec = mdoc_atomsec(p); if (MSEC_DEFAULT != mdoc->meta.msec) break; - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_nerr(mdoc, n, "badly-formed manual section parameter")); case (2): mdoc->meta.vol = mdoc_atovol(p); if (VOL_DEFAULT != mdoc->meta.vol) @@ -216,9 +216,9 @@ post_dt(struct mdoc *mdoc) mdoc->meta.arch = mdoc_atoarch(p); if (ARCH_DEFAULT != mdoc->meta.arch) break; - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_nerr(mdoc, n, "badly-formed manual volume parameter")); default: - return(mdoc_err(mdoc, ERR_ARGS_MANY)); + return(mdoc_nerr(mdoc, n, "too many parameters")); } } @@ -246,9 +246,9 @@ post_os(struct mdoc *mdoc) p = n->data.text.string; if ( ! xstrlcat(mdoc->meta.os, p, sz)) - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_nerr(mdoc, n, "badly-formed manual system parameter")); if ( ! xstrlcat(mdoc->meta.os, " ", sz)) - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_nerr(mdoc, n, "badly-formed manual system parameter")); } if (0 == mdoc->meta.os[0]) @@ -291,9 +291,9 @@ post_dd(struct mdoc *mdoc) continue; if ( ! xstrlcat(date, n->data.text.string, sz)) - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_nerr(mdoc, n, "badly-formed manual date parameter")); if ( ! xstrlcat(date, " ", sz)) - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_nerr(mdoc, n, "badly-formed manual date parameter")); } if (mdoc->meta.date && NULL == n) { @@ -302,7 +302,7 @@ post_dd(struct mdoc *mdoc) return(1); } - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_err(mdoc, "badly-formed manual date")); } @@ -46,11 +46,11 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, char *buf, int fl, char **v) return(ARGS_EOLN); if ('\"' == buf[*pos] && ! (fl & ARGS_QUOTED)) - if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_SYNTAX_QUOTED)) + if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_SYNTAX, "unexpected quoted parameter")) return(ARGS_ERROR); if ('-' == buf[*pos]) - if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_SYNTAX_ARGLIKE)) + if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_SYNTAX, "argument-like parameter")) return(ARGS_ERROR); if ((fl & ARGS_DELIM) && mdoc_iscdelim(buf[*pos])) { @@ -115,7 +115,7 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, char *buf, int fl, char **v) if (buf[*pos]) return(ARGS_WORD); - if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_SYNTAX_WS_EOLN)) + if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_COMPAT, "whitespace at end-of-line")) return(ARGS_ERROR); return(ARGS_WORD); @@ -127,15 +127,13 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, char *buf, int fl, char **v) * error. After, parse to the next word. */ - assert( ! (ARGS_TABSEP & fl)); - *v = &buf[++(*pos)]; while (buf[*pos] && '\"' != buf[*pos]) (*pos)++; if (0 == buf[*pos]) { - (void)mdoc_perr(mdoc, line, *pos, ERR_SYNTAX_UNQUOTE); + (void)mdoc_perr(mdoc, line, *pos, "unterminated quoted parameter"); return(ARGS_ERROR); } @@ -149,7 +147,7 @@ mdoc_args(struct mdoc *mdoc, int line, int *pos, char *buf, int fl, char **v) if (buf[*pos]) return(ARGS_WORD); - if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_SYNTAX_WS_EOLN)) + if ( ! mdoc_pwarn(mdoc, line, *pos, WARN_COMPAT, "whitespace at end-of-line")) return(ARGS_ERROR); return(ARGS_WORD); @@ -338,7 +336,7 @@ postparse(struct mdoc *mdoc, int line, const struct mdoc_arg *v, int pos) break; if (xstrcmp(v->value[0], "indent-two")) break; - return(mdoc_perr(mdoc, line, pos, ERR_SYNTAX_ARGBAD)); + return(mdoc_perr(mdoc, line, pos, "invalid offset value")); default: break; } @@ -374,9 +372,10 @@ parse_multi(struct mdoc *mdoc, int line, if (0 < v->sz && v->sz < MDOC_LINEARG_MAX) return(1); - c = 0 == v->sz ? ERR_SYNTAX_ARGVAL : ERR_SYNTAX_ARGMANY; free(v->value); - return(mdoc_perr(mdoc, line, ppos, c)); + return(mdoc_perr(mdoc, line, ppos, 0 == v->sz ? + "argument requires a value" : + "too many values to argument")); } @@ -393,7 +392,7 @@ parse_single(struct mdoc *mdoc, int line, if (ARGS_ERROR == c) return(0); if (ARGS_EOLN == c) - return(mdoc_perr(mdoc, line, ppos, ERR_SYNTAX_ARGVAL)); + return(mdoc_perr(mdoc, line, ppos, "argument requires a value")); v->sz = 1; v->value = xcalloc(1, sizeof(char *)); @@ -457,7 +456,8 @@ mdoc_argv(struct mdoc *mdoc, int line, int tok, buf[(*pos)++] = 0; if (MDOC_ARG_MAX == (v->arg = lookup(tok, argv))) { - (void)mdoc_pwarn(mdoc, line, i, WARN_SYNTAX_ARGLIKE); + if ( ! mdoc_pwarn(mdoc, line, i, WARN_SYNTAX, "argument-like parameter")) + return(ARGV_ERROR); return(ARGV_WORD); } @@ -40,8 +40,8 @@ static int rewind_dobreak(int, enum mdoc_type, static int rewind_elem(struct mdoc *, int); -static int rewind_impblock(struct mdoc *, int); -static int rewind_expblock(struct mdoc *, int); +static int rewind_impblock(struct mdoc *, int, int, int); +static int rewind_expblock(struct mdoc *, int, int, int); static int rewind_subblock(enum mdoc_type, struct mdoc *, int); static int rewind_last(int, int, struct mdoc *, struct mdoc_node *); @@ -61,7 +61,7 @@ lookup(struct mdoc *mdoc, int line, int pos, int from, const char *p) if (MDOC_MAX == res) return(res); - if ( ! mdoc_pwarn(mdoc, line, pos, WARN_SYNTAX_MACLIKE)) + if ( ! mdoc_pwarn(mdoc, line, pos, WARN_SYNTAX, "macro-like parameter")) return(-1); return(MDOC_MAX); } @@ -364,14 +364,14 @@ rewind_subblock(enum mdoc_type type, struct mdoc *mdoc, int tok) static int -rewind_expblock(struct mdoc *mdoc, int tok) +rewind_expblock(struct mdoc *mdoc, int tok, int line, int ppos) { struct mdoc_node *n; int c; c = rewind_dohalt(tok, MDOC_BLOCK, mdoc->last); if (REWIND_HALT == c) - return(mdoc_err(mdoc, ERR_SCOPE_NOCTX)); + return(mdoc_perr(mdoc, line, ppos, "closing macro has no context")); if (REWIND_REWIND == c) return(rewind_last(tok, MDOC_BLOCK, mdoc, mdoc->last)); @@ -379,12 +379,12 @@ rewind_expblock(struct mdoc *mdoc, int tok) for (n = mdoc->last->parent; n; n = n->parent) { c = rewind_dohalt(tok, MDOC_BLOCK, n); if (REWIND_HALT == c) - return(mdoc_err(mdoc, ERR_SCOPE_NOCTX)); + return(mdoc_perr(mdoc, line, ppos, "closing macro has no context")); if (REWIND_REWIND == c) break; else if (rewind_dobreak(tok, MDOC_BLOCK, n)) continue; - return(mdoc_nerr(mdoc, n, "macro scope broken")); + return(mdoc_nerr(mdoc, n, "block scope broken")); } assert(n); @@ -393,12 +393,11 @@ rewind_expblock(struct mdoc *mdoc, int tok) static int -rewind_impblock(struct mdoc *mdoc, int tok) +rewind_impblock(struct mdoc *mdoc, int tok, int line, int ppos) { struct mdoc_node *n; int c; - printf("1\n"); c = rewind_dohalt(tok, MDOC_BLOCK, mdoc->last); if (REWIND_HALT == c) return(1); @@ -414,7 +413,7 @@ rewind_impblock(struct mdoc *mdoc, int tok) break; else if (rewind_dobreak(tok, MDOC_BLOCK, n)) continue; - return(mdoc_nerr(mdoc, n, "macro scope broken")); + return(mdoc_nerr(mdoc, n, "block scope broken")); } assert(n); @@ -474,9 +473,9 @@ macro_scoped_close(MACRO_PROT_ARGS) if (0 == buf[*pos]) { if ( ! rewind_subblock(MDOC_BODY, mdoc, tok)) return(0); - return(rewind_expblock(mdoc, tok)); + return(rewind_expblock(mdoc, tok, line, ppos)); } - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_EQ0)); + return(mdoc_perr(mdoc, line, ppos, "macro expects no parameters")); } if ( ! rewind_subblock(MDOC_BODY, mdoc, tok)) @@ -495,7 +494,7 @@ macro_scoped_close(MACRO_PROT_ARGS) lastarg = *pos; if (j == maxargs && ! flushed) { - if ( ! rewind_expblock(mdoc, tok)) + if ( ! rewind_expblock(mdoc, tok, line, ppos)) return(0); flushed = 1; } @@ -512,7 +511,7 @@ macro_scoped_close(MACRO_PROT_ARGS) return(0); else if (MDOC_MAX != c) { if ( ! flushed) { - if ( ! rewind_expblock(mdoc, tok)) + if ( ! rewind_expblock(mdoc, tok, line, ppos)) return(0); flushed = 1; } @@ -527,9 +526,9 @@ macro_scoped_close(MACRO_PROT_ARGS) } if (MDOC_LINEARG_MAX == j) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); - if ( ! flushed && ! rewind_expblock(mdoc, tok)) + if ( ! flushed && ! rewind_expblock(mdoc, tok, line, ppos)) return(0); if (ppos > 1) @@ -561,17 +560,21 @@ macro_text(MACRO_PROT_ARGS) la = *pos; c = mdoc_argv(mdoc, line, tok, &argv[argc], pos, buf); - if (ARGV_EOLN == c || ARGV_WORD == c) + if (ARGV_EOLN == c) break; - else if (ARGV_ARG == c) + if (ARGV_WORD == c) { + *pos = la; + break; + } else if (ARGV_ARG == c) continue; + mdoc_argv_free(argc, argv); return(0); } if (MDOC_LINEARG_MAX == argc) { mdoc_argv_free(argc, argv); - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); } c = mdoc_elem_alloc(mdoc, line, la, tok, argc, argv); @@ -643,7 +646,7 @@ macro_text(MACRO_PROT_ARGS) mdoc_argv_free(argc, argv); if (sz == MDOC_LINEARG_MAX) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); if (0 == lastpunct && ! rewind_elem(mdoc, tok)) return(0); @@ -668,16 +671,19 @@ macro_scoped(MACRO_PROT_ARGS) if ( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags)) { if ( ! rewind_subblock(MDOC_BODY, mdoc, tok)) return(0); - if ( ! rewind_impblock(mdoc, tok)) + if ( ! rewind_impblock(mdoc, tok, line, ppos)) return(0); } for (argc = 0; argc < MDOC_LINEARG_MAX; argc++) { lastarg = *pos; c = mdoc_argv(mdoc, line, tok, &argv[argc], pos, buf); - if (ARGV_EOLN == c || ARGV_WORD == c) + if (ARGV_EOLN == c) + break; + if (ARGV_WORD == c) { + *pos = lastarg; break; - else if (ARGV_ARG == c) + } else if (ARGV_ARG == c) continue; mdoc_argv_free(argc, argv); return(0); @@ -685,7 +691,7 @@ macro_scoped(MACRO_PROT_ARGS) if (MDOC_LINEARG_MAX == argc) { mdoc_argv_free(argc, argv); - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); } c = mdoc_block_alloc(mdoc, line, ppos, @@ -742,7 +748,7 @@ macro_scoped(MACRO_PROT_ARGS) } if (j == MDOC_LINEARG_MAX) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); if ( ! rewind_subblock(MDOC_HEAD, mdoc, tok)) return(0); @@ -804,7 +810,7 @@ macro_scoped_line(MACRO_PROT_ARGS) } if (j == MDOC_LINEARG_MAX) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); if (1 == ppos) { if ( ! rewind_subblock(MDOC_HEAD, mdoc, tok)) @@ -813,7 +819,7 @@ macro_scoped_line(MACRO_PROT_ARGS) return(0); } else if ( ! rewind_subblock(MDOC_HEAD, mdoc, tok)) return(0); - return(rewind_impblock(mdoc, tok)); + return(rewind_impblock(mdoc, tok, line, ppos)); } @@ -907,7 +913,7 @@ macro_constant_scoped(MACRO_PROT_ARGS) } if (MDOC_LINEARG_MAX == j) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); if ( ! flushed) { if ( ! rewind_subblock(MDOC_HEAD, mdoc, tok)) @@ -957,9 +963,12 @@ macro_constant_delimited(MACRO_PROT_ARGS) for (argc = 0; argc < MDOC_LINEARG_MAX; argc++) { lastarg = *pos; c = mdoc_argv(mdoc, line, tok, &argv[argc], pos, buf); - if (ARGV_EOLN == c || ARGV_WORD == c) + if (ARGV_EOLN == c) break; - else if (ARGV_ARG == c) + if (ARGV_WORD == c) { + *pos = lastarg; + break; + } else if (ARGV_ARG == c) continue; mdoc_argv_free(argc, argv); return(0); @@ -1013,7 +1022,7 @@ macro_constant_delimited(MACRO_PROT_ARGS) } if (MDOC_LINEARG_MAX == j) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); if ( ! flushed && rewind_elem(mdoc, tok)) return(0); @@ -1046,10 +1055,11 @@ macro_constant(MACRO_PROT_ARGS) c = mdoc_argv(mdoc, line, tok, &argv[argc], pos, buf); if (ARGV_EOLN == c) break; - else if (ARGV_ARG == c) - continue; - else if (ARGV_WORD == c) + if (ARGV_WORD == c) { + *pos = lastarg; break; + } else if (ARGV_ARG == c) + continue; mdoc_argv_free(argc, argv); return(0); @@ -1064,7 +1074,7 @@ macro_constant(MACRO_PROT_ARGS) mdoc->next = MDOC_NEXT_CHILD; if (MDOC_LINEARG_MAX == argc) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); for (sz = 0; sz + argc < MDOC_LINEARG_MAX; sz++) { lastarg = *pos; @@ -1080,7 +1090,7 @@ macro_constant(MACRO_PROT_ARGS) } if (MDOC_LINEARG_MAX == sz + argc) - return(mdoc_perr(mdoc, line, ppos, ERR_ARGS_MANY)); + return(mdoc_perr(mdoc, line, ppos, "too many arguments")); return(rewind_elem(mdoc, tok)); } @@ -1091,7 +1101,7 @@ int macro_obsolete(MACRO_PROT_ARGS) { - return(mdoc_pwarn(mdoc, line, ppos, WARN_IGN_OBSOLETE)); + return(mdoc_pwarn(mdoc, line, ppos, WARN_SYNTAX, "macro is obsolete")); } @@ -339,7 +339,7 @@ msg_err(void *arg, int line, int col, const char *msg) p = (struct md_parse *)arg; - xfprintf(stderr, "%s:%d: error: %s (column %d)", + xfprintf(stderr, "%s:%d: error: %s (column %d)\n", p->name, line, msg, col); return(0); } @@ -355,7 +355,7 @@ msg_msg(void *arg, int line, int col, const char *msg) if (0 == p->dbg) return; - xfprintf(stderr, "%s:%d: debug: %s (column %d)", + xfprintf(stderr, "%s:%d: debug: %s (column %d)\n", p->name, line, msg, col); } @@ -36,8 +36,6 @@ mdoc_iscdelim(char p) { switch (p) { - case('{'): - /* FALLTHROUGH */ case('.'): /* FALLTHROUGH */ case(','): @@ -58,6 +56,8 @@ mdoc_iscdelim(char p) /* FALLTHROUGH */ case(']'): /* FALLTHROUGH */ + case('{'): + /* FALLTHROUGH */ case('}'): return(1); default: @@ -200,7 +200,7 @@ bodychild_err_eq0(struct mdoc *mdoc) return(1); if (NULL == mdoc->last->child) return(1); - return(mdoc_warn(mdoc, WARN_ARGS_EQ0)); + return(mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests no body children")); } @@ -212,7 +212,7 @@ bodychild_warn_ge1(struct mdoc *mdoc) return(1); if (mdoc->last->child) return(1); - return(mdoc_warn(mdoc, WARN_ARGS_GE1)); + return(mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests one or more body children")); } @@ -224,7 +224,7 @@ elemchild_warn_eq0(struct mdoc *mdoc) if (NULL == mdoc->last->child) return(1); return(mdoc_pwarn(mdoc, mdoc->last->child->line, - mdoc->last->child->pos, WARN_ARGS_EQ0)); + mdoc->last->child->pos, WARN_SYNTAX, "macro suggests no parameters")); } @@ -235,7 +235,7 @@ elemchild_warn_ge1(struct mdoc *mdoc) assert(MDOC_ELEM == mdoc->last->type); if (mdoc->last->child) return(1); - return(mdoc_warn(mdoc, WARN_ARGS_GE1)); + return(mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests one or more parameters")); } @@ -246,7 +246,7 @@ elemchild_err_eq0(struct mdoc *mdoc) assert(MDOC_ELEM == mdoc->last->type); if (NULL == mdoc->last->child) return(1); - return(mdoc_err(mdoc, ERR_ARGS_EQ0)); + return(mdoc_err(mdoc, "macro expects no parameters")); } @@ -257,7 +257,7 @@ elemchild_err_ge1(struct mdoc *mdoc) assert(MDOC_ELEM == mdoc->last->type); if (mdoc->last->child) return(1); - return(mdoc_err(mdoc, ERR_ARGS_GE1)); + return(mdoc_err(mdoc, "macro expects one or more parameters")); } @@ -270,7 +270,7 @@ headchild_err_eq0(struct mdoc *mdoc) if (NULL == mdoc->last->child) return(1); return(mdoc_perr(mdoc, mdoc->last->child->line, - mdoc->last->child->pos, ERR_ARGS_EQ0)); + mdoc->last->child->pos, "macro expects no parameters")); } @@ -282,7 +282,7 @@ headchild_warn_ge1(struct mdoc *mdoc) return(1); if (mdoc->last->child) return(1); - return(mdoc_warn(mdoc, WARN_ARGS_GE1)); + return(mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests one or more parameters")); } @@ -294,7 +294,7 @@ headchild_err_ge1(struct mdoc *mdoc) return(1); if (mdoc->last->child) return(1); - return(mdoc_err(mdoc, ERR_ARGS_GE1)); + return(mdoc_err(mdoc, "macro expects one or more parameters")); } @@ -312,7 +312,7 @@ pre_display(struct mdoc *mdoc, struct mdoc_node *node) break; if (NULL == n) return(1); - return(mdoc_nerr(mdoc, node, ERR_SCOPE_NONEST)); + return(mdoc_nerr(mdoc, node, "displays may not be nested")); } @@ -364,12 +364,12 @@ pre_bl(struct mdoc *mdoc, struct mdoc_node *node) } } if (0 == type) - return(mdoc_err(mdoc, ERR_SYNTAX_ARGMISS)); + return(mdoc_err(mdoc, "no list type specified")); if (0 == err) return(1); assert(argv); return(mdoc_perr(mdoc, argv->line, - argv->pos, ERR_SYNTAX_ARGBAD)); + argv->pos, "only one list type possible")); } @@ -409,12 +409,12 @@ pre_bd(struct mdoc *mdoc, struct mdoc_node *node) } } if (0 == type) - return(mdoc_err(mdoc, ERR_SYNTAX_ARGMISS)); + return(mdoc_err(mdoc, "no display type specified")); if (0 == err) return(1); assert(argv); return(mdoc_perr(mdoc, argv->line, - argv->pos, ERR_SYNTAX_ARGBAD)); + argv->pos, "only one display type possible")); } @@ -427,9 +427,9 @@ pre_it(struct mdoc *mdoc, struct mdoc_node *node) assert(MDOC_It == mdoc->last->tok); if (MDOC_BODY != mdoc->last->parent->type) - return(mdoc_nerr(mdoc, node, ERR_SYNTAX_PARENTBAD)); + return(mdoc_nerr(mdoc, node, "invalid macro parent `%s'", mdoc_macronames[mdoc->last->parent->tok])); if (MDOC_Bl != mdoc->last->parent->tok) - return(mdoc_nerr(mdoc, node, ERR_SYNTAX_PARENTBAD)); + return(mdoc_nerr(mdoc, node, "invalid macro parent `%s'", mdoc_macronames[mdoc->last->parent->tok])); return(1); } @@ -440,7 +440,7 @@ pre_prologue(struct mdoc *mdoc, struct mdoc_node *node) { if (SEC_PROLOGUE != mdoc->sec_lastn) - return(mdoc_nerr(mdoc, node, ERR_SEC_NPROLOGUE)); + return(mdoc_nerr(mdoc, node, "macro may only be invoked in the prologue")); assert(MDOC_ELEM == node->type); /* Check for ordering. */ @@ -449,15 +449,15 @@ pre_prologue(struct mdoc *mdoc, struct mdoc_node *node) case (MDOC_Os): if (mdoc->meta.title[0] && mdoc->meta.date) break; - return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_OO)); + return(mdoc_nerr(mdoc, node, "prologue macro out-of-order")); case (MDOC_Dt): if (0 == mdoc->meta.title[0] && mdoc->meta.date) break; - return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_OO)); + return(mdoc_nerr(mdoc, node, "prologue macro out-of-order")); case (MDOC_Dd): if (0 == mdoc->meta.title[0] && 0 == mdoc->meta.date) break; - return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_OO)); + return(mdoc_nerr(mdoc, node, "prologue macro out-of-order")); default: abort(); /* NOTREACHED */ @@ -483,7 +483,7 @@ pre_prologue(struct mdoc *mdoc, struct mdoc_node *node) /* NOTREACHED */ } - return(mdoc_nerr(mdoc, node, ERR_SEC_PROLOGUE_REP)); + return(mdoc_nerr(mdoc, node, "prologue macro repeated")); } @@ -552,31 +552,31 @@ post_it(struct mdoc *mdoc) if (TYPE_HEAD == type) { if (NULL == (n = mdoc->last->data.block.head)) { - if ( ! mdoc_warn(mdoc, WARN_SYNTAX_EMPTYHEAD)) + if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests line parameters")) return(0); } else if (NULL == n->child) - if ( ! mdoc_warn(mdoc, WARN_SYNTAX_EMPTYHEAD)) + if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests line parameters")) return(0); if (NULL == (n = mdoc->last->data.block.body)) { - if ( ! mdoc_warn(mdoc, WARN_SYNTAX_EMPTYBODY)) + if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests body children")) return(0); } else if (NULL == n->child) - if ( ! mdoc_warn(mdoc, WARN_SYNTAX_EMPTYBODY)) + if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests body children")) return(0); return(1); } if (NULL == (n = mdoc->last->data.block.head)) { - if ( ! mdoc_warn(mdoc, WARN_SYNTAX_EMPTYHEAD)) + if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests line parameters")) return(0); } else if (NULL == n->child) - if ( ! mdoc_warn(mdoc, WARN_SYNTAX_EMPTYHEAD)) + if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests line parameters")) return(0); if ((n = mdoc->last->data.block.body) && n->child) - if ( ! mdoc_warn(mdoc, WARN_SYNTAX_NOBODY)) + if ( ! mdoc_warn(mdoc, WARN_SYNTAX, "macro suggests body children")) return(0); if (MDOC_Column != sv) @@ -592,7 +592,7 @@ post_it(struct mdoc *mdoc) if (i == (size_t)sv) return(1); - return(mdoc_err(mdoc, ERR_SYNTAX_ARGFORM)); + return(mdoc_err(mdoc, "expected %d list columns, have %d", sv, (int)i)); #undef TYPE_NONE #undef TYPE_BODY @@ -618,7 +618,7 @@ post_bl(struct mdoc *mdoc) } if (NULL == n) return(1); - return(mdoc_nerr(mdoc, n, ERR_SYNTAX_CHILDBAD)); + return(mdoc_nerr(mdoc, n, "invalid child of parent macro `Bl'")); } @@ -653,8 +653,8 @@ post_sh(struct mdoc *mdoc) return(1); if (sec == mdoc->sec_lastn) - return(mdoc_warn(mdoc, WARN_SEC_REP)); - return(mdoc_warn(mdoc, WARN_SEC_OO)); + return(mdoc_warn(mdoc, WARN_SYNTAX, "section repeated")); + return(mdoc_warn(mdoc, WARN_SYNTAX, "section out of conventional order")); } |