mirror of
git://anongit.mindrot.org/openssh.git
synced 2025-02-18 14:56:55 +00:00
- (bal) getopt now can be staticly compiled on those platforms missing
optreset. Patch by binder@arago.de
This commit is contained in:
parent
f102bf6e50
commit
ee9ac35fc2
@ -1,6 +1,8 @@
|
|||||||
20020622
|
20020622
|
||||||
- (djm) Update README.privsep; spotted by fries@
|
- (djm) Update README.privsep; spotted by fries@
|
||||||
- (djm) Release 3.3p1
|
- (djm) Release 3.3p1
|
||||||
|
- (bal) getopt now can be staticly compiled on those platforms missing
|
||||||
|
optreset. Patch by binder@arago.de
|
||||||
|
|
||||||
20020621
|
20020621
|
||||||
- (djm) Sync:
|
- (djm) Sync:
|
||||||
@ -1004,4 +1006,4 @@
|
|||||||
- (stevesk) entropy.c: typo in debug message
|
- (stevesk) entropy.c: typo in debug message
|
||||||
- (djm) ssh-keygen -i needs seeded RNG; report from markus@
|
- (djm) ssh-keygen -i needs seeded RNG; report from markus@
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.2240 2002/06/21 15:44:45 djm Exp $
|
$Id: ChangeLog,v 1.2241 2002/06/22 00:26:59 mouring Exp $
|
||||||
|
15
defines.h
15
defines.h
@ -1,7 +1,7 @@
|
|||||||
#ifndef _DEFINES_H
|
#ifndef _DEFINES_H
|
||||||
#define _DEFINES_H
|
#define _DEFINES_H
|
||||||
|
|
||||||
/* $Id: defines.h,v 1.90 2002/06/07 03:19:36 mouring Exp $ */
|
/* $Id: defines.h,v 1.91 2002/06/22 00:27:00 mouring Exp $ */
|
||||||
|
|
||||||
|
|
||||||
/* Constants */
|
/* Constants */
|
||||||
@ -417,7 +417,18 @@ struct winsize {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_GETOPT_OPTRESET
|
#ifndef HAVE_GETOPT_OPTRESET
|
||||||
#define getopt(ac, av, o) BSDgetopt(ac, av, o)
|
# undef getopt
|
||||||
|
# undef opterr
|
||||||
|
# undef optind
|
||||||
|
# undef optopt
|
||||||
|
# undef optreset
|
||||||
|
# undef optarg
|
||||||
|
# define getopt(ac, av, o) BSDgetopt(ac, av, o)
|
||||||
|
# define opterr BSDopterr
|
||||||
|
# define optind BSDoptind
|
||||||
|
# define optopt BSDoptopt
|
||||||
|
# define optreset BSDoptreset
|
||||||
|
# define optarg BSDoptarg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* In older versions of libpam, pam_strerror takes a single argument */
|
/* In older versions of libpam, pam_strerror takes a single argument */
|
||||||
|
@ -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 <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int opterr = 1, /* if error message should be printed */
|
int BSDopterr = 1, /* if error message should be printed */
|
||||||
optind = 1, /* index into parent argv vector */
|
BSDoptind = 1, /* index into parent argv vector */
|
||||||
optopt, /* character checked for validity */
|
BSDoptopt, /* character checked for validity */
|
||||||
optreset; /* reset getopt */
|
BSDoptreset; /* reset getopt */
|
||||||
char *optarg; /* argument associated with option */
|
char *BSDoptarg; /* argument associated with option */
|
||||||
|
|
||||||
#define BADCH (int)'?'
|
#define BADCH (int)'?'
|
||||||
#define BADARG (int)':'
|
#define BADARG (int)':'
|
||||||
@ -66,57 +66,57 @@ BSDgetopt(nargc, nargv, ostr)
|
|||||||
static char *place = EMSG; /* option letter processing */
|
static char *place = EMSG; /* option letter processing */
|
||||||
char *oli; /* option letter list index */
|
char *oli; /* option letter list index */
|
||||||
|
|
||||||
if (optreset || !*place) { /* update scanning pointer */
|
if (BSDoptreset || !*place) { /* update scanning pointer */
|
||||||
optreset = 0;
|
BSDoptreset = 0;
|
||||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
if (BSDoptind >= nargc || *(place = nargv[BSDoptind]) != '-') {
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
if (place[1] && *++place == '-') { /* found "--" */
|
if (place[1] && *++place == '-') { /* found "--" */
|
||||||
++optind;
|
++BSDoptind;
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
} /* option letter okay? */
|
} /* option letter okay? */
|
||||||
if ((optopt = (int)*place++) == (int)':' ||
|
if ((BSDoptopt = (int)*place++) == (int)':' ||
|
||||||
!(oli = strchr(ostr, optopt))) {
|
!(oli = strchr(ostr, BSDoptopt))) {
|
||||||
/*
|
/*
|
||||||
* if the user didn't specify '-' as an option,
|
* if the user didn't specify '-' as an option,
|
||||||
* assume it means -1.
|
* assume it means -1.
|
||||||
*/
|
*/
|
||||||
if (optopt == (int)'-')
|
if (BSDoptopt == (int)'-')
|
||||||
return (-1);
|
return (-1);
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++optind;
|
++BSDoptind;
|
||||||
if (opterr && *ostr != ':')
|
if (BSDopterr && *ostr != ':')
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"%s: illegal option -- %c\n", __progname, optopt);
|
"%s: illegal option -- %c\n", __progname, BSDoptopt);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
if (*++oli != ':') { /* don't need argument */
|
if (*++oli != ':') { /* don't need argument */
|
||||||
optarg = NULL;
|
BSDoptarg = NULL;
|
||||||
if (!*place)
|
if (!*place)
|
||||||
++optind;
|
++BSDoptind;
|
||||||
}
|
}
|
||||||
else { /* need an argument */
|
else { /* need an argument */
|
||||||
if (*place) /* no white space */
|
if (*place) /* no white space */
|
||||||
optarg = place;
|
BSDoptarg = place;
|
||||||
else if (nargc <= ++optind) { /* no arg */
|
else if (nargc <= ++BSDoptind) { /* no arg */
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
if (*ostr == ':')
|
if (*ostr == ':')
|
||||||
return (BADARG);
|
return (BADARG);
|
||||||
if (opterr)
|
if (BSDopterr)
|
||||||
(void)fprintf(stderr,
|
(void)fprintf(stderr,
|
||||||
"%s: option requires an argument -- %c\n",
|
"%s: option requires an argument -- %c\n",
|
||||||
__progname, optopt);
|
__progname, BSDoptopt);
|
||||||
return (BADCH);
|
return (BADCH);
|
||||||
}
|
}
|
||||||
else /* white space */
|
else /* white space */
|
||||||
optarg = nargv[optind];
|
BSDoptarg = nargv[BSDoptind];
|
||||||
place = EMSG;
|
place = EMSG;
|
||||||
++optind;
|
++BSDoptind;
|
||||||
}
|
}
|
||||||
return (optopt); /* dump back option letter */
|
return (BSDoptopt); /* dump back option letter */
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !defined(HAVE_GETOPT) || !defined(HAVE_OPTRESET) */
|
#endif /* !defined(HAVE_GETOPT) || !defined(HAVE_OPTRESET) */
|
||||||
|
Loading…
Reference in New Issue
Block a user