diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2019-09-13 19:26:46 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2019-09-13 19:26:46 +0000 |
commit | 4ef634f0d16fbda69aef241fb561f27496c09867 (patch) | |
tree | 647f01e796b5b830b46968f589435f4bcd69b255 /mdoc_validate.c | |
parent | cdc19ab62bcbc6a6f545f4f8f654f00a9a662f10 (diff) | |
download | mandoc-4ef634f0d16fbda69aef241fb561f27496c09867.tar.gz |
Improve validation of function names:
1. Relax checking to accept function types of the form
"ret_type (fname)(args)" (suggested by Yuri Pankov <yuripv dot net>).
2. Tighten checking to require the closing parenthesis.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index ef2df798..390667d5 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1186,11 +1186,17 @@ post_fname(POST_ARGS) size_t pos; n = mdoc->last->child; - pos = strcspn(n->string, "()"); - cp = n->string + pos; - if ( ! (cp[0] == '\0' || (cp[0] == '(' && cp[1] == '*'))) - mandoc_msg(MANDOCERR_FN_PAREN, n->line, n->pos + pos, - "%s", n->string); + cp = n->string; + if (*cp == '(') { + if (cp[strlen(cp + 1)] == ')') + return; + pos = 0; + } else { + pos = strcspn(cp, "()"); + if (cp[pos] == '\0') + return; + } + mandoc_msg(MANDOCERR_FN_PAREN, n->line, n->pos + pos, "%s", cp); } static void |