summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-03-12 00:26:59 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-03-12 00:26:59 +0000
commit8591b9347a88daa2818c0c9a72f2e02fae4f45cf (patch)
tree6684f1d269e681f2a92a8d2ec02df1ab7faa697c
parent1d8b3be15ea37678b523802ae1e5df5252978468 (diff)
might as well make ksh_getopt() match real getopt(), ie. get rid of that
stupid EOF concept that was never true. adobriyan@gmail
-rw-r--r--bin/ksh/c_ksh.c22
-rw-r--r--bin/ksh/c_sh.c12
-rw-r--r--bin/ksh/c_ulimit.c4
-rw-r--r--bin/ksh/history.c4
-rw-r--r--bin/ksh/misc.c8
5 files changed, 25 insertions, 25 deletions
diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c
index 8d46460e67f..7a1751d930a 100644
--- a/bin/ksh/c_ksh.c
+++ b/bin/ksh/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.28 2005/12/11 20:31:21 otto Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.29 2006/03/12 00:26:58 deraadt Exp $ */
/*
* built-in Korn commands: c_*
@@ -24,7 +24,7 @@ c_cd(char **wp)
int phys_path;
char *cdpath;
- while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != -1)
switch (optc) {
case 'L':
physical = 0;
@@ -159,7 +159,7 @@ c_pwd(char **wp)
int physical = Flag(FPHYSICAL);
char *p;
- while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "LP")) != -1)
switch (optc) {
case 'L':
physical = 0;
@@ -241,7 +241,7 @@ c_print(char **wp)
} else {
int optc;
const char *options = "Rnprsu,";
- while ((optc = ksh_getopt(wp, &builtin_opt, options)) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, options)) != -1)
switch (optc) {
case 'R': /* fake BSD echo command */
flags |= PO_PMINUSMINUS;
@@ -398,7 +398,7 @@ c_whence(char **wp)
int fcflags;
const char *options = iam_whence ? "pv" : "pvV";
- while ((optc = ksh_getopt(wp, &builtin_opt, options)) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, options)) != -1)
switch (optc) {
case 'p':
pflag = 1;
@@ -557,7 +557,7 @@ c_typeset(char **wp)
* Here, the number must follow the RLZi option, but is optional
* (see the # kludge in ksh_getopt()).
*/
- while ((optc = ksh_getopt(wp, &builtin_opt, options)) != EOF) {
+ while ((optc = ksh_getopt(wp, &builtin_opt, options)) != -1) {
flag = 0;
switch (optc) {
case 'L':
@@ -825,7 +825,7 @@ c_alias(char **wp)
int optc;
builtin_opt.flags |= GF_PLUSOPT;
- while ((optc = ksh_getopt(wp, &builtin_opt, "dprtUx")) != EOF) {
+ while ((optc = ksh_getopt(wp, &builtin_opt, "dprtUx")) != -1) {
prefix = builtin_opt.info & GI_PLUS ? '+' : '-';
switch (optc) {
case 'd':
@@ -959,7 +959,7 @@ c_unalias(char **wp)
int rv = 0, all = 0;
int optc;
- while ((optc = ksh_getopt(wp, &builtin_opt, "adt")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "adt")) != -1)
switch (optc) {
case 'a':
all = 1;
@@ -1029,7 +1029,7 @@ c_jobs(char **wp)
int nflag = 0;
int rv = 0;
- while ((optc = ksh_getopt(wp, &builtin_opt, "lpnz")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "lpnz")) != -1)
switch (optc) {
case 'l':
flag = 1;
@@ -1129,7 +1129,7 @@ c_kill(char **wp)
} else {
int optc;
- while ((optc = ksh_getopt(wp, &builtin_opt, "ls:")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "ls:")) != -1)
switch (optc) {
case 'l':
lflag = 1;
@@ -1333,7 +1333,7 @@ c_bind(char **wp)
int optc, rv = 0, macro = 0, list = 0;
char *cp;
- while ((optc = ksh_getopt(wp, &builtin_opt, "lm")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "lm")) != -1)
switch (optc) {
case 'l':
list = 1;
diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c
index 5be063f62e2..458c88fd1b6 100644
--- a/bin/ksh/c_sh.c
+++ b/bin/ksh/c_sh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_sh.c,v 1.31 2005/10/08 18:07:31 otto Exp $ */
+/* $OpenBSD: c_sh.c,v 1.32 2006/03/12 00:26:58 deraadt Exp $ */
/*
* built-in Bourne commands
@@ -58,7 +58,7 @@ c_umask(char **wp)
mode_t old_umask;
int optc;
- while ((optc = ksh_getopt(wp, &builtin_opt, "S")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "S")) != -1)
switch (optc) {
case 'S':
symbolic = 1;
@@ -252,7 +252,7 @@ c_read(char **wp)
struct tbl *vp;
char *xp = NULL;
- while ((optc = ksh_getopt(wp, &builtin_opt, "prsu,")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "prsu,")) != -1)
switch (optc) {
case 'p':
if ((fd = coproc_getfd(R_OK, &emsg)) < 0) {
@@ -646,7 +646,7 @@ c_unset(char **wp)
int optc, unset_var = 1;
int ret = 0;
- while ((optc = ksh_getopt(wp, &builtin_opt, "fv")) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, "fv")) != -1)
switch (optc) {
case 'f':
unset_var = 0;
@@ -787,7 +787,7 @@ timex_hook(struct op *t, char **volatile *app)
ksh_getopt_reset(&opt, 0);
opt.optind = 0; /* start at the start */
- while ((optc = ksh_getopt(wp, &opt, ":p")) != EOF)
+ while ((optc = ksh_getopt(wp, &opt, ":p")) != -1)
switch (optc) {
case 'p':
t->str[0] |= TF_POSIX;
@@ -843,7 +843,7 @@ c_mknod(char **wp)
void *set = NULL;
mode_t mode = 0, oldmode = 0;
- while ((optc = ksh_getopt(wp, &builtin_opt, "m:")) != EOF) {
+ while ((optc = ksh_getopt(wp, &builtin_opt, "m:")) != -1) {
switch (optc) {
case 'm':
set = setmode(builtin_opt.optarg);
diff --git a/bin/ksh/c_ulimit.c b/bin/ksh/c_ulimit.c
index f4bde13e103..d955303800e 100644
--- a/bin/ksh/c_ulimit.c
+++ b/bin/ksh/c_ulimit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ulimit.c,v 1.14 2005/03/30 17:16:37 deraadt Exp $ */
+/* $OpenBSD: c_ulimit.c,v 1.15 2006/03/12 00:26:58 deraadt Exp $ */
/*
ulimit -- handle "ulimit" builtin
@@ -69,7 +69,7 @@ c_ulimit(char **wp)
*p = '\0';
}
what = 'f';
- while ((optc = ksh_getopt(wp, &builtin_opt, options)) != EOF)
+ while ((optc = ksh_getopt(wp, &builtin_opt, options)) != -1)
switch (optc) {
case 'H':
how = HARD;
diff --git a/bin/ksh/history.c b/bin/ksh/history.c
index 9a90b5deb00..7b959455f95 100644
--- a/bin/ksh/history.c
+++ b/bin/ksh/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.32 2005/12/11 18:53:51 deraadt Exp $ */
+/* $OpenBSD: history.c,v 1.33 2006/03/12 00:26:58 deraadt Exp $ */
/*
* command history
@@ -65,7 +65,7 @@ c_fc(char **wp)
}
while ((optc = ksh_getopt(wp, &builtin_opt,
- "e:glnrs0,1,2,3,4,5,6,7,8,9,")) != EOF)
+ "e:glnrs0,1,2,3,4,5,6,7,8,9,")) != -1)
switch (optc) {
case 'e':
p = builtin_opt.optarg;
diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c
index b9a779ff349..912b990ac3d 100644
--- a/bin/ksh/misc.c
+++ b/bin/ksh/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.29 2006/03/06 10:44:10 djm Exp $ */
+/* $OpenBSD: misc.c,v 1.30 2006/03/12 00:26:58 deraadt Exp $ */
/*
* Miscellaneous functions
@@ -359,7 +359,7 @@ parse_args(char **argv,
} else
opts = set_opts;
ksh_getopt_reset(&go, GF_ERROR|GF_PLUSOPT);
- while ((optc = ksh_getopt(argv, &go, opts)) != EOF) {
+ while ((optc = ksh_getopt(argv, &go, opts)) != -1) {
set = (go.info & GI_PLUS) ? 0 : 1;
switch (optc) {
case 'A':
@@ -913,14 +913,14 @@ ksh_getopt(char **argv, Getopt *go, const char *options)
go->optind++;
go->p = 0;
go->info |= GI_MINUSMINUS;
- return EOF;
+ return -1;
}
if (arg == (char *) 0 ||
((flag != '-' ) && /* neither a - nor a + (if + allowed) */
(!(go->flags & GF_PLUSOPT) || flag != '+')) ||
(c = arg[1]) == '\0') {
go->p = 0;
- return EOF;
+ return -1;
}
go->optind++;
go->info &= ~(GI_MINUS|GI_PLUS);