diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-10-11 21:14:16 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-10-11 21:14:16 +0000 |
commit | faae039ceebc3ae28b1b82cafbd646d619a0358c (patch) | |
tree | 47c2f8229c8fd8f560ea8b254b36d03b430cb534 /mdoc_validate.c | |
parent | 1861ab2e818a4f9e21e8ed19d05cd46f8dc4e409 (diff) | |
download | mandoc-faae039ceebc3ae28b1b82cafbd646d619a0358c.tar.gz mandoc-faae039ceebc3ae28b1b82cafbd646d619a0358c.tar.zst mandoc-faae039ceebc3ae28b1b82cafbd646d619a0358c.zip |
warn about parentheses in function names after .Fn and .Fo;
particularly useful when converting from other languages to mdoc(7);
feature suggested by bentley@
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index a566ad00..f2e85a36 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.249 2014/09/12 00:54:10 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.250 2014/10/11 21:14:16 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -101,6 +101,8 @@ static int post_es(POST_ARGS); static int post_eoln(POST_ARGS); static int post_ex(POST_ARGS); static int post_fa(POST_ARGS); +static int post_fn(POST_ARGS); +static int post_fname(POST_ARGS); static int post_fo(POST_ARGS); static int post_hyph(POST_ARGS); static int post_hyphtext(POST_ARGS); @@ -161,7 +163,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = { { NULL, post_fa }, /* Fa */ { NULL, ewarn_ge1 }, /* Fd */ { NULL, NULL }, /* Fl */ - { NULL, post_fa }, /* Fn */ + { NULL, post_fn }, /* Fn */ { NULL, NULL }, /* Ft */ { NULL, NULL }, /* Ic */ { NULL, ewarn_eq1 }, /* In */ @@ -1000,11 +1002,36 @@ post_eoln(POST_ARGS) } static int +post_fname(POST_ARGS) +{ + const struct mdoc_node *n; + size_t pos; + + n = mdoc->last->child; + pos = strcspn(n->string, "()"); + if (n->string[pos] != '\0') + mandoc_msg(MANDOCERR_FN_PAREN, mdoc->parse, + n->line, n->pos + pos, n->string); + return(1); +} + +static int +post_fn(POST_ARGS) +{ + + post_fname(mdoc); + post_fa(mdoc); + return(1); +} + +static int post_fo(POST_ARGS) { hwarn_eq1(mdoc); bwarn_ge1(mdoc); + if (mdoc->last->type == MDOC_HEAD) + post_fname(mdoc); return(1); } |