Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!rutgers!mcdchg!laidbak!shh From: shh@i88.isc.com (Shiv Haris) Newsgroups: comp.unix.aix Subject: Re: getopt (3) problem? Message-ID: <1990Sep13.144109.1764@i88.isc.com> Date: 13 Sep 90 14:41:09 GMT References: <1990Sep12.011152.26067@maverick.ksu.ksu.edu> Sender: usenet@i88.isc.com (Usenet News) Organization: INTERACTIVE Systems Corporation, Naperville, IL Lines: 33 In article <1990Sep12.011152.26067@maverick.ksu.ksu.edu> proot@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