summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1999-12-17 01:52:15 +0000
committerjkh <jkh@FreeBSD.org>1999-12-17 01:52:15 +0000
commitdd89aff00103d7c2081869aa63be4814c400610e (patch)
treea54ad0d750b0adb70fad02988212925966dd9a79 /lib
parent07d0cafdf2018e8789e4e0671eb0ccc8bbc5c186 (diff)
downloadFreeBSD-src-dd89aff00103d7c2081869aa63be4814c400610e.zip
FreeBSD-src-dd89aff00103d7c2081869aa63be4814c400610e.tar.gz
Fix handling of trailing :'s to match what other OSes do (spit out
a diagnostis). Submitted by: Guy Harris <gharris@flashcom.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdlib/getopt.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libc/stdlib/getopt.c b/lib/libc/stdlib/getopt.c
index 5dddf86..1b297a7 100644
--- a/lib/libc/stdlib/getopt.c
+++ b/lib/libc/stdlib/getopt.c
@@ -32,7 +32,10 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
+#endif
+static const char rcsid[] = "$FreeBSD$";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -62,6 +65,7 @@ getopt(nargc, nargv, ostr)
extern char *__progname;
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
+ int ret;
if (optreset || !*place) { /* update scanning pointer */
optreset = 0;
@@ -101,12 +105,14 @@ getopt(nargc, nargv, ostr)
else if (nargc <= ++optind) { /* no arg */
place = EMSG;
if (*ostr == ':')
- return (BADARG);
+ ret = BADARG;
+ else
+ ret = BADCH;
if (opterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
__progname, optopt);
- return (BADCH);
+ return (ret);
}
else /* white space */
optarg = nargv[optind];
OpenPOWER on IntegriCloud