Skip to Content.
Sympa Menu

freetds - Re: [freetds] getopt compatibility

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] getopt compatibility
  • Date: Tue, 27 May 2008 15:37:32 +0200

>
> 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. However under
> *BSD there is a
> > optreset to reset status. However I mainly got problems with HP-UX
> > getopt... as you can read from
> > http://docs.hp.com/en/B2355-60105/getopt.3C.html getopt get
> reset with 1
> > as optind. ... From HP-UX manual it seems also that behavior
> > of this getopt implementation is quite different as from my
> > understanding it stops reading parameters at the first
> no-options one...
> > How to fix this problem??
>
> Hi Freddy,
>
> 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 ??

> (Curiously, I use tsql on NetBSD and have never noticed any problem.
> Maybe that's because of the sequence I usually put the options in.)
>

it can be... I don't want to debug even *BSD code...

> I think refactoring is best because otherwise you need an
> autoconf test
> for behavior (testing for HP/UX isn't the Right Thing) and a
> tds_getopt
> 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...

> Besides, the code will be easier to understand when all the
> options are
> parsed in one place.
>

bye
freddy77




Archive powered by MHonArc 2.6.24.

Top of Page