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

Commit3fcc98c

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 parentd8c61c9 commit3fcc98c

File tree

1 file changed

+17
-28
lines changed
  • src/interfaces/ecpg/preproc

1 file changed

+17
-28
lines changed

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

Lines changed: 17 additions & 28 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,32 +140,25 @@ 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 %s\n",PG_VERSION);
153+
exit(0);
154+
}
155+
}
156+
147157
output_filename=NULL;
148-
while ((c=getopt_long(argc,argv,"vcio:I:tD:dC:r:h?",ecpg_options,NULL))!=-1)
158+
while ((c=getopt_long(argc,argv,"vcio:I:tD:dC:r:h",ecpg_options,NULL))!=-1)
149159
{
150160
switch (c)
151161
{
152-
caseECPG_GETOPT_LONG_VERSION:
153-
printf("ecpg %s\n",PG_VERSION);
154-
exit(0);
155-
caseECPG_GETOPT_LONG_HELP:
156-
help(progname);
157-
exit(0);
158-
159-
/*
160-
* -? is an alternative spelling of --help. However it is also
161-
* returned by getopt_long for unknown options. We can
162-
* distinguish both cases by means of the optopt variable
163-
* which is set to 0 if it was really -? and not an unknown
164-
* option character.
165-
*/
166-
case'?':
167-
if (optopt==0)
168-
{
169-
help(progname);
170-
exit(0);
171-
}
172-
break;
173162
caseECPG_GETOPT_LONG_REGRESSION:
174163
regression_mode= true;
175164
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp