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

12
c_ksh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/c_ksh.c,v 2.5 2004/12/18 19:22:28 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_ksh.c,v 2.6 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: c_ksh.c,v 1.18 2004/02/10 13:03:36 jmc Exp $ */
/*
@ -13,7 +13,7 @@
#include <sys/cygwin.h>
#endif /* __CYGWIN__ */
__RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 2.5 2004/12/18 19:22:28 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 2.6 2004/12/28 22:32:08 tg Exp $");
int
c_cd(char **wp)
@ -691,7 +691,7 @@ c_typeset(char **wp)
for (i = builtin_opt.optind; wp[i]; i++) {
if (func) {
f = findfunc(wp[i], hash(wp[i]),
(fset&UCASEV_AL) ? TRUE : FALSE);
(fset&UCASEV_AL) ? true : false);
if (!f) {
/* at&t ksh does ++rval: bogus */
rval = 1;
@ -1134,7 +1134,7 @@ c_kill(char **wp)
/* assume old style options if -digits or -UPPERCASE */
if ((p = wp[1]) && *p == '-' && (digit(p[1]) || isupper(p[1]))) {
if (!(t = gettrap(p + 1, TRUE))) {
if (!(t = gettrap(p + 1, true))) {
bi_errorf("bad signal '%s'", p + 1);
return 1;
}
@ -1148,7 +1148,7 @@ c_kill(char **wp)
lflag = 1;
break;
case 's':
if (!(t = gettrap(builtin_opt.optarg, TRUE))) {
if (!(t = gettrap(builtin_opt.optarg, true))) {
bi_errorf("bad signal '%s'",
builtin_opt.optarg);
return 1;
@ -1269,7 +1269,7 @@ c_getopts(char **wp)
bi_errorf("missing name argument");
return 1;
}
if (!*var || *skip_varname(var, TRUE)) {
if (!*var || *skip_varname(var, true)) {
bi_errorf("%s: is not an identifier", var);
return 1;
}

16
c_sh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/c_sh.c,v 2.6 2004/12/28 22:22:49 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_sh.c,v 2.7 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: c_sh.c,v 1.22 2004/12/19 01:58:04 millert Exp $ */
/*
@ -10,7 +10,7 @@
#include "ksh_time.h"
#include "ksh_times.h"
__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.6 2004/12/28 22:22:49 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.7 2004/12/28 22:32:08 tg Exp $");
static char *clocktos(clock_t t);
@ -444,7 +444,7 @@ c_eval(char **wp)
exstat = subst_exstat;
}
return shell(s, FALSE);
return shell(s, false);
}
int
@ -478,13 +478,13 @@ c_trap(char **wp)
* command 'exit' isn't confused with the pseudo-signal
* 'EXIT'.
*/
s = (gettrap(*wp, FALSE) == NULL) ? *wp++ : NULL; /* get command */
s = (gettrap(*wp, false) == NULL) ? *wp++ : NULL; /* get command */
if (s != NULL && s[0] == '-' && s[1] == '\0')
s = NULL;
/* set/clear traps */
while (*wp != NULL) {
p = gettrap(*wp++, TRUE);
p = gettrap(*wp++, true);
if (p == NULL) {
bi_errorf("bad signal %s", wp[-1]);
return 1;
@ -508,7 +508,7 @@ c_exitreturn(char **wp)
if (arg) {
if (!getn(arg, &n)) {
exstat = 1;
warningf(TRUE, "%s: bad number", arg);
warningf(true, "%s: bad number", arg);
} else
exstat = n;
}
@ -573,7 +573,7 @@ c_brkcont(char **wp)
* scripts, but don't generate an error (ie, keep going).
*/
if (n == quit) {
warningf(TRUE, "%s: cannot %s", wp[0], wp[0]);
warningf(true, "%s: cannot %s", wp[0], wp[0]);
return 0;
}
/* POSIX says if n is too big, the last enclosing loop
@ -581,7 +581,7 @@ c_brkcont(char **wp)
* do anyway 'cause the user messed up.
*/
last_ep->flags &= ~EF_BRKCONT_PASS;
warningf(TRUE, "%s: can only %s %d level(s)",
warningf(true, "%s: can only %s %d level(s)",
wp[0], wp[0], n - quit);
}

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/c_test.c,v 2.3 2004/12/18 19:22:28 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_test.c,v 2.4 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */
/*
@ -14,7 +14,7 @@
#include "ksh_stat.h"
#include "c_test.h"
__RCSID("$MirBSD: src/bin/ksh/c_test.c,v 2.3 2004/12/18 19:22:28 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_test.c,v 2.4 2004/12/28 22:32:08 tg Exp $");
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
@ -338,11 +338,11 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, int do
*/
case TO_STEQL: /* = */
if (te->flags & TEF_DBRACKET)
return gmatch(opnd1, opnd2, FALSE);
return gmatch(opnd1, opnd2, false);
return strcmp(opnd1, opnd2) == 0;
case TO_STNEQ: /* != */
if (te->flags & TEF_DBRACKET)
return !gmatch(opnd1, opnd2, FALSE);
return !gmatch(opnd1, opnd2, false);
return strcmp(opnd1, opnd2) != 0;
case TO_STLT: /* < */
return strcmp(opnd1, opnd2) < 0;

26
edit.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/edit.c,v 2.5 2004/12/28 22:28:01 tg Exp $ */
/** $MirBSD: src/bin/ksh/edit.c,v 2.6 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: edit.c,v 1.23 2004/12/18 22:12:23 millert Exp $ */
/*
@ -21,7 +21,7 @@
#include <ctype.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.5 2004/12/28 22:28:01 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.6 2004/12/28 22:32:08 tg Exp $");
#if defined(TIOCGWINSZ)
static RETSIGTYPE x_sigwinch(int sig);
@ -130,14 +130,14 @@ x_read(char *buf, size_t len)
check_sigwinch();
#endif /* TIOCGWINSZ */
x_mode(TRUE);
x_mode(true);
if (Flag(FEMACS) || Flag(FGMACS))
i = x_emacs(buf, len);
else if (Flag(FVI))
i = x_vi(buf, len);
else
i = -1; /* internal error */
x_mode(FALSE);
x_mode(false);
return i;
}
@ -151,9 +151,9 @@ x_getc(void)
while ((n = blocking_read(0, &c, 1)) < 0 && errno == EINTR)
if (trap) {
x_mode(FALSE);
x_mode(false);
runtraps(0);
x_mode(TRUE);
x_mode(true);
}
if (n != 1)
return -1;
@ -179,11 +179,11 @@ x_puts(const char *s)
shf_putc(*s++, shl_out);
}
bool_t
x_mode(bool_t onoff)
bool
x_mode(bool onoff)
{
static bool_t x_cur_mode;
bool_t prev;
static bool x_cur_mode;
bool prev;
if (x_cur_mode == onoff)
return x_cur_mode;
@ -758,7 +758,7 @@ add_glob(const char *str, int slen)
{
char *toglob;
char *s;
bool_t saw_slash = FALSE;
bool saw_slash = false;
if (slen < 0)
return NULL;
@ -779,7 +779,7 @@ add_glob(const char *str, int slen)
|| (s[1] == '(' /*)*/ && strchr("*+?@!", *s)))
break;
else if (ISDIRSEP(*s))
saw_slash = TRUE;
saw_slash = true;
}
if (!*s && (*toglob != '~' || saw_slash)) {
toglob[slen] = '*';
@ -867,7 +867,7 @@ glob_table(const char *pat, XPtrV *wp, struct table *tp)
struct tbl *te;
for (twalk(&ts, tp); (te = tnext(&ts)); ) {
if (gmatch(te->name, pat, FALSE))
if (gmatch(te->name, pat, false))
XPput(*wp, str_save(te->name, ATEMP));
}
}

4
edit.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/edit.h,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/edit.h,v 2.2 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: edit.h,v 1.3 1999/11/14 22:04:02 d Exp $ */
/* $From: edit.h,v 1.2 1994/05/19 18:32:40 michael Exp michael $ */
@ -39,7 +39,7 @@ int x_getc(void);
void x_flush(void);
void x_putc(int c);
void x_puts(const char *s);
bool_t x_mode(bool_t onoff);
bool x_mode(bool onoff);
int promptlen(const char *cp, const char **spp);
int x_do_comment(char *buf, int bsize, int *lenp);
void x_print_expansions(int nwords, char *const *words, int is_command);

46
emacs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/emacs.c,v 2.5 2004/12/18 19:22:28 tg Exp $ */
/** $MirBSD: src/bin/ksh/emacs.c,v 2.6 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: emacs.c,v 1.28 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -18,7 +18,7 @@
#include <locale.h>
#include "edit.h"
__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.5 2004/12/18 19:22:28 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.6 2004/12/28 22:32:08 tg Exp $");
static Area aedit;
#define AEDIT &aedit /* area for kill ring and macro defns */
@ -315,7 +315,7 @@ x_emacs(char *buf, size_t len)
xbp = xbuf = buf; xend = buf + len;
xlp = xcp = xep = buf;
*xcp = 0;
xlp_valid = TRUE;
xlp_valid = true;
xmp = NULL;
x_curprefix = 0;
macroptr = NULL;
@ -369,7 +369,7 @@ x_emacs(char *buf, size_t len)
return i;
case KINTR: /* special case for interrupt */
trapsig(SIGINT);
x_mode(FALSE);
x_mode(false);
unwind(LSHELL);
}
}
@ -438,7 +438,7 @@ x_ins(char *s)
* x_zots() may result in a call to x_adjust()
* we want xcp to reflect the new position.
*/
xlp_valid = FALSE;
xlp_valid = false;
x_lastcp();
x_adj_ok = (xcp >= xlp);
x_zots(cp);
@ -478,7 +478,7 @@ x_del_back(int c GCC_FUNC_ATTR(unused))
if (x_arg > col)
x_arg = col;
x_goto(xcp - x_arg);
x_delete(x_arg, FALSE);
x_delete(x_arg, false);
return KSTD;
}
@ -493,7 +493,7 @@ x_del_char(int c GCC_FUNC_ATTR(unused))
}
if (x_arg > nleft)
x_arg = nleft;
x_delete(x_arg, FALSE);
x_delete(x_arg, false);
return KSTD;
}
@ -546,7 +546,7 @@ x_delete(int nc, int push)
}
/*x_goto(xcp);*/
x_adj_ok = 1;
xlp_valid = FALSE;
xlp_valid = false;
for (cp = x_lastcp(); cp > xcp; )
x_bs(*--cp);
@ -556,7 +556,7 @@ x_delete(int nc, int push)
static int
x_del_bword(int c GCC_FUNC_ATTR(unused))
{
x_delete(x_bword(), TRUE);
x_delete(x_bword(), true);
return KSTD;
}
@ -577,7 +577,7 @@ x_mv_fword(int c GCC_FUNC_ATTR(unused))
static int
x_del_fword(int c GCC_FUNC_ATTR(unused))
{
x_delete(x_fword(), TRUE);
x_delete(x_fword(), true);
return KSTD;
}
@ -855,7 +855,7 @@ x_load_hist(char **hp)
strlcpy(xbuf, *hp, xend - xbuf);
xbp = xbuf;
xep = xcp = xbuf + strlen(xbuf);
xlp_valid = FALSE;
xlp_valid = false;
if (xep > x_lastcp())
x_goto(xep);
else
@ -985,7 +985,7 @@ x_del_line(int c GCC_FUNC_ATTR(unused))
xcp = xbuf;
x_push(i);
xlp = xbp = xep = xbuf;
xlp_valid = TRUE;
xlp_valid = true;
*xcp = 0;
xmp = NULL;
x_redraw(j);
@ -1036,7 +1036,7 @@ x_redraw(int limit)
x_col = promptlen(prompt, NULL);
}
x_displen = xx_cols - 2 - x_col;
xlp_valid = FALSE;
xlp_valid = false;
cp = x_lastcp();
x_zots(xbp);
if (xbp != xbuf || xep > xlp)
@ -1162,7 +1162,7 @@ x_kill(int c GCC_FUNC_ATTR(unused))
x_goto(xbuf + x_arg);
ndel = -ndel;
}
x_delete(ndel, TRUE);
x_delete(ndel, true);
return KSTD;
}
@ -1207,7 +1207,7 @@ x_meta_yank(int c GCC_FUNC_ATTR(unused))
}
len = strlen(killstack[killtp]);
x_goto(xcp - len);
x_delete(len, FALSE);
x_delete(len, false);
do {
if (killtp == 0)
killtp = KILLSIZE - 1;
@ -1223,7 +1223,7 @@ x_abort(int c GCC_FUNC_ATTR(unused))
{
/* x_zotc(c); */
xlp = xep = xcp = xbp = xbuf;
xlp_valid = TRUE;
xlp_valid = true;
*xcp = 0;
return KINTR;
}
@ -1244,7 +1244,7 @@ x_stuffreset(int c GCC_FUNC_ATTR(unused))
#else
x_zotc(c);
xlp = xcp = xep = xbp = xbuf;
xlp_valid = TRUE;
xlp_valid = true;
*xcp = 0;
x_redraw(-1);
return KSTD;
@ -1256,7 +1256,7 @@ x_stuff(int c GCC_FUNC_ATTR(unused))
{
#if defined(TIOCSTI)
char ch = c;
bool_t savmode = x_mode(FALSE);
bool savmode = x_mode(false);
(void)ioctl(TTY, TIOCSTI, &ch);
(void)x_mode(savmode);
@ -1495,7 +1495,7 @@ x_kill_region(int c GCC_FUNC_ATTR(unused))
xr = xmp;
}
x_goto(xr);
x_delete(rsize, TRUE);
x_delete(rsize, true);
xmp = xr;
return KSTD;
}
@ -1616,7 +1616,7 @@ x_expand(int c GCC_FUNC_ATTR(unused))
}
x_goto(xbuf + start);
x_delete(end - start, FALSE);
x_delete(end - start, false);
for (i = 0; i < nwords;) {
if (x_escape(words[i], strlen(words[i]), x_emacs_putbuf) < 0 ||
(++i < nwords && x_ins(space) < 0))
@ -1662,7 +1662,7 @@ do_complete(int flags, Comp_type type)
/* complete */
if (nwords == 1 || nlen > olen) {
x_goto(xbuf + start);
x_delete(olen, FALSE);
x_delete(olen, false);
x_escape(words[0], nlen, x_emacs_putbuf);
x_adjust();
completed = 1;
@ -1707,7 +1707,7 @@ x_adjust(void)
*/
if ((xbp = xcp - (x_displen / 2)) < xbuf)
xbp = xbuf;
xlp_valid = FALSE;
xlp_valid = false;
x_redraw(xx_cols);
x_flush();
}
@ -2024,6 +2024,6 @@ x_lastcp(void)
i += x_size(*rcp);
xlp = rcp;
}
xlp_valid = TRUE;
xlp_valid = true;
return (xlp);
}

16
eval.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/eval.c,v 2.6 2004/12/18 19:27:21 tg Exp $ */
/** $MirBSD: src/bin/ksh/eval.c,v 2.7 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: eval.c,v 1.18 2004/12/13 16:37:06 millert Exp $ */
/*
@ -10,7 +10,7 @@
#include "ksh_dir.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/eval.c,v 2.6 2004/12/18 19:27:21 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/eval.c,v 2.7 2004/12/28 22:32:08 tg Exp $");
/*
* string expansion
@ -874,7 +874,7 @@ comsub(Expand *xp, char *cp)
shf = shf_fdopen(pv[0], SHF_RD, NULL);
ofd1 = savefd(1, 0); /* fd 1 may be closed... */
if (pv[1] != 1) {
ksh_dup2(pv[1], 1, FALSE);
ksh_dup2(pv[1], 1, false);
close(pv[1]);
}
execute(t, XFORK|XXCOM|XPIPEO);
@ -901,7 +901,7 @@ trimsub(char *str, char *pat, int how)
case '#': /* shortest at beginning */
for (p = str; p <= end; p++) {
c = *p; *p = '\0';
if (gmatch(str, pat, FALSE)) {
if (gmatch(str, pat, false)) {
*p = c;
return p;
}
@ -911,7 +911,7 @@ trimsub(char *str, char *pat, int how)
case '#'|0x80: /* longest match at beginning */
for (p = end; p >= str; p--) {
c = *p; *p = '\0';
if (gmatch(str, pat, FALSE)) {
if (gmatch(str, pat, false)) {
*p = c;
return p;
}
@ -920,13 +920,13 @@ trimsub(char *str, char *pat, int how)
break;
case '%': /* shortest match at end */
for (p = end; p >= str; p--) {
if (gmatch(p, pat, FALSE))
if (gmatch(p, pat, false))
return str_nsave(str, p - str, ATEMP);
}
break;
case '%'|0x80: /* longest match at end */
for (p = str; p <= end; p++) {
if (gmatch(p, pat, FALSE))
if (gmatch(p, pat, false))
return str_nsave(str, p - str, ATEMP);
}
break;
@ -1094,7 +1094,7 @@ globit(XString *xs, char **xpp, char *sp, XPtrV *wp, int check)
(name[1] == 0 || (name[1] == '.' && name[2] == 0)))
continue; /* always ignore . and .. */
if ((*name == '.' && *sp != '.')
|| !gmatch(name, sp, TRUE))
|| !gmatch(name, sp, true))
continue;
len = NLENGTH(d) + 1;

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};

24
expr.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/expr.c,v 2.4 2004/12/18 19:22:29 tg Exp $ */
/** $MirBSD: src/bin/ksh/expr.c,v 2.5 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: expr.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -8,7 +8,7 @@
#include "sh.h"
#include <ctype.h>
__RCSID("$MirBSD: src/bin/ksh/expr.c,v 2.4 2004/12/18 19:22:29 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/expr.c,v 2.5 2004/12/28 22:32:08 tg Exp $");
/* The order of these enums is constrained by the order of opinfo[] */
enum token {
@ -132,7 +132,7 @@ static void evalerr(Expr_state *es, enum error_type type,
static struct tbl *evalexpr(Expr_state *es, enum prec prec);
static void token(Expr_state *es);
static struct tbl *do_ppmm(Expr_state *es, enum token op,
struct tbl *vasn, bool_t is_prefix);
struct tbl *vasn, bool is_prefix);
static void assign_check(Expr_state *es, enum token op,
struct tbl *vasn);
static struct tbl *tempvar(void);
@ -233,31 +233,31 @@ evalerr(Expr_state *es, enum error_type type, const char *str)
default:
s = opinfo[(int)es->tok].name;
}
warningf(TRUE, "%s: unexpected '%s'", es->expression, s);
warningf(true, "%s: unexpected '%s'", es->expression, s);
break;
case ET_BADLIT:
warningf(TRUE, "%s: bad number '%s'", es->expression, str);
warningf(true, "%s: bad number '%s'", es->expression, str);
break;
case ET_RECURSIVE:
warningf(TRUE, "%s: expression recurses on parameter '%s'",
warningf(true, "%s: expression recurses on parameter '%s'",
es->expression, str);
break;
case ET_LVALUE:
warningf(TRUE, "%s: %s requires lvalue",
warningf(true, "%s: %s requires lvalue",
es->expression, str);
break;
case ET_RDONLY:
warningf(TRUE, "%s: %s applied to read only variable",
warningf(true, "%s: %s applied to read only variable",
es->expression, str);
break;
default: /* keep gcc happy */
case ET_STR:
warningf(TRUE, "%s: %s", es->expression, str);
warningf(true, "%s: %s", es->expression, str);
break;
}
unwind(LAEXPR);
@ -292,7 +292,7 @@ evalexpr(Expr_state *es, enum prec prec)
token(es);
} else if (op == O_PLUSPLUS || op == O_MINUSMINUS) {
token(es);
vl = do_ppmm(es, op, es->val, TRUE);
vl = do_ppmm(es, op, es->val, true);
token(es);
} else if (op == VAR || op == LIT) {
vl = es->val;
@ -302,7 +302,7 @@ evalexpr(Expr_state *es, enum prec prec)
/*NOTREACHED*/
}
if (es->tok == O_PLUSPLUS || es->tok == O_MINUSMINUS) {
vl = do_ppmm(es, es->tok, vl, FALSE);
vl = do_ppmm(es, es->tok, vl, false);
token(es);
}
return vl;
@ -513,7 +513,7 @@ token(Expr_state *es)
/* Do a ++ or -- operation */
static struct tbl *
do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool_t is_prefix)
do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool is_prefix)
{
struct tbl *vl;
int oval;

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/history.c,v 2.6 2004/12/18 19:22:29 tg Exp $ */
/** $MirBSD: src/bin/ksh/history.c,v 2.7 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: history.c,v 1.24 2004/08/03 12:44:59 danh Exp $ */
/*
@ -21,7 +21,7 @@
#include "sh.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/history.c,v 2.6 2004/12/18 19:22:29 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/history.c,v 2.7 2004/12/28 22:32:08 tg Exp $");
#ifndef EASY_HISTORY
/* Defines and includes for the complicated case */
@ -153,8 +153,8 @@ c_fc(char **wp)
return 1;
}
hp = first ? hist_get(first, FALSE, FALSE)
: hist_get_newest(FALSE);
hp = first ? hist_get(first, false, false)
: hist_get_newest(false);
if (!hp)
return 1;
return hist_replace(hp, pat, rep, gflag);
@ -174,23 +174,23 @@ c_fc(char **wp)
return 1;
}
if (!first) {
hfirst = lflag ? hist_get("-16", TRUE, TRUE)
: hist_get_newest(FALSE);
hfirst = lflag ? hist_get("-16", true, true)
: hist_get_newest(false);
if (!hfirst)
return 1;
/* can't fail if hfirst didn't fail */
hlast = hist_get_newest(FALSE);
hlast = hist_get_newest(false);
} else {
/* POSIX says not an error if first/last out of bounds
* when range is specified; at&t ksh and pdksh allow out of
* bounds for -l as well.
*/
hfirst = hist_get(first, (lflag || last) ? TRUE : FALSE,
lflag ? TRUE : FALSE);
hfirst = hist_get(first, (lflag || last) ? true : false,
lflag ? true : false);
if (!hfirst)
return 1;
hlast = last ? hist_get(last, TRUE, lflag ? TRUE : FALSE)
: (lflag ? hist_get_newest(FALSE) : hfirst);
hlast = last ? hist_get(last, true, lflag ? true : false)
: (lflag ? hist_get_newest(false) : hfirst);
if (!hlast)
return 1;
}
@ -237,7 +237,7 @@ c_fc(char **wp)
}
/* Ignore setstr errors here (arbitrary) */
setstr(local("_", FALSE), tf->name, KSH_RETURN_ERROR);
setstr(local("_", false), tf->name, KSH_RETURN_ERROR);
/* XXX: source should not get trashed by this.. */
{
@ -300,7 +300,7 @@ hist_execute(char *cmd)
}
#ifdef EASY_HISTORY
if (p != cmd)
histappend(p, TRUE);
histappend(p, true);
else
#endif /* EASY_HISTORY */
histsave(++(hist_source->line), p, 1);

10
io.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/io.c,v 2.4 2004/12/18 19:22:29 tg Exp $ */
/** $MirBSD: src/bin/ksh/io.c,v 2.5 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
/*
@ -25,7 +25,7 @@ errorf(const char *fmt, ...)
shl_stdout_ok = 0; /* debugging: note that stdout not valid */
exstat = 1;
if (*fmt) {
error_prefix(TRUE);
error_prefix(true);
SH_VA_START(va, fmt);
shf_vfprintf(shl_out, fmt, va);
va_end(va);
@ -60,7 +60,7 @@ bi_errorf(const char *fmt, ...)
shl_stdout_ok = 0; /* debugging: note that stdout not valid */
exstat = 1;
if (*fmt) {
error_prefix(TRUE);
error_prefix(true);
/* not set when main() calls parse_args() */
if (builtin_argv0)
shf_fprintf(shl_out, "%s: ", builtin_argv0);
@ -88,7 +88,7 @@ internal_errorf(int jump, const char *fmt, ...)
{
va_list va;
error_prefix(TRUE);
error_prefix(true);
shf_fprintf(shl_out, "internal error: ");
SH_VA_START(va, fmt);
shf_vfprintf(shl_out, fmt, va);
@ -271,7 +271,7 @@ restfd(int fd, int ofd)
if (ofd < 0) /* original fd closed */
close(fd);
else if (fd != ofd) {
ksh_dup2(ofd, fd, TRUE); /* XXX: what to do if this fails? */
ksh_dup2(ofd, fd, true); /* XXX: what to do if this fails? */
close(ofd);
}
}

32
jobs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/jobs.c,v 2.5 2004/12/28 22:28:01 tg Exp $ */
/** $MirBSD: src/bin/ksh/jobs.c,v 2.6 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: jobs.c,v 1.26 2004/12/18 22:12:23 millert Exp $ */
/*
@ -31,7 +31,7 @@
#include "ksh_times.h"
#include "tty.h"
__RCSID("$MirBSD: src/bin/ksh/jobs.c,v 2.5 2004/12/28 22:28:01 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/jobs.c,v 2.6 2004/12/28 22:32:08 tg Exp $");
/* Start of system configuration stuff */
@ -272,7 +272,7 @@ j_init(int mflagset)
else
#endif /* JOBS */
if (Flag(FTALKING))
tty_init(TRUE);
tty_init(true);
}
/* job cleanup before shell exit */
@ -340,14 +340,14 @@ j_change(void)
if (Flag(FMONITOR)) {
/* Don't call get_tty() 'til we own the tty process group */
tty_init(FALSE);
tty_init(false);
# ifdef TTY_PGRP
/* no controlling tty, no SIGT* */
ttypgrp_ok = tty_fd >= 0 && tty_devtty;
if (ttypgrp_ok && (our_pgrp = getpgID()) < 0) {
warningf(FALSE, "j_init: getpgrp() failed: %s",
warningf(false, "j_init: getpgrp() failed: %s",
strerror(errno));
ttypgrp_ok = 0;
}
@ -359,7 +359,7 @@ j_change(void)
pid_t ttypgrp;
if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) {
warningf(FALSE,
warningf(false,
"j_init: tcgetpgrp() failed: %s",
strerror(errno));
ttypgrp_ok = 0;
@ -375,13 +375,13 @@ j_change(void)
SS_RESTORE_DFL|SS_FORCE);
if (ttypgrp_ok && our_pgrp != kshpid) {
if (setpgid(0, kshpid) < 0) {
warningf(FALSE,
warningf(false,
"j_init: setpgid() failed: %s",
strerror(errno));
ttypgrp_ok = 0;
} else {
if (tcsetpgrp(tty_fd, kshpid) < 0) {
warningf(FALSE,
warningf(false,
"j_init: tcsetpgrp() failed: %s",
strerror(errno));
ttypgrp_ok = 0;
@ -395,13 +395,13 @@ j_change(void)
int ldisc = NTTYDISC;
if (ioctl(tty_fd, TIOCSETD, &ldisc) < 0)
warningf(FALSE,
warningf(false,
"j_init: can't set new line discipline: %s",
strerror(errno));
}
# endif /* NTTYDISC && TIOCSETD */
if (!ttypgrp_ok)
warningf(FALSE, "warning: won't have full job control");
warningf(false, "warning: won't have full job control");
# endif /* TTY_PGRP */
if (tty_fd >= 0)
get_tty(tty_fd, &tty_state);
@ -595,7 +595,7 @@ exchild(struct op *t, int flags, int close_fd)
if (ischild) { /* child */
/* Do this before restoring signal */
if (flags & XCOPROC)
coproc_cleanup(FALSE);
coproc_cleanup(false);
#ifdef JOB_SIGS
sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */
@ -623,7 +623,7 @@ exchild(struct op *t, int flags, int close_fd)
if (!(flags & (XPIPEI | XCOPROC))) {
int fd = open("/dev/null", 0);
if (fd != 0) {
(void) ksh_dup2(fd, 0, TRUE);
(void) ksh_dup2(fd, 0, true);
close(fd);
}
}
@ -714,7 +714,7 @@ waitlast(void)
j = last_job;
if (!j || !(j->flags & JF_STARTED)) {
if (!j)
warningf(TRUE, "waitlast: no last job");
warningf(true, "waitlast: no last job");
else
internal_errorf(0, "waitlast: not started");
#ifdef JOB_SIGS
@ -919,7 +919,7 @@ j_resume(const char *cp, int bg)
set_tty(tty_fd, &tty_state, TF_NONE);
}
if (ttypgrp_ok && tcsetpgrp(tty_fd, our_pgrp) < 0) {
warningf(TRUE,
warningf(true,
"fg: 2nd tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) our_pgrp,
strerror(errno));
@ -1209,7 +1209,7 @@ j_waitj(Job *j, int flags, const char *where)
&& (j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0)
j->flags |= JF_SAVEDTTYPGRP;
if (tcsetpgrp(tty_fd, our_pgrp) < 0) {
warningf(TRUE,
warningf(true,
"j_waitj: tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) our_pgrp,
strerror(errno));
@ -1330,7 +1330,7 @@ j_sigchld(int sig GCC_FUNC_ATTR(unused))
found:
if (j == NULL) {
/* Can occur if process has kids, then execs shell
warningf(TRUE, "bad process waited for (pid = %d)",
warningf(true, "bad process waited for (pid = %d)",
pid);
*/
t0 = t1;

8
lex.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/lex.c,v 2.6 2004/12/18 19:22:29 tg Exp $ */
/** $MirBSD: src/bin/ksh/lex.c,v 2.7 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: lex.c,v 1.18 2003/08/06 21:08:05 millert Exp $ */
/*
@ -8,7 +8,7 @@
#include "sh.h"
#include <ctype.h>
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.6 2004/12/18 19:22:29 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.7 2004/12/28 22:32:08 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state.
@ -162,7 +162,7 @@ yylex(int cf)
case SBASE:
if (c == '[' && (cf & (VARASN|ARRAYVAR))) {
*wp = EOS; /* temporary */
if (is_wdvarname(Xstring(ws, wp), FALSE))
if (is_wdvarname(Xstring(ws, wp), false))
{
char *p, *tmp;
@ -831,7 +831,7 @@ yyerror(const char *fmt, ...)
source = source->next;
source->str = null; /* zap pending input */
error_prefix(TRUE);
error_prefix(true);
SH_VA_START(va, fmt);
shf_vfprintf(shl_out, fmt, va);
va_end(va);

12
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/main.c,v 2.11 2004/12/18 19:27:21 tg Exp $ */
/** $MirBSD: src/bin/ksh/main.c,v 2.12 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
/*
@ -15,7 +15,7 @@
* shell version
*/
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.11 2004/12/18 19:27:21 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.12 2004/12/28 22:32:08 tg Exp $");
const char ksh_version[] =
"@(#)PD KSH v5.2.14 MirOS R20 in "
@ -332,7 +332,7 @@ main(int argc, char *argv[])
* user will know why things broke.
*/
if (!current_wd[0] && Flag(FTALKING))
warningf(FALSE, "Cannot determine current working directory");
warningf(false, "Cannot determine current working directory");
if (Flag(FLOGIN)) {
include(KSH_SYSTEM_PROFILE, 0, NULL, 1);
@ -380,7 +380,7 @@ main(int argc, char *argv[])
} else
Flag(FTRACKALL) = 1; /* set after ENV */
shell(s, TRUE); /* doesn't return */
shell(s, true); /* doesn't return */
return 0;
}
@ -440,7 +440,7 @@ include(const char *name, int argc, char **argv, int intr_ok)
s = pushs(SFILE, ATEMP);
s->u.shf = shf;
s->file = str_save(name, ATEMP);
i = shell(s, FALSE);
i = shell(s, false);
quitenv(s->u.shf);
if (old_argv) {
e->loc->argv = old_argv;
@ -456,7 +456,7 @@ command(const char *comm)
s = pushs(SSTRING, ATEMP);
s->start = s->str = comm;
return shell(s, FALSE);
return shell(s, false);
}
/*

10
misc.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/misc.c,v 2.7 2004/12/18 19:27:21 tg Exp $ */
/** $MirBSD: src/bin/ksh/misc.c,v 2.8 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -13,7 +13,7 @@
#include <sys/ioctl.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.7 2004/12/18 19:27:21 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.8 2004/12/28 22:32:08 tg Exp $");
#ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF
@ -439,7 +439,7 @@ parse_args(char **argv, int what, int *setargsp)
*setargsp = !arrayset && ((go.info & GI_MINUSMINUS)
|| argv[go.optind]);
if (arrayset && (!*array || *skip_varname(array, FALSE))) {
if (arrayset && (!*array || *skip_varname(array, false))) {
bi_errorf("%s: is not an identifier", array);
return -1;
}
@ -955,7 +955,7 @@ ksh_getopt(char **argv, Getopt *go, const char *options)
go->buf[0] = c;
go->optarg = go->buf;
} else {
warningf(TRUE, "%s%s-%c: unknown option",
warningf(true, "%s%s-%c: unknown option",
(go->flags & GF_NONAME) ? "" : argv[0],
(go->flags & GF_NONAME) ? "" : ": ", c);
if (go->flags & GF_ERROR)
@ -981,7 +981,7 @@ ksh_getopt(char **argv, Getopt *go, const char *options)
go->optarg = go->buf;
return ':';
}
warningf(TRUE, "%s%s-'%c' requires argument",
warningf(true, "%s%s-'%c' requires argument",
(go->flags & GF_NONAME) ? "" : argv[0],
(go->flags & GF_NONAME) ? "" : ": ", c);
if (go->flags & GF_ERROR)

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/proto.h,v 2.5 2004/12/18 19:17:10 tg Exp $ */
/** $MirBSD: src/bin/ksh/proto.h,v 2.6 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: proto.h,v 1.11 2003/05/16 19:58:57 jsyn Exp $ */
/* $From: proto.h,v 1.3 1994/05/19 18:32:40 michael Exp michael $ */
@ -252,7 +252,7 @@ void newblock(void);
void popblock(void);
void initvar(void);
struct tbl * global(const char *n);
struct tbl * local(const char *n, bool_t copy);
struct tbl * local(const char *n, bool copy);
char * str_val(struct tbl *vp);
long intval(struct tbl *vp);
int setstr(struct tbl *vq, const char *s, int error_ok);

6
sh.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/sh.h,v 2.7 2004/12/28 22:28:01 tg Exp $ */
/** $MirBSD: src/bin/ksh/sh.h,v 2.8 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: sh.h,v 1.23 2004/12/18 22:11:43 millert Exp $ */
#ifndef SH_H
@ -293,10 +293,6 @@ extern int dup2(int, int);
# define ksh_strchr_dirsep(p) strchr(p, DIRSEP)
# define ksh_strrchr_dirsep(p) strrchr(p, DIRSEP)
typedef int bool_t;
#define FALSE 0
#define TRUE 1
#define NELEM(a) (sizeof(a) / sizeof((a)[0]))
#define sizeofN(type, n) (sizeof(type) * (n))
#define BIT(i) (1<<(i)) /* define bit in flag */

80
syn.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/syn.c,v 2.4 2004/12/18 19:22:30 tg Exp $ */
/** $MirBSD: src/bin/ksh/syn.c,v 2.5 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: syn.c,v 1.14 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -8,7 +8,7 @@
#include "sh.h"
#include "c_test.h"
__RCSID("$MirBSD: src/bin/ksh/syn.c,v 2.4 2004/12/18 19:22:30 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/syn.c,v 2.5 2004/12/28 22:32:08 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */
@ -188,7 +188,7 @@ nested(int type, int smark, int emark)
struct nesting_state old_nesting;
nesting_push(&old_nesting, smark);
t = c_list(TRUE);
t = c_list(true);
musthave(emark, KEYWORD|ALIAS);
nesting_pop(&old_nesting);
return (block(type, t, NOBLOCK, NOWORDS));
@ -265,7 +265,7 @@ get_command(int cf)
ACCEPT;
/*(*/
musthave(')', 0);
t = function_body(XPptrv(args)[0], FALSE);
t = function_body(XPptrv(args)[0], false);
goto Leave;
default:
@ -320,7 +320,7 @@ get_command(int cf)
case SELECT:
t = newtp((c == FOR) ? TFOR : TSELECT);
musthave(LWORD, ARRAYVAR);
if (!is_wdvarname(yylval.cp, TRUE))
if (!is_wdvarname(yylval.cp, true))
yyerror("%s: bad identifier\n",
c == FOR ? "for" : "select");
t->str = str_save(ident, ATEMP);
@ -334,7 +334,7 @@ get_command(int cf)
case UNTIL:
nesting_push(&old_nesting, c);
t = newtp((c == WHILE) ? TWHILE : TUNTIL);
t->left = c_list(TRUE);
t->left = c_list(true);
t->right = dogroup();
nesting_pop(&old_nesting);
break;
@ -351,7 +351,7 @@ get_command(int cf)
case IF:
nesting_push(&old_nesting, c);
t = newtp(TIF);
t->left = c_list(TRUE);
t->left = c_list(true);
t->right = thenpart();
musthave(FI, KEYWORD|ALIAS);
nesting_pop(&old_nesting);
@ -373,7 +373,7 @@ get_command(int cf)
case FUNCTION:
musthave(LWORD, 0);
t = function_body(yylval.cp, TRUE);
t = function_body(yylval.cp, true);
break;
}
@ -424,7 +424,7 @@ dogroup(void)
c = '}';
else
syntaxerr(NULL);
list = c_list(TRUE);
list = c_list(true);
musthave(c, KEYWORD|ALIAS);
return list;
}
@ -436,7 +436,7 @@ thenpart(void)
musthave(THEN, KEYWORD|ALIAS);
t = newtp(0);
t->left = c_list(TRUE);
t->left = c_list(true);
if (t->left == NULL)
syntaxerr(NULL);
t->right = elsepart();
@ -450,13 +450,13 @@ elsepart(void)
switch (token(KEYWORD|ALIAS|VARASN)) {
case ELSE:
if ((t = c_list(TRUE)) == NULL)
if ((t = c_list(true)) == NULL)
syntaxerr(NULL);
return (t);
case ELIF:
t = newtp(TELIF);
t->left = c_list(TRUE);
t->left = c_list(true);
t->right = thenpart();
return (t);
@ -513,7 +513,7 @@ casepart(int endtok)
t->vars = (char **) XPclose(ptns);
musthave(')', 0);
t->left = c_list(TRUE);
t->left = c_list(true);
/* Note: Posix requires the ;; */
if ((tpeek(CONTIN|KEYWORD|ALIAS)) != endtok)
musthave(BREAK, CONTIN|KEYWORD|ALIAS);
@ -629,35 +629,35 @@ const struct tokeninfo {
short reserved;
} tokentab[] = {
/* Reserved words */
{ "if", IF, TRUE },
{ "then", THEN, TRUE },
{ "else", ELSE, TRUE },
{ "elif", ELIF, TRUE },
{ "fi", FI, TRUE },
{ "case", CASE, TRUE },
{ "esac", ESAC, TRUE },
{ "for", FOR, TRUE },
{ "select", SELECT, TRUE },
{ "while", WHILE, TRUE },
{ "until", UNTIL, TRUE },
{ "do", DO, TRUE },
{ "done", DONE, TRUE },
{ "in", IN, TRUE },
{ "function", FUNCTION, TRUE },
{ "time", TIME, TRUE },
{ "{", '{', TRUE },
{ "}", '}', TRUE },
{ "!", BANG, TRUE },
{ "[[", DBRACKET, TRUE },
{ "if", IF, true },
{ "then", THEN, true },
{ "else", ELSE, true },
{ "elif", ELIF, true },
{ "fi", FI, true },
{ "case", CASE, true },
{ "esac", ESAC, true },
{ "for", FOR, true },
{ "select", SELECT, true },
{ "while", WHILE, true },
{ "until", UNTIL, true },
{ "do", DO, true },
{ "done", DONE, true },
{ "in", IN, true },
{ "function", FUNCTION, true },
{ "time", TIME, true },
{ "{", '{', true },
{ "}", '}', true },
{ "!", BANG, true },
{ "[[", DBRACKET, true },
/* Lexical tokens (0[EOF], LWORD and REDIR handled specially) */
{ "&&", LOGAND, FALSE },
{ "||", LOGOR, FALSE },
{ ";;", BREAK, FALSE },
{ "((", MDPAREN, FALSE },
{ "|&", COPROC, FALSE },
{ "&&", LOGAND, false },
{ "||", LOGOR, false },
{ ";;", BREAK, false },
{ "((", MDPAREN, false },
{ "|&", COPROC, false },
/* and some special cases... */
{ "newline", '\n', FALSE },
{ NULL, 0, FALSE }
{ "newline", '\n', false },
{ NULL, 0, false }
};
void

6
trap.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/trap.c,v 2.3 2004/12/18 19:22:30 tg Exp $ */
/** $MirBSD: src/bin/ksh/trap.c,v 2.4 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: trap.c,v 1.13 2003/02/28 09:45:09 jmc Exp $ */
/*
@ -9,7 +9,7 @@
#define FROM_TRAP_C
#include "sh.h"
__RCSID("$MirBSD: src/bin/ksh/trap.c,v 2.3 2004/12/18 19:22:30 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/trap.c,v 2.4 2004/12/28 22:32:08 tg Exp $");
/* Table is indexed by signal number
*
@ -200,7 +200,7 @@ runtraps(int flag)
if (ksh_tmout_state == TMOUT_LEAVING) {
ksh_tmout_state = TMOUT_EXECUTING;
warningf(FALSE, "timed out waiting for input");
warningf(false, "timed out waiting for input");
unwind(LEXIT);
} else
/* XXX: this means the alarm will have no effect if a trap

12
tty.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/tty.c,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/tty.c,v 2.2 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */
#include "sh.h"
@ -7,7 +7,7 @@
#include "tty.h"
#undef EXTERN
__RCSID("$MirBSD: src/bin/ksh/tty.c,v 2.1 2004/12/10 18:09:42 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/tty.c,v 2.2 2004/12/28 22:32:08 tg Exp $");
int
get_tty(int fd, TTY_state *ts)
@ -131,7 +131,7 @@ tty_init(int init_ttystate)
# if !defined(__mips) || !(defined(_SYSTYPE_BSD43) || defined(__SYSTYPE_BSD43))
if (tfd < 0) {
tty_devtty = 0;
warningf(FALSE,
warningf(false,
"No controlling tty (open /dev/tty: %s)",
strerror(errno));
}
@ -148,15 +148,15 @@ tty_init(int init_ttystate)
else if (isatty(2))
tfd = 2;
else {
warningf(FALSE, "Can't find tty file descriptor");
warningf(false, "Can't find tty file descriptor");
return;
}
}
if ((tty_fd = ksh_dupbase(tfd, FDBASE)) < 0) {
warningf(FALSE, "j_ttyinit: dup of tty fd failed: %s",
warningf(false, "j_ttyinit: dup of tty fd failed: %s",
strerror(errno));
} else if (fd_clexec(tty_fd) < 0) {
warningf(FALSE, "j_ttyinit: can't set close-on-exec flag: %s",
warningf(false, "j_ttyinit: can't set close-on-exec flag: %s",
strerror(errno));
close(tty_fd);
tty_fd = -1;

30
var.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/var.c,v 2.5 2004/12/18 19:22:30 tg Exp $ */
/** $MirBSD: src/bin/ksh/var.c,v 2.6 2004/12/28 22:32:08 tg Exp $ */
/* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */
#include "sh.h"
@ -7,7 +7,7 @@
#include "ksh_stat.h"
#include <ctype.h>
__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.5 2004/12/18 19:22:30 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.6 2004/12/28 22:32:08 tg Exp $");
/*
* Variables
@ -119,22 +119,22 @@ initvar(void)
* non-zero if this is an array, sets *valp to the array index, returns
* the basename of the array.
*/
static const char *array_index_calc(const char *, bool_t *, int *);
static const char *array_index_calc(const char *, bool *, int *);
static const char *
array_index_calc(const char *n, bool_t *arrayp, int *valp)
array_index_calc(const char *n, bool *arrayp, int *valp)
{
const char *p;
int len;
*arrayp = FALSE;
p = skip_varname(n, FALSE);
*arrayp = false;
p = skip_varname(n, false);
if (p != n && *p == '[' && (len = array_ref_len(p))) {
char *sub, *tmp;
long rval;
/* Calculate the value of the subscript */
*arrayp = TRUE;
*arrayp = true;
tmp = str_nsave(p+1, len-2, ATEMP);
sub = substitute(tmp, 0);
afree(tmp, ATEMP);
@ -158,7 +158,7 @@ global(const char *n)
struct tbl *vp;
int c;
unsigned h;
bool_t array;
bool array;
int val;
/* Check to see if this is an array */
@ -234,12 +234,12 @@ global(const char *n)
* Search for local variable, if not found create locally.
*/
struct tbl *
local(const char *n, bool_t copy)
local(const char *n, bool copy)
{
struct block *l = e->loc;
struct tbl *vp;
unsigned h;
bool_t array;
bool array;
int val;
/* Check to see if this is an array */
@ -345,7 +345,7 @@ setstr(struct tbl *vq, const char *s, int error_ok)
int no_ro_check = error_ok & 0x4;
error_ok &= ~0x4;
if ((vq->flag & RDONLY) && !no_ro_check) {
warningf(TRUE, "%s: is read only", vq->name);
warningf(true, "%s: is read only", vq->name);
if (!error_ok)
errorf(null);
return 0;
@ -355,7 +355,7 @@ setstr(struct tbl *vq, const char *s, int error_ok)
/* debugging */
if (s >= vq->val.s
&& s <= vq->val.s + strlen(vq->val.s))
internal_errorf(TRUE,
internal_errorf(true,
"setstr: %s=%s: assigning to self",
vq->name, s);
afree((void*)vq->val.s, vq->areap);
@ -571,7 +571,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
const char *val;
/* check for valid variable name, search for value */
val = skip_varname(var, FALSE);
val = skip_varname(var, false);
if (val == var)
return NULL;
if (*val == '[') {
@ -610,7 +610,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
|| strcmp(tvar, "SHELL") == 0))
errorf("%s: restricted", tvar);
vp = (set&LOCAL) ? local(tvar, (set & LOCAL_COPY) ? TRUE : FALSE)
vp = (set&LOCAL) ? local(tvar, (set & LOCAL_COPY) ? true : false)
: global(tvar);
set &= ~(LOCAL|LOCAL_COPY);
@ -801,7 +801,7 @@ is_wdvarname(const char *s, int aok)
int
is_wdvarassign(const char *s)
{
char *p = skip_wdvarname(s, TRUE);
char *p = skip_wdvarname(s, true);
return p != s && p[0] == CHAR && p[1] == '=';
}

6
vi.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/vi.c,v 2.4 2004/12/18 19:22:30 tg Exp $ */
/** $MirBSD: src/bin/ksh/vi.c,v 2.5 2004/12/28 22:32:09 tg Exp $ */
/* $OpenBSD: vi.c,v 1.13 2004/05/10 16:28:47 pvalchev Exp $ */
/*
@ -14,7 +14,7 @@
#include "ksh_stat.h" /* completion */
#include "edit.h"
__RCSID("$MirBSD: src/bin/ksh/vi.c,v 2.4 2004/12/18 19:22:30 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/vi.c,v 2.5 2004/12/28 22:32:09 tg Exp $");
#define Ctrl(c) (c&0x1f)
#define is_wordch(c) (letnum(c))
@ -219,7 +219,7 @@ x_vi(char *buf, size_t len)
x_vi_zotc(c);
x_flush();
trapsig(c == edchars.intr ? SIGINT : SIGQUIT);
x_mode(FALSE);
x_mode(false);
unwind(LSHELL);
} else if (c == edchars.eof && state != VVERSION) {
if (es->linelen == 0) {