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

Commitb31f335

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 parent0db3c55 commitb31f335

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
};
@@ -140,33 +136,26 @@ main(int argc, char *const argv[])
140136

141137
find_my_exec(argv[0],my_exec_path);
142138

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp