Thread: ecpg -? option doesn't work in windows

ecpg -? option doesn't work in windows

From
Haribabu Kommi
Date:
ecpg option --help alternative -? doesn't work in windows.
In windows, the PG provided getopt_long function is used
for reading the provided options.

The getopt_long function returns '?' for invalid characters
also but it sets optopt option to 0 in case if the character
itself is a '?'. But this works for Linux and others, whereas
for windows, optopt is not 0. Because of this reason it is
failing.

I feel, from this commit 5b88b85c on wards, it is not working.
I feel instead of fixing the getopt_long function to reset optopt
parameter to zero whenever it is returning '?', I prefer fixing
the ecpg in handling the version and help options seperate.

Patch is attached. Any one prefers the getopt_long function
fix, I can produce the patch for the same.

Regards,
Hari Babu
Fujitsu Australia

Attachment

Re: ecpg -? option doesn't work in windows

From
Heikki Linnakangas
Date:
On 08/29/2016 09:10 AM, Haribabu Kommi wrote:
> ecpg option --help alternative -? doesn't work in windows.
> In windows, the PG provided getopt_long function is used
> for reading the provided options.
>
> The getopt_long function returns '?' for invalid characters
> also but it sets optopt option to 0 in case if the character
> itself is a '?'. But this works for Linux and others, whereas
> for windows, optopt is not 0. Because of this reason it is
> failing.
>
> I feel, from this commit 5b88b85c on wards, it is not working.
> I feel instead of fixing the getopt_long function to reset optopt
> parameter to zero whenever it is returning '?', I prefer fixing
> the ecpg in handling the version and help options seperate.

Agreed. This does have one annoying consequence, though: --help and 
--version are now only accepted as the first argument. But that's 
consistent with most of our binaries. psql does this slightly 
differently, though, so e.g. "psql --t --help" works. It might be worth 
changing all our binaries to follow psql's example, but that's another 
story.

> Patch is attached. Any one prefers the getopt_long function
> fix, I can produce the patch for the same.

Committed, thanks!

- Heikki