diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-09-12 00:53:22 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-09-12 00:53:22 +0000 |
commit | 2cb7ce110e22298c69e03cd5f561f1ea661a6b67 (patch) | |
tree | 986dd3141938f33deb95b5bf755da9b60ef0403d /usr.bin/mandoc/mdoc_validate.c | |
parent | f543e57479ed531514961b9154a9d7c831ded686 (diff) |
warn about commas in function arguments; inspired by mdoclint(1)
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 2c5c7e1f149..2cc58af547e 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.165 2014/09/11 23:52:47 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.166 2014/09/12 00:53:21 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -99,6 +99,7 @@ static int post_en(POST_ARGS); 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_fo(POST_ARGS); static int post_hyph(POST_ARGS); static int post_hyphtext(POST_ARGS); @@ -156,10 +157,10 @@ static const struct valids mdoc_valids[MDOC_MAX] = { { NULL, NULL }, /* Er */ { NULL, NULL }, /* Ev */ { pre_std, post_ex }, /* Ex */ - { NULL, NULL }, /* Fa */ + { NULL, post_fa }, /* Fa */ { NULL, ewarn_ge1 }, /* Fd */ { NULL, NULL }, /* Fl */ - { NULL, NULL }, /* Fn */ + { NULL, post_fa }, /* Fn */ { NULL, NULL }, /* Ft */ { NULL, NULL }, /* Ic */ { NULL, ewarn_eq1 }, /* In */ @@ -1007,6 +1008,28 @@ post_fo(POST_ARGS) } static int +post_fa(POST_ARGS) +{ + const struct mdoc_node *n; + const char *cp; + + for (n = mdoc->last->child; n != NULL; n = n->next) { + for (cp = n->string; *cp != '\0'; cp++) { + /* Ignore callbacks and alterations. */ + if (*cp == '(' || *cp == '{') + break; + if (*cp != ',') + continue; + mandoc_msg(MANDOCERR_FA_COMMA, mdoc->parse, + n->line, n->pos + (cp - n->string), + n->string); + break; + } + } + return(1); +} + +static int post_vt(POST_ARGS) { const struct mdoc_node *n; |