getopt (3) problem?
Shiv Haris
shh at i88.isc.com
Fri Sep 14 00:41:09 AEST 1990
In article <1990Sep12.011152.26067 at maverick.ksu.ksu.edu> proot at ksuvax1.cis.ksu.edu (Paul T. Root) writes:
>In compiling and running some things, I have found that getopt doesn't act
>right. When it runs out of parameters instead of returning an EOF it returns
>a -1.
>
>I have called my Rep and he said he'd pass it along.
>
>
>The work around I use is like this:
>
> while(( c = getopt( argc, argv, "d:m" )), c != EOF && c != -1 ) {
> switch( c ) {
> .
> }
> }
>
>Keeping the world informed...
>Paul.
Take a quick look to see if your machine has type "char" to be unsigned.
if so then if you do a compare of
(c != EOF) and c is 0xff and EOF is -1, will be false.
Hence you problem. The fix should really be:
while(( c = getopt( argc, argv, "d:m" )) != 0xff) {
}
Hope this helps,
-Shiv
More information about the Comp.unix.aix
mailing list