Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 92d4294

Browse files
committed
psql: Fix some strange code in SQL help creation
Struct QL_HELP used to be defined as static in the sql_help.h header file, which is included in sql_help.c and help.c, thus creating two separate instances of the struct. This causes a warning from GCC 6, because the struct is not used in sql_help.c. Instead, declare the struct as extern in the header file and define it in sql_help.c. This also allows making a bunch of functions static because they are no longer needed outside of sql_help.c. Reviewed-by: Thomas Munro <thomas.munro@enterprisedb.com>
1 parent 0d0644d commit 92d4294

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/bin/psql/create_help.pl

+10-10
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
#ifndef $define
6060
#define $define
6161
62-
#define N_(x) (x) /* gettext noop */
63-
6462
#include \"postgres_fe.h\"
6563
#include \"pqexpbuffer.h\"
6664
@@ -72,6 +70,7 @@
7270
int nl_count; /* number of newlines in syntax (for pager) */
7371
};
7472
73+
extern const struct _helpStruct QL_HELP[];
7574
";
7675

7776
print CFILE "/*
@@ -83,6 +82,8 @@
8382
*
8483
*/
8584
85+
#define N_(x) (x) /* gettext noop */
86+
8687
#include \"$hfile\"
8788
8889
";
@@ -170,8 +171,7 @@
170171
$synopsis =~ s/\\n/\\n"\n$prefix"/g;
171172
my @args =
172173
("buf", $synopsis, map("_(\"$_\")", @{ $entries{$_}{params} }));
173-
print HFILE "extern void sql_help_$id(PQExpBuffer buf);\n";
174-
print CFILE "void
174+
print CFILE "static void
175175
sql_help_$id(PQExpBuffer buf)
176176
{
177177
\tappendPQExpBuffer(" . join(",\n$prefix", @args) . ");
@@ -180,27 +180,27 @@
180180
";
181181
}
182182

183-
print HFILE "
184-
185-
static const struct _helpStruct QL_HELP[] = {
183+
print CFILE "
184+
const struct _helpStruct QL_HELP[] = {
186185
";
187186
foreach (sort keys %entries)
188187
{
189188
my $id = $_;
190189
$id =~ s/ /_/g;
191-
print HFILE " { \"$_\",
190+
print CFILE " { \"$_\",
192191
N_(\"$entries{$_}{cmddesc}\"),
193192
sql_help_$id,
194193
$entries{$_}{nl_count} },
195194
196195
";
197196
}
198197

199-
print HFILE "
198+
print CFILE "
200199
{ NULL, NULL, NULL } /* End of list marker */
201200
};
201+
";
202202

203-
203+
print HFILE "
204204
#define QL_HELP_COUNT "
205205
. scalar(keys %entries) . " /* number of help items */
206206
#define QL_MAX_CMD_LEN $maxlen /* largest strlen(cmd) */

0 commit comments

Comments
 (0)