diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-07-02 15:31:59 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-07-02 15:31:59 +0000 |
commit | 9a0fd61677909a43ee8a1f7d69598769f9a7ad6b (patch) | |
tree | ff9b788408b481515dd3eae168a45e4aea03416d /mdoc_validate.c | |
parent | 58be69d2a5cab3e51bf16a2880fbfa2115dad47d (diff) | |
download | mandoc-9a0fd61677909a43ee8a1f7d69598769f9a7ad6b.tar.gz |
add warning "cross reference to self"; inspired by mdoclint
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index a15ce33e..79fbe420 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1104,6 +1104,8 @@ post_fname(POST_ARGS) if ( ! (cp[0] == '\0' || (cp[0] == '(' && cp[1] == '*'))) mandoc_msg(MANDOCERR_FN_PAREN, mdoc->parse, n->line, n->pos + pos, n->string); + if (n->sec == SEC_SYNOPSIS && mdoc->meta.msec != NULL) + mandoc_xr_add(mdoc->meta.msec, n->string, -1, -1); } static void @@ -1169,6 +1171,11 @@ post_nm(POST_ARGS) n = mdoc->last; + if ((n->sec == SEC_NAME || n->sec == SEC_SYNOPSIS) && + n->child != NULL && n->child->type == ROFFT_TEXT && + mdoc->meta.msec != NULL) + mandoc_xr_add(mdoc->meta.msec, n->child->string, -1, -1); + if (n->last != NULL && (n->last->tok == MDOC_Pp || n->last->tok == MDOC_Lp)) @@ -2339,8 +2346,11 @@ post_xr(POST_ARGS) n->line, n->pos, "Xr %s", nch->string); } else { assert(nch->next == n->last); - mandoc_xr_add(nch->next->string, nch->string, - nch->line, nch->pos); + if(mandoc_xr_add(nch->next->string, nch->string, + nch->line, nch->pos)) + mandoc_vmsg(MANDOCERR_XR_SELF, mdoc->parse, + nch->line, nch->pos, "Xr %s %s", + nch->string, nch->next->string); } post_delim(mdoc); } |