Skip to Content.
Sympa Menu

freetds - Re: [freetds] getopt compatibility

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] getopt compatibility
  • Date: Tue, 27 May 2008 10:15:10 -0400

ZIGLIO, Frediano, VF-IT wrote:
> >
> > ZIGLIO, Frediano, VF-IT wrote:
> > > In tsql
> > > getopt is restarted to read options. It's currently
> > > restarted using GNU getopt way, that is setting optind with 0.
> >
> > Looking at the code, I think the most portable choice -- and
> > probably the
> > least work -- is to refactor tsql.c: call getopt(3) in only
> > one place, and
> > don't reset optind/optreset.
>
> ehm.... that is only for main argc/argv ??

So ... are you suggesting I should read the code before offering advice?
Don't you understand how much harder that is?

OK, I see: the "go flags".

www.opengroup.org/onlinepubs/ 000095399/functions/getopt.html

There is no standard for resetting getopt.

Do what you think is easiest or most interesting. I don't see the need --
unless you want to -- to develop an autoconf test for this. (A quick
search didn't turn up anything, and "getopt" doesn't appear in the
autoconf info file. It seems it's a void that needs filling.)

The quickest and least kludgy answer is probably to write a function:

static int reset_getopt();

that does what you want, complete with all the #ifs you need. :-/

At least it won't be very big!

>>> try to detect HP-UX and reset optind with 1?

ISTR we already test HP/UX symbols somewhere?

> > I think refactoring is best because otherwise you need an
> > autoconf test ...
> > with a bunch of #define macros. It would look like
> > src/tds/net.c. :-(
>
> I know.. net.c is ugly but it does a lot of system optimizations and all
> contained in a single file... all others use mainly plain C and some
> allocation/deallocation function...

Yeah, a dancing bear: not graceful, but impressive that it does what it
does.

Regards,

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page