[freetds] getopt compatibility
James K. Lowden
jklowden at freetds.org
Tue May 27 11:35:34 EDT 2008
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
> #if hpux
> optind = 1;
> #if HAVE_OPTRESET
> optreset = 1;
> optind = 0;
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:
so there's no need even to test HAVE_OPTRESET:
optreset = 1;
optind = 1;
which of course means we don't need the funciton at all. :-)
More information about the FreeTDS