diff options
author | 2019-09-13 19:26:46 +0000 | |
---|---|---|
committer | 2019-09-13 19:26:46 +0000 | |
commit | 333417082dab30264386c33095d1f6e64f6939cc (patch) | |
tree | 848b1ddd19c1d1104764ca4b8dfd818c6e77d90a | |
parent | f6bc3c824b41837a8b513e2805d3fd8a638f9912 (diff) | |
download | mandoc-333417082dab30264386c33095d1f6e64f6939cc.tar.gz mandoc-333417082dab30264386c33095d1f6e64f6939cc.tar.zst mandoc-333417082dab30264386c33095d1f6e64f6939cc.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.
-rw-r--r-- | mdoc_validate.c | 18 | ||||
-rw-r--r-- | regress/mdoc/Fo/warn.in | 18 | ||||
-rw-r--r-- | regress/mdoc/Fo/warn.out_ascii | 23 | ||||
-rw-r--r-- | regress/mdoc/Fo/warn.out_lint | 4 | ||||
-rw-r--r-- | regress/mdoc/Fo/warn.out_markdown | 23 |
5 files changed, 76 insertions, 10 deletions
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 <kristaps@bsd.lv> * Copyright (c) 2010-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -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 diff --git a/regress/mdoc/Fo/warn.in b/regress/mdoc/Fo/warn.in index eb7cf2a6..af4c1448 100644 --- a/regress/mdoc/Fo/warn.in +++ b/regress/mdoc/Fo/warn.in @@ -1,5 +1,5 @@ -.\" $OpenBSD: warn.in,v 1.2 2017/07/04 14:53:25 schwarze Exp $ -.Dd $Mdocdate: July 4 2017 $ +.\" $OpenBSD: warn.in,v 1.3 2019/09/13 19:18:48 schwarze Exp $ +.Dd $Mdocdate: September 13 2019 $ .Dt FO-WARN 1 .Os .Sh NAME @@ -12,3 +12,17 @@ .Fc .Ft double .Fn atan2 "double y, double x" +.Ft int +.Fn close) "int fd" +.Ft typedef void +.Fn (handler) int +.Ft typedef void +.Fn (*fp) int +.Ft int +.Fn (open "const char *path" +.Ft FILE * +.Fn (*popen "const char *cmd" +.Ft void +.Fn (trail)x void +.Ft void +.Fn *star void diff --git a/regress/mdoc/Fo/warn.out_ascii b/regress/mdoc/Fo/warn.out_ascii index 85f0b46f..d4ed2e43 100644 --- a/regress/mdoc/Fo/warn.out_ascii +++ b/regress/mdoc/Fo/warn.out_ascii @@ -10,4 +10,25 @@ SSYYNNOOPPSSIISS _d_o_u_b_l_e aattaann22(_d_o_u_b_l_e _y_, _d_o_u_b_l_e _x); -OpenBSD July 4, 2017 OpenBSD + _i_n_t + cclloossee))(_i_n_t _f_d); + + _t_y_p_e_d_e_f _v_o_i_d + ((hhaannddlleerr))(_i_n_t); + + _t_y_p_e_d_e_f _v_o_i_d + ((**ffpp))(_i_n_t); + + _i_n_t + ((ooppeenn(_c_o_n_s_t _c_h_a_r _*_p_a_t_h); + + _F_I_L_E _* + ((**ppooppeenn(_c_o_n_s_t _c_h_a_r _*_c_m_d); + + _v_o_i_d + ((ttrraaiill))xx(_v_o_i_d); + + _v_o_i_d + **ssttaarr(_v_o_i_d); + +OpenBSD September 13, 2019 OpenBSD diff --git a/regress/mdoc/Fo/warn.out_lint b/regress/mdoc/Fo/warn.out_lint index 3af27fc6..c4991f03 100644 --- a/regress/mdoc/Fo/warn.out_lint +++ b/regress/mdoc/Fo/warn.out_lint @@ -1,2 +1,6 @@ mandoc: warn.in:10:8: WARNING: parenthesis in function name: sin() mandoc: warn.in:14:19: WARNING: comma in function argument: double y, double x +mandoc: warn.in:16:10: WARNING: parenthesis in function name: close) +mandoc: warn.in:22:5: WARNING: parenthesis in function name: (open +mandoc: warn.in:24:5: WARNING: parenthesis in function name: (*popen +mandoc: warn.in:26:5: WARNING: parenthesis in function name: (trail)x diff --git a/regress/mdoc/Fo/warn.out_markdown b/regress/mdoc/Fo/warn.out_markdown index 9d37abba..b793fb9f 100644 --- a/regress/mdoc/Fo/warn.out_markdown +++ b/regress/mdoc/Fo/warn.out_markdown @@ -12,4 +12,25 @@ FO-WARN(1) - General Commands Manual *double* **atan2**(*double y, double x*); -OpenBSD - July 4, 2017 +*int* +**close)**(*int fd*); + +*typedef void* +**(handler)**(*int*); + +*typedef void* +**(\*fp)**(*int*); + +*int* +**(open**(*const char \*path*); + +*FILE \*‌* +**(\*popen**(*const char \*cmd*); + +*void* +**(trail)x**(*void*); + +*void* +**\*star**(*void*); + +OpenBSD - September 13, 2019 |