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

Commite06728d

Browse files
committed
Fix ecpg -? option on Windows, add -V alias for --version.
This makes the -? and -V options work consistently with other binaries.--help and --version are now only recognized as the first option, i.e."ecpg --foobar --help" no longer prints the help, but that's consistentwith most of our other binaries, too.Backpatch to all supported versions.Haribabu KommiDiscussion: <CAJrrPGfnRXvmCzxq6Dy=stAWebfNHxiL+Y_z7uqksZUCkW_waQ@mail.gmail.com>
1 parent9895818 commite06728d

File tree

1 file changed

+18
-29
lines changed
  • src/interfaces/ecpg/preproc

1 file changed

+18
-29
lines changed

‎src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ help(const char *progname)
5454
" \"no_indicator\", \"prepare\", \"questionmarks\"\n"));
5555
printf(_(" --regression run in regression testing mode\n"));
5656
printf(_(" -t turn on autocommit of transactions\n"));
57-
printf(_(" --version output version information, then exit\n"));
57+
printf(_(" -V, --version output version information, then exit\n"));
5858
printf(_(" -?, --help show this help, then exit\n"));
5959
printf(_("\nIf no output file is specified, the name is formed by adding .c to the\n"
6060
"input file name, after stripping off .pgc if present.\n"));
@@ -111,15 +111,11 @@ add_preprocessor_define(char *define)
111111
defines->next=pd;
112112
}
113113

114-
#defineECPG_GETOPT_LONG_HELP1
115-
#defineECPG_GETOPT_LONG_VERSION2
116-
#defineECPG_GETOPT_LONG_REGRESSION3
114+
#defineECPG_GETOPT_LONG_REGRESSION1
117115
int
118116
main(intargc,char*constargv[])
119117
{
120118
staticstructoptionecpg_options[]= {
121-
{"help",no_argument,NULL,ECPG_GETOPT_LONG_HELP},
122-
{"version",no_argument,NULL,ECPG_GETOPT_LONG_VERSION},
123119
{"regression",no_argument,NULL,ECPG_GETOPT_LONG_REGRESSION},
124120
{NULL,0,NULL,0}
125121
};
@@ -144,33 +140,26 @@ main(int argc, char *const argv[])
144140
return (ILLEGAL_OPTION);
145141
}
146142

143+
if (argc>1)
144+
{
145+
if (strcmp(argv[1],"--help")==0||strcmp(argv[1],"-?")==0)
146+
{
147+
help(progname);
148+
exit(0);
149+
}
150+
if (strcmp(argv[1],"--version")==0||strcmp(argv[1],"-V")==0)
151+
{
152+
printf("ecpg (PostgreSQL %s) %d.%d.%d\n",PG_VERSION,
153+
MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL);
154+
exit(0);
155+
}
156+
}
157+
147158
output_filename=NULL;
148-
while ((c=getopt_long(argc,argv,"vcio:I:tD:dC:r:h?",ecpg_options,NULL))!=-1)
159+
while ((c=getopt_long(argc,argv,"vcio:I:tD:dC:r:h",ecpg_options,NULL))!=-1)
149160
{
150161
switch (c)
151162
{
152-
caseECPG_GETOPT_LONG_VERSION:
153-
printf("ecpg (PostgreSQL %s) %d.%d.%d\n",PG_VERSION,
154-
MAJOR_VERSION,MINOR_VERSION,PATCHLEVEL);
155-
exit(0);
156-
caseECPG_GETOPT_LONG_HELP:
157-
help(progname);
158-
exit(0);
159-
160-
/*
161-
* -? is an alternative spelling of --help. However it is also
162-
* returned by getopt_long for unknown options. We can
163-
* distinguish both cases by means of the optopt variable
164-
* which is set to 0 if it was really -? and not an unknown
165-
* option character.
166-
*/
167-
case'?':
168-
if (optopt==0)
169-
{
170-
help(progname);
171-
exit(0);
172-
}
173-
break;
174163
caseECPG_GETOPT_LONG_REGRESSION:
175164
regression_mode= true;
176165
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp