source@mandoc.bsd.lv
 help / color / Atom feed
* mandoc: Improve validation of function names: 1.
@ 2019-09-13 19:26 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2019-09-13 19:26 UTC (permalink / raw)
  To: source

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 source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 19:26 mandoc: Improve validation of function names: 1 schwarze

source@mandoc.bsd.lv

Archives are clonable: git clone --mirror http://inbox.vuxu.org/mandoc-source

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.mandoc.source


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git