From add105840b673ab3949abc2568da0d4f2fd496c5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 16 Sep 2020 20:31:19 -0400 Subject: [PATCH] Improve formatting of create_help.pl and plperl_opmask.pl output. Adjust the whitespace in the emitted files so that it matches what pgindent would do. This makes the generated files look like they match project style, and avoids confusion if someone does run pgindent on the generated files. Also, add probes.h to pgindent's exclusion list, because it can confuse pgindent, plus there's not much point in processing it. Daniel Gustafsson, additional fixes by me Discussion: https://postgr.es/m/79ed5348-be7a-b647-dd40-742207186a22@2ndquadrant.com --- src/bin/psql/create_help.pl | 25 ++++++++++++------------ src/pl/plperl/plperl_opmask.pl | 2 +- src/tools/pgindent/README | 8 ++++++++ src/tools/pgindent/exclude_file_patterns | 1 + 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl index ee82e64583..60e093bad4 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[]; @@ -190,17 +191,17 @@ foreach (sort keys %entries) { my $id = $_; $id =~ s/ /_/g; - print $cfile_handle " { \"$_\", - N_(\"$entries{$_}{cmddesc}\"), - \"$entries{$_}{cmdid}\", - sql_help_$id, - $entries{$_}{nl_count} }, + print $cfile_handle "\t{\"$_\", +\t\tN_(\"$entries{$_}{cmddesc}\"), +\t\t\"$entries{$_}{cmdid}\", +\t\tsql_help_$id, +\t$entries{$_}{nl_count}}, "; } print $cfile_handle " - { NULL, NULL, NULL } /* End of list marker */ +\t{NULL, NULL, NULL}\t\t\t/* End of list marker */ }; "; @@ -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..9b16b0ed50 100644 --- a/src/tools/pgindent/README +++ b/src/tools/pgindent/README @@ -157,6 +157,14 @@ 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/include/jit/llvmjit.h is excluded because it contains C++ constructs +that confuse pgindent. + +src/backend/utils/probes.h and its alias src/include/utils/probes.h +are excluded because that file is machine-generated by code not under +our control, and some versions of dtrace build files that confuse +pgindent. + 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/