1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

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
This commit is contained in:
Peter Eisentraut
2022-12-12 14:33:41 +01:00
parent 840ff5f451
commit df8b8968d4
19 changed files with 473 additions and 479 deletions

View File

@ -157,48 +157,13 @@ main(int argc, char *const argv[])
}
output_filename = NULL;
while ((c = getopt_long(argc, argv, "vcio:I:tD:dC:r:h", ecpg_options, NULL)) != -1)
while ((c = getopt_long(argc, argv, "cC:dD:hiI:o:r:tv", ecpg_options, NULL)) != -1)
{
switch (c)
{
case ECPG_GETOPT_LONG_REGRESSION:
regression_mode = true;
break;
case 'o':
output_filename = mm_strdup(optarg);
if (strcmp(output_filename, "-") == 0)
base_yyout = stdout;
else
base_yyout = fopen(output_filename, PG_BINARY_W);
if (base_yyout == NULL)
{
fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
progname, output_filename, strerror(errno));
output_filename = NULL;
}
else
out_option = 1;
break;
case 'I':
add_include_path(optarg);
break;
case 't':
autocommit = true;
break;
case 'v':
verbose = true;
break;
case 'h':
header_mode = true;
/* this must include "-c" to make sense, so fall through */
/* FALLTHROUGH */
case 'c':
auto_create_c = true;
break;
case 'i':
system_includes = true;
break;
case 'C':
if (pg_strcasecmp(optarg, "INFORMIX") == 0 || pg_strcasecmp(optarg, "INFORMIX_SE") == 0)
{
@ -220,6 +185,44 @@ main(int argc, char *const argv[])
return ILLEGAL_OPTION;
}
break;
case 'd':
#ifdef YYDEBUG
base_yydebug = 1;
#else
fprintf(stderr, _("%s: parser debug support (-d) not available\n"),
progname);
#endif
break;
case 'D':
add_preprocessor_define(optarg);
break;
case 'h':
header_mode = true;
/* this must include "-c" to make sense: */
auto_create_c = true;
break;
case 'i':
system_includes = true;
break;
case 'I':
add_include_path(optarg);
break;
case 'o':
output_filename = mm_strdup(optarg);
if (strcmp(output_filename, "-") == 0)
base_yyout = stdout;
else
base_yyout = fopen(output_filename, PG_BINARY_W);
if (base_yyout == NULL)
{
fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
progname, output_filename, strerror(errno));
output_filename = NULL;
}
else
out_option = 1;
break;
case 'r':
if (pg_strcasecmp(optarg, "no_indicator") == 0)
force_indicator = false;
@ -233,16 +236,14 @@ main(int argc, char *const argv[])
return ILLEGAL_OPTION;
}
break;
case 'D':
add_preprocessor_define(optarg);
case 't':
autocommit = true;
break;
case 'd':
#ifdef YYDEBUG
base_yydebug = 1;
#else
fprintf(stderr, _("%s: parser debug support (-d) not available\n"),
progname);
#endif
case 'v':
verbose = true;
break;
case ECPG_GETOPT_LONG_REGRESSION:
regression_mode = true;
break;
default:
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);