Re: Detecting glibc getopt? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Detecting glibc getopt?
Date
Msg-id 12747.1003595602@sss.pgh.pa.us
Whole thread Raw
In response to Re: Detecting glibc getopt?  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> How about copying the entire argv[] array to a new location before the
> very first call to getopt().  Then you can use getopt() without hackery
> and can do anything you want to the "real" argv area.  That should be a
> lot safer.  (We don't know yet what other platforms might play
> optimization tricks in getopt().)

Well, mumble --- strictly speaking, there is *NO* way to use getopt
over multiple cycles "without hackery".  The standard for getopt
(http://www.opengroup.org/onlinepubs/7908799/xsh/getopt.html)
doesn't say you're allowed to scribble on optind in the first place.
But you're probably right that having a read-only copy of the argv
vector will make things safer.  Will do it that way.
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Serguei Mokhov"
Date:
Subject: Re: namespaces
Next
From: Bill Studenmund
Date:
Subject: Re: Package support for Postgres