discuss@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: Ingo Schwarze <schwarze@usta.de>
To: Yuri Pankov <yuripv@yuripv.net>
Cc: discuss@mandoc.bsd.lv
Subject: Re: "WARNING: parenthesis in function name" correctness
Date: Fri, 13 Sep 2019 21:31:09 +0200	[thread overview]
Message-ID: <20190913193109.GA81601@athene.usta.de> (raw)
In-Reply-To: <a80abcfc-e8bd-e7ee-060c-eb4ba6d53caf@yuripv.net>

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 <yuripv dot net>).
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
===================================================================
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;
 
 	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
Index: warn.in
===================================================================
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
===================================================================
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_markdown -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*  
 **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 \*&zwnj;*  
+**(\*popen**(*const char \*cmd*);
+
+*void*  
+**(trail)x**(*void*);
+
+*void*  
+**\*star**(*void*);
+
+OpenBSD - September 13, 2019
Index: warn.out_lint
===================================================================
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, 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
Index: warn.out_ascii
===================================================================
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\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
      _\bd_\bo_\bu_\bb_\bl_\be
      a\bat\bta\ban\bn2\b2(_\bd_\bo_\bu_\bb_\bl_\be _\by_\b, _\bd_\bo_\bu_\bb_\bl_\be _\bx);
 
-OpenBSD                          July 4, 2017                          OpenBSD
+     _\bi_\bn_\bt
+     c\bcl\blo\bos\bse\be)\b)(_\bi_\bn_\bt _\bf_\bd);
+
+     _\bt_\by_\bp_\be_\bd_\be_\bf _\bv_\bo_\bi_\bd
+     (\b(h\bha\ban\bnd\bdl\ble\ber\br)\b)(_\bi_\bn_\bt);
+
+     _\bt_\by_\bp_\be_\bd_\be_\bf _\bv_\bo_\bi_\bd
+     (\b(*\b*f\bfp\bp)\b)(_\bi_\bn_\bt);
+
+     _\bi_\bn_\bt
+     (\b(o\bop\bpe\ben\bn(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bp_\ba_\bt_\bh);
+
+     _\bF_\bI_\bL_\bE _\b*
+     (\b(*\b*p\bpo\bop\bpe\ben\bn(_\bc_\bo_\bn_\bs_\bt _\bc_\bh_\ba_\br _\b*_\bc_\bm_\bd);
+
+     _\bv_\bo_\bi_\bd
+     (\b(t\btr\bra\bai\bil\bl)\b)x\bx(_\bv_\bo_\bi_\bd);
+
+     _\bv_\bo_\bi_\bd
+     *\b*s\bst\bta\bar\br(_\bv_\bo_\bi_\bd);
+
+OpenBSD                       September 13, 2019                       OpenBSD
--
 To unsubscribe send an email to discuss+unsubscribe@mandoc.bsd.lv

      reply	other threads:[~2019-09-13 19:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10  8:20 Yuri Pankov
2019-09-10 17:47 ` Ingo Schwarze
2019-09-10 22:43   ` Yuri Pankov
2019-09-13 19:31     ` Ingo Schwarze [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190913193109.GA81601@athene.usta.de \
    --to=schwarze@usta.de \
    --cc=discuss@mandoc.bsd.lv \
    --cc=yuripv@yuripv.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).