summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-12-08 16:50:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-12-08 16:50:08 +0000
commitc5a38b6fdf1c2335f7f5558976e478f12d297990 (patch)
treea24f21bafd589dbe349a9eb8ce3651b05695577c
parent575d3fc4197705961dd3a1a91780df758087ebec (diff)
GNU semantics say that if optstring begins with '-' then
each non-option shall be treated as arguments to option '\1'. BSD getopt match '-' in optstring with a '-' on the command line. This is used to support deprecated options like "su -" that would otherwise prevent the use of getopt(). Resolving this simply requires that the leading '-' be moved somewhere else (I moved it to the end of optstring) since position within optstring is not meaningful.
-rw-r--r--sbin/shutdown/shutdown.c6
-rw-r--r--usr.bin/calendar/calendar.c6
-rw-r--r--usr.bin/env/env.c6
-rw-r--r--usr.bin/man/man.c6
-rw-r--r--usr.bin/split/split.c6
-rw-r--r--usr.bin/strings/strings.c6
-rw-r--r--usr.bin/su/su.c6
-rw-r--r--usr.bin/xstr/xstr.c6
-rw-r--r--usr.sbin/eeprom/main.c6
-rw-r--r--usr.sbin/lpr/lprm/lprm.c6
10 files changed, 30 insertions, 30 deletions
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index f5a15702ec8..8327de16b8f 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shutdown.c,v 1.26 2002/07/03 22:32:33 deraadt Exp $ */
+/* $OpenBSD: shutdown.c,v 1.27 2002/12/08 16:50:07 millert Exp $ */
/* $NetBSD: shutdown.c,v 1.9 1995/03/18 15:01:09 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94";
#else
-static char rcsid[] = "$OpenBSD: shutdown.c,v 1.26 2002/07/03 22:32:33 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: shutdown.c,v 1.27 2002/12/08 16:50:07 millert Exp $";
#endif
#endif /* not lint */
@@ -131,7 +131,7 @@ main(int argc, char *argv[])
}
#endif
readstdin = 0;
- while ((ch = getopt(argc, argv, "-dfhknpr")) != -1)
+ while ((ch = getopt(argc, argv, "dfhknpr-")) != -1)
switch (ch) {
case '-':
readstdin = 1;
diff --git a/usr.bin/calendar/calendar.c b/usr.bin/calendar/calendar.c
index 9ea6589bdd3..35a73f6a944 100644
--- a/usr.bin/calendar/calendar.c
+++ b/usr.bin/calendar/calendar.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: calendar.c,v 1.18 2002/06/23 03:07:21 deraadt Exp $ */
+/* $OpenBSD: calendar.c,v 1.19 2002/12/08 16:50:07 millert Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -43,7 +43,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
#else
-static char rcsid[] = "$OpenBSD: calendar.c,v 1.18 2002/06/23 03:07:21 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: calendar.c,v 1.19 2002/12/08 16:50:07 millert Exp $";
#endif
#endif /* not lint */
@@ -92,7 +92,7 @@ main(argc, argv)
(void)setlocale(LC_ALL, "");
- while ((ch = getopt(argc, argv, "-abf:t:A:B:")) != -1)
+ while ((ch = getopt(argc, argv, "abf:t:A:B:-")) != -1)
switch (ch) {
case '-': /* backward contemptible */
case 'a':
diff --git a/usr.bin/env/env.c b/usr.bin/env/env.c
index 2f6fe09a0e6..eda66a36569 100644
--- a/usr.bin/env/env.c
+++ b/usr.bin/env/env.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: env.c,v 1.7 2002/02/16 21:27:45 millert Exp $ */
+/* $OpenBSD: env.c,v 1.8 2002/12/08 16:50:07 millert Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@@ -41,7 +41,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "@(#)env.c 8.3 (Berkeley) 4/2/94";*/
-static char rcsid[] = "$OpenBSD: env.c,v 1.7 2002/02/16 21:27:45 millert Exp $";
+static char rcsid[] = "$OpenBSD: env.c,v 1.8 2002/12/08 16:50:07 millert Exp $";
#endif /* not lint */
#include <err.h>
@@ -66,7 +66,7 @@ main(argc, argv)
setlocale(LC_ALL, "");
- while ((ch = getopt(argc, argv, "-i")) != -1)
+ while ((ch = getopt(argc, argv, "i-")) != -1)
switch((char)ch) {
case '-': /* obsolete */
case 'i':
diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c
index bf77cb11b97..e4ffe0e03ca 100644
--- a/usr.bin/man/man.c
+++ b/usr.bin/man/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.22 2002/11/23 18:43:29 espie Exp $ */
+/* $OpenBSD: man.c,v 1.23 2002/12/08 16:50:07 millert Exp $ */
/* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
#else
-static char rcsid[] = "$OpenBSD: man.c,v 1.22 2002/11/23 18:43:29 espie Exp $";
+static char rcsid[] = "$OpenBSD: man.c,v 1.23 2002/12/08 16:50:07 millert Exp $";
#endif
#endif /* not lint */
@@ -109,7 +109,7 @@ main(int argc, char *argv[])
machine = sflag = NULL;
f_cat = f_how = 0;
conffile = p_add = p_path = NULL;
- while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1)
+ while ((ch = getopt(argc, argv, "aC:cfhkM:m:P:s:S:w-")) != -1)
switch (ch) {
case 'a':
f_all = 1;
diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c
index d052b919235..bc8be83fa95 100644
--- a/usr.bin/split/split.c
+++ b/usr.bin/split/split.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: split.c,v 1.6 2002/02/16 21:27:53 millert Exp $ */
+/* $OpenBSD: split.c,v 1.7 2002/12/08 16:50:07 millert Exp $ */
/* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)split.c 8.3 (Berkeley) 4/25/94";
#else
-static char rcsid[] = "$OpenBSD: split.c,v 1.6 2002/02/16 21:27:53 millert Exp $";
+static char rcsid[] = "$OpenBSD: split.c,v 1.7 2002/12/08 16:50:07 millert Exp $";
#endif
#endif /* not lint */
@@ -85,7 +85,7 @@ main(argc, argv)
int ch;
char *ep, *p;
- while ((ch = getopt(argc, argv, "-0123456789b:l:p:")) != -1)
+ while ((ch = getopt(argc, argv, "0123456789b:l:p:-")) != -1)
switch (ch) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
diff --git a/usr.bin/strings/strings.c b/usr.bin/strings/strings.c
index 5ab6a58f6ff..89882bc1cd0 100644
--- a/usr.bin/strings/strings.c
+++ b/usr.bin/strings/strings.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strings.c,v 1.8 2002/09/23 04:10:14 millert Exp $ */
+/* $OpenBSD: strings.c,v 1.9 2002/12/08 16:50:07 millert Exp $ */
/* $NetBSD: strings.c,v 1.7 1995/02/15 15:49:19 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)strings.c 8.2 (Berkeley) 1/28/94";
#endif
-static char rcsid[] = "$OpenBSD: strings.c,v 1.8 2002/09/23 04:10:14 millert Exp $";
+static char rcsid[] = "$OpenBSD: strings.c,v 1.9 2002/12/08 16:50:07 millert Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -103,7 +103,7 @@ main(argc, argv)
offset_format = NULL;
minlen = -1;
maxlen = -1;
- while ((ch = getopt(argc, argv, "-0123456789an:m:oft:")) != -1)
+ while ((ch = getopt(argc, argv, "0123456789an:m:oft:-")) != -1)
switch((char)ch) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
diff --git a/usr.bin/su/su.c b/usr.bin/su/su.c
index 9559ca769a9..ea0b1b6dd1a 100644
--- a/usr.bin/su/su.c
+++ b/usr.bin/su/su.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: su.c,v 1.49 2002/12/07 22:54:13 millert Exp $ */
+/* $OpenBSD: su.c,v 1.50 2002/12/08 16:50:07 millert Exp $ */
/*
* Copyright (c) 1988 The Regents of the University of California.
@@ -43,7 +43,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "from: @(#)su.c 5.26 (Berkeley) 7/6/91";
#else
-static const char rcsid[] = "$OpenBSD: su.c,v 1.49 2002/12/07 22:54:13 millert Exp $";
+static const char rcsid[] = "$OpenBSD: su.c,v 1.50 2002/12/08 16:50:07 millert Exp $";
#endif
#endif /* not lint */
@@ -89,7 +89,7 @@ main(int argc, char **argv)
login_cap_t *lc;
uid_t ruid;
- while ((ch = getopt(argc, argv, "-a:c:fKLlm")) != -1)
+ while ((ch = getopt(argc, argv, "a:c:fKLlm-")) != -1)
switch (ch) {
case 'a':
if (style)
diff --git a/usr.bin/xstr/xstr.c b/usr.bin/xstr/xstr.c
index b51a67e9592..896b13ae3df 100644
--- a/usr.bin/xstr/xstr.c
+++ b/usr.bin/xstr/xstr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xstr.c,v 1.9 2002/02/24 02:25:48 deraadt Exp $ */
+/* $OpenBSD: xstr.c,v 1.10 2002/12/08 16:50:07 millert Exp $ */
/* $NetBSD: xstr.c,v 1.5 1994/12/24 16:57:59 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)xstr.c 8.1 (Berkeley) 6/9/93";
#endif
-static char rcsid[] = "$OpenBSD: xstr.c,v 1.9 2002/02/24 02:25:48 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: xstr.c,v 1.10 2002/12/08 16:50:07 millert Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -103,7 +103,7 @@ main(int argc, char *argv[])
int c;
int fdesc;
- while ((c = getopt(argc, argv, "-cvl:")) != -1)
+ while ((c = getopt(argc, argv, "cvl:-")) != -1)
switch (c) {
case '-':
readstd++;
diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c
index 8777a98d98b..f12893403f5 100644
--- a/usr.sbin/eeprom/main.c
+++ b/usr.sbin/eeprom/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.9 2002/06/14 04:21:54 art Exp $ */
+/* $OpenBSD: main.c,v 1.10 2002/12/08 16:50:07 millert Exp $ */
/* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */
/*-
@@ -122,9 +122,9 @@ main(argc, argv)
int ch, do_stdin = 0;
char *cp, line[BUFSIZE];
#ifdef __sparc__
- char *optstring = "-cf:ivN:";
+ char *optstring = "cf:ivN:-";
#else
- char *optstring = "-cf:i";
+ char *optstring = "cf:i-";
#endif /* __sparc__ */
while ((ch = getopt(argc, argv, optstring)) != -1)
diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c
index 0189767a996..fb3de97d42d 100644
--- a/usr.sbin/lpr/lprm/lprm.c
+++ b/usr.sbin/lpr/lprm/lprm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lprm.c,v 1.12 2002/06/08 01:53:43 millert Exp $ */
+/* $OpenBSD: lprm.c,v 1.13 2002/12/08 16:50:07 millert Exp $ */
/* $$NetBSD: lprm.c,v 1.9 1999/08/16 03:12:32 simonb Exp $ */
/*
@@ -45,7 +45,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93";
#else
-static const char rcsid[] = "$OpenBSD: lprm.c,v 1.12 2002/06/08 01:53:43 millert Exp $";
+static const char rcsid[] = "$OpenBSD: lprm.c,v 1.13 2002/12/08 16:50:07 millert Exp $";
#endif
#endif /* not lint */
@@ -111,7 +111,7 @@ main(int argc, char **argv)
fatal("Your name is too long");
strlcpy(luser, p->pw_name, sizeof(luser));
person = luser;
- while ((ch = getopt(argc, argv, "-P:w:")) != -1) {
+ while ((ch = getopt(argc, argv, "P:w:-")) != -1) {
switch (ch) {
case '-':
users = -1;