Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf8b896

Browse files
committed
Order getopt arguments
Order the letters in the arguments of getopt() and getopt_long(), aswell as in the subsequent switch statements. In most cases, I usedalphabetical with lower case first. In a few cases, existingdifferent orders (e.g., upper case first) was kept to reduce the diffsize.Discussion:https://www.postgresql.org/message-id/flat/3efd0fe8-351b-f836-9122-886002602357%40enterprisedb.com
1 parent840ff5f commitdf8b896

File tree

19 files changed

+458
-464
lines changed

19 files changed

+458
-464
lines changed

‎src/backend/bootstrap/bootstrap.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,32 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
228228
case'B':
229229
SetConfigOption("shared_buffers",optarg,PGC_POSTMASTER,PGC_S_ARGV);
230230
break;
231+
case'c':
232+
case'-':
233+
{
234+
char*name,
235+
*value;
236+
237+
ParseLongOption(optarg,&name,&value);
238+
if (!value)
239+
{
240+
if (flag=='-')
241+
ereport(ERROR,
242+
(errcode(ERRCODE_SYNTAX_ERROR),
243+
errmsg("--%s requires a value",
244+
optarg)));
245+
else
246+
ereport(ERROR,
247+
(errcode(ERRCODE_SYNTAX_ERROR),
248+
errmsg("-c %s requires a value",
249+
optarg)));
250+
}
251+
252+
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
253+
pfree(name);
254+
pfree(value);
255+
break;
256+
}
231257
case'D':
232258
userDoption=pstrdup(optarg);
233259
break;
@@ -265,32 +291,6 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
265291
PGC_S_DYNAMIC_DEFAULT);
266292
}
267293
break;
268-
case'c':
269-
case'-':
270-
{
271-
char*name,
272-
*value;
273-
274-
ParseLongOption(optarg,&name,&value);
275-
if (!value)
276-
{
277-
if (flag=='-')
278-
ereport(ERROR,
279-
(errcode(ERRCODE_SYNTAX_ERROR),
280-
errmsg("--%s requires a value",
281-
optarg)));
282-
else
283-
ereport(ERROR,
284-
(errcode(ERRCODE_SYNTAX_ERROR),
285-
errmsg("-c %s requires a value",
286-
optarg)));
287-
}
288-
289-
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
290-
pfree(name);
291-
pfree(value);
292-
break;
293-
}
294294
default:
295295
write_stderr("Try \"%s --help\" for more information.\n",
296296
progname);

