Use stdbool.h instead of rolling our own bools.

From: Todd C. Miller <millert@cvs.openbsd.org>

XXX #ifndef HAVE_STDBOOL_H ?
This commit is contained in:
tg
2004-12-28 22:32:09 +00:00
parent cddaa62a46
commit 0114af375d
22 changed files with 231 additions and 235 deletions

72
exec.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/exec.c,v 2.6 2004/12/18 19:22:29 tg Exp $ */
/** $MirBSD: src/bin/ksh/exec.c,v 2.7 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
/*
@ -10,7 +10,7 @@
#include <ctype.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.6 2004/12/18 19:22:29 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.7 2004/12/28 22:32:08 tg Exp $");
static int comexec(struct op *t, struct tbl *volatile tp, char **ap,
int volatile flags);
@ -18,7 +18,7 @@ static void scriptexec(struct op *tp, char **ap);
static int call_builtin(struct tbl *tp, char **wp);
static int iosetup(struct ioword *iop, struct tbl *tp);
static int herein(const char *content, int sub);
static char *do_selectargs(char **ap, bool_t print_menu);
static char *do_selectargs(char **ap, bool print_menu);
static int dbteste_isa(Test_env *te, Test_meta meta);
static const char *dbteste_getopnd(Test_env *te, Test_op op,
int do_eval);
@ -77,9 +77,9 @@ execute(struct op *volatile t, volatile int flags)
/* Is this the end of a pipeline? If so, we want to evaluate the
* command arguments
bool_t eval_done = FALSE;
bool eval_done = false;
if ((flags&XFORK) && !(flags&XEXEC) && (flags&XPCLOSE)) {
eval_done = TRUE;
eval_done = true;
tp = eval_execute_args(t, &ap);
}
*/
@ -153,18 +153,18 @@ execute(struct op *volatile t, volatile int flags)
flags |= XFORK;
flags &= ~XEXEC;
e->savefd[0] = savefd(0, 0);
(void) ksh_dup2(e->savefd[0], 0, FALSE); /* stdin of first */
(void) ksh_dup2(e->savefd[0], 0, false); /* stdin of first */
e->savefd[1] = savefd(1, 0);
while (t->type == TPIPE) {
openpipe(pv);
(void) ksh_dup2(pv[1], 1, FALSE); /* stdout of curr */
(void) ksh_dup2(pv[1], 1, false); /* stdout of curr */
/* Let exchild() close pv[0] in child
* (if this isn't done, commands like
* (: ; cat /etc/termcap) | sleep 1
* will hang forever).
*/
exchild(t->left, flags|XPIPEO|XCCLOSE, pv[0]);
(void) ksh_dup2(pv[0], 0, FALSE); /* stdin of next */
(void) ksh_dup2(pv[0], 0, false); /* stdin of next */
closepipe(pv);
flags |= XPIPEI;
t = t->right;
@ -210,7 +210,7 @@ execute(struct op *volatile t, volatile int flags)
errorf("coprocess already exists");
/* Can we re-use the existing co-process pipe? */
coproc_cleanup(TRUE);
coproc_cleanup(true);
/* do this before opening pipes, in case these fail */
e->savefd[0] = savefd(0, 0);
@ -218,18 +218,18 @@ execute(struct op *volatile t, volatile int flags)
openpipe(pv);
if (pv[0] != 0) {
ksh_dup2(pv[0], 0, FALSE);
ksh_dup2(pv[0], 0, false);
close(pv[0]);
}
coproc.write = pv[1];
coproc.job = NULL;
if (coproc.readw >= 0)
ksh_dup2(coproc.readw, 1, FALSE);
ksh_dup2(coproc.readw, 1, false);
else {
openpipe(pv);
coproc.read = pv[0];
ksh_dup2(pv[1], 1, FALSE);
ksh_dup2(pv[1], 1, false);
coproc.readw = pv[1]; /* closed before first read */
coproc.njobs = 0;
/* create new coprocess id */
@ -289,7 +289,7 @@ execute(struct op *volatile t, volatile int flags)
case TFOR:
case TSELECT:
{
volatile bool_t is_first = TRUE;
volatile bool is_first = true;
ap = (t->vars != NULL) ?
eval(t->vars, DOBLANK|DOGLOB|DOTILDE)
: e->loc->argv + 1;
@ -320,7 +320,7 @@ execute(struct op *volatile t, volatile int flags)
rv = 1;
break;
}
is_first = FALSE;
is_first = false;
setstr(global(t->str), cp, KSH_UNWIND_ERROR);
rv = execute(t->left, flags & XERROK);
}
@ -364,7 +364,7 @@ execute(struct op *volatile t, volatile int flags)
for (t = t->left; t != NULL && t->type == TPAT; t = t->right)
for (ap = t->vars; *ap; ap++)
if ((s = evalstr(*ap, DOTILDE|DOPAT))
&& gmatch(cp, s, FALSE))
&& gmatch(cp, s, false))
goto Found;
break;
Found:
@ -493,7 +493,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
fcflags = FC_BI|FC_PATH;
if (saw_p) {
if (Flag(FRESTRICTED)) {
warningf(TRUE,
warningf(true,
"command -p: restricted");
rv = 1;
goto Leave;
@ -550,7 +550,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
goto Leave;
} else if (!tp) {
if (Flag(FRESTRICTED) && ksh_strchr_dirsep(cp)) {
warningf(TRUE, "%s: restricted", cp);
warningf(true, "%s: restricted", cp);
rv = 1;
goto Leave;
}
@ -573,28 +573,28 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
if (!tp->u.fpath) {
if (tp->u2.errno_) {
warningf(TRUE,
warningf(true,
"%s: can't find function definition file - %s",
cp, strerror(tp->u2.errno_));
rv = 126;
} else {
warningf(TRUE,
warningf(true,
"%s: can't find function definition file", cp);
rv = 127;
}
break;
}
if (include(tp->u.fpath, 0, NULL, 0) < 0) {
warningf(TRUE,
warningf(true,
"%s: can't open function definition file %s - %s",
cp, tp->u.fpath, strerror(errno));
rv = 127;
break;
}
if (!(ftp = findfunc(cp, hash(cp), FALSE))
if (!(ftp = findfunc(cp, hash(cp), false))
|| !(ftp->flag & ISSET))
{
warningf(TRUE,
warningf(true,
"%s: function not defined by %s",
cp, tp->u.fpath);
rv = 127;
@ -625,7 +625,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
}
old_xflag = Flag(FXTRACE);
Flag(FXTRACE) = tp->flag & TRACE ? TRUE : FALSE;
Flag(FXTRACE) = tp->flag & TRACE ? true : false;
old_inuse = tp->flag & FINUSE;
tp->flag |= FINUSE;
@ -679,11 +679,11 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
* useful error message and set the exit status to 126.
*/
if (tp->u2.errno_) {
warningf(TRUE, "%s: cannot execute - %s", cp,
warningf(true, "%s: cannot execute - %s", cp,
strerror(tp->u2.errno_));
rv = 126; /* POSIX */
} else {
warningf(TRUE, "%s: not found", cp);
warningf(true, "%s: not found", cp);
rv = 127;
}
break;
@ -831,7 +831,7 @@ define(const char *name, struct op *t)
int was_set = 0;
while (1) {
tp = findfunc(name, hash(name), TRUE);
tp = findfunc(name, hash(name), true);
if (tp->flag & ISSET)
was_set = 1;
@ -920,7 +920,7 @@ findcom(const char *name, int flags)
if ((flags & FC_SPECBI) && tbi && (tbi->flag & SPEC_BI))
tp = tbi;
if (!tp && (flags & FC_FUNC)) {
tp = findfunc(name, h, FALSE);
tp = findfunc(name, h, false);
if (tp && !(tp->flag & ISSET)) {
if ((fpath = str_val(global("FPATH"))) == null) {
tp->u.fpath = NULL;
@ -1174,7 +1174,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
X_OK | ((iop->flag & IORDUP) ? R_OK : W_OK),
&emsg)) < 0)
{
warningf(TRUE, "%s: %s",
warningf(true, "%s: %s",
snptreef(NULL, 32, "%R", &iotmp), emsg);
return -1;
}
@ -1185,7 +1185,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
}
if (do_open) {
if (Flag(FRESTRICTED) && (flags & O_CREAT)) {
warningf(TRUE, "%s: restricted", cp);
warningf(true, "%s: restricted", cp);
return -1;
}
u = open(cp, flags, 0666);
@ -1193,7 +1193,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
if (u < 0) {
/* herein() may already have printed message */
if (u == -1)
warningf(TRUE, "cannot %s %s: %s",
warningf(true, "cannot %s %s: %s",
iotype == IODUP ? "dup"
: (iotype == IOREAD || iotype == IOHERE) ?
"open" : "create", cp, strerror(errno));
@ -1217,8 +1217,8 @@ iosetup(struct ioword *iop, struct tbl *tp)
if (do_close)
close(iop->unit);
else if (u != iop->unit) {
if (ksh_dup2(u, iop->unit, TRUE) < 0) {
warningf(TRUE,
if (ksh_dup2(u, iop->unit, true) < 0) {
warningf(true,
"could not finish (dup) redirection %s: %s",
snptreef(NULL, 32, "%R", &iotmp),
strerror(errno));
@ -1258,7 +1258,7 @@ herein(const char *content, int sub)
/* ksh -c 'cat << EOF' can cause this... */
if (content == NULL) {
warningf(TRUE, "here document missing");
warningf(true, "here document missing");
return -2; /* special to iosetup(): don't print error */
}
@ -1267,7 +1267,7 @@ herein(const char *content, int sub)
*/
h = maketemp(ATEMP, TT_HEREDOC_EXP, &e->temps);
if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) < 0) {
warningf(TRUE, "can't %s temporary file %s: %s",
warningf(true, "can't %s temporary file %s: %s",
!shf ? "create" : "open",
h->name, strerror(errno));
if (shf)
@ -1300,7 +1300,7 @@ herein(const char *content, int sub)
if (shf_close(shf) == EOF) {
close(fd);
warningf(TRUE, "error writing %s: %s", h->name,
warningf(true, "error writing %s: %s", h->name,
strerror(errno));
return -2; /* special to iosetup(): don't print error */
}
@ -1313,7 +1313,7 @@ herein(const char *content, int sub)
* print the args in column form - assuming that we can
*/
static char *
do_selectargs(char **ap, bool_t print_menu)
do_selectargs(char **ap, bool print_menu)
{
static const char *const read_args[] =
{"read", "-r", "REPLY", NULL};