Re: Detecting glibc getopt?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Detecting glibc getopt?
Date: 2001-10-20 16:33:22
Message-ID: 12747.1003595602@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-10-20 16:36:16 Re: Error while restoring database
Previous Message Ron de Jong 2001-10-20 16:31:49 Typhoon-Web-DataBase-Administrator-1.3.0 with PostgreSQL support released!!!