summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/openbsd-compat/getopt.c
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-06-29 11:34:13 +0000
committerdes <des@FreeBSD.org>2002-06-29 11:34:13 +0000
commit1ba793a7c09e24d920de3983a3223770cb37ebff (patch)
tree8238d8d0755b8c75c2f77d82c8f96d4360c7ee11 /crypto/openssh/openbsd-compat/getopt.c
parentbb02848f18878bddada7a9f55b110116f63c2f3c (diff)
downloadFreeBSD-src-1ba793a7c09e24d920de3983a3223770cb37ebff.zip
FreeBSD-src-1ba793a7c09e24d920de3983a3223770cb37ebff.tar.gz
Vendor import of OpenSSH 3.4p1.
Diffstat (limited to 'crypto/openssh/openbsd-compat/getopt.c')
-rw-r--r--crypto/openssh/openbsd-compat/getopt.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/crypto/openssh/openbsd-compat/getopt.c b/crypto/openssh/openbsd-compat/getopt.c
index 9e13504..f4fbc9b 100644
--- a/crypto/openssh/openbsd-compat/getopt.c
+++ b/crypto/openssh/openbsd-compat/getopt.c
@@ -42,11 +42,11 @@ static char *rcsid = "$OpenBSD: getopt.c,v 1.2 1996/08/19 08:33:32 tholo Exp $";
#include <stdlib.h>
#include <string.h>
-int opterr = 1, /* if error message should be printed */
- optind = 1, /* index into parent argv vector */
- optopt, /* character checked for validity */
- optreset; /* reset getopt */
-char *optarg; /* argument associated with option */
+int BSDopterr = 1, /* if error message should be printed */
+ BSDoptind = 1, /* index into parent argv vector */
+ BSDoptopt, /* character checked for validity */
+ BSDoptreset; /* reset getopt */
+char *BSDoptarg; /* argument associated with option */
#define BADCH (int)'?'
#define BADARG (int)':'
@@ -66,57 +66,57 @@ BSDgetopt(nargc, nargv, ostr)
static char *place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
- if (optreset || !*place) { /* update scanning pointer */
- optreset = 0;
- if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ if (BSDoptreset || !*place) { /* update scanning pointer */
+ BSDoptreset = 0;
+ if (BSDoptind >= nargc || *(place = nargv[BSDoptind]) != '-') {
place = EMSG;
return (-1);
}
if (place[1] && *++place == '-') { /* found "--" */
- ++optind;
+ ++BSDoptind;
place = EMSG;
return (-1);
}
} /* option letter okay? */
- if ((optopt = (int)*place++) == (int)':' ||
- !(oli = strchr(ostr, optopt))) {
+ if ((BSDoptopt = (int)*place++) == (int)':' ||
+ !(oli = strchr(ostr, BSDoptopt))) {
/*
* if the user didn't specify '-' as an option,
* assume it means -1.
*/
- if (optopt == (int)'-')
+ if (BSDoptopt == (int)'-')
return (-1);
if (!*place)
- ++optind;
- if (opterr && *ostr != ':')
+ ++BSDoptind;
+ if (BSDopterr && *ostr != ':')
(void)fprintf(stderr,
- "%s: illegal option -- %c\n", __progname, optopt);
+ "%s: illegal option -- %c\n", __progname, BSDoptopt);
return (BADCH);
}
if (*++oli != ':') { /* don't need argument */
- optarg = NULL;
+ BSDoptarg = NULL;
if (!*place)
- ++optind;
+ ++BSDoptind;
}
else { /* need an argument */
if (*place) /* no white space */
- optarg = place;
- else if (nargc <= ++optind) { /* no arg */
+ BSDoptarg = place;
+ else if (nargc <= ++BSDoptind) { /* no arg */
place = EMSG;
if (*ostr == ':')
return (BADARG);
- if (opterr)
+ if (BSDopterr)
(void)fprintf(stderr,
"%s: option requires an argument -- %c\n",
- __progname, optopt);
+ __progname, BSDoptopt);
return (BADCH);
}
else /* white space */
- optarg = nargv[optind];
+ BSDoptarg = nargv[BSDoptind];
place = EMSG;
- ++optind;
+ ++BSDoptind;
}
- return (optopt); /* dump back option letter */
+ return (BSDoptopt); /* dump back option letter */
}
#endif /* !defined(HAVE_GETOPT) || !defined(HAVE_OPTRESET) */
OpenPOWER on IntegriCloud