From 333417082dab30264386c33095d1f6e64f6939cc Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 13 Sep 2019 19:26:46 +0000 Subject: Improve validation of function names: 1. Relax checking to accept function types of the form "ret_type (fname)(args)" (suggested by Yuri Pankov ). 2. Tighten checking to require the closing parenthesis. --- mdoc_validate.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'mdoc_validate.c') diff --git a/mdoc_validate.c b/mdoc_validate.c index 11cdf00b..c14d4008 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.374 2019/06/27 15:07:30 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.375 2019/09/13 19:26:46 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2019 Ingo Schwarze @@ -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 -- cgit v1.2.3