diff options
author | 2019-09-13 19:18:48 +0000 | |
---|---|---|
committer | 2019-09-13 19:18:48 +0000 | |
commit | 8dbab69b5d0934a7f4ed2f2d70f6755af00887ae (patch) | |
tree | 4b68696aa337998ebc2fdcbfe88c96b325e4cd8f /usr.bin/mandoc/mdoc_validate.c | |
parent | fix markup of the return types of function pointers; (diff) | |
download | wireguard-openbsd-8dbab69b5d0934a7f4ed2f2d70f6755af00887ae.tar.xz wireguard-openbsd-8dbab69b5d0934a7f4ed2f2d70f6755af00887ae.zip |
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 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index e9105cdca56..0d14812760a 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.289 2019/06/27 15:05:14 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.290 2019/09/13 19:18:48 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -1171,11 +1171,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 |