Skip to content

Commit 0a7bde4

Browse files
committed
Use designated initializers for guc_tables
This makes the generating script simpler and the output easier to read. In the future, it will make it easier to reorder and rearrange the underlying C structures. Reviewed-by: Chao Li <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
1 parent 0d82163 commit 0a7bde4

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

src/backend/utils/misc/gen_guc_tables.pl

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,41 +57,32 @@ sub print_one_table
5757

5858
print $ofh "#ifdef $entry->{ifdef}\n" if $entry->{ifdef};
5959
print $ofh "\t{\n";
60-
printf $ofh "\t\t{%s, %s, %s,\n",
61-
dquote($entry->{name}),
62-
$entry->{context},
63-
$entry->{group};
64-
printf $ofh "\t\t\tgettext_noop(%s),\n", dquote($entry->{short_desc});
65-
if ($entry->{long_desc})
66-
{
67-
printf $ofh "\t\t\tgettext_noop(%s)", dquote($entry->{long_desc});
68-
}
69-
else
70-
{
71-
print $ofh "\t\t\tNULL";
72-
}
73-
if ($entry->{flags})
74-
{
75-
print $ofh ",\n\t\t\t$entry->{flags}\n";
76-
}
77-
else
78-
{
79-
print $ofh "\n";
80-
}
60+
print $ofh "\t\t{\n";
61+
printf $ofh "\t\t\t.name = %s,\n", dquote($entry->{name});
62+
printf $ofh "\t\t\t.context = %s,\n", $entry->{context};
63+
printf $ofh "\t\t\t.group = %s,\n", $entry->{group};
64+
printf $ofh "\t\t\t.short_desc = gettext_noop(%s),\n",
65+
dquote($entry->{short_desc});
66+
printf $ofh "\t\t\t.long_desc = gettext_noop(%s),\n",
67+
dquote($entry->{long_desc})
68+
if $entry->{long_desc};
69+
printf $ofh "\t\t\t.flags = %s,\n", $entry->{flags}
70+
if $entry->{flags};
8171
print $ofh "\t\t},\n";
82-
print $ofh "\t\t&$entry->{variable},\n";
83-
print $ofh "\t\t$entry->{boot_val},";
84-
print $ofh " $entry->{min},"
72+
printf $ofh "\t\t.variable = &%s,\n", $entry->{variable};
73+
printf $ofh "\t\t.boot_val = %s,\n", $entry->{boot_val};
74+
printf $ofh "\t\t.min = %s,\n", $entry->{min}
8575
if $entry->{type} eq 'int' || $entry->{type} eq 'real';
86-
print $ofh " $entry->{max},"
76+
printf $ofh "\t\t.max = %s,\n", $entry->{max}
8777
if $entry->{type} eq 'int' || $entry->{type} eq 'real';
88-
print $ofh " $entry->{options},"
78+
printf $ofh "\t\t.options = %s,\n", $entry->{options}
8979
if $entry->{type} eq 'enum';
90-
print $ofh "\n";
91-
printf $ofh "\t\t%s, %s, %s\n",
92-
($entry->{check_hook} || 'NULL'),
93-
($entry->{assign_hook} || 'NULL'),
94-
($entry->{show_hook} || 'NULL');
80+
printf $ofh "\t\t.check_hook = %s,\n", $entry->{check_hook}
81+
if $entry->{check_hook};
82+
printf $ofh "\t\t.assign_hook = %s,\n", $entry->{assign_hook}
83+
if $entry->{assign_hook};
84+
printf $ofh "\t\t.show_hook = %s,\n", $entry->{show_hook}
85+
if $entry->{show_hook};
9586
print $ofh "\t},\n";
9687
print $ofh "#endif\n" if $entry->{ifdef};
9788
print $ofh "\n";

0 commit comments

Comments
 (0)