diff options
author | Peter Eisentraut | 2022-12-12 13:33:41 +0000 |
---|---|---|
committer | Peter Eisentraut | 2022-12-12 14:20:00 +0000 |
commit | df8b8968d4095f44acd6de03b4add65f9709b79d (patch) | |
tree | 249063ed382f2d9fc913729de73bac3d915afcab /src/backend | |
parent | 840ff5f451cd9a391d237fc60894fea7ad82a189 (diff) |
Order getopt arguments
Order the letters in the arguments of getopt() and getopt_long(), as
well as in the subsequent switch statements. In most cases, I used
alphabetical with lower case first. In a few cases, existing
different orders (e.g., upper case first) was kept to reduce the diff
size.
Discussion: https://www.postgresql.org/message-id/flat/3efd0fe8-351b-f836-9122-886002602357%40enterprisedb.com
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/bootstrap/bootstrap.c | 52 | ||||
-rw-r--r-- | src/backend/postmaster/postmaster.c | 56 | ||||
-rw-r--r-- | src/backend/tcop/postgres.c | 54 |
3 files changed, 81 insertions, 81 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 661ebacb0c2..d623ad9d50d 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -228,6 +228,32 @@ BootstrapModeMain(int argc, char *argv[], bool check_only) case 'B': SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV); break; + case 'c': + case '-': + { + char *name, + *value; + + ParseLongOption(optarg, &name, &value); + if (!value) + { + if (flag == '-') + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("--%s requires a value", + optarg))); + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("-c %s requires a value", + optarg))); + } + + SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV); + pfree(name); + pfree(value); + break; + } case 'D': userDoption = pstrdup(optarg); break; @@ -265,32 +291,6 @@ BootstrapModeMain(int argc, char *argv[], bool check_only) PGC_S_DYNAMIC_DEFAULT); } break; - case 'c': - case '-': - { - char *name, - *value; - - ParseLongOption(optarg, &name, &value); - if (!value) - { - if (flag == '-') - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("--%s requires a value", - optarg))); - else - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("-c %s requires a value", - optarg))); - } - - SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV); - pfree(name); - pfree(value); - break; - } default: write_stderr("Try \"%s --help\" for more information.\n", progname); diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index a8a246921f2..f459dab3609 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -690,7 +690,7 @@ PostmasterMain(int argc, char *argv[]) * tcop/postgres.c (the option sets should not conflict) and with the * common help() function in main/main.c. */ - while ((opt = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:")) != -1) + while ((opt = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:")) != -1) { switch (opt) { @@ -707,6 +707,33 @@ PostmasterMain(int argc, char *argv[]) output_config_variable = strdup(optarg); break; + case 'c': + case '-': + { + char *name, + *value; + + ParseLongOption(optarg, &name, &value); + if (!value) + { + if (opt == '-') + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("--%s requires a value", + optarg))); + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("-c %s requires a value", + optarg))); + } + + SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV); + pfree(name); + pfree(value); + break; + } + case 'D': userDoption = strdup(optarg); break; @@ -814,33 +841,6 @@ PostmasterMain(int argc, char *argv[]) SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV); break; - case 'c': - case '-': - { - char *name, - *value; - - ParseLongOption(optarg, &name, &value); - if (!value) - { - if (opt == '-') - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("--%s requires a value", - optarg))); - else - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("-c %s requires a value", - optarg))); - } - - SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV); - pfree(name); - pfree(value); - break; - } - default: write_stderr("Try \"%s --help\" for more information.\n", progname); diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 3082093d1ea..f8808d2191f 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3718,7 +3718,7 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx, * postmaster/postmaster.c (the option sets should not conflict) and with * the common help() function in main/main.c. */ - while ((flag = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1) + while ((flag = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1) { switch (flag) { @@ -3736,6 +3736,32 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx, /* ignored for consistency with the postmaster */ break; + case 'c': + case '-': + { + char *name, + *value; + + ParseLongOption(optarg, &name, &value); + if (!value) + { + if (flag == '-') + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("--%s requires a value", + optarg))); + else + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("-c %s requires a value", + optarg))); + } + SetConfigOption(name, value, ctx, gucsource); + pfree(name); + pfree(value); + break; + } + case 'D': if (secure) userDoption = strdup(optarg); @@ -3850,32 +3876,6 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx, SetConfigOption("post_auth_delay", optarg, ctx, gucsource); break; - case 'c': - case '-': - { - char *name, - *value; - - ParseLongOption(optarg, &name, &value); - if (!value) - { - if (flag == '-') - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("--%s requires a value", - optarg))); - else - ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("-c %s requires a value", - optarg))); - } - SetConfigOption(name, value, ctx, gucsource); - pfree(name); - pfree(value); - break; - } - default: errs++; break; |