diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-01 17:27:44 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-01 17:27:44 +0000 |
commit | 85ebc4c346a67252f8e7e3a1c4326920984c01e7 (patch) | |
tree | eb357aa2d9480946318b9ecccf29e86489a2862c | |
parent | 120073f11aa98a6e6187a5bd14df4505cfe2c087 (diff) | |
download | mandoc-85ebc4c346a67252f8e7e3a1c4326920984c01e7.tar.gz |
mention requests and macros in more messages
-rw-r--r-- | man.c | 4 | ||||
-rw-r--r-- | man_validate.c | 14 | ||||
-rw-r--r-- | mandoc.h | 58 | ||||
-rw-r--r-- | mdoc.c | 4 | ||||
-rw-r--r-- | mdoc_macro.c | 2 | ||||
-rw-r--r-- | mdoc_validate.c | 76 | ||||
-rw-r--r-- | read.c | 16 | ||||
-rw-r--r-- | roff.c | 5 |
8 files changed, 98 insertions, 81 deletions
@@ -496,8 +496,8 @@ man_pmacro(struct man *man, int ln, char *buf, int offs) tok = (i > 0 && i < 4) ? man_hash_find(mac) : MAN_MAX; if (MAN_MAX == tok) { - mandoc_vmsg(MANDOCERR_MACRO, man->parse, ln, ppos, - "%s", buf + ppos - 1); + mandoc_msg(MANDOCERR_MACRO, man->parse, + ln, ppos, buf + ppos - 1); return(1); } diff --git a/man_validate.c b/man_validate.c index 877b7e9d..535f4006 100644 --- a/man_validate.c +++ b/man_validate.c @@ -404,10 +404,10 @@ post_TH(CHKARGS) /* Only warn about this once... */ if (isalpha((unsigned char)*p) && ! isupper((unsigned char)*p)) { - mandoc_msg(MANDOCERR_TITLE_CASE, + mandoc_vmsg(MANDOCERR_TITLE_CASE, man->parse, n->line, n->pos + (p - n->string), - n->string); + "TH %s", n->string); break; } } @@ -435,7 +435,9 @@ post_TH(CHKARGS) n->line, n->pos); } else { man->meta.date = mandoc_strdup(""); - man_nmsg(man, n ? n : nb, MANDOCERR_DATE_MISSING); + mandoc_msg(MANDOCERR_DATE_MISSING, man->parse, + n ? n->line : nb->line, + n ? n->pos : nb->pos, "TH"); } /* TITLE MSEC DATE ->SOURCE<- VOL */ @@ -465,7 +467,8 @@ post_nf(CHKARGS) { if (MAN_LITERAL & man->flags) - man_nmsg(man, n, MANDOCERR_NF_SKIP); + mandoc_msg(MANDOCERR_NF_SKIP, man->parse, + n->line, n->pos, "nf"); man->flags |= MAN_LITERAL; return(1); @@ -476,7 +479,8 @@ post_fi(CHKARGS) { if ( ! (MAN_LITERAL & man->flags)) - man_nmsg(man, n, MANDOCERR_FI_SKIP); + mandoc_msg(MANDOCERR_FI_SKIP, man->parse, + n->line, n->pos, "fi"); man->flags &= ~MAN_LITERAL; return(1); @@ -51,8 +51,8 @@ enum mandocerr { /* related to the prologue */ MANDOCERR_TH_MISSING, /* missing .TH macro, using "unknown 1" */ MANDOCERR_TITLE_CASE, /* lower case character in document title */ - MANDOCERR_MSEC_BAD, /* unknown manual section: section */ - MANDOCERR_ARCH_BAD, /* unknown manual volume or arch: volume */ + MANDOCERR_MSEC_BAD, /* unknown manual section: Dt ... section */ + MANDOCERR_ARCH_BAD, /* unknown manual volume or arch: Dt ... volume */ MANDOCERR_DATE_MISSING, /* missing date, using today's date */ MANDOCERR_DATE_BAD, /* cannot parse date, using it verbatim: date */ MANDOCERR_PROLOG_ORDER, /* prologue macros out of order: macro */ @@ -61,14 +61,14 @@ enum mandocerr { MANDOCERR_PROLOG_ONLY, /* skipping prologue macro in body: macro */ /* related to document structure */ - MANDOCERR_SO, /* .so is fragile, better use ln(1): .so path */ + MANDOCERR_SO, /* .so is fragile, better use ln(1): so path */ MANDOCERR_DOC_EMPTY, /* no document body */ MANDOCERR_SEC_BEFORE, /* content before first section header: macro */ - MANDOCERR_NAMESEC_FIRST, /* first section is not "NAME": title */ + MANDOCERR_NAMESEC_FIRST, /* first section is not NAME: Sh title */ MANDOCERR_NAMESEC_BAD, /* bad NAME section contents: macro */ - MANDOCERR_SEC_ORDER, /* sections out of conventional order: title */ - MANDOCERR_SEC_REP, /* duplicate section title: title */ - MANDOCERR_SEC_MSEC, /* unexpected section: title for ... only */ + MANDOCERR_SEC_ORDER, /* sections out of conventional order: Sh title */ + MANDOCERR_SEC_REP, /* duplicate section title: Sh title */ + MANDOCERR_SEC_MSEC, /* unexpected section: Sh title for ... only */ /* related to macros and nesting */ MANDOCERR_MACRO_OBS, /* obsolete macro: macro */ @@ -79,8 +79,8 @@ enum mandocerr { MANDOCERR_BD_NEST, /* nested displays are not portable: macro ... */ MANDOCERR_BL_MOVE, /* moving content out of list: macro */ MANDOCERR_VT_CHILD, /* .Vt block has child macro: macro */ - MANDOCERR_FI_SKIP, /* fill mode already enabled, skipping .fi */ - MANDOCERR_NF_SKIP, /* fill mode already disabled, skipping .nf */ + MANDOCERR_FI_SKIP, /* fill mode already enabled, skipping: fi */ + MANDOCERR_NF_SKIP, /* fill mode already disabled, skipping: nf */ MANDOCERR_BLK_LINE, /* line scope broken: macro breaks macro */ /* related to missing arguments */ @@ -89,27 +89,27 @@ enum mandocerr { MANDOCERR_MACRO_EMPTY, /* skipping empty macro: macro */ MANDOCERR_ARG_EMPTY, /* empty argument, using 0n: macro arg */ MANDOCERR_ARGCWARN, /* argument count wrong */ - MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged */ - MANDOCERR_BL_LATETYPE, /* list type is not the first argument: arg */ + MANDOCERR_BD_NOTYPE, /* missing display type, using -ragged: Bd */ + MANDOCERR_BL_LATETYPE, /* list type is not the first argument: Bl arg */ MANDOCERR_BL_NOWIDTH, /* missing -width in -tag list, using 8n */ - MANDOCERR_EX_NONAME, /* missing name for .Ex, using "" */ - MANDOCERR_IT_NOHEAD, /* empty head in list item: type */ - MANDOCERR_IT_NOBODY, /* empty list item: type */ - MANDOCERR_BF_NOFONT, /* missing font type, using \fR */ - MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: macro font */ + MANDOCERR_EX_NONAME, /* missing utility name, using "": Ex */ + MANDOCERR_IT_NOHEAD, /* empty head in list item: Bl -type It */ + MANDOCERR_IT_NOBODY, /* empty list item: Bl -type It */ + MANDOCERR_BF_NOFONT, /* missing font type, using \fR: Bf */ + MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */ MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */ /* related to bad arguments */ MANDOCERR_ARG_QUOTE, /* unterminated quoted argument */ MANDOCERR_ARG_REP, /* duplicate argument: macro arg */ MANDOCERR_AN_REP, /* skipping duplicate argument: An -arg */ - MANDOCERR_BD_REP, /* skipping duplicate display type: type */ - MANDOCERR_BL_REP, /* skipping duplicate list type: type */ + MANDOCERR_BD_REP, /* skipping duplicate display type: Bd -type */ + MANDOCERR_BL_REP, /* skipping duplicate list type: Bl -type */ MANDOCERR_BL_SKIPW, /* skipping -width argument: Bl -type */ - MANDOCERR_AT_BAD, /* unknown AT&T UNIX version: version */ + MANDOCERR_AT_BAD, /* unknown AT&T UNIX version: At version */ MANDOCERR_RS_BAD, /* invalid content in Rs block: macro */ MANDOCERR_SM_BAD, /* invalid Boolean argument: macro arg */ - MANDOCERR_FT_BAD, /* unknown font, skipping request: request font */ + MANDOCERR_FT_BAD, /* unknown font, skipping request: ft font */ /* related to plain text */ MANDOCERR_FI_BLANK, /* blank line in fill mode, using .sp */ @@ -140,21 +140,21 @@ enum mandocerr { /* related to document structure and macros */ MANDOCERR_ROFFLOOP, /* input stack limit exceeded, infinite loop? */ - MANDOCERR_BADCHAR, /* skipping bad character */ - MANDOCERR_MACRO, /* skipping unknown macro */ - MANDOCERR_IT_STRAY, /* skipping item outside list */ - MANDOCERR_TA_STRAY, /* skipping column outside column list */ + MANDOCERR_BADCHAR, /* skipping bad character: number */ + MANDOCERR_MACRO, /* skipping unknown macro: macro */ + MANDOCERR_IT_STRAY, /* skipping item outside list: It ... */ + MANDOCERR_TA_STRAY, /* skipping column outside column list: Ta */ MANDOCERR_BLK_NOTOPEN, /* skipping end of block that is not open */ MANDOCERR_BLK_BROKEN, /* inserting missing end of block: macro ... */ MANDOCERR_BLK_NOEND, /* appending missing end of block: macro */ /* related to request and macro arguments */ - MANDOCERR_NAMESC, /* escaped character not allowed in a name */ + MANDOCERR_NAMESC, /* escaped character not allowed in a name: name */ MANDOCERR_ARGCOUNT, /* argument count wrong */ - MANDOCERR_BL_NOTYPE, /* missing list type, using -item */ - MANDOCERR_NM_NONAME, /* missing manual name, using "" */ + MANDOCERR_BL_NOTYPE, /* missing list type, using -item: Bl */ + MANDOCERR_NM_NONAME, /* missing manual name, using "": Nm */ MANDOCERR_OS_UNAME, /* uname(3) system call failed, using UNKNOWN */ - MANDOCERR_ST_BAD, /* unknown standard specifier: standard */ + MANDOCERR_ST_BAD, /* unknown standard specifier: St standard */ MANDOCERR_IT_NONUM, /* skipping request without numeric argument */ MANDOCERR_ARG_SKIP, /* skipping all arguments: macro args */ MANDOCERR_ARG_EXCESS, /* skipping excess arguments: macro ... args */ @@ -162,7 +162,7 @@ enum mandocerr { MANDOCERR_FATAL, /* ===== start of fatal errors ===== */ MANDOCERR_TOOLARGE, /* input too large */ - MANDOCERR_BADDISP, /* NOT IMPLEMENTED: .Bd -file */ + MANDOCERR_BD_FILE, /* NOT IMPLEMENTED: Bd -file */ MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */ MANDOCERR_SO_FAIL, /* .so request failed */ @@ -838,8 +838,8 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs) tok = (i > 1 && i < 4) ? mdoc_hash_find(mac) : MDOC_MAX; if (MDOC_MAX == tok) { - mandoc_vmsg(MANDOCERR_MACRO, mdoc->parse, - ln, sv, "%s", buf + sv - 1); + mandoc_msg(MANDOCERR_MACRO, mdoc->parse, + ln, sv, buf + sv - 1); return(1); } diff --git a/mdoc_macro.c b/mdoc_macro.c index 4baebd65..04f494c3 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1785,7 +1785,7 @@ phrase_ta(MACRO_PROT_ARGS) n = n->parent; if (NULL == n || LIST_column != n->norm->Bl.type) { mandoc_msg(MANDOCERR_TA_STRAY, mdoc->parse, - line, ppos, NULL); + line, ppos, "Ta"); return(1); } diff --git a/mdoc_validate.c b/mdoc_validate.c index ce4fe96c..70b10b1d 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -680,9 +680,9 @@ pre_bl(PRE_ARGS) /* Check: multiple list types. */ if (LIST__NONE != n->norm->Bl.type) { - mandoc_msg(MANDOCERR_BL_REP, + mandoc_vmsg(MANDOCERR_BL_REP, mdoc->parse, n->line, n->pos, - mdoc_argnames[argv->arg]); + "Bl -%s", mdoc_argnames[argv->arg]); continue; } @@ -691,8 +691,8 @@ pre_bl(PRE_ARGS) if (n->norm->Bl.width || n->norm->Bl.offs || n->norm->Bl.comp) - mandoc_msg(MANDOCERR_BL_LATETYPE, - mdoc->parse, n->line, n->pos, + mandoc_vmsg(MANDOCERR_BL_LATETYPE, + mdoc->parse, n->line, n->pos, "Bl -%s", mdoc_argnames[n->args->argv[0].arg]); n->norm->Bl.type = lt; @@ -705,7 +705,8 @@ pre_bl(PRE_ARGS) /* Allow lists to default to LIST_item. */ if (LIST__NONE == n->norm->Bl.type) { - mdoc_nmsg(mdoc, n, MANDOCERR_BL_NOTYPE); + mandoc_msg(MANDOCERR_BL_NOTYPE, mdoc->parse, + n->line, n->pos, "Bl"); n->norm->Bl.type = LIST_item; } @@ -719,7 +720,8 @@ pre_bl(PRE_ARGS) switch (n->norm->Bl.type) { case LIST_tag: if (NULL == n->norm->Bl.width) - mdoc_nmsg(mdoc, n, MANDOCERR_BL_NOWIDTH); + mandoc_msg(MANDOCERR_BL_NOWIDTH, mdoc->parse, + n->line, n->pos, "Bl -tag"); break; case LIST_column: /* FALLTHROUGH */ @@ -796,7 +798,8 @@ pre_bd(PRE_ARGS) dt = DISP_literal; break; case MDOC_File: - mdoc_nmsg(mdoc, n, MANDOCERR_BADDISP); + mandoc_msg(MANDOCERR_BD_FILE, mdoc->parse, + n->line, n->pos, NULL); return(0); case MDOC_Offset: if (0 == argv->sz) { @@ -829,13 +832,14 @@ pre_bd(PRE_ARGS) if (DISP__NONE == n->norm->Bd.type) n->norm->Bd.type = dt; else - mandoc_msg(MANDOCERR_BD_REP, + mandoc_vmsg(MANDOCERR_BD_REP, mdoc->parse, n->line, n->pos, - mdoc_argnames[argv->arg]); + "Bd -%s", mdoc_argnames[argv->arg]); } if (DISP__NONE == n->norm->Bd.type) { - mdoc_nmsg(mdoc, n, MANDOCERR_BD_NOTYPE); + mandoc_msg(MANDOCERR_BD_NOTYPE, mdoc->parse, + n->line, n->pos, "Bd"); n->norm->Bd.type = DISP_ragged; } @@ -972,7 +976,8 @@ post_bf(POST_ARGS) nch = np->child; if (NULL == np->parent->args) { if (NULL == nch) { - mdoc_nmsg(mdoc, np, MANDOCERR_BF_NOFONT); + mandoc_msg(MANDOCERR_BF_NOFONT, mdoc->parse, + np->line, np->pos, "Bf"); return(1); } nch = nch->next; @@ -1085,7 +1090,8 @@ post_nm(POST_ARGS) mdoc_deroff(&mdoc->meta.name, mdoc->last); if (NULL == mdoc->meta.name) - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NM_NONAME); + mandoc_msg(MANDOCERR_NM_NONAME, mdoc->parse, + mdoc->last->line, mdoc->last->pos, "Nm"); return(1); } @@ -1173,8 +1179,8 @@ post_at(POST_ARGS) assert(MDOC_TEXT == n->type); if (NULL == (std_att = mdoc_a2att(n->string))) { - mandoc_msg(MANDOCERR_AT_BAD, mdoc->parse, - n->line, n->pos, n->string); + mandoc_vmsg(MANDOCERR_AT_BAD, mdoc->parse, + n->line, n->pos, "At %s", n->string); mandoc_asprintf(&att, "AT&T UNIX %s", n->string); } else att = mandoc_strdup(std_att); @@ -1241,8 +1247,9 @@ post_it(POST_ARGS) /* FALLTHROUGH */ case LIST_diag: if (NULL == nit->head->child) - mandoc_msg(MANDOCERR_IT_NOHEAD, + mandoc_vmsg(MANDOCERR_IT_NOHEAD, mdoc->parse, nit->line, nit->pos, + "Bl -%s It", mdoc_argnames[nbl->args->argv[0].arg]); break; case LIST_bullet: @@ -1253,8 +1260,9 @@ post_it(POST_ARGS) /* FALLTHROUGH */ case LIST_hyphen: if (NULL == nit->body->child) - mandoc_msg(MANDOCERR_IT_NOBODY, + mandoc_vmsg(MANDOCERR_IT_NOBODY, mdoc->parse, nit->line, nit->pos, + "Bl -%s It", mdoc_argnames[nbl->args->argv[0].arg]); /* FALLTHROUGH */ case LIST_item: @@ -1685,8 +1693,8 @@ post_st(POST_ARGS) assert(MDOC_TEXT == nch->type); if (NULL == (p = mdoc_a2st(nch->string))) { - mandoc_msg(MANDOCERR_ST_BAD, mdoc->parse, - nch->line, nch->pos, nch->string); + mandoc_vmsg(MANDOCERR_ST_BAD, mdoc->parse, + nch->line, nch->pos, "St %s", nch->string); mdoc_node_delete(mdoc, n); } else { free(nch->string); @@ -1913,8 +1921,9 @@ post_sh_head(POST_ARGS) /* The NAME should be first. */ if (SEC_NAME != sec && SEC_NONE == mdoc->lastnamed) - mandoc_msg(MANDOCERR_NAMESEC_FIRST, mdoc->parse, - mdoc->last->line, mdoc->last->pos, secname); + mandoc_vmsg(MANDOCERR_NAMESEC_FIRST, mdoc->parse, + mdoc->last->line, mdoc->last->pos, + "Sh %s", secname); /* The SYNOPSIS gets special attention in other areas. */ @@ -1957,12 +1966,14 @@ post_sh_head(POST_ARGS) */ if (sec == mdoc->lastnamed) - mandoc_msg(MANDOCERR_SEC_REP, mdoc->parse, - mdoc->last->line, mdoc->last->pos, secname); + mandoc_vmsg(MANDOCERR_SEC_REP, mdoc->parse, + mdoc->last->line, mdoc->last->pos, + "Sh %s", secname); if (sec < mdoc->lastnamed) - mandoc_msg(MANDOCERR_SEC_ORDER, mdoc->parse, - mdoc->last->line, mdoc->last->pos, secname); + mandoc_vmsg(MANDOCERR_SEC_ORDER, mdoc->parse, + mdoc->last->line, mdoc->last->pos, + "Sh %s", secname); /* Mark the last named section. */ @@ -1996,7 +2007,7 @@ post_sh_head(POST_ARGS) goodsec = "9"; mandoc_vmsg(MANDOCERR_SEC_MSEC, mdoc->parse, mdoc->last->line, mdoc->last->pos, - "%s for %s only", secname, goodsec); + "Sh %s for %s only", secname, goodsec); break; default: break; @@ -2178,10 +2189,10 @@ post_dt(POST_ARGS) for (p = nn->string; *p; p++) { if (toupper((unsigned char)*p) == *p) continue; - mandoc_msg(MANDOCERR_TITLE_CASE, + mandoc_vmsg(MANDOCERR_TITLE_CASE, mdoc->parse, nn->line, nn->pos + (p - nn->string), - nn->string); + "Dt %s", nn->string); break; } @@ -2225,8 +2236,8 @@ post_dt(POST_ARGS) mdoc->meta.vol = mandoc_strdup(cp); mdoc->meta.msec = mandoc_strdup(nn->string); } else { - mandoc_msg(MANDOCERR_MSEC_BAD, mdoc->parse, - nn->line, nn->pos, nn->string); + mandoc_vmsg(MANDOCERR_MSEC_BAD, mdoc->parse, + nn->line, nn->pos, "Dt ... %s", nn->string); mdoc->meta.vol = mandoc_strdup(nn->string); mdoc->meta.msec = mandoc_strdup(nn->string); } @@ -2248,8 +2259,8 @@ post_dt(POST_ARGS) } else { cp = mdoc_a2arch(nn->string); if (NULL == cp) { - mandoc_msg(MANDOCERR_ARCH_BAD, mdoc->parse, - nn->line, nn->pos, nn->string); + mandoc_vmsg(MANDOCERR_ARCH_BAD, mdoc->parse, + nn->line, nn->pos, "Dt ... %s", nn->string); free(mdoc->meta.vol); mdoc->meta.vol = mandoc_strdup(nn->string); } else @@ -2359,7 +2370,8 @@ post_ex(POST_ARGS) return(1); if (mdoc->meta.name == NULL) { - mdoc_nmsg(mdoc, n, MANDOCERR_EX_NONAME); + mandoc_msg(MANDOCERR_EX_NONAME, mdoc->parse, + n->line, n->pos, "Ex"); return(1); } @@ -123,8 +123,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "nested displays are not portable", "moving content out of list", ".Vt block has child macro", - "fill mode already enabled, skipping .fi", - "fill mode already disabled, skipping .nf", + "fill mode already enabled, skipping", + "fill mode already disabled, skipping", "line scope broken", /* related to missing macro arguments */ @@ -136,7 +136,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "missing display type, using -ragged", "list type is not the first argument", "missing -width in -tag list, using 8n", - "missing name for .Ex, using \"\"", + "missing utility name, using \"\"", "empty head in list item", "empty list item", "missing font type, using \\fR", @@ -206,7 +206,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "generic fatal error", "input too large", - "NOT IMPLEMENTED: .Bd -file", + "NOT IMPLEMENTED: Bd -file", "NOT IMPLEMENTED: .so with absolute path or \"..\"", ".so request failed", @@ -353,8 +353,8 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int start) if ( ! (isascii(c) && (isgraph(c) || isblank(c)))) { - mandoc_msg(MANDOCERR_BADCHAR, curp, - curp->line, pos, NULL); + mandoc_vmsg(MANDOCERR_BADCHAR, curp, + curp->line, pos, "0x%x", c); i++; ln.buf[pos++] = '?'; continue; @@ -410,8 +410,8 @@ mparse_buf_r(struct mparse *curp, struct buf blk, int start) if ( ! (isascii(c) && (isgraph(c) || isblank(c)))) { - mandoc_msg(MANDOCERR_BADCHAR, curp, - curp->line, pos, NULL); + mandoc_vmsg(MANDOCERR_BADCHAR, curp, + curp->line, pos, "0x%x", c); i += 2; ln.buf[pos++] = '?'; continue; @@ -1975,7 +1975,7 @@ roff_so(ROFF_ARGS) char *name; name = *bufp + pos; - mandoc_vmsg(MANDOCERR_SO, r->parse, ln, ppos, ".so %s", name); + mandoc_vmsg(MANDOCERR_SO, r->parse, ln, ppos, "so %s", name); /* * Handle `so'. Be EXTREMELY careful, as we shouldn't be @@ -2067,7 +2067,8 @@ roff_getname(struct roff *r, char **cpp, int ln, int pos) cp++; if ('\\' == *cp) continue; - mandoc_msg(MANDOCERR_NAMESC, r->parse, ln, pos, NULL); + mandoc_vmsg(MANDOCERR_NAMESC, r->parse, ln, pos, + "%.*s", (int)(cp - name + 1), name); mandoc_escape((const char **)&cp, NULL, NULL); break; } |