freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: christos AT zoulas.com (Christos Zoulas)
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] getopt compatibility
- Date: Tue, 27 May 2008 12:01:56 -0400
On May 27, 11:35am, jklowden AT freetds.org ("James K. Lowden") wrote:
-- Subject: Re: [freetds] getopt compatibility
| ZIGLIO, Frediano, VF-IT wrote:
| > Testing for HP-UX from code is not that
| > difficult and optreset variable can be tested quite easily in autoconf,
| > something like
| >
| > static int
| > reset_getopt(void)
| > {
| > #if hpux
| > optind = 1;
| > #else
| > #if HAVE_OPTRESET
| > optreset = 1;
| > #endif
| > optind = 0;
| > #endif
| > }
|
| www.gnu.org/software/libtool/manual/libc/Getopt.htm
|
| Actually, this is going to be much easier than you think.
|
| 1. tsql appears to be wrong: GNU says "The initial value of this variable
| is 1." Not zero.
| 2. NetBSD, HP/UX, and opengroup.org all say the same thing.
|
| I tested getopt(3) on a RHEL system; setting optind to 1 caused it to
| parse again from the beginning.
|
| 3. I think it's legal in C to declare
|
| extern int optreset;
|
| without ever having:
|
| int optreset;
|
| so there's no need even to test HAVE_OPTRESET:
|
| static int
| reset_getopt(void)
| {
| optreset = 1;
| optind = 1;
| }
|
| which of course means we don't need the funciton at all. :-)
Yes, it is, but then you get a link error unless you make it weak.
setting optind always to 1 is probably the best way. For the belt
and suspenders version, setting optreset if it exists is good too.
christos
-
[freetds] getopt compatibility,
ZIGLIO, Frediano, VF-IT, 05/26/2008
-
Re: [freetds] getopt compatibility,
James K. Lowden, 05/26/2008
-
Re: [freetds] getopt compatibility,
ZIGLIO, Frediano, VF-IT, 05/27/2008
-
Re: [freetds] getopt compatibility,
James K. Lowden, 05/27/2008
-
Re: [freetds] getopt compatibility,
ZIGLIO, Frediano, VF-IT, 05/27/2008
- Re: [freetds] getopt compatibility, ZIGLIO, Frediano, VF-IT, 05/27/2008
-
Re: [freetds] getopt compatibility,
James K. Lowden, 05/27/2008
- Re: [freetds] getopt compatibility, Christos Zoulas, 05/27/2008
-
Re: [freetds] getopt compatibility,
ZIGLIO, Frediano, VF-IT, 05/28/2008
- Re: [freetds] getopt compatibility, James K. Lowden, 05/28/2008
-
Re: [freetds] getopt compatibility,
ZIGLIO, Frediano, VF-IT, 05/27/2008
-
Re: [freetds] getopt compatibility,
James K. Lowden, 05/27/2008
-
Re: [freetds] getopt compatibility,
ZIGLIO, Frediano, VF-IT, 05/27/2008
-
Re: [freetds] getopt compatibility,
James K. Lowden, 05/26/2008
Archive powered by MHonArc 2.6.24.