compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
This commit is contained in:
parent
caccaa9b2a
commit
93ef08af3e
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: cat.c,v 1.8 1997/02/22 14:01:26 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -78,7 +78,7 @@ main(argc, argv)
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
||||
while ((ch = getopt(argc, argv, "benstuv")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "benstuv")) != -1)
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
bflag = nflag = 1; /* -b implies -n */
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: chmod.c,v 1.8 1997/02/22 14:01:30 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -73,7 +73,7 @@ main(argc, argv)
|
||||
set = NULL;
|
||||
omode = 0;
|
||||
Hflag = Lflag = Pflag = Rflag = fflag = hflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: cp.c,v 1.13 1997/02/22 14:01:33 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -105,7 +105,7 @@ main(argc, argv)
|
||||
char *target;
|
||||
|
||||
Hflag = Lflag = Pflag = 0;
|
||||
while ((ch = getopt(argc, argv, "HLPRfipr")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "HLPRfipr")) != -1)
|
||||
switch (ch) {
|
||||
case 'H':
|
||||
Hflag = 1;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: date.c,v 1.10 1997/02/22 14:02:33 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -84,7 +84,7 @@ main(argc, argv)
|
||||
tz.tz_dsttime = tz.tz_minuteswest = 0;
|
||||
rflag = 0;
|
||||
set_timezone = 0;
|
||||
while ((ch = getopt(argc, argv, "d:nr:ut:")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "d:nr:ut:")) != -1)
|
||||
switch((char)ch) {
|
||||
case 'd': /* daylight savings time */
|
||||
tz.tz_dsttime = strtol(optarg, &endptr, 10) ? 1 : 0;
|
||||
|
@ -35,7 +35,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: df.c,v 1.13 1997/02/22 14:02:57 peter Exp $
|
||||
* $Id: df.c,v 1.15 1997/03/13 17:41:37 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -85,7 +85,7 @@ main(argc, argv)
|
||||
char *mntpt, **vfslist;
|
||||
|
||||
vfslist = NULL;
|
||||
while ((ch = getopt(argc, argv, "iknt:")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "iknt:")) != -1)
|
||||
switch (ch) {
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
|
@ -25,7 +25,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: main.c,v 1.9 1997/02/22 14:03:17 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -122,7 +122,7 @@ main(argc, argv)
|
||||
|
||||
red = (n = strlen(argv[0])) > 2 && argv[0][n - 3] == 'r';
|
||||
top:
|
||||
while ((c = getopt(argc, argv, "p:sx")) != EOF)
|
||||
while ((c = getopt(argc, argv, "p:sx")) != -1)
|
||||
switch(c) {
|
||||
case 'p': /* set prompt */
|
||||
prompt = optarg;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: hostname.c,v 1.5 1997/02/22 14:03:42 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -62,7 +62,7 @@ main(argc,argv)
|
||||
char *p, hostname[MAXHOSTNAMELEN];
|
||||
|
||||
sflag = 0;
|
||||
while ((ch = getopt(argc, argv, "s")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "s")) != -1)
|
||||
switch (ch) {
|
||||
case 's':
|
||||
sflag = 1;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: ln.c,v 1.9 1997/02/22 14:03:49 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -71,7 +71,7 @@ main(argc, argv)
|
||||
int ch, exitval;
|
||||
char *sourcedir;
|
||||
|
||||
while ((ch = getopt(argc, argv, "fs")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "fs")) != -1)
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
fflag = 1;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: ls.c,v 1.13 1997/02/22 14:03:59 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -135,9 +135,9 @@ main(argc, argv)
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
#ifdef BSD4_4_LITE
|
||||
while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) {
|
||||
while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != -1) {
|
||||
#else
|
||||
while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != EOF) {
|
||||
while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != -1) {
|
||||
#endif
|
||||
switch (ch) {
|
||||
/*
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: mkdir.c,v 1.8 1997/02/22 14:04:08 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -67,7 +67,7 @@ main(argc, argv)
|
||||
|
||||
omode = pflag = 0;
|
||||
mode = NULL;
|
||||
while ((ch = getopt(argc, argv, "m:p")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "m:p")) != -1)
|
||||
switch(ch) {
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mv.c,v 1.11 1997/02/22 14:04:12 peter Exp $
|
||||
* $Id: mv.c,v 1.12 1997/03/08 16:05:44 guido Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -79,7 +79,7 @@ main(argc, argv)
|
||||
int ch;
|
||||
char path[MAXPATHLEN + 1];
|
||||
|
||||
while ((ch = getopt(argc, argv, "fi")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "fi")) != -1)
|
||||
switch (ch) {
|
||||
case 'i':
|
||||
iflg = 1;
|
||||
|
@ -34,7 +34,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: options.c,v 1.7 1997/02/22 14:04:33 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -195,7 +195,7 @@ pax_options(argc, argv)
|
||||
* process option flags
|
||||
*/
|
||||
while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:B:DE:G:HLPT:U:XYZ"))
|
||||
!= EOF) {
|
||||
!= -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
/*
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: ps.c,v 1.17 1997/02/22 14:05:08 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -139,7 +139,7 @@ main(argc, argv)
|
||||
ttydev = NODEV;
|
||||
memf = nlistf = swapf = NULL;
|
||||
while ((ch = getopt(argc, argv,
|
||||
"aCceghjLlM:mN:O:o:p:rSTt:U:uvW:wx")) != EOF)
|
||||
"aCceghjLlM:mN:O:o:p:rSTt:U:uvW:wx")) != -1)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
all = 1;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: pwd.c,v 1.5 1997/02/22 14:05:16 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -65,7 +65,7 @@ main(argc, argv)
|
||||
* there's no way to display a logical path after forking. We don't
|
||||
* document either flag, only adding -P for future portability.
|
||||
*/
|
||||
while ((ch = getopt(argc, argv, "P")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "P")) != -1)
|
||||
switch (ch) {
|
||||
case 'P':
|
||||
break;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: rcp.c,v 1.11 1997/02/22 14:05:22 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -121,7 +121,7 @@ main(argc, argv)
|
||||
char *targ, *shell;
|
||||
|
||||
fflag = tflag = 0;
|
||||
while ((ch = getopt(argc, argv, OPTIONS)) != EOF)
|
||||
while ((ch = getopt(argc, argv, OPTIONS)) != -1)
|
||||
switch(ch) { /* User-visible flags. */
|
||||
case 'K':
|
||||
#ifdef KERBEROS
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: rm.c,v 1.14 1997/02/22 14:05:27 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -93,9 +93,9 @@ main(argc, argv)
|
||||
|
||||
Pflag = rflag = 0;
|
||||
#ifdef BSD4_4_LITE
|
||||
while ((ch = getopt(argc, argv, "dfiPRr")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "dfiPRr")) != -1)
|
||||
#else
|
||||
while ((ch = getopt(argc, argv, "dfiPRrW")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "dfiPRrW")) != -1)
|
||||
#endif
|
||||
switch(ch) {
|
||||
case 'd':
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: rmail.c,v 1.9 1997/02/22 14:05:31 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -101,7 +101,7 @@ main(argc, argv)
|
||||
|
||||
debug = 0;
|
||||
domain = "UUCP"; /* Default "domain". */
|
||||
while ((ch = getopt(argc, argv, "D:T")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "D:T")) != -1)
|
||||
switch (ch) {
|
||||
case 'T':
|
||||
debug = 1;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: rmdir.c,v 1.5 1997/02/22 14:05:40 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -62,7 +62,7 @@ main(argc, argv)
|
||||
int pflag;
|
||||
|
||||
pflag = 0;
|
||||
while ((ch = getopt(argc, argv, "p")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "p")) != -1)
|
||||
switch(ch) {
|
||||
case 'p':
|
||||
pflag = 1;
|
||||
|
@ -33,7 +33,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: histedit.c,v 1.9 1997/02/22 13:58:27 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -206,7 +206,7 @@ histcmd(argc, argv)
|
||||
|
||||
optreset = 1; optind = 1; /* initialize getopt */
|
||||
while (not_fcnumber(argv[optind]) &&
|
||||
(ch = getopt(argc, argv, ":e:lnrs")) != EOF)
|
||||
(ch = getopt(argc, argv, ":e:lnrs")) != -1)
|
||||
switch ((char)ch) {
|
||||
case 'e':
|
||||
editor = optarg;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: sleep.c,v 1.5 1997/02/22 14:05:45 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -56,7 +56,7 @@ main(argc, argv)
|
||||
{
|
||||
int ch, secs;
|
||||
|
||||
while ((ch = getopt(argc, argv, "")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "")) != -1)
|
||||
switch(ch) {
|
||||
case '?':
|
||||
default:
|
||||
|
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: stty.c,v 1.9 1997/02/22 14:05:54 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -72,7 +72,7 @@ main(argc, argv)
|
||||
opterr = 0;
|
||||
while (optind < argc &&
|
||||
strspn(argv[optind], "-aefg") == strlen(argv[optind]) &&
|
||||
(ch = getopt(argc, argv, "aef:g")) != EOF)
|
||||
(ch = getopt(argc, argv, "aef:g")) != -1)
|
||||
switch(ch) {
|
||||
case 'a': /* undocumented: POSIX compatibility */
|
||||
fmt = POSIX;
|
||||
|
Loading…
Reference in New Issue
Block a user