Module Name:    src
Committed By:   rillig
Date:           Fri Jun  9 09:49:07 UTC 2023

Modified Files:
        src/tests/usr.bin/indent: fmt_decl.c
        src/usr.bin/indent: lexi.c

Log Message:
indent: improve heuristics for function declaration vs. definition


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.218 -r1.219 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.51 src/tests/usr.bin/indent/fmt_decl.c:1.52
--- src/tests/usr.bin/indent/fmt_decl.c:1.51	Fri Jun  9 09:45:55 2023
+++ src/tests/usr.bin/indent/fmt_decl.c	Fri Jun  9 09:49:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.51 2023/06/09 09:45:55 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.52 2023/06/09 09:49:07 rillig Exp $	*/
 
 /*
  * Tests for declarations of global variables, external functions, and local
@@ -1026,10 +1026,9 @@ typedef struct {
 //indent end
 
 //indent run -fbs -di0 -psl
-// $ FIXME: Must be detected as a function declaration, not a definition.
-static FILE *
-ArchFindMember(const char *, const char *,
-	       struct ar_hdr *, const char *);
+// $ Must be detected as a function declaration, not a definition.
+static FILE *ArchFindMember(const char *, const char *,
+			    struct ar_hdr *, const char *);
 
 bool
 Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...))

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.218 src/usr.bin/indent/lexi.c:1.219
--- src/usr.bin/indent/lexi.c:1.218	Fri Jun  9 07:20:30 2023
+++ src/usr.bin/indent/lexi.c	Fri Jun  9 09:49:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.219 2023/06/09 09:49:07 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.219 2023/06/09 09:49:07 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -338,6 +338,9 @@ probably_looking_at_definition(void)
 			else
 				break;	/* func(...) { ... */
 		}
+
+		if (paren_level == 1 && p[0] == '*' && p[1] == ',')
+			return false;
 	}
 
 	/* To further reduce the cases where indent wrongly treats an

Reply via email to