From 251f9c67304f785d4577648b1e7b14c66e3b64ba Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <daniel@yesql.se>
Date: Tue, 15 Sep 2020 16:28:49 +0200
Subject: [PATCH] Ensure that generated headers follow pgindent rules

Headers which are generated by tools inside the repository should
follow pgindent rules to avoid surprises. Also make sure to exclude
probes.h which can be generated by an external tool.

Discussion: https://postgr.es/m/79ed5348-be7a-b647-dd40-742207186a22@2ndquadrant.com
---
 src/bin/psql/create_help.pl              | 13 +++++++------
 src/pl/plperl/plperl_opmask.pl           |  2 +-
 src/tools/pgindent/README                |  3 +++
 src/tools/pgindent/exclude_file_patterns |  1 +
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl
index ee82e64583..8b9266f22e 100644
--- a/src/bin/psql/create_help.pl
+++ b/src/bin/psql/create_help.pl
@@ -63,11 +63,12 @@ print $hfile_handle "/*
 
 struct _helpStruct
 {
-	const char	   *cmd;		/* the command name */
-	const char	   *help;		/* the help associated with it */
-	const char	   *docbook_id;	/* DocBook XML id (for generating URL) */
-	void (*syntaxfunc)(PQExpBuffer);	/* function that prints the syntax associated with it */
-	int				nl_count;	/* number of newlines in syntax (for pager) */
+	const char *cmd;			/* the command name */
+	const char *help;			/* the help associated with it */
+	const char *docbook_id;		/* DocBook XML id (for generating URL) */
+	void		(*syntaxfunc) (PQExpBuffer);	/* function that prints the
+												 * syntax associated with it */
+	int			nl_count;		/* number of newlines in syntax (for pager) */
 };
 
 extern const struct _helpStruct QL_HELP[];
@@ -210,7 +211,7 @@ print $hfile_handle "
 #define QL_MAX_CMD_LEN	$maxlen		/* largest strlen(cmd) */
 
 
-#endif /* $define */
+#endif							/* $define */
 ";
 
 close $cfile_handle;
diff --git a/src/pl/plperl/plperl_opmask.pl b/src/pl/plperl/plperl_opmask.pl
index 3b33112ff9..ee18e91528 100644
--- a/src/pl/plperl/plperl_opmask.pl
+++ b/src/pl/plperl/plperl_opmask.pl
@@ -52,7 +52,7 @@ foreach my $opname (opset_to_ops(opset(@allowed_ops)))
 	printf $fh qq{  opmask[OP_%-12s] = 0;\t/* %s */ \\\n},
 	  uc($opname), opdesc($opname);
 }
-printf $fh "  /* end */ \n";
+printf $fh "								/* end */\n";
 
 close $fh
   or die "Error closing $plperl_opmask_tmp: $!";
diff --git a/src/tools/pgindent/README b/src/tools/pgindent/README
index 8eb15fafb9..e35091aa54 100644
--- a/src/tools/pgindent/README
+++ b/src/tools/pgindent/README
@@ -157,6 +157,9 @@ are excluded because those files are imported from an external project,
 not maintained locally, and are machine-generated anyway.  Likewise for
 plperl/ppport.h.
 
+src/backend/utils/probes.h and src/include/utils/probes.h are excluded
+because those files are machine-generated.
+
 
 The perltidy run processes all *.pl and *.pm files, plus a few
 executable Perl scripts that are not named that way.  See the "find"
diff --git a/src/tools/pgindent/exclude_file_patterns b/src/tools/pgindent/exclude_file_patterns
index c8efc9a913..a8f1a92f4b 100644
--- a/src/tools/pgindent/exclude_file_patterns
+++ b/src/tools/pgindent/exclude_file_patterns
@@ -6,5 +6,6 @@
 /snowball/libstemmer/
 /pl/plperl/ppport\.h$
 /jit/llvmjit\.h$
+/utils/probes\.h$
 /tmp_check/
 /tmp_install/
-- 
2.21.1 (Apple Git-122.3)