‎src/backend/postmaster/postmaster.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ PostmasterMain(int argc, char *argv[])
690690
* tcop/postgres.c (the option sets should not conflict) and with the
691691
* common help() function in main/main.c.
692692
*/
693-
while ((opt=getopt(argc,argv,"B:bc:C:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:"))!=-1)
693+
while ((opt=getopt(argc,argv,"B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:"))!=-1)
694694
{
695695
switch (opt)
696696
{
@@ -707,6 +707,33 @@ PostmasterMain(int argc, char *argv[])
707707
output_config_variable=strdup(optarg);
708708
break;
709709

710+
case'c':
711+
case'-':
712+
{
713+
char*name,
714+
*value;
715+
716+
ParseLongOption(optarg,&name,&value);
717+
if (!value)
718+
{
719+
if (opt=='-')
720+
ereport(ERROR,
721+
(errcode(ERRCODE_SYNTAX_ERROR),
722+
errmsg("--%s requires a value",
723+
optarg)));
724+
else
725+
ereport(ERROR,
726+
(errcode(ERRCODE_SYNTAX_ERROR),
727+
errmsg("-c %s requires a value",
728+
optarg)));
729+
}
730+
731+
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
732+
pfree(name);
733+
pfree(value);
734+
break;
735+
}
736+
710737
case'D':
711738
userDoption=strdup(optarg);
712739
break;
@@ -814,33 +841,6 @@ PostmasterMain(int argc, char *argv[])
814841
SetConfigOption("post_auth_delay",optarg,PGC_POSTMASTER,PGC_S_ARGV);
815842
break;
816843

817-
case'c':
818-
case'-':
819-
{
820-
char*name,
821-
*value;
822-
823-
ParseLongOption(optarg,&name,&value);
824-
if (!value)
825-
{
826-
if (opt=='-')
827-
ereport(ERROR,
828-
(errcode(ERRCODE_SYNTAX_ERROR),
829-
errmsg("--%s requires a value",
830-
optarg)));
831-
else
832-
ereport(ERROR,
833-
(errcode(ERRCODE_SYNTAX_ERROR),
834-
errmsg("-c %s requires a value",
835-
optarg)));
836-
}
837-
838-
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
839-
pfree(name);
840-
pfree(value);
841-
break;
842-
}
843-
844844
default:
845845
write_stderr("Try \"%s --help\" for more information.\n",
846846
progname);

‎src/backend/tcop/postgres.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,7 +3718,7 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
37183718
* postmaster/postmaster.c (the option sets should not conflict) and with
37193719
* the common help() function in main/main.c.
37203720
*/
3721-
while ((flag=getopt(argc,argv,"B:bc:C:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:"))!=-1)
3721+
while ((flag=getopt(argc,argv,"B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:"))!=-1)
37223722
{
37233723
switch (flag)
37243724
{
@@ -3736,6 +3736,32 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
37363736
/* ignored for consistency with the postmaster */
37373737
break;
37383738

3739+
case'c':
3740+
case'-':
3741+
{
3742+
char*name,
3743+
*value;
3744+
3745+
ParseLongOption(optarg,&name,&value);
3746+
if (!value)
3747+
{
3748+
if (flag=='-')
3749+
ereport(ERROR,
3750+
(errcode(ERRCODE_SYNTAX_ERROR),
3751+
errmsg("--%s requires a value",
3752+
optarg)));
3753+
else
3754+
ereport(ERROR,
3755+
(errcode(ERRCODE_SYNTAX_ERROR),
3756+
errmsg("-c %s requires a value",
3757+
optarg)));
3758+
}
3759+
SetConfigOption(name,value,ctx,gucsource);
3760+
pfree(name);
3761+
pfree(value);
3762+
break;
3763+
}
3764+
37393765
case'D':
37403766
if (secure)
37413767
userDoption=strdup(optarg);
@@ -3850,32 +3876,6 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
38503876
SetConfigOption("post_auth_delay",optarg,ctx,gucsource);
38513877
break;
38523878

3853-
case'c':
3854-
case'-':
3855-
{
3856-
char*name,
3857-
*value;
3858-
3859-
ParseLongOption(optarg,&name,&value);
3860-
if (!value)
3861-
{
3862-
if (flag=='-')
3863-
ereport(ERROR,
3864-
(errcode(ERRCODE_SYNTAX_ERROR),
3865-
errmsg("--%s requires a value",
3866-
optarg)));
3867-
else
3868-
ereport(ERROR,
3869-
(errcode(ERRCODE_SYNTAX_ERROR),
3870-
errmsg("-c %s requires a value",
3871-
optarg)));
3872-
}
3873-
SetConfigOption(name,value,ctx,gucsource);
3874-
pfree(name);
3875-
pfree(value);
3876-
break;
3877-
}
3878-
38793879
default:
38803880
errs++;
38813881
break;

‎src/bin/pg_amcheck/pg_amcheck.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ main(int argc, char *argv[])
291291
handle_help_version_opts(argc,argv,progname,help);
292292

293293
/* process command-line options */
294-
while ((c=getopt_long(argc,argv,"ad:D:eh:Hi:I:j:p:Pr:R:s:S:t:T:U:wWv",
294+
while ((c=getopt_long(argc,argv,"ad:D:eh:Hi:I:j:p:Pr:R:s:S:t:T:U:vwW",
295295
long_options,&optindex))!=-1)
296296
{
297297
char*endptr;
@@ -363,16 +363,16 @@ main(int argc, char *argv[])
363363
case'U':
364364
username=pg_strdup(optarg);
365365
break;
366+
case'v':
367+
opts.verbose= true;
368+
pg_logging_increase_verbosity();
369+
break;
366370
case'w':
367371
prompt_password=TRI_NO;
368372
break;
369373
case'W':
370374
prompt_password=TRI_YES;
371375
break;
372-
case'v':
373-
opts.verbose= true;
374-
pg_logging_increase_verbosity();
375-
break;
376376
case1:
377377
maintenance_db=pg_strdup(optarg);
378378
break;

‎src/bin/pg_archivecleanup/pg_archivecleanup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ main(int argc, char **argv)
294294
}
295295
}
296296

297-
while ((c=getopt(argc,argv,"x:dn"))!=-1)
297+
while ((c=getopt(argc,argv,"dnx:"))!=-1)
298298
{
299299
switch (c)
300300
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp