From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from scc-mailout-kit-02.scc.kit.edu (scc-mailout-kit-02.scc.kit.edu [129.13.231.82]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id d7da6e30 for ; Fri, 13 Sep 2019 14:31:12 -0500 (EST) Received: from asta-nat.asta.uni-karlsruhe.de ([172.22.63.82] helo=hekate.usta.de) by scc-mailout-kit-02.scc.kit.edu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (envelope-from ) id 1i8rHi-0000ZB-IQ; Fri, 13 Sep 2019 21:31:12 +0200 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.77) (envelope-from ) id 1i8rHh-0007Sn-QS; Fri, 13 Sep 2019 21:31:09 +0200 Received: from athene.usta.de ([172.24.96.10]) by donnerwolke.usta.de with esmtp (Exim 4.84_2) (envelope-from ) id 1i8rHg-0005hM-Av; Fri, 13 Sep 2019 21:31:08 +0200 Received: from localhost (athene.usta.de [local]) by athene.usta.de (OpenSMTPD) with ESMTPA id 111ef9c1; Fri, 13 Sep 2019 21:31:09 +0200 (CEST) Date: Fri, 13 Sep 2019 21:31:09 +0200 From: Ingo Schwarze To: Yuri Pankov Cc: discuss@mandoc.bsd.lv Subject: Re: "WARNING: parenthesis in function name" correctness Message-ID: <20190913193109.GA81601@athene.usta.de> References: <421eeed3-8da5-b852-4581-1058de113831@yuripv.net> <20190910174707.GD6626@athene.usta.de> X-Mailinglist: mandoc-discuss Reply-To: discuss@mandoc.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) Hi Yuri, Yuri Pankov wrote on Wed, Sep 11, 2019 at 01:43:22AM +0300: > Ingo Schwarze wrote: >> I plan to suppress the warning for ".Fo (f)" just like for ".Fo (*f)" >> in the future. The likely typo that should be warned about >> is ".Fo f()", and that warning will still work. > Sounds good, thank you! Committed, see below. Thanks again for the report! Ingo Log Message: ----------- 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. Modified Files: -------------- mandoc: mdoc_validate.c mandoc/regress/mdoc/Fo: warn.in warn.out_ascii warn.out_lint warn.out_markdown Revision Data ------------- Index: mdoc_validate.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v retrieving revision 1.374 retrieving revision 1.375 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.374 -r1.375 --- mdoc_validate.c +++ mdoc_validate.c @@ -1186,11 +1186,17 @@ post_fname(POST_ARGS) size_t pos; =20 n =3D mdoc->last->child; - pos =3D strcspn(n->string, "()"); - cp =3D n->string + pos; - if ( ! (cp[0] =3D=3D '\0' || (cp[0] =3D=3D '(' && cp[1] =3D=3D '*'))) - mandoc_msg(MANDOCERR_FN_PAREN, n->line, n->pos + pos, - "%s", n->string); + cp =3D n->string; + if (*cp =3D=3D '(') { + if (cp[strlen(cp + 1)] =3D=3D ')') + return; + pos =3D 0; + } else { + pos =3D strcspn(cp, "()"); + if (cp[pos] =3D=3D '\0') + return; + } + mandoc_msg(MANDOCERR_FN_PAREN, n->line, n->pos + pos, "%s", cp); } =20 static void Index: warn.in =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Fo/warn.in,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Fo/warn.in -Lregress/mdoc/Fo/warn.in -u -p -r1.2 -r1.3 --- regress/mdoc/Fo/warn.in +++ regress/mdoc/Fo/warn.in @@ -1,4 +1,4 @@ -.\" $OpenBSD: warn.in,v 1.2 2017/07/04 14:53:25 schwarze Exp $ +.\" $OpenBSD: warn.in,v 1.3 2019/09/13 19:18:48 schwarze Exp $ .Dd $Mdocdate$ .Dt FO-WARN 1 .Os @@ -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 Index: warn.out_markdown =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Fo/warn.out_markdown,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Fo/warn.out_markdown -Lregress/mdoc/Fo/warn.out_markdow= n -u -p -r1.2 -r1.3 --- regress/mdoc/Fo/warn.out_markdown +++ regress/mdoc/Fo/warn.out_markdown @@ -12,4 +12,25 @@ FO-WARN(1) - General Commands Manual *double* =20 **atan2**(*double y, double x*); =20 -OpenBSD - July 4, 2017 +*int* =20 +**close)**(*int fd*); + +*typedef void* =20 +**(handler)**(*int*); + +*typedef void* =20 +**(\*fp)**(*int*); + +*int* =20 +**(open**(*const char \*path*); + +*FILE \*‌* =20 +**(\*popen**(*const char \*cmd*); + +*void* =20 +**(trail)x**(*void*); + +*void* =20 +**\*star**(*void*); + +OpenBSD - September 13, 2019 Index: warn.out_lint =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Fo/warn.out_lint,v retrieving revision 1.5 retrieving revision 1.6 diff -Lregress/mdoc/Fo/warn.out_lint -Lregress/mdoc/Fo/warn.out_lint -u -p = -r1.5 -r1.6 --- regress/mdoc/Fo/warn.out_lint +++ 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, doub= le 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 Index: warn.out_ascii =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Fo/warn.out_ascii,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Fo/warn.out_ascii -Lregress/mdoc/Fo/warn.out_ascii -u -= p -r1.2 -r1.3 --- regress/mdoc/Fo/warn.out_ascii +++ regress/mdoc/Fo/warn.out_ascii @@ -10,4 +10,25 @@ S=08SY=08YN=08NO=08OP=08PS=08SI=08IS=08S _=08d_=08o_=08u_=08b_=08l_=08e a=08at=08ta=08an=08n2=082(_=08d_=08o_=08u_=08b_=08l_=08e _=08y_=08, _= =08d_=08o_=08u_=08b_=08l_=08e _=08x); =20 -OpenBSD July 4, 2017 Ope= nBSD + _=08i_=08n_=08t + c=08cl=08lo=08os=08se=08e)=08)(_=08i_=08n_=08t _=08f_=08d); + + _=08t_=08y_=08p_=08e_=08d_=08e_=08f _=08v_=08o_=08i_=08d + (=08(h=08ha=08an=08nd=08dl=08le=08er=08r)=08)(_=08i_=08n_=08t); + + _=08t_=08y_=08p_=08e_=08d_=08e_=08f _=08v_=08o_=08i_=08d + (=08(*=08*f=08fp=08p)=08)(_=08i_=08n_=08t); + + _=08i_=08n_=08t + (=08(o=08op=08pe=08en=08n(_=08c_=08o_=08n_=08s_=08t _=08c_=08h_=08a_= =08r _=08*_=08p_=08a_=08t_=08h); + + _=08F_=08I_=08L_=08E _=08* + (=08(*=08*p=08po=08op=08pe=08en=08n(_=08c_=08o_=08n_=08s_=08t _=08c_= =08h_=08a_=08r _=08*_=08c_=08m_=08d); + + _=08v_=08o_=08i_=08d + (=08(t=08tr=08ra=08ai=08il=08l)=08)x=08x(_=08v_=08o_=08i_=08d); + + _=08v_=08o_=08i_=08d + *=08*s=08st=08ta=08ar=08r(_=08v_=08o_=08i_=08d); + +OpenBSD September 13, 2019 Ope= nBSD -- To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv