Re: getopt compatibility

"ZIGLIO, Frediano, VF-IT" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
> 
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.