From 93ef08af3ef1a9fb7a3af6b7212d3ca094e9aba6 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 28 Mar 1997 15:24:41 +0000 Subject: [PATCH] compare return value from getopt against -1 rather than EOF, per the final posix standard on the topic. --- bin/cat/cat.c | 4 ++-- bin/chmod/chmod.c | 4 ++-- bin/cp/cp.c | 4 ++-- bin/date/date.c | 4 ++-- bin/df/df.c | 4 ++-- bin/ed/main.c | 4 ++-- bin/hostname/hostname.c | 4 ++-- bin/ln/ln.c | 4 ++-- bin/ls/ls.c | 6 +++--- bin/mkdir/mkdir.c | 4 ++-- bin/mv/mv.c | 4 ++-- bin/pax/options.c | 4 ++-- bin/ps/ps.c | 4 ++-- bin/pwd/pwd.c | 4 ++-- bin/rcp/rcp.c | 4 ++-- bin/rm/rm.c | 6 +++--- bin/rmail/rmail.c | 4 ++-- bin/rmdir/rmdir.c | 4 ++-- bin/sh/histedit.c | 4 ++-- bin/sleep/sleep.c | 4 ++-- bin/stty/stty.c | 4 ++-- 21 files changed, 44 insertions(+), 44 deletions(-) diff --git a/bin/cat/cat.c b/bin/cat/cat.c index 101653d5bbf2..175f2f8be3ce 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -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 */ diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c index 2004a5188d2f..6d61ca449aea 100644 --- a/bin/chmod/chmod.c +++ b/bin/chmod/chmod.c @@ -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; diff --git a/bin/cp/cp.c b/bin/cp/cp.c index b45582cfa132..6143c10af235 100644 --- a/bin/cp/cp.c +++ b/bin/cp/cp.c @@ -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; diff --git a/bin/date/date.c b/bin/date/date.c index 815a304a5ca0..4d7e74e0848b 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -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; diff --git a/bin/df/df.c b/bin/df/df.c index f32dba304f43..122906c6f5b7 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -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; diff --git a/bin/ed/main.c b/bin/ed/main.c index 22206eda99f5..d17ab62fec69 100644 --- a/bin/ed/main.c +++ b/bin/ed/main.c @@ -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; diff --git a/bin/hostname/hostname.c b/bin/hostname/hostname.c index a64beef40dc1..15aee0072636 100644 --- a/bin/hostname/hostname.c +++ b/bin/hostname/hostname.c @@ -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; diff --git a/bin/ln/ln.c b/bin/ln/ln.c index e6d5f651eb18..81467409d46a 100644 --- a/bin/ln/ln.c +++ b/bin/ln/ln.c @@ -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; diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 60bb05181cda..353914fda35a 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -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) { /* diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c index 7857a0db1c84..4b9c0d55461c 100644 --- a/bin/mkdir/mkdir.c +++ b/bin/mkdir/mkdir.c @@ -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; diff --git a/bin/mv/mv.c b/bin/mv/mv.c index aeddd9c56769..ea6db6d86501 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -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; diff --git a/bin/pax/options.c b/bin/pax/options.c index 4edd43f7b298..3e0efa4b1fc0 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -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': /* diff --git a/bin/ps/ps.c b/bin/ps/ps.c index ee2d40786aa0..a26b9817d0df 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -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; diff --git a/bin/pwd/pwd.c b/bin/pwd/pwd.c index d80423a10d0b..63b68686406a 100644 --- a/bin/pwd/pwd.c +++ b/bin/pwd/pwd.c @@ -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; diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c index 72baa4469900..a186f8378af3 100644 --- a/bin/rcp/rcp.c +++ b/bin/rcp/rcp.c @@ -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 diff --git a/bin/rm/rm.c b/bin/rm/rm.c index 80f6012d5b7f..40a86dce1490 100644 --- a/bin/rm/rm.c +++ b/bin/rm/rm.c @@ -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': diff --git a/bin/rmail/rmail.c b/bin/rmail/rmail.c index 52b60aa4ab31..f80cd3b7d0bc 100644 --- a/bin/rmail/rmail.c +++ b/bin/rmail/rmail.c @@ -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; diff --git a/bin/rmdir/rmdir.c b/bin/rmdir/rmdir.c index 9830835fab5c..89672926b510 100644 --- a/bin/rmdir/rmdir.c +++ b/bin/rmdir/rmdir.c @@ -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; diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index c6376ae53b4f..5605d13bbb28 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -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; diff --git a/bin/sleep/sleep.c b/bin/sleep/sleep.c index 892c520aa1c7..d11dd0798d52 100644 --- a/bin/sleep/sleep.c +++ b/bin/sleep/sleep.c @@ -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: diff --git a/bin/stty/stty.c b/bin/stty/stty.c index 3bf2fd66b37a..123e8e24abb3 100644 --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -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;