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 $ */ /* $OpenBSD: c_ksh.c,v 1.18 2004/02/10 13:03:36 jmc Exp $ */
/* /*
@ -13,7 +13,7 @@
#include <sys/cygwin.h> #include <sys/cygwin.h>
#endif /* __CYGWIN__ */ #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 int
c_cd(char **wp) c_cd(char **wp)
@ -691,7 +691,7 @@ c_typeset(char **wp)
for (i = builtin_opt.optind; wp[i]; i++) { for (i = builtin_opt.optind; wp[i]; i++) {
if (func) { if (func) {
f = findfunc(wp[i], hash(wp[i]), f = findfunc(wp[i], hash(wp[i]),
(fset&UCASEV_AL) ? TRUE : FALSE); (fset&UCASEV_AL) ? true : false);
if (!f) { if (!f) {
/* at&t ksh does ++rval: bogus */ /* at&t ksh does ++rval: bogus */
rval = 1; rval = 1;
@ -1134,7 +1134,7 @@ c_kill(char **wp)
/* assume old style options if -digits or -UPPERCASE */ /* assume old style options if -digits or -UPPERCASE */
if ((p = wp[1]) && *p == '-' && (digit(p[1]) || isupper(p[1]))) { 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); bi_errorf("bad signal '%s'", p + 1);
return 1; return 1;
} }
@ -1148,7 +1148,7 @@ c_kill(char **wp)
lflag = 1; lflag = 1;
break; break;
case 's': case 's':
if (!(t = gettrap(builtin_opt.optarg, TRUE))) { if (!(t = gettrap(builtin_opt.optarg, true))) {
bi_errorf("bad signal '%s'", bi_errorf("bad signal '%s'",
builtin_opt.optarg); builtin_opt.optarg);
return 1; return 1;
@ -1269,7 +1269,7 @@ c_getopts(char **wp)
bi_errorf("missing name argument"); bi_errorf("missing name argument");
return 1; return 1;
} }
if (!*var || *skip_varname(var, TRUE)) { if (!*var || *skip_varname(var, true)) {
bi_errorf("%s: is not an identifier", var); bi_errorf("%s: is not an identifier", var);
return 1; 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 $ */ /* $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_time.h"
#include "ksh_times.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); static char *clocktos(clock_t t);
@ -444,7 +444,7 @@ c_eval(char **wp)
exstat = subst_exstat; exstat = subst_exstat;
} }
return shell(s, FALSE); return shell(s, false);
} }
int int
@ -478,13 +478,13 @@ c_trap(char **wp)
* command 'exit' isn't confused with the pseudo-signal * command 'exit' isn't confused with the pseudo-signal
* 'EXIT'. * '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') if (s != NULL && s[0] == '-' && s[1] == '\0')
s = NULL; s = NULL;
/* set/clear traps */ /* set/clear traps */
while (*wp != NULL) { while (*wp != NULL) {
p = gettrap(*wp++, TRUE); p = gettrap(*wp++, true);
if (p == NULL) { if (p == NULL) {
bi_errorf("bad signal %s", wp[-1]); bi_errorf("bad signal %s", wp[-1]);
return 1; return 1;
@ -508,7 +508,7 @@ c_exitreturn(char **wp)
if (arg) { if (arg) {
if (!getn(arg, &n)) { if (!getn(arg, &n)) {
exstat = 1; exstat = 1;
warningf(TRUE, "%s: bad number", arg); warningf(true, "%s: bad number", arg);
} else } else
exstat = n; exstat = n;
} }
@ -573,7 +573,7 @@ c_brkcont(char **wp)
* scripts, but don't generate an error (ie, keep going). * scripts, but don't generate an error (ie, keep going).
*/ */
if (n == quit) { if (n == quit) {
warningf(TRUE, "%s: cannot %s", wp[0], wp[0]); warningf(true, "%s: cannot %s", wp[0], wp[0]);
return 0; return 0;
} }
/* POSIX says if n is too big, the last enclosing loop /* 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. * do anyway 'cause the user messed up.
*/ */
last_ep->flags &= ~EF_BRKCONT_PASS; 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); 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 $ */ /* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */
/* /*
@ -14,7 +14,7 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include "c_test.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: /* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ; 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: /* = */ case TO_STEQL: /* = */
if (te->flags & TEF_DBRACKET) if (te->flags & TEF_DBRACKET)
return gmatch(opnd1, opnd2, FALSE); return gmatch(opnd1, opnd2, false);
return strcmp(opnd1, opnd2) == 0; return strcmp(opnd1, opnd2) == 0;
case TO_STNEQ: /* != */ case TO_STNEQ: /* != */
if (te->flags & TEF_DBRACKET) if (te->flags & TEF_DBRACKET)
return !gmatch(opnd1, opnd2, FALSE); return !gmatch(opnd1, opnd2, false);
return strcmp(opnd1, opnd2) != 0; return strcmp(opnd1, opnd2) != 0;
case TO_STLT: /* < */ case TO_STLT: /* < */
return strcmp(opnd1, opnd2) < 0; 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 $ */ /* $OpenBSD: edit.c,v 1.23 2004/12/18 22:12:23 millert Exp $ */
/* /*
@ -21,7 +21,7 @@
#include <ctype.h> #include <ctype.h>
#include "ksh_stat.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) #if defined(TIOCGWINSZ)
static RETSIGTYPE x_sigwinch(int sig); static RETSIGTYPE x_sigwinch(int sig);
@ -130,14 +130,14 @@ x_read(char *buf, size_t len)
check_sigwinch(); check_sigwinch();
#endif /* TIOCGWINSZ */ #endif /* TIOCGWINSZ */
x_mode(TRUE); x_mode(true);
if (Flag(FEMACS) || Flag(FGMACS)) if (Flag(FEMACS) || Flag(FGMACS))
i = x_emacs(buf, len); i = x_emacs(buf, len);
else if (Flag(FVI)) else if (Flag(FVI))
i = x_vi(buf, len); i = x_vi(buf, len);
else else
i = -1; /* internal error */ i = -1; /* internal error */
x_mode(FALSE); x_mode(false);
return i; return i;
} }
@ -151,9 +151,9 @@ x_getc(void)
while ((n = blocking_read(0, &c, 1)) < 0 && errno == EINTR) while ((n = blocking_read(0, &c, 1)) < 0 && errno == EINTR)
if (trap) { if (trap) {
x_mode(FALSE); x_mode(false);
runtraps(0); runtraps(0);
x_mode(TRUE); x_mode(true);
} }
if (n != 1) if (n != 1)
return -1; return -1;
@ -179,11 +179,11 @@ x_puts(const char *s)
shf_putc(*s++, shl_out); shf_putc(*s++, shl_out);
} }
bool_t bool
x_mode(bool_t onoff) x_mode(bool onoff)
{ {
static bool_t x_cur_mode; static bool x_cur_mode;
bool_t prev; bool prev;
if (x_cur_mode == onoff) if (x_cur_mode == onoff)
return x_cur_mode; return x_cur_mode;
@ -758,7 +758,7 @@ add_glob(const char *str, int slen)
{ {
char *toglob; char *toglob;
char *s; char *s;
bool_t saw_slash = FALSE; bool saw_slash = false;
if (slen < 0) if (slen < 0)
return NULL; return NULL;
@ -779,7 +779,7 @@ add_glob(const char *str, int slen)
|| (s[1] == '(' /*)*/ && strchr("*+?@!", *s))) || (s[1] == '(' /*)*/ && strchr("*+?@!", *s)))
break; break;
else if (ISDIRSEP(*s)) else if (ISDIRSEP(*s))
saw_slash = TRUE; saw_slash = true;
} }
if (!*s && (*toglob != '~' || saw_slash)) { if (!*s && (*toglob != '~' || saw_slash)) {
toglob[slen] = '*'; toglob[slen] = '*';
@ -867,7 +867,7 @@ glob_table(const char *pat, XPtrV *wp, struct table *tp)
struct tbl *te; struct tbl *te;
for (twalk(&ts, tp); (te = tnext(&ts)); ) { 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)); 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 $ */ /* $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 $ */ /* $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_flush(void);
void x_putc(int c); void x_putc(int c);
void x_puts(const char *s); 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 promptlen(const char *cp, const char **spp);
int x_do_comment(char *buf, int bsize, int *lenp); int x_do_comment(char *buf, int bsize, int *lenp);
void x_print_expansions(int nwords, char *const *words, int is_command); 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 $ */ /* $OpenBSD: emacs.c,v 1.28 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -18,7 +18,7 @@
#include <locale.h> #include <locale.h>
#include "edit.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; static Area aedit;
#define AEDIT &aedit /* area for kill ring and macro defns */ #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; xbp = xbuf = buf; xend = buf + len;
xlp = xcp = xep = buf; xlp = xcp = xep = buf;
*xcp = 0; *xcp = 0;
xlp_valid = TRUE; xlp_valid = true;
xmp = NULL; xmp = NULL;
x_curprefix = 0; x_curprefix = 0;
macroptr = NULL; macroptr = NULL;
@ -369,7 +369,7 @@ x_emacs(char *buf, size_t len)
return i; return i;
case KINTR: /* special case for interrupt */ case KINTR: /* special case for interrupt */
trapsig(SIGINT); trapsig(SIGINT);
x_mode(FALSE); x_mode(false);
unwind(LSHELL); unwind(LSHELL);
} }
} }
@ -438,7 +438,7 @@ x_ins(char *s)
* x_zots() may result in a call to x_adjust() * x_zots() may result in a call to x_adjust()
* we want xcp to reflect the new position. * we want xcp to reflect the new position.
*/ */
xlp_valid = FALSE; xlp_valid = false;
x_lastcp(); x_lastcp();
x_adj_ok = (xcp >= xlp); x_adj_ok = (xcp >= xlp);
x_zots(cp); x_zots(cp);
@ -478,7 +478,7 @@ x_del_back(int c GCC_FUNC_ATTR(unused))
if (x_arg > col) if (x_arg > col)
x_arg = col; x_arg = col;
x_goto(xcp - x_arg); x_goto(xcp - x_arg);
x_delete(x_arg, FALSE); x_delete(x_arg, false);
return KSTD; return KSTD;
} }
@ -493,7 +493,7 @@ x_del_char(int c GCC_FUNC_ATTR(unused))
} }
if (x_arg > nleft) if (x_arg > nleft)
x_arg = nleft; x_arg = nleft;
x_delete(x_arg, FALSE); x_delete(x_arg, false);
return KSTD; return KSTD;
} }
@ -546,7 +546,7 @@ x_delete(int nc, int push)
} }
/*x_goto(xcp);*/ /*x_goto(xcp);*/
x_adj_ok = 1; x_adj_ok = 1;
xlp_valid = FALSE; xlp_valid = false;
for (cp = x_lastcp(); cp > xcp; ) for (cp = x_lastcp(); cp > xcp; )
x_bs(*--cp); x_bs(*--cp);
@ -556,7 +556,7 @@ x_delete(int nc, int push)
static int static int
x_del_bword(int c GCC_FUNC_ATTR(unused)) x_del_bword(int c GCC_FUNC_ATTR(unused))
{ {
x_delete(x_bword(), TRUE); x_delete(x_bword(), true);
return KSTD; return KSTD;
} }
@ -577,7 +577,7 @@ x_mv_fword(int c GCC_FUNC_ATTR(unused))
static int static int
x_del_fword(int c GCC_FUNC_ATTR(unused)) x_del_fword(int c GCC_FUNC_ATTR(unused))
{ {
x_delete(x_fword(), TRUE); x_delete(x_fword(), true);
return KSTD; return KSTD;
} }
@ -855,7 +855,7 @@ x_load_hist(char **hp)
strlcpy(xbuf, *hp, xend - xbuf); strlcpy(xbuf, *hp, xend - xbuf);
xbp = xbuf; xbp = xbuf;
xep = xcp = xbuf + strlen(xbuf); xep = xcp = xbuf + strlen(xbuf);
xlp_valid = FALSE; xlp_valid = false;
if (xep > x_lastcp()) if (xep > x_lastcp())
x_goto(xep); x_goto(xep);
else else
@ -985,7 +985,7 @@ x_del_line(int c GCC_FUNC_ATTR(unused))
xcp = xbuf; xcp = xbuf;
x_push(i); x_push(i);
xlp = xbp = xep = xbuf; xlp = xbp = xep = xbuf;
xlp_valid = TRUE; xlp_valid = true;
*xcp = 0; *xcp = 0;
xmp = NULL; xmp = NULL;
x_redraw(j); x_redraw(j);
@ -1036,7 +1036,7 @@ x_redraw(int limit)
x_col = promptlen(prompt, NULL); x_col = promptlen(prompt, NULL);
} }
x_displen = xx_cols - 2 - x_col; x_displen = xx_cols - 2 - x_col;
xlp_valid = FALSE; xlp_valid = false;
cp = x_lastcp(); cp = x_lastcp();
x_zots(xbp); x_zots(xbp);
if (xbp != xbuf || xep > xlp) if (xbp != xbuf || xep > xlp)
@ -1162,7 +1162,7 @@ x_kill(int c GCC_FUNC_ATTR(unused))
x_goto(xbuf + x_arg); x_goto(xbuf + x_arg);
ndel = -ndel; ndel = -ndel;
} }
x_delete(ndel, TRUE); x_delete(ndel, true);
return KSTD; return KSTD;
} }
@ -1207,7 +1207,7 @@ x_meta_yank(int c GCC_FUNC_ATTR(unused))
} }
len = strlen(killstack[killtp]); len = strlen(killstack[killtp]);
x_goto(xcp - len); x_goto(xcp - len);
x_delete(len, FALSE); x_delete(len, false);
do { do {
if (killtp == 0) if (killtp == 0)
killtp = KILLSIZE - 1; killtp = KILLSIZE - 1;
@ -1223,7 +1223,7 @@ x_abort(int c GCC_FUNC_ATTR(unused))
{ {
/* x_zotc(c); */ /* x_zotc(c); */
xlp = xep = xcp = xbp = xbuf; xlp = xep = xcp = xbp = xbuf;
xlp_valid = TRUE; xlp_valid = true;
*xcp = 0; *xcp = 0;
return KINTR; return KINTR;
} }
@ -1244,7 +1244,7 @@ x_stuffreset(int c GCC_FUNC_ATTR(unused))
#else #else
x_zotc(c); x_zotc(c);
xlp = xcp = xep = xbp = xbuf; xlp = xcp = xep = xbp = xbuf;
xlp_valid = TRUE; xlp_valid = true;
*xcp = 0; *xcp = 0;
x_redraw(-1); x_redraw(-1);
return KSTD; return KSTD;
@ -1256,7 +1256,7 @@ x_stuff(int c GCC_FUNC_ATTR(unused))
{ {
#if defined(TIOCSTI) #if defined(TIOCSTI)
char ch = c; char ch = c;
bool_t savmode = x_mode(FALSE); bool savmode = x_mode(false);
(void)ioctl(TTY, TIOCSTI, &ch); (void)ioctl(TTY, TIOCSTI, &ch);
(void)x_mode(savmode); (void)x_mode(savmode);
@ -1495,7 +1495,7 @@ x_kill_region(int c GCC_FUNC_ATTR(unused))
xr = xmp; xr = xmp;
} }
x_goto(xr); x_goto(xr);
x_delete(rsize, TRUE); x_delete(rsize, true);
xmp = xr; xmp = xr;
return KSTD; return KSTD;
} }
@ -1616,7 +1616,7 @@ x_expand(int c GCC_FUNC_ATTR(unused))
} }
x_goto(xbuf + start); x_goto(xbuf + start);
x_delete(end - start, FALSE); x_delete(end - start, false);
for (i = 0; i < nwords;) { for (i = 0; i < nwords;) {
if (x_escape(words[i], strlen(words[i]), x_emacs_putbuf) < 0 || if (x_escape(words[i], strlen(words[i]), x_emacs_putbuf) < 0 ||
(++i < nwords && x_ins(space) < 0)) (++i < nwords && x_ins(space) < 0))
@ -1662,7 +1662,7 @@ do_complete(int flags, Comp_type type)
/* complete */ /* complete */
if (nwords == 1 || nlen > olen) { if (nwords == 1 || nlen > olen) {
x_goto(xbuf + start); x_goto(xbuf + start);
x_delete(olen, FALSE); x_delete(olen, false);
x_escape(words[0], nlen, x_emacs_putbuf); x_escape(words[0], nlen, x_emacs_putbuf);
x_adjust(); x_adjust();
completed = 1; completed = 1;
@ -1707,7 +1707,7 @@ x_adjust(void)
*/ */
if ((xbp = xcp - (x_displen / 2)) < xbuf) if ((xbp = xcp - (x_displen / 2)) < xbuf)
xbp = xbuf; xbp = xbuf;
xlp_valid = FALSE; xlp_valid = false;
x_redraw(xx_cols); x_redraw(xx_cols);
x_flush(); x_flush();
} }
@ -2024,6 +2024,6 @@ x_lastcp(void)
i += x_size(*rcp); i += x_size(*rcp);
xlp = rcp; xlp = rcp;
} }
xlp_valid = TRUE; xlp_valid = true;
return (xlp); 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 $ */ /* $OpenBSD: eval.c,v 1.18 2004/12/13 16:37:06 millert Exp $ */
/* /*
@ -10,7 +10,7 @@
#include "ksh_dir.h" #include "ksh_dir.h"
#include "ksh_stat.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 * string expansion
@ -874,7 +874,7 @@ comsub(Expand *xp, char *cp)
shf = shf_fdopen(pv[0], SHF_RD, NULL); shf = shf_fdopen(pv[0], SHF_RD, NULL);
ofd1 = savefd(1, 0); /* fd 1 may be closed... */ ofd1 = savefd(1, 0); /* fd 1 may be closed... */
if (pv[1] != 1) { if (pv[1] != 1) {
ksh_dup2(pv[1], 1, FALSE); ksh_dup2(pv[1], 1, false);
close(pv[1]); close(pv[1]);
} }
execute(t, XFORK|XXCOM|XPIPEO); execute(t, XFORK|XXCOM|XPIPEO);
@ -901,7 +901,7 @@ trimsub(char *str, char *pat, int how)
case '#': /* shortest at beginning */ case '#': /* shortest at beginning */
for (p = str; p <= end; p++) { for (p = str; p <= end; p++) {
c = *p; *p = '\0'; c = *p; *p = '\0';
if (gmatch(str, pat, FALSE)) { if (gmatch(str, pat, false)) {
*p = c; *p = c;
return p; return p;
} }
@ -911,7 +911,7 @@ trimsub(char *str, char *pat, int how)
case '#'|0x80: /* longest match at beginning */ case '#'|0x80: /* longest match at beginning */
for (p = end; p >= str; p--) { for (p = end; p >= str; p--) {
c = *p; *p = '\0'; c = *p; *p = '\0';
if (gmatch(str, pat, FALSE)) { if (gmatch(str, pat, false)) {
*p = c; *p = c;
return p; return p;
} }
@ -920,13 +920,13 @@ trimsub(char *str, char *pat, int how)
break; break;
case '%': /* shortest match at end */ case '%': /* shortest match at end */
for (p = end; p >= str; p--) { for (p = end; p >= str; p--) {
if (gmatch(p, pat, FALSE)) if (gmatch(p, pat, false))
return str_nsave(str, p - str, ATEMP); return str_nsave(str, p - str, ATEMP);
} }
break; break;
case '%'|0x80: /* longest match at end */ case '%'|0x80: /* longest match at end */
for (p = str; p <= end; p++) { for (p = str; p <= end; p++) {
if (gmatch(p, pat, FALSE)) if (gmatch(p, pat, false))
return str_nsave(str, p - str, ATEMP); return str_nsave(str, p - str, ATEMP);
} }
break; break;
@ -1094,7 +1094,7 @@ globit(XString *xs, char **xpp, char *sp, XPtrV *wp, int check)
(name[1] == 0 || (name[1] == '.' && name[2] == 0))) (name[1] == 0 || (name[1] == '.' && name[2] == 0)))
continue; /* always ignore . and .. */ continue; /* always ignore . and .. */
if ((*name == '.' && *sp != '.') if ((*name == '.' && *sp != '.')
|| !gmatch(name, sp, TRUE)) || !gmatch(name, sp, true))
continue; continue;
len = NLENGTH(d) + 1; 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 $ */ /* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
/* /*
@ -10,7 +10,7 @@
#include <ctype.h> #include <ctype.h>
#include "ksh_stat.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, static int comexec(struct op *t, struct tbl *volatile tp, char **ap,
int volatile flags); 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 call_builtin(struct tbl *tp, char **wp);
static int iosetup(struct ioword *iop, struct tbl *tp); static int iosetup(struct ioword *iop, struct tbl *tp);
static int herein(const char *content, int sub); 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 int dbteste_isa(Test_env *te, Test_meta meta);
static const char *dbteste_getopnd(Test_env *te, Test_op op, static const char *dbteste_getopnd(Test_env *te, Test_op op,
int do_eval); 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 /* Is this the end of a pipeline? If so, we want to evaluate the
* command arguments * command arguments
bool_t eval_done = FALSE; bool eval_done = false;
if ((flags&XFORK) && !(flags&XEXEC) && (flags&XPCLOSE)) { if ((flags&XFORK) && !(flags&XEXEC) && (flags&XPCLOSE)) {
eval_done = TRUE; eval_done = true;
tp = eval_execute_args(t, &ap); tp = eval_execute_args(t, &ap);
} }
*/ */
@ -153,18 +153,18 @@ execute(struct op *volatile t, volatile int flags)
flags |= XFORK; flags |= XFORK;
flags &= ~XEXEC; flags &= ~XEXEC;
e->savefd[0] = savefd(0, 0); 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); e->savefd[1] = savefd(1, 0);
while (t->type == TPIPE) { while (t->type == TPIPE) {
openpipe(pv); 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 /* Let exchild() close pv[0] in child
* (if this isn't done, commands like * (if this isn't done, commands like
* (: ; cat /etc/termcap) | sleep 1 * (: ; cat /etc/termcap) | sleep 1
* will hang forever). * will hang forever).
*/ */
exchild(t->left, flags|XPIPEO|XCCLOSE, pv[0]); 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); closepipe(pv);
flags |= XPIPEI; flags |= XPIPEI;
t = t->right; t = t->right;
@ -210,7 +210,7 @@ execute(struct op *volatile t, volatile int flags)
errorf("coprocess already exists"); errorf("coprocess already exists");
/* Can we re-use the existing co-process pipe? */ /* Can we re-use the existing co-process pipe? */
coproc_cleanup(TRUE); coproc_cleanup(true);
/* do this before opening pipes, in case these fail */ /* do this before opening pipes, in case these fail */
e->savefd[0] = savefd(0, 0); e->savefd[0] = savefd(0, 0);
@ -218,18 +218,18 @@ execute(struct op *volatile t, volatile int flags)
openpipe(pv); openpipe(pv);
if (pv[0] != 0) { if (pv[0] != 0) {
ksh_dup2(pv[0], 0, FALSE); ksh_dup2(pv[0], 0, false);
close(pv[0]); close(pv[0]);
} }
coproc.write = pv[1]; coproc.write = pv[1];
coproc.job = NULL; coproc.job = NULL;
if (coproc.readw >= 0) if (coproc.readw >= 0)
ksh_dup2(coproc.readw, 1, FALSE); ksh_dup2(coproc.readw, 1, false);
else { else {
openpipe(pv); openpipe(pv);
coproc.read = pv[0]; 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.readw = pv[1]; /* closed before first read */
coproc.njobs = 0; coproc.njobs = 0;
/* create new coprocess id */ /* create new coprocess id */
@ -289,7 +289,7 @@ execute(struct op *volatile t, volatile int flags)
case TFOR: case TFOR:
case TSELECT: case TSELECT:
{ {
volatile bool_t is_first = TRUE; volatile bool is_first = true;
ap = (t->vars != NULL) ? ap = (t->vars != NULL) ?
eval(t->vars, DOBLANK|DOGLOB|DOTILDE) eval(t->vars, DOBLANK|DOGLOB|DOTILDE)
: e->loc->argv + 1; : e->loc->argv + 1;
@ -320,7 +320,7 @@ execute(struct op *volatile t, volatile int flags)
rv = 1; rv = 1;
break; break;
} }
is_first = FALSE; is_first = false;
setstr(global(t->str), cp, KSH_UNWIND_ERROR); setstr(global(t->str), cp, KSH_UNWIND_ERROR);
rv = execute(t->left, flags & XERROK); 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 (t = t->left; t != NULL && t->type == TPAT; t = t->right)
for (ap = t->vars; *ap; ap++) for (ap = t->vars; *ap; ap++)
if ((s = evalstr(*ap, DOTILDE|DOPAT)) if ((s = evalstr(*ap, DOTILDE|DOPAT))
&& gmatch(cp, s, FALSE)) && gmatch(cp, s, false))
goto Found; goto Found;
break; break;
Found: Found:
@ -493,7 +493,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
fcflags = FC_BI|FC_PATH; fcflags = FC_BI|FC_PATH;
if (saw_p) { if (saw_p) {
if (Flag(FRESTRICTED)) { if (Flag(FRESTRICTED)) {
warningf(TRUE, warningf(true,
"command -p: restricted"); "command -p: restricted");
rv = 1; rv = 1;
goto Leave; goto Leave;
@ -550,7 +550,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
goto Leave; goto Leave;
} else if (!tp) { } else if (!tp) {
if (Flag(FRESTRICTED) && ksh_strchr_dirsep(cp)) { if (Flag(FRESTRICTED) && ksh_strchr_dirsep(cp)) {
warningf(TRUE, "%s: restricted", cp); warningf(true, "%s: restricted", cp);
rv = 1; rv = 1;
goto Leave; 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->u.fpath) {
if (tp->u2.errno_) { if (tp->u2.errno_) {
warningf(TRUE, warningf(true,
"%s: can't find function definition file - %s", "%s: can't find function definition file - %s",
cp, strerror(tp->u2.errno_)); cp, strerror(tp->u2.errno_));
rv = 126; rv = 126;
} else { } else {
warningf(TRUE, warningf(true,
"%s: can't find function definition file", cp); "%s: can't find function definition file", cp);
rv = 127; rv = 127;
} }
break; break;
} }
if (include(tp->u.fpath, 0, NULL, 0) < 0) { if (include(tp->u.fpath, 0, NULL, 0) < 0) {
warningf(TRUE, warningf(true,
"%s: can't open function definition file %s - %s", "%s: can't open function definition file %s - %s",
cp, tp->u.fpath, strerror(errno)); cp, tp->u.fpath, strerror(errno));
rv = 127; rv = 127;
break; break;
} }
if (!(ftp = findfunc(cp, hash(cp), FALSE)) if (!(ftp = findfunc(cp, hash(cp), false))
|| !(ftp->flag & ISSET)) || !(ftp->flag & ISSET))
{ {
warningf(TRUE, warningf(true,
"%s: function not defined by %s", "%s: function not defined by %s",
cp, tp->u.fpath); cp, tp->u.fpath);
rv = 127; rv = 127;
@ -625,7 +625,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
} }
old_xflag = Flag(FXTRACE); old_xflag = Flag(FXTRACE);
Flag(FXTRACE) = tp->flag & TRACE ? TRUE : FALSE; Flag(FXTRACE) = tp->flag & TRACE ? true : false;
old_inuse = tp->flag & FINUSE; old_inuse = tp->flag & FINUSE;
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. * useful error message and set the exit status to 126.
*/ */
if (tp->u2.errno_) { if (tp->u2.errno_) {
warningf(TRUE, "%s: cannot execute - %s", cp, warningf(true, "%s: cannot execute - %s", cp,
strerror(tp->u2.errno_)); strerror(tp->u2.errno_));
rv = 126; /* POSIX */ rv = 126; /* POSIX */
} else { } else {
warningf(TRUE, "%s: not found", cp); warningf(true, "%s: not found", cp);
rv = 127; rv = 127;
} }
break; break;
@ -831,7 +831,7 @@ define(const char *name, struct op *t)
int was_set = 0; int was_set = 0;
while (1) { while (1) {
tp = findfunc(name, hash(name), TRUE); tp = findfunc(name, hash(name), true);
if (tp->flag & ISSET) if (tp->flag & ISSET)
was_set = 1; was_set = 1;
@ -920,7 +920,7 @@ findcom(const char *name, int flags)
if ((flags & FC_SPECBI) && tbi && (tbi->flag & SPEC_BI)) if ((flags & FC_SPECBI) && tbi && (tbi->flag & SPEC_BI))
tp = tbi; tp = tbi;
if (!tp && (flags & FC_FUNC)) { if (!tp && (flags & FC_FUNC)) {
tp = findfunc(name, h, FALSE); tp = findfunc(name, h, false);
if (tp && !(tp->flag & ISSET)) { if (tp && !(tp->flag & ISSET)) {
if ((fpath = str_val(global("FPATH"))) == null) { if ((fpath = str_val(global("FPATH"))) == null) {
tp->u.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), X_OK | ((iop->flag & IORDUP) ? R_OK : W_OK),
&emsg)) < 0) &emsg)) < 0)
{ {
warningf(TRUE, "%s: %s", warningf(true, "%s: %s",
snptreef(NULL, 32, "%R", &iotmp), emsg); snptreef(NULL, 32, "%R", &iotmp), emsg);
return -1; return -1;
} }
@ -1185,7 +1185,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
} }
if (do_open) { if (do_open) {
if (Flag(FRESTRICTED) && (flags & O_CREAT)) { if (Flag(FRESTRICTED) && (flags & O_CREAT)) {
warningf(TRUE, "%s: restricted", cp); warningf(true, "%s: restricted", cp);
return -1; return -1;
} }
u = open(cp, flags, 0666); u = open(cp, flags, 0666);
@ -1193,7 +1193,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
if (u < 0) { if (u < 0) {
/* herein() may already have printed message */ /* herein() may already have printed message */
if (u == -1) if (u == -1)
warningf(TRUE, "cannot %s %s: %s", warningf(true, "cannot %s %s: %s",
iotype == IODUP ? "dup" iotype == IODUP ? "dup"
: (iotype == IOREAD || iotype == IOHERE) ? : (iotype == IOREAD || iotype == IOHERE) ?
"open" : "create", cp, strerror(errno)); "open" : "create", cp, strerror(errno));
@ -1217,8 +1217,8 @@ iosetup(struct ioword *iop, struct tbl *tp)
if (do_close) if (do_close)
close(iop->unit); close(iop->unit);
else if (u != iop->unit) { else if (u != iop->unit) {
if (ksh_dup2(u, iop->unit, TRUE) < 0) { if (ksh_dup2(u, iop->unit, true) < 0) {
warningf(TRUE, warningf(true,
"could not finish (dup) redirection %s: %s", "could not finish (dup) redirection %s: %s",
snptreef(NULL, 32, "%R", &iotmp), snptreef(NULL, 32, "%R", &iotmp),
strerror(errno)); strerror(errno));
@ -1258,7 +1258,7 @@ herein(const char *content, int sub)
/* ksh -c 'cat << EOF' can cause this... */ /* ksh -c 'cat << EOF' can cause this... */
if (content == NULL) { if (content == NULL) {
warningf(TRUE, "here document missing"); warningf(true, "here document missing");
return -2; /* special to iosetup(): don't print error */ 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); h = maketemp(ATEMP, TT_HEREDOC_EXP, &e->temps);
if (!(shf = h->shf) || (fd = open(h->name, O_RDONLY, 0)) < 0) { 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", !shf ? "create" : "open",
h->name, strerror(errno)); h->name, strerror(errno));
if (shf) if (shf)
@ -1300,7 +1300,7 @@ herein(const char *content, int sub)
if (shf_close(shf) == EOF) { if (shf_close(shf) == EOF) {
close(fd); close(fd);
warningf(TRUE, "error writing %s: %s", h->name, warningf(true, "error writing %s: %s", h->name,
strerror(errno)); strerror(errno));
return -2; /* special to iosetup(): don't print error */ 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 * print the args in column form - assuming that we can
*/ */
static char * static char *
do_selectargs(char **ap, bool_t print_menu) do_selectargs(char **ap, bool print_menu)
{ {
static const char *const read_args[] = static const char *const read_args[] =
{"read", "-r", "REPLY", NULL}; {"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 $ */ /* $OpenBSD: expr.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -8,7 +8,7 @@
#include "sh.h" #include "sh.h"
#include <ctype.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[] */ /* The order of these enums is constrained by the order of opinfo[] */
enum token { 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 struct tbl *evalexpr(Expr_state *es, enum prec prec);
static void token(Expr_state *es); static void token(Expr_state *es);
static struct tbl *do_ppmm(Expr_state *es, enum token op, 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, static void assign_check(Expr_state *es, enum token op,
struct tbl *vasn); struct tbl *vasn);
static struct tbl *tempvar(void); static struct tbl *tempvar(void);
@ -233,31 +233,31 @@ evalerr(Expr_state *es, enum error_type type, const char *str)
default: default:
s = opinfo[(int)es->tok].name; s = opinfo[(int)es->tok].name;
} }
warningf(TRUE, "%s: unexpected '%s'", es->expression, s); warningf(true, "%s: unexpected '%s'", es->expression, s);
break; break;
case ET_BADLIT: case ET_BADLIT:
warningf(TRUE, "%s: bad number '%s'", es->expression, str); warningf(true, "%s: bad number '%s'", es->expression, str);
break; break;
case ET_RECURSIVE: case ET_RECURSIVE:
warningf(TRUE, "%s: expression recurses on parameter '%s'", warningf(true, "%s: expression recurses on parameter '%s'",
es->expression, str); es->expression, str);
break; break;
case ET_LVALUE: case ET_LVALUE:
warningf(TRUE, "%s: %s requires lvalue", warningf(true, "%s: %s requires lvalue",
es->expression, str); es->expression, str);
break; break;
case ET_RDONLY: case ET_RDONLY:
warningf(TRUE, "%s: %s applied to read only variable", warningf(true, "%s: %s applied to read only variable",
es->expression, str); es->expression, str);
break; break;
default: /* keep gcc happy */ default: /* keep gcc happy */
case ET_STR: case ET_STR:
warningf(TRUE, "%s: %s", es->expression, str); warningf(true, "%s: %s", es->expression, str);
break; break;
} }
unwind(LAEXPR); unwind(LAEXPR);
@ -292,7 +292,7 @@ evalexpr(Expr_state *es, enum prec prec)
token(es); token(es);
} else if (op == O_PLUSPLUS || op == O_MINUSMINUS) { } else if (op == O_PLUSPLUS || op == O_MINUSMINUS) {
token(es); token(es);
vl = do_ppmm(es, op, es->val, TRUE); vl = do_ppmm(es, op, es->val, true);
token(es); token(es);
} else if (op == VAR || op == LIT) { } else if (op == VAR || op == LIT) {
vl = es->val; vl = es->val;
@ -302,7 +302,7 @@ evalexpr(Expr_state *es, enum prec prec)
/*NOTREACHED*/ /*NOTREACHED*/
} }
if (es->tok == O_PLUSPLUS || es->tok == O_MINUSMINUS) { 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); token(es);
} }
return vl; return vl;
@ -513,7 +513,7 @@ token(Expr_state *es)
/* Do a ++ or -- operation */ /* Do a ++ or -- operation */
static struct tbl * 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; struct tbl *vl;
int oval; 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 $ */ /* $OpenBSD: history.c,v 1.24 2004/08/03 12:44:59 danh Exp $ */
/* /*
@ -21,7 +21,7 @@
#include "sh.h" #include "sh.h"
#include "ksh_stat.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 #ifndef EASY_HISTORY
/* Defines and includes for the complicated case */ /* Defines and includes for the complicated case */
@ -153,8 +153,8 @@ c_fc(char **wp)
return 1; return 1;
} }
hp = first ? hist_get(first, FALSE, FALSE) hp = first ? hist_get(first, false, false)
: hist_get_newest(FALSE); : hist_get_newest(false);
if (!hp) if (!hp)
return 1; return 1;
return hist_replace(hp, pat, rep, gflag); return hist_replace(hp, pat, rep, gflag);
@ -174,23 +174,23 @@ c_fc(char **wp)
return 1; return 1;
} }
if (!first) { if (!first) {
hfirst = lflag ? hist_get("-16", TRUE, TRUE) hfirst = lflag ? hist_get("-16", true, true)
: hist_get_newest(FALSE); : hist_get_newest(false);
if (!hfirst) if (!hfirst)
return 1; return 1;
/* can't fail if hfirst didn't fail */ /* can't fail if hfirst didn't fail */
hlast = hist_get_newest(FALSE); hlast = hist_get_newest(false);
} else { } else {
/* POSIX says not an error if first/last out of bounds /* POSIX says not an error if first/last out of bounds
* when range is specified; at&t ksh and pdksh allow out of * when range is specified; at&t ksh and pdksh allow out of
* bounds for -l as well. * bounds for -l as well.
*/ */
hfirst = hist_get(first, (lflag || last) ? TRUE : FALSE, hfirst = hist_get(first, (lflag || last) ? true : false,
lflag ? TRUE : FALSE); lflag ? true : false);
if (!hfirst) if (!hfirst)
return 1; return 1;
hlast = last ? hist_get(last, TRUE, lflag ? TRUE : FALSE) hlast = last ? hist_get(last, true, lflag ? true : false)
: (lflag ? hist_get_newest(FALSE) : hfirst); : (lflag ? hist_get_newest(false) : hfirst);
if (!hlast) if (!hlast)
return 1; return 1;
} }
@ -237,7 +237,7 @@ c_fc(char **wp)
} }
/* Ignore setstr errors here (arbitrary) */ /* 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.. */ /* XXX: source should not get trashed by this.. */
{ {
@ -300,7 +300,7 @@ hist_execute(char *cmd)
} }
#ifdef EASY_HISTORY #ifdef EASY_HISTORY
if (p != cmd) if (p != cmd)
histappend(p, TRUE); histappend(p, true);
else else
#endif /* EASY_HISTORY */ #endif /* EASY_HISTORY */
histsave(++(hist_source->line), p, 1); 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 $ */ /* $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 */ shl_stdout_ok = 0; /* debugging: note that stdout not valid */
exstat = 1; exstat = 1;
if (*fmt) { if (*fmt) {
error_prefix(TRUE); error_prefix(true);
SH_VA_START(va, fmt); SH_VA_START(va, fmt);
shf_vfprintf(shl_out, fmt, va); shf_vfprintf(shl_out, fmt, va);
va_end(va); va_end(va);
@ -60,7 +60,7 @@ bi_errorf(const char *fmt, ...)
shl_stdout_ok = 0; /* debugging: note that stdout not valid */ shl_stdout_ok = 0; /* debugging: note that stdout not valid */
exstat = 1; exstat = 1;
if (*fmt) { if (*fmt) {
error_prefix(TRUE); error_prefix(true);
/* not set when main() calls parse_args() */ /* not set when main() calls parse_args() */
if (builtin_argv0) if (builtin_argv0)
shf_fprintf(shl_out, "%s: ", builtin_argv0); shf_fprintf(shl_out, "%s: ", builtin_argv0);
@ -88,7 +88,7 @@ internal_errorf(int jump, const char *fmt, ...)
{ {
va_list va; va_list va;
error_prefix(TRUE); error_prefix(true);
shf_fprintf(shl_out, "internal error: "); shf_fprintf(shl_out, "internal error: ");
SH_VA_START(va, fmt); SH_VA_START(va, fmt);
shf_vfprintf(shl_out, fmt, va); shf_vfprintf(shl_out, fmt, va);
@ -271,7 +271,7 @@ restfd(int fd, int ofd)
if (ofd < 0) /* original fd closed */ if (ofd < 0) /* original fd closed */
close(fd); close(fd);
else if (fd != ofd) { 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); 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 $ */ /* $OpenBSD: jobs.c,v 1.26 2004/12/18 22:12:23 millert Exp $ */
/* /*
@ -31,7 +31,7 @@
#include "ksh_times.h" #include "ksh_times.h"
#include "tty.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 */ /* Start of system configuration stuff */
@ -272,7 +272,7 @@ j_init(int mflagset)
else else
#endif /* JOBS */ #endif /* JOBS */
if (Flag(FTALKING)) if (Flag(FTALKING))
tty_init(TRUE); tty_init(true);
} }
/* job cleanup before shell exit */ /* job cleanup before shell exit */
@ -340,14 +340,14 @@ j_change(void)
if (Flag(FMONITOR)) { if (Flag(FMONITOR)) {
/* Don't call get_tty() 'til we own the tty process group */ /* Don't call get_tty() 'til we own the tty process group */
tty_init(FALSE); tty_init(false);
# ifdef TTY_PGRP # ifdef TTY_PGRP
/* no controlling tty, no SIGT* */ /* no controlling tty, no SIGT* */
ttypgrp_ok = tty_fd >= 0 && tty_devtty; ttypgrp_ok = tty_fd >= 0 && tty_devtty;
if (ttypgrp_ok && (our_pgrp = getpgID()) < 0) { if (ttypgrp_ok && (our_pgrp = getpgID()) < 0) {
warningf(FALSE, "j_init: getpgrp() failed: %s", warningf(false, "j_init: getpgrp() failed: %s",
strerror(errno)); strerror(errno));
ttypgrp_ok = 0; ttypgrp_ok = 0;
} }
@ -359,7 +359,7 @@ j_change(void)
pid_t ttypgrp; pid_t ttypgrp;
if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) { if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) {
warningf(FALSE, warningf(false,
"j_init: tcgetpgrp() failed: %s", "j_init: tcgetpgrp() failed: %s",
strerror(errno)); strerror(errno));
ttypgrp_ok = 0; ttypgrp_ok = 0;
@ -375,13 +375,13 @@ j_change(void)
SS_RESTORE_DFL|SS_FORCE); SS_RESTORE_DFL|SS_FORCE);
if (ttypgrp_ok && our_pgrp != kshpid) { if (ttypgrp_ok && our_pgrp != kshpid) {
if (setpgid(0, kshpid) < 0) { if (setpgid(0, kshpid) < 0) {
warningf(FALSE, warningf(false,
"j_init: setpgid() failed: %s", "j_init: setpgid() failed: %s",
strerror(errno)); strerror(errno));
ttypgrp_ok = 0; ttypgrp_ok = 0;
} else { } else {
if (tcsetpgrp(tty_fd, kshpid) < 0) { if (tcsetpgrp(tty_fd, kshpid) < 0) {
warningf(FALSE, warningf(false,
"j_init: tcsetpgrp() failed: %s", "j_init: tcsetpgrp() failed: %s",
strerror(errno)); strerror(errno));
ttypgrp_ok = 0; ttypgrp_ok = 0;
@ -395,13 +395,13 @@ j_change(void)
int ldisc = NTTYDISC; int ldisc = NTTYDISC;
if (ioctl(tty_fd, TIOCSETD, &ldisc) < 0) if (ioctl(tty_fd, TIOCSETD, &ldisc) < 0)
warningf(FALSE, warningf(false,
"j_init: can't set new line discipline: %s", "j_init: can't set new line discipline: %s",
strerror(errno)); strerror(errno));
} }
# endif /* NTTYDISC && TIOCSETD */ # endif /* NTTYDISC && TIOCSETD */
if (!ttypgrp_ok) if (!ttypgrp_ok)
warningf(FALSE, "warning: won't have full job control"); warningf(false, "warning: won't have full job control");
# endif /* TTY_PGRP */ # endif /* TTY_PGRP */
if (tty_fd >= 0) if (tty_fd >= 0)
get_tty(tty_fd, &tty_state); get_tty(tty_fd, &tty_state);
@ -595,7 +595,7 @@ exchild(struct op *t, int flags, int close_fd)
if (ischild) { /* child */ if (ischild) { /* child */
/* Do this before restoring signal */ /* Do this before restoring signal */
if (flags & XCOPROC) if (flags & XCOPROC)
coproc_cleanup(FALSE); coproc_cleanup(false);
#ifdef JOB_SIGS #ifdef JOB_SIGS
sigprocmask(SIG_SETMASK, &omask, NULL); sigprocmask(SIG_SETMASK, &omask, NULL);
#endif /* JOB_SIGS */ #endif /* JOB_SIGS */
@ -623,7 +623,7 @@ exchild(struct op *t, int flags, int close_fd)
if (!(flags & (XPIPEI | XCOPROC))) { if (!(flags & (XPIPEI | XCOPROC))) {
int fd = open("/dev/null", 0); int fd = open("/dev/null", 0);
if (fd != 0) { if (fd != 0) {
(void) ksh_dup2(fd, 0, TRUE); (void) ksh_dup2(fd, 0, true);
close(fd); close(fd);
} }
} }
@ -714,7 +714,7 @@ waitlast(void)
j = last_job; j = last_job;
if (!j || !(j->flags & JF_STARTED)) { if (!j || !(j->flags & JF_STARTED)) {
if (!j) if (!j)
warningf(TRUE, "waitlast: no last job"); warningf(true, "waitlast: no last job");
else else
internal_errorf(0, "waitlast: not started"); internal_errorf(0, "waitlast: not started");
#ifdef JOB_SIGS #ifdef JOB_SIGS
@ -919,7 +919,7 @@ j_resume(const char *cp, int bg)
set_tty(tty_fd, &tty_state, TF_NONE); set_tty(tty_fd, &tty_state, TF_NONE);
} }
if (ttypgrp_ok && tcsetpgrp(tty_fd, our_pgrp) < 0) { if (ttypgrp_ok && tcsetpgrp(tty_fd, our_pgrp) < 0) {
warningf(TRUE, warningf(true,
"fg: 2nd tcsetpgrp(%d, %d) failed: %s", "fg: 2nd tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) our_pgrp, tty_fd, (int) our_pgrp,
strerror(errno)); strerror(errno));
@ -1209,7 +1209,7 @@ j_waitj(Job *j, int flags, const char *where)
&& (j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0) && (j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0)
j->flags |= JF_SAVEDTTYPGRP; j->flags |= JF_SAVEDTTYPGRP;
if (tcsetpgrp(tty_fd, our_pgrp) < 0) { if (tcsetpgrp(tty_fd, our_pgrp) < 0) {
warningf(TRUE, warningf(true,
"j_waitj: tcsetpgrp(%d, %d) failed: %s", "j_waitj: tcsetpgrp(%d, %d) failed: %s",
tty_fd, (int) our_pgrp, tty_fd, (int) our_pgrp,
strerror(errno)); strerror(errno));
@ -1330,7 +1330,7 @@ j_sigchld(int sig GCC_FUNC_ATTR(unused))
found: found:
if (j == NULL) { if (j == NULL) {
/* Can occur if process has kids, then execs shell /* 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); pid);
*/ */
t0 = t1; 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 $ */ /* $OpenBSD: lex.c,v 1.18 2003/08/06 21:08:05 millert Exp $ */
/* /*
@ -8,7 +8,7 @@
#include "sh.h" #include "sh.h"
#include <ctype.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 /* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state. * needed for each particular state.
@ -162,7 +162,7 @@ yylex(int cf)
case SBASE: case SBASE:
if (c == '[' && (cf & (VARASN|ARRAYVAR))) { if (c == '[' && (cf & (VARASN|ARRAYVAR))) {
*wp = EOS; /* temporary */ *wp = EOS; /* temporary */
if (is_wdvarname(Xstring(ws, wp), FALSE)) if (is_wdvarname(Xstring(ws, wp), false))
{ {
char *p, *tmp; char *p, *tmp;
@ -831,7 +831,7 @@ yyerror(const char *fmt, ...)
source = source->next; source = source->next;
source->str = null; /* zap pending input */ source->str = null; /* zap pending input */
error_prefix(TRUE); error_prefix(true);
SH_VA_START(va, fmt); SH_VA_START(va, fmt);
shf_vfprintf(shl_out, fmt, va); shf_vfprintf(shl_out, fmt, va);
va_end(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 $ */ /* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
/* /*
@ -15,7 +15,7 @@
* shell version * 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[] = const char ksh_version[] =
"@(#)PD KSH v5.2.14 MirOS R20 in " "@(#)PD KSH v5.2.14 MirOS R20 in "
@ -332,7 +332,7 @@ main(int argc, char *argv[])
* user will know why things broke. * user will know why things broke.
*/ */
if (!current_wd[0] && Flag(FTALKING)) if (!current_wd[0] && Flag(FTALKING))
warningf(FALSE, "Cannot determine current working directory"); warningf(false, "Cannot determine current working directory");
if (Flag(FLOGIN)) { if (Flag(FLOGIN)) {
include(KSH_SYSTEM_PROFILE, 0, NULL, 1); include(KSH_SYSTEM_PROFILE, 0, NULL, 1);
@ -380,7 +380,7 @@ main(int argc, char *argv[])
} else } else
Flag(FTRACKALL) = 1; /* set after ENV */ Flag(FTRACKALL) = 1; /* set after ENV */
shell(s, TRUE); /* doesn't return */ shell(s, true); /* doesn't return */
return 0; return 0;
} }
@ -440,7 +440,7 @@ include(const char *name, int argc, char **argv, int intr_ok)
s = pushs(SFILE, ATEMP); s = pushs(SFILE, ATEMP);
s->u.shf = shf; s->u.shf = shf;
s->file = str_save(name, ATEMP); s->file = str_save(name, ATEMP);
i = shell(s, FALSE); i = shell(s, false);
quitenv(s->u.shf); quitenv(s->u.shf);
if (old_argv) { if (old_argv) {
e->loc->argv = old_argv; e->loc->argv = old_argv;
@ -456,7 +456,7 @@ command(const char *comm)
s = pushs(SSTRING, ATEMP); s = pushs(SSTRING, ATEMP);
s->start = s->str = comm; 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 $ */ /* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -13,7 +13,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "ksh_stat.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 #ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF # define UCHAR_MAX 0xFF
@ -439,7 +439,7 @@ parse_args(char **argv, int what, int *setargsp)
*setargsp = !arrayset && ((go.info & GI_MINUSMINUS) *setargsp = !arrayset && ((go.info & GI_MINUSMINUS)
|| argv[go.optind]); || 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); bi_errorf("%s: is not an identifier", array);
return -1; return -1;
} }
@ -955,7 +955,7 @@ ksh_getopt(char **argv, Getopt *go, const char *options)
go->buf[0] = c; go->buf[0] = c;
go->optarg = go->buf; go->optarg = go->buf;
} else { } 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) ? "" : argv[0],
(go->flags & GF_NONAME) ? "" : ": ", c); (go->flags & GF_NONAME) ? "" : ": ", c);
if (go->flags & GF_ERROR) if (go->flags & GF_ERROR)
@ -981,7 +981,7 @@ ksh_getopt(char **argv, Getopt *go, const char *options)
go->optarg = go->buf; go->optarg = go->buf;
return ':'; 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) ? "" : argv[0],
(go->flags & GF_NONAME) ? "" : ": ", c); (go->flags & GF_NONAME) ? "" : ": ", c);
if (go->flags & GF_ERROR) 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 $ */ /* $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 $ */ /* $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 popblock(void);
void initvar(void); void initvar(void);
struct tbl * global(const char *n); 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); char * str_val(struct tbl *vp);
long intval(struct tbl *vp); long intval(struct tbl *vp);
int setstr(struct tbl *vq, const char *s, int error_ok); 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 $ */ /* $OpenBSD: sh.h,v 1.23 2004/12/18 22:11:43 millert Exp $ */
#ifndef SH_H #ifndef SH_H
@ -293,10 +293,6 @@ extern int dup2(int, int);
# define ksh_strchr_dirsep(p) strchr(p, DIRSEP) # define ksh_strchr_dirsep(p) strchr(p, DIRSEP)
# define ksh_strrchr_dirsep(p) strrchr(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 NELEM(a) (sizeof(a) / sizeof((a)[0]))
#define sizeofN(type, n) (sizeof(type) * (n)) #define sizeofN(type, n) (sizeof(type) * (n))
#define BIT(i) (1<<(i)) /* define bit in flag */ #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 $ */ /* $OpenBSD: syn.c,v 1.14 2003/10/22 07:40:38 jmc Exp $ */
/* /*
@ -8,7 +8,7 @@
#include "sh.h" #include "sh.h"
#include "c_test.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 { struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */ 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; struct nesting_state old_nesting;
nesting_push(&old_nesting, smark); nesting_push(&old_nesting, smark);
t = c_list(TRUE); t = c_list(true);
musthave(emark, KEYWORD|ALIAS); musthave(emark, KEYWORD|ALIAS);
nesting_pop(&old_nesting); nesting_pop(&old_nesting);
return (block(type, t, NOBLOCK, NOWORDS)); return (block(type, t, NOBLOCK, NOWORDS));
@ -265,7 +265,7 @@ get_command(int cf)
ACCEPT; ACCEPT;
/*(*/ /*(*/
musthave(')', 0); musthave(')', 0);
t = function_body(XPptrv(args)[0], FALSE); t = function_body(XPptrv(args)[0], false);
goto Leave; goto Leave;
default: default:
@ -320,7 +320,7 @@ get_command(int cf)
case SELECT: case SELECT:
t = newtp((c == FOR) ? TFOR : TSELECT); t = newtp((c == FOR) ? TFOR : TSELECT);
musthave(LWORD, ARRAYVAR); musthave(LWORD, ARRAYVAR);
if (!is_wdvarname(yylval.cp, TRUE)) if (!is_wdvarname(yylval.cp, true))
yyerror("%s: bad identifier\n", yyerror("%s: bad identifier\n",
c == FOR ? "for" : "select"); c == FOR ? "for" : "select");
t->str = str_save(ident, ATEMP); t->str = str_save(ident, ATEMP);
@ -334,7 +334,7 @@ get_command(int cf)
case UNTIL: case UNTIL:
nesting_push(&old_nesting, c); nesting_push(&old_nesting, c);
t = newtp((c == WHILE) ? TWHILE : TUNTIL); t = newtp((c == WHILE) ? TWHILE : TUNTIL);
t->left = c_list(TRUE); t->left = c_list(true);
t->right = dogroup(); t->right = dogroup();
nesting_pop(&old_nesting); nesting_pop(&old_nesting);
break; break;
@ -351,7 +351,7 @@ get_command(int cf)
case IF: case IF:
nesting_push(&old_nesting, c); nesting_push(&old_nesting, c);
t = newtp(TIF); t = newtp(TIF);
t->left = c_list(TRUE); t->left = c_list(true);
t->right = thenpart(); t->right = thenpart();
musthave(FI, KEYWORD|ALIAS); musthave(FI, KEYWORD|ALIAS);
nesting_pop(&old_nesting); nesting_pop(&old_nesting);
@ -373,7 +373,7 @@ get_command(int cf)
case FUNCTION: case FUNCTION:
musthave(LWORD, 0); musthave(LWORD, 0);
t = function_body(yylval.cp, TRUE); t = function_body(yylval.cp, true);
break; break;
} }
@ -424,7 +424,7 @@ dogroup(void)
c = '}'; c = '}';
else else
syntaxerr(NULL); syntaxerr(NULL);
list = c_list(TRUE); list = c_list(true);
musthave(c, KEYWORD|ALIAS); musthave(c, KEYWORD|ALIAS);
return list; return list;
} }
@ -436,7 +436,7 @@ thenpart(void)
musthave(THEN, KEYWORD|ALIAS); musthave(THEN, KEYWORD|ALIAS);
t = newtp(0); t = newtp(0);
t->left = c_list(TRUE); t->left = c_list(true);
if (t->left == NULL) if (t->left == NULL)
syntaxerr(NULL); syntaxerr(NULL);
t->right = elsepart(); t->right = elsepart();
@ -450,13 +450,13 @@ elsepart(void)
switch (token(KEYWORD|ALIAS|VARASN)) { switch (token(KEYWORD|ALIAS|VARASN)) {
case ELSE: case ELSE:
if ((t = c_list(TRUE)) == NULL) if ((t = c_list(true)) == NULL)
syntaxerr(NULL); syntaxerr(NULL);
return (t); return (t);
case ELIF: case ELIF:
t = newtp(TELIF); t = newtp(TELIF);
t->left = c_list(TRUE); t->left = c_list(true);
t->right = thenpart(); t->right = thenpart();
return (t); return (t);
@ -513,7 +513,7 @@ casepart(int endtok)
t->vars = (char **) XPclose(ptns); t->vars = (char **) XPclose(ptns);
musthave(')', 0); musthave(')', 0);
t->left = c_list(TRUE); t->left = c_list(true);
/* Note: Posix requires the ;; */ /* Note: Posix requires the ;; */
if ((tpeek(CONTIN|KEYWORD|ALIAS)) != endtok) if ((tpeek(CONTIN|KEYWORD|ALIAS)) != endtok)
musthave(BREAK, CONTIN|KEYWORD|ALIAS); musthave(BREAK, CONTIN|KEYWORD|ALIAS);
@ -629,35 +629,35 @@ const struct tokeninfo {
short reserved; short reserved;
} tokentab[] = { } tokentab[] = {
/* Reserved words */ /* Reserved words */
{ "if", IF, TRUE }, { "if", IF, true },
{ "then", THEN, TRUE }, { "then", THEN, true },
{ "else", ELSE, TRUE }, { "else", ELSE, true },
{ "elif", ELIF, TRUE }, { "elif", ELIF, true },
{ "fi", FI, TRUE }, { "fi", FI, true },
{ "case", CASE, TRUE }, { "case", CASE, true },
{ "esac", ESAC, TRUE }, { "esac", ESAC, true },
{ "for", FOR, TRUE }, { "for", FOR, true },
{ "select", SELECT, TRUE }, { "select", SELECT, true },
{ "while", WHILE, TRUE }, { "while", WHILE, true },
{ "until", UNTIL, TRUE }, { "until", UNTIL, true },
{ "do", DO, TRUE }, { "do", DO, true },
{ "done", DONE, TRUE }, { "done", DONE, true },
{ "in", IN, TRUE }, { "in", IN, true },
{ "function", FUNCTION, TRUE }, { "function", FUNCTION, true },
{ "time", TIME, TRUE }, { "time", TIME, true },
{ "{", '{', TRUE }, { "{", '{', true },
{ "}", '}', TRUE }, { "}", '}', true },
{ "!", BANG, TRUE }, { "!", BANG, true },
{ "[[", DBRACKET, TRUE }, { "[[", DBRACKET, true },
/* Lexical tokens (0[EOF], LWORD and REDIR handled specially) */ /* Lexical tokens (0[EOF], LWORD and REDIR handled specially) */
{ "&&", LOGAND, FALSE }, { "&&", LOGAND, false },
{ "||", LOGOR, FALSE }, { "||", LOGOR, false },
{ ";;", BREAK, FALSE }, { ";;", BREAK, false },
{ "((", MDPAREN, FALSE }, { "((", MDPAREN, false },
{ "|&", COPROC, FALSE }, { "|&", COPROC, false },
/* and some special cases... */ /* and some special cases... */
{ "newline", '\n', FALSE }, { "newline", '\n', false },
{ NULL, 0, FALSE } { NULL, 0, false }
}; };
void 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 $ */ /* $OpenBSD: trap.c,v 1.13 2003/02/28 09:45:09 jmc Exp $ */
/* /*
@ -9,7 +9,7 @@
#define FROM_TRAP_C #define FROM_TRAP_C
#include "sh.h" #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 /* Table is indexed by signal number
* *
@ -200,7 +200,7 @@ runtraps(int flag)
if (ksh_tmout_state == TMOUT_LEAVING) { if (ksh_tmout_state == TMOUT_LEAVING) {
ksh_tmout_state = TMOUT_EXECUTING; ksh_tmout_state = TMOUT_EXECUTING;
warningf(FALSE, "timed out waiting for input"); warningf(false, "timed out waiting for input");
unwind(LEXIT); unwind(LEXIT);
} else } else
/* XXX: this means the alarm will have no effect if a trap /* 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 $ */ /* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */
#include "sh.h" #include "sh.h"
@ -7,7 +7,7 @@
#include "tty.h" #include "tty.h"
#undef EXTERN #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 int
get_tty(int fd, TTY_state *ts) 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 !defined(__mips) || !(defined(_SYSTYPE_BSD43) || defined(__SYSTYPE_BSD43))
if (tfd < 0) { if (tfd < 0) {
tty_devtty = 0; tty_devtty = 0;
warningf(FALSE, warningf(false,
"No controlling tty (open /dev/tty: %s)", "No controlling tty (open /dev/tty: %s)",
strerror(errno)); strerror(errno));
} }
@ -148,15 +148,15 @@ tty_init(int init_ttystate)
else if (isatty(2)) else if (isatty(2))
tfd = 2; tfd = 2;
else { else {
warningf(FALSE, "Can't find tty file descriptor"); warningf(false, "Can't find tty file descriptor");
return; return;
} }
} }
if ((tty_fd = ksh_dupbase(tfd, FDBASE)) < 0) { 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)); strerror(errno));
} else if (fd_clexec(tty_fd) < 0) { } 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)); strerror(errno));
close(tty_fd); close(tty_fd);
tty_fd = -1; 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 $ */ /* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */
#include "sh.h" #include "sh.h"
@ -7,7 +7,7 @@
#include "ksh_stat.h" #include "ksh_stat.h"
#include <ctype.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 * Variables
@ -119,22 +119,22 @@ initvar(void)
* non-zero if this is an array, sets *valp to the array index, returns * non-zero if this is an array, sets *valp to the array index, returns
* the basename of the array. * 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 * 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; const char *p;
int len; int len;
*arrayp = FALSE; *arrayp = false;
p = skip_varname(n, FALSE); p = skip_varname(n, false);
if (p != n && *p == '[' && (len = array_ref_len(p))) { if (p != n && *p == '[' && (len = array_ref_len(p))) {
char *sub, *tmp; char *sub, *tmp;
long rval; long rval;
/* Calculate the value of the subscript */ /* Calculate the value of the subscript */
*arrayp = TRUE; *arrayp = true;
tmp = str_nsave(p+1, len-2, ATEMP); tmp = str_nsave(p+1, len-2, ATEMP);
sub = substitute(tmp, 0); sub = substitute(tmp, 0);
afree(tmp, ATEMP); afree(tmp, ATEMP);
@ -158,7 +158,7 @@ global(const char *n)
struct tbl *vp; struct tbl *vp;
int c; int c;
unsigned h; unsigned h;
bool_t array; bool array;
int val; int val;
/* Check to see if this is an array */ /* 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. * Search for local variable, if not found create locally.
*/ */
struct tbl * struct tbl *
local(const char *n, bool_t copy) local(const char *n, bool copy)
{ {
struct block *l = e->loc; struct block *l = e->loc;
struct tbl *vp; struct tbl *vp;
unsigned h; unsigned h;
bool_t array; bool array;
int val; int val;
/* Check to see if this is an array */ /* 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; int no_ro_check = error_ok & 0x4;
error_ok &= ~0x4; error_ok &= ~0x4;
if ((vq->flag & RDONLY) && !no_ro_check) { 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) if (!error_ok)
errorf(null); errorf(null);
return 0; return 0;
@ -355,7 +355,7 @@ setstr(struct tbl *vq, const char *s, int error_ok)
/* debugging */ /* debugging */
if (s >= vq->val.s if (s >= vq->val.s
&& s <= vq->val.s + strlen(vq->val.s)) && s <= vq->val.s + strlen(vq->val.s))
internal_errorf(TRUE, internal_errorf(true,
"setstr: %s=%s: assigning to self", "setstr: %s=%s: assigning to self",
vq->name, s); vq->name, s);
afree((void*)vq->val.s, vq->areap); 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; const char *val;
/* check for valid variable name, search for value */ /* check for valid variable name, search for value */
val = skip_varname(var, FALSE); val = skip_varname(var, false);
if (val == var) if (val == var)
return NULL; return NULL;
if (*val == '[') { if (*val == '[') {
@ -610,7 +610,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
|| strcmp(tvar, "SHELL") == 0)) || strcmp(tvar, "SHELL") == 0))
errorf("%s: restricted", tvar); 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); : global(tvar);
set &= ~(LOCAL|LOCAL_COPY); set &= ~(LOCAL|LOCAL_COPY);
@ -801,7 +801,7 @@ is_wdvarname(const char *s, int aok)
int int
is_wdvarassign(const char *s) 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] == '='; 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 $ */ /* $OpenBSD: vi.c,v 1.13 2004/05/10 16:28:47 pvalchev Exp $ */
/* /*
@ -14,7 +14,7 @@
#include "ksh_stat.h" /* completion */ #include "ksh_stat.h" /* completion */
#include "edit.h" #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 Ctrl(c) (c&0x1f)
#define is_wordch(c) (letnum(c)) #define is_wordch(c) (letnum(c))
@ -219,7 +219,7 @@ x_vi(char *buf, size_t len)
x_vi_zotc(c); x_vi_zotc(c);
x_flush(); x_flush();
trapsig(c == edchars.intr ? SIGINT : SIGQUIT); trapsig(c == edchars.intr ? SIGINT : SIGQUIT);
x_mode(FALSE); x_mode(false);
unwind(LSHELL); unwind(LSHELL);
} else if (c == edchars.eof && state != VVERSION) { } else if (c == edchars.eof && state != VVERSION) {
if (es->linelen == 0) { if (es->linelen == 0) {