Module Name: src Committed By: kamil Date: Fri Jun 30 04:41:19 UTC 2017
Modified Files: src/bin/ksh: c_ksh.c c_sh.c c_test.c edit.c edit.h emacs.c eval.c exec.c expr.c history.c io.c jobs.c lex.c mail.c main.c misc.c proto.h sh.h syn.c trap.c tty.c var.c vi.c Log Message: ksh: Upgrade to C99 <stdbool.h> This shell already used C99 functions. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/bin/ksh/c_ksh.c cvs rdiff -u -r1.22 -r1.23 src/bin/ksh/c_sh.c src/bin/ksh/exec.c \ src/bin/ksh/misc.c cvs rdiff -u -r1.8 -r1.9 src/bin/ksh/c_test.c src/bin/ksh/proto.h \ src/bin/ksh/tty.c cvs rdiff -u -r1.31 -r1.32 src/bin/ksh/edit.c cvs rdiff -u -r1.3 -r1.4 src/bin/ksh/edit.h cvs rdiff -u -r1.36 -r1.37 src/bin/ksh/emacs.c cvs rdiff -u -r1.21 -r1.22 src/bin/ksh/eval.c src/bin/ksh/main.c cvs rdiff -u -r1.9 -r1.10 src/bin/ksh/expr.c src/bin/ksh/syn.c cvs rdiff -u -r1.16 -r1.17 src/bin/ksh/history.c src/bin/ksh/io.c cvs rdiff -u -r1.18 -r1.19 src/bin/ksh/jobs.c cvs rdiff -u -r1.20 -r1.21 src/bin/ksh/lex.c cvs rdiff -u -r1.7 -r1.8 src/bin/ksh/mail.c cvs rdiff -u -r1.33 -r1.34 src/bin/ksh/sh.h cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/trap.c cvs rdiff -u -r1.19 -r1.20 src/bin/ksh/var.c cvs rdiff -u -r1.17 -r1.18 src/bin/ksh/vi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/ksh/c_ksh.c diff -u src/bin/ksh/c_ksh.c:1.25 src/bin/ksh/c_ksh.c:1.26 --- src/bin/ksh/c_ksh.c:1.25 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/c_ksh.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: c_ksh.c,v 1.25 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: c_ksh.c,v 1.26 2017/06/30 04:41:19 kamil Exp $ */ /* * built-in Korn commands: c_* @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: c_ksh.c,v 1.25 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: c_ksh.c,v 1.26 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -717,7 +717,7 @@ c_typeset(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; @@ -1173,7 +1173,7 @@ c_kill(wp) /* assume old style options if -digits or -UPPERCASE */ if ((p = wp[1]) && *p == '-' && (digit(p[1]) || isupper((unsigned char)p[1]))) { - if (!(t = gettrap(p + 1, TRUE))) { + if (!(t = gettrap(p + 1, true))) { bi_errorf("bad signal `%s'", p + 1); return 1; } @@ -1187,7 +1187,7 @@ c_kill(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; @@ -1311,7 +1311,7 @@ c_getopts(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; } Index: src/bin/ksh/c_sh.c diff -u src/bin/ksh/c_sh.c:1.22 src/bin/ksh/c_sh.c:1.23 --- src/bin/ksh/c_sh.c:1.22 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/c_sh.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: c_sh.c,v 1.22 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: c_sh.c,v 1.23 2017/06/30 04:41:19 kamil Exp $ */ /* * built-in Bourne commands @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: c_sh.c,v 1.22 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: c_sh.c,v 1.23 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -464,7 +464,7 @@ c_eval(wp) exstat = subst_exstat; } - rv = shell(s, FALSE); + rv = shell(s, false); afree(s, ATEMP); return rv; } @@ -515,13 +515,13 @@ c_trap(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; @@ -546,7 +546,7 @@ c_exitreturn(wp) if (arg) { if (!getn(arg, &n)) { exstat = 1; - warningf(TRUE, "%s: bad number", arg); + warningf(true, "%s: bad number", arg); } else exstat = n; } @@ -612,7 +612,7 @@ c_brkcont(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 @@ -621,7 +621,7 @@ c_brkcont(wp) */ if (last_ep) 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); } Index: src/bin/ksh/exec.c diff -u src/bin/ksh/exec.c:1.22 src/bin/ksh/exec.c:1.23 --- src/bin/ksh/exec.c:1.22 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/exec.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.22 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: exec.c,v 1.23 2017/06/30 04:41:19 kamil Exp $ */ /* * execute command tree @@ -6,11 +6,12 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: exec.c,v 1.22 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: exec.c,v 1.23 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> #include <ctype.h> +#include <stdbool.h> #include "sh.h" #include "c_test.h" @@ -29,7 +30,7 @@ static int call_builtin ARGS((struct tbl static int iosetup ARGS((struct ioword *, struct tbl *)); static int herein ARGS((const char *, int)); #ifdef KSH -static char *do_selectargs ARGS((char **, bool_t)); +static char *do_selectargs ARGS((char **, bool)); #endif /* KSH */ #ifdef KSH static int dbteste_isa ARGS((Test_env *, Test_meta)); @@ -90,9 +91,9 @@ execute(t, 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); } */ @@ -166,18 +167,18 @@ execute(t, 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; @@ -221,7 +222,7 @@ execute(t, 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); @@ -229,18 +230,18 @@ execute(t, 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 = (void *) 0; 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 */ @@ -303,7 +304,7 @@ execute(t, flags) #ifdef KSH case TSELECT: { - volatile bool_t is_first = TRUE; + volatile bool is_first = true; #endif /* KSH */ ap = (t->vars != NULL) ? eval(t->vars, DOBLANK|DOGLOB|DOTILDE) @@ -337,7 +338,7 @@ execute(t, flags) rv = 1; break; } - is_first = FALSE; + is_first = false; setstr(global(t->str), cp, KSH_UNWIND_ERROR); rv = execute(t->left, flags & XERROK); } @@ -382,7 +383,7 @@ execute(t, 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: @@ -518,7 +519,7 @@ comexec(t, tp, ap, flags) fcflags = FC_BI|FC_PATH; if (saw_p) { if (Flag(FRESTRICTED)) { - warningf(TRUE, + warningf(true, "command -p: restricted"); rv = 1; goto Leave; @@ -575,7 +576,7 @@ comexec(t, tp, ap, 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; } @@ -598,28 +599,28 @@ comexec(t, tp, ap, 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, (char **) 0, 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; @@ -650,7 +651,7 @@ comexec(t, tp, ap, 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; @@ -704,11 +705,11 @@ comexec(t, tp, ap, 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; @@ -821,7 +822,7 @@ define(name, 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; @@ -912,7 +913,7 @@ findcom(name, 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 = (char *) 0; @@ -1176,7 +1177,7 @@ iosetup(iop, tp) X_OK | ((iop->flag & IORDUP) ? R_OK : W_OK), &emsg)) < 0) { - warningf(TRUE, "%s: %s", + warningf(true, "%s: %s", snptreef((char *) 0, 32, "%R", &iotmp), emsg); return -1; } @@ -1187,7 +1188,7 @@ iosetup(iop, 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); @@ -1195,7 +1196,7 @@ iosetup(iop, 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)); @@ -1219,8 +1220,8 @@ iosetup(iop, 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((char *) 0, 32, "%R", &iotmp), strerror(errno)); @@ -1264,7 +1265,7 @@ herein(content, sub) /* ksh -c 'cat << EOF' can cause this... */ if (content == (char *) 0) { - warningf(TRUE, "here document missing"); + warningf(true, "here document missing"); return -2; /* special to iosetup(): don't print error */ } @@ -1273,7 +1274,7 @@ herein(content, 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) @@ -1307,7 +1308,7 @@ herein(content, 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 */ } @@ -1323,7 +1324,7 @@ herein(content, sub) static char * do_selectargs(ap, print_menu) register char **ap; - bool_t print_menu; + bool print_menu; { static const char *const read_args[] = { "read", "-r", "REPLY", (char *) 0 Index: src/bin/ksh/misc.c diff -u src/bin/ksh/misc.c:1.22 src/bin/ksh/misc.c:1.23 --- src/bin/ksh/misc.c:1.22 Thu Jun 22 23:38:49 2017 +++ src/bin/ksh/misc.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.22 2017/06/22 23:38:49 kamil Exp $ */ +/* $NetBSD: misc.c,v 1.23 2017/06/30 04:41:19 kamil Exp $ */ /* * Miscellaneous functions @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: misc.c,v 1.22 2017/06/22 23:38:49 kamil Exp $"); +__RCSID("$NetBSD: misc.c,v 1.23 2017/06/30 04:41:19 kamil Exp $"); #endif @@ -461,7 +461,7 @@ parse_args(argv, what, 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; } @@ -1010,7 +1010,7 @@ ksh_getopt(argv, go, 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) @@ -1036,7 +1036,7 @@ ksh_getopt(argv, go, 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) Index: src/bin/ksh/c_test.c diff -u src/bin/ksh/c_test.c:1.8 src/bin/ksh/c_test.c:1.9 --- src/bin/ksh/c_test.c:1.8 Fri Jun 30 04:11:57 2017 +++ src/bin/ksh/c_test.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: c_test.c,v 1.8 2017/06/30 04:11:57 kamil Exp $ */ +/* $NetBSD: c_test.c,v 1.9 2017/06/30 04:41:19 kamil Exp $ */ /* * test(1); version 7-like -- author Erik Baalbergen @@ -11,7 +11,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: c_test.c,v 1.8 2017/06/30 04:11:57 kamil Exp $"); +__RCSID("$NetBSD: c_test.c,v 1.9 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -352,11 +352,11 @@ test_eval(te, op, opnd1, opnd2, do_eval) */ 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; Index: src/bin/ksh/proto.h diff -u src/bin/ksh/proto.h:1.8 src/bin/ksh/proto.h:1.9 --- src/bin/ksh/proto.h:1.8 Fri Jun 30 04:01:48 2017 +++ src/bin/ksh/proto.h Fri Jun 30 04:41:19 2017 @@ -1,11 +1,13 @@ -/* $NetBSD: proto.h,v 1.8 2017/06/30 04:01:48 kamil Exp $ */ +/* $NetBSD: proto.h,v 1.9 2017/06/30 04:41:19 kamil Exp $ */ /* * prototypes for PD-KSH * originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang " - * $Id: proto.h,v 1.8 2017/06/30 04:01:48 kamil Exp $ + * $Id: proto.h,v 1.9 2017/06/30 04:41:19 kamil Exp $ */ +#include <stdbool.h> + /* alloc.c */ Area * ainit ARGS((Area *)); void afreeall ARGS((Area *)); @@ -253,7 +255,7 @@ void newblock ARGS((void)); void popblock ARGS((void)); void initvar ARGS((void)); struct tbl * global ARGS((const char *)); -struct tbl * local ARGS((const char *, bool_t)); +struct tbl * local ARGS((const char *, bool)); char * str_val ARGS((struct tbl *)); long intval ARGS((struct tbl *)); int setstr ARGS((struct tbl *, const char *, int)); Index: src/bin/ksh/tty.c diff -u src/bin/ksh/tty.c:1.8 src/bin/ksh/tty.c:1.9 --- src/bin/ksh/tty.c:1.8 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/tty.c Fri Jun 30 04:41:19 2017 @@ -1,9 +1,9 @@ -/* $NetBSD: tty.c,v 1.8 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: tty.c,v 1.9 2017/06/30 04:41:19 kamil Exp $ */ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: tty.c,v 1.8 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: tty.c,v 1.9 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -112,7 +112,7 @@ tty_init(init_ttystate) if ((tfd = open(devtty, O_RDWR, 0)) < 0) { if (tfd < 0) { tty_devtty = 0; - warningf(FALSE, + warningf(false, "No controlling tty (open %s: %s)", devtty, strerror(errno)); } @@ -125,15 +125,15 @@ tty_init(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; Index: src/bin/ksh/edit.c diff -u src/bin/ksh/edit.c:1.31 src/bin/ksh/edit.c:1.32 --- src/bin/ksh/edit.c:1.31 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/edit.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: edit.c,v 1.31 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: edit.c,v 1.32 2017/06/30 04:41:19 kamil Exp $ */ /* * Command line editing - common code @@ -7,9 +7,10 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: edit.c,v 1.31 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: edit.c,v 1.32 2017/06/30 04:41:19 kamil Exp $"); #endif +#include <stdbool.h> #include "config.h" #ifdef EDIT @@ -131,7 +132,7 @@ x_read(buf, len) { int i; - x_mode(TRUE); + x_mode(true); #ifdef EMACS if (Flag(FEMACS) || Flag(FGMACS)) i = x_emacs(buf, len); @@ -143,7 +144,7 @@ x_read(buf, len) else #endif i = -1; /* internal error */ - x_mode(FALSE); + x_mode(false); #if defined(TIOCGWINSZ) if (got_sigwinch) check_sigwinch(); @@ -162,9 +163,9 @@ x_getc() 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; @@ -192,12 +193,12 @@ x_puts(s) shf_putc(*s++, shl_out); } -bool_t +bool x_mode(onoff) - bool_t onoff; + 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; @@ -849,7 +850,7 @@ add_glob(str, slen) { char *toglob; char *s; - bool_t saw_slash = FALSE; + bool saw_slash = false; if (slen < 0) return (char *) 0; @@ -870,7 +871,7 @@ add_glob(str, slen) || (s[1] == '(' /*)*/ && strchr("*+?@!", *s))) break; else if (ISDIRSEP(*s)) - saw_slash = TRUE; + saw_slash = true; } if (!*s && (*toglob != '~' || saw_slash)) { toglob[slen] = '*'; @@ -968,7 +969,7 @@ glob_table(pat, wp, 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)); } } Index: src/bin/ksh/edit.h diff -u src/bin/ksh/edit.h:1.3 src/bin/ksh/edit.h:1.4 --- src/bin/ksh/edit.h:1.3 Tue Nov 2 22:06:45 1999 +++ src/bin/ksh/edit.h Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: edit.h,v 1.3 1999/11/02 22:06:45 jdolecek Exp $ */ +/* $NetBSD: edit.h,v 1.4 2017/06/30 04:41:19 kamil Exp $ */ /* NAME: * edit.h - globals for edit modes @@ -10,10 +10,12 @@ * * * RCSid: - * $NetBSD: edit.h,v 1.3 1999/11/02 22:06:45 jdolecek Exp $ + * $NetBSD: edit.h,v 1.4 2017/06/30 04:41:19 kamil Exp $ * */ +#include <stdbool.h> + /* some useful #defines */ #ifdef EXTERN # define I__(i) = i @@ -48,7 +50,7 @@ int x_getc ARGS((void)); void x_flush ARGS((void)); void x_putc ARGS((int c)); void x_puts ARGS((const char *s)); -bool_t x_mode ARGS((bool_t onoff)); +bool x_mode ARGS((bool onoff)); int promptlen ARGS((const char *cp, const char **spp)); int x_do_comment ARGS((char *buf, int bsize, int *lenp)); void x_print_expansions ARGS((int nwords, char *const *words, int is_command)); Index: src/bin/ksh/emacs.c diff -u src/bin/ksh/emacs.c:1.36 src/bin/ksh/emacs.c:1.37 --- src/bin/ksh/emacs.c:1.36 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/emacs.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: emacs.c,v 1.36 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: emacs.c,v 1.37 2017/06/30 04:41:19 kamil Exp $ */ /* * Emacs-like command line editing and history @@ -10,7 +10,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: emacs.c,v 1.36 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: emacs.c,v 1.37 2017/06/30 04:41:19 kamil Exp $"); #endif #include "config.h" @@ -19,6 +19,7 @@ __RCSID("$NetBSD: emacs.c,v 1.36 2017/06 #include <sys/stat.h> #include <ctype.h> #include <locale.h> +#include <stdbool.h> #include "sh.h" #include "ksh_dir.h" @@ -328,7 +329,7 @@ x_emacs(buf, 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 = (char *) 0; @@ -387,7 +388,7 @@ x_emacs(buf, len) return i; case KINTR: /* special case for interrupt */ trapsig(SIGINT); - x_mode(FALSE); + x_mode(false); unwind(LSHELL); } } @@ -461,7 +462,7 @@ x_ins(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); @@ -504,7 +505,7 @@ x_del_back(c) if (x_arg > col) x_arg = col; x_goto(xcp - x_arg); - x_delete(x_arg, FALSE); + x_delete(x_arg, false); return KSTD; } @@ -520,7 +521,7 @@ x_del_char(c) } if (x_arg > nleft) x_arg = nleft; - x_delete(x_arg, FALSE); + x_delete(x_arg, false); return KSTD; } @@ -575,7 +576,7 @@ x_delete(nc, push) } /*x_goto(xcp);*/ x_adj_ok = 1; - xlp_valid = FALSE; + xlp_valid = false; for (cp = x_lastcp(); cp > xcp; ) x_bs(*--cp); @@ -586,7 +587,7 @@ static int x_del_bword(c) int c; { - x_delete(x_bword(), TRUE); + x_delete(x_bword(), true); return KSTD; } @@ -610,7 +611,7 @@ static int x_del_fword(c) int c; { - x_delete(x_fword(), TRUE); + x_delete(x_fword(), true); return KSTD; } @@ -882,7 +883,7 @@ x_load_hist(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 @@ -1020,7 +1021,7 @@ x_del_line(c) xcp = xbuf; x_push(i); xlp = xbp = xep = xbuf; - xlp_valid = TRUE; + xlp_valid = true; *xcp = 0; xmp = NULL; x_redraw(j); @@ -1075,7 +1076,7 @@ x_redraw(limit) x_col = promptlen(prompt, (const char **) 0); } x_displen = xx_cols - 2 - x_col; - xlp_valid = FALSE; + xlp_valid = false; cp = x_lastcp(); x_zots(xbp); if (xbp != xbuf || xep > xlp) @@ -1206,7 +1207,7 @@ x_kill(c) x_goto(xbuf + x_arg); ndel = -ndel; } - x_delete(ndel, TRUE); + x_delete(ndel, true); return KSTD; } @@ -1254,7 +1255,7 @@ x_meta_yank(c) } len = strlen(killstack[killtp]); x_goto(xcp - len); - x_delete(len, FALSE); + x_delete(len, false); do { if (killtp == 0) killtp = KILLSIZE - 1; @@ -1271,7 +1272,7 @@ x_abort(c) { /* x_zotc(c); */ xlp = xep = xcp = xbp = xbuf; - xlp_valid = TRUE; + xlp_valid = true; *xcp = 0; return KINTR; } @@ -1294,7 +1295,7 @@ x_stuffreset(c) #else x_zotc(c); xlp = xcp = xep = xbp = xbuf; - xlp_valid = TRUE; + xlp_valid = true; *xcp = 0; x_redraw(-1); return KSTD; @@ -1307,7 +1308,7 @@ x_stuff(c) { #if 0 || 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); @@ -1562,7 +1563,7 @@ x_kill_region(c) xr = xmp; } x_goto(xr); - x_delete(rsize, TRUE); + x_delete(rsize, true); xmp = xr; return KSTD; } @@ -1747,7 +1748,7 @@ x_expand(c) } 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)) @@ -1793,7 +1794,7 @@ do_complete(flags, 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; @@ -1838,7 +1839,7 @@ x_adjust() */ if ((xbp = xcp - (x_displen / 2)) < xbuf) xbp = xbuf; - xlp_valid = FALSE; + xlp_valid = false; x_redraw(xx_cols); x_flush(); } @@ -2166,7 +2167,7 @@ x_lastcp() i += x_size(*rcp); xlp = rcp; } - xlp_valid = TRUE; + xlp_valid = true; return (xlp); } Index: src/bin/ksh/eval.c diff -u src/bin/ksh/eval.c:1.21 src/bin/ksh/eval.c:1.22 --- src/bin/ksh/eval.c:1.21 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/eval.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.21 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: eval.c,v 1.22 2017/06/30 04:41:19 kamil Exp $ */ /* * Expansion - quoting, separation, substitution, globbing @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: eval.c,v 1.21 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: eval.c,v 1.22 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -880,7 +880,7 @@ comsub(xp, cp) shf = shf_fdopen(pv[0], SHF_RD, (struct shf *) 0); 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); @@ -910,7 +910,7 @@ trimsub(str, pat, 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; } @@ -920,7 +920,7 @@ trimsub(str, pat, 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; } @@ -929,13 +929,13 @@ trimsub(str, pat, 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; @@ -1106,7 +1106,7 @@ globit(xs, xpp, sp, wp, check) while ((d = readdir(dirp)) != NULL) { name = d->d_name; if ((*name == '.' && *sp != '.') - || !gmatch(name, sp, TRUE)) + || !gmatch(name, sp, true)) continue; len = NLENGTH(d) + 1; Index: src/bin/ksh/main.c diff -u src/bin/ksh/main.c:1.21 src/bin/ksh/main.c:1.22 --- src/bin/ksh/main.c:1.21 Fri Jun 30 04:30:26 2017 +++ src/bin/ksh/main.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.21 2017/06/30 04:30:26 kamil Exp $ */ +/* $NetBSD: main.c,v 1.22 2017/06/30 04:41:19 kamil Exp $ */ /* * startup, main loop, environments and error handling @@ -10,7 +10,7 @@ #include <time.h> #ifndef lint -__RCSID("$NetBSD: main.c,v 1.21 2017/06/30 04:30:26 kamil Exp $"); +__RCSID("$NetBSD: main.c,v 1.22 2017/06/30 04:41:19 kamil Exp $"); #endif @@ -351,7 +351,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, (char **) 0, 1); @@ -410,7 +410,7 @@ main(int argc, char *argv[]) Flag(FTRACKALL) = 1; /* set after ENV */ setlocale(LC_CTYPE, ""); - shell(s, TRUE); /* doesn't return */ + shell(s, true); /* doesn't return */ return 0; } @@ -476,7 +476,7 @@ include(name, argc, argv, intr_ok) s = pushs(SFILE, ATEMP); s->u.shf = shf; s->file = str_save(name, ATEMP); - i = shell(s, FALSE); + i = shell(s, false); shf_close(s->u.shf); quitenv(); if (old_argv) { @@ -495,7 +495,7 @@ command(comm) s = pushs(SSTRING, ATEMP); s->start = s->str = comm; - r = shell(s, FALSE); + r = shell(s, false); afree(s, ATEMP); return r; } Index: src/bin/ksh/expr.c diff -u src/bin/ksh/expr.c:1.9 src/bin/ksh/expr.c:1.10 --- src/bin/ksh/expr.c:1.9 Sun Oct 16 17:12:11 2011 +++ src/bin/ksh/expr.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: expr.c,v 1.9 2011/10/16 17:12:11 joerg Exp $ */ +/* $NetBSD: expr.c,v 1.10 2017/06/30 04:41:19 kamil Exp $ */ /* * Korn expression evaluation @@ -9,13 +9,13 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: expr.c,v 1.9 2011/10/16 17:12:11 joerg Exp $"); +__RCSID("$NetBSD: expr.c,v 1.10 2017/06/30 04:41:19 kamil Exp $"); #endif #include "sh.h" #include <ctype.h> - +#include <stdbool.h> /* The order of these enums is constrained by the order of opinfo[] */ enum token { @@ -139,7 +139,7 @@ static void evalerr ARGS((Expr_s static struct tbl *evalexpr ARGS((Expr_state *es, enum prec prec)); static void token ARGS((Expr_state *es)); static struct tbl *do_ppmm ARGS((Expr_state *es, enum token op, - struct tbl *vasn, bool_t is_prefix)); + struct tbl *vasn, bool is_prefix)); static void assign_check ARGS((Expr_state *es, enum token op, struct tbl *vasn)); static struct tbl *tempvar ARGS((void)); @@ -251,31 +251,31 @@ evalerr(es, type, 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); @@ -312,7 +312,7 @@ evalexpr(es, 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; @@ -322,7 +322,7 @@ evalexpr(es, 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; @@ -541,7 +541,7 @@ do_ppmm(es, op, vasn, is_prefix) Expr_state *es; enum token op; struct tbl *vasn; - bool_t is_prefix; + bool is_prefix; { struct tbl *vl; int oval; Index: src/bin/ksh/syn.c diff -u src/bin/ksh/syn.c:1.9 src/bin/ksh/syn.c:1.10 --- src/bin/ksh/syn.c:1.9 Mon Oct 16 00:07:32 2006 +++ src/bin/ksh/syn.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: syn.c,v 1.9 2006/10/16 00:07:32 christos Exp $ */ +/* $NetBSD: syn.c,v 1.10 2017/06/30 04:41:19 kamil Exp $ */ /* * shell parser (C version) @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: syn.c,v 1.9 2006/10/16 00:07:32 christos Exp $"); +__RCSID("$NetBSD: syn.c,v 1.10 2017/06/30 04:41:19 kamil Exp $"); #endif @@ -199,7 +199,7 @@ nested(type, smark, 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)); @@ -277,7 +277,7 @@ get_command(cf) ACCEPT; /*(*/ musthave(')', 0); - t = function_body(XPptrv(args)[0], FALSE); + t = function_body(XPptrv(args)[0], false); goto Leave; default: @@ -336,7 +336,7 @@ get_command(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); @@ -350,7 +350,7 @@ get_command(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; @@ -367,7 +367,7 @@ get_command(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); @@ -389,7 +389,7 @@ get_command(cf) case FUNCTION: musthave(LWORD, 0); - t = function_body(yylval.cp, TRUE); + t = function_body(yylval.cp, true); break; } @@ -440,7 +440,7 @@ dogroup() c = '}'; else syntaxerr((char *) 0); - list = c_list(TRUE); + list = c_list(true); musthave(c, KEYWORD|ALIAS); return list; } @@ -452,7 +452,7 @@ thenpart() musthave(THEN, KEYWORD|ALIAS); t = newtp(0); - t->left = c_list(TRUE); + t->left = c_list(true); if (t->left == NULL) syntaxerr((char *) 0); t->right = elsepart(); @@ -466,13 +466,13 @@ elsepart() switch (token(KEYWORD|ALIAS|VARASN)) { case ELSE: - if ((t = c_list(TRUE)) == NULL) + if ((t = c_list(true)) == NULL) syntaxerr((char *) 0); return (t); case ELIF: t = newtp(TELIF); - t->left = c_list(TRUE); + t->left = c_list(true); t->right = thenpart(); return (t); @@ -530,7 +530,7 @@ casepart(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); @@ -649,40 +649,40 @@ 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 }, + { "if", IF, true }, + { "then", THEN, true }, + { "else", ELSE, true }, + { "elif", ELIF, true }, + { "fi", FI, true }, + { "case", CASE, true }, + { "esac", ESAC, true }, + { "for", FOR, true }, #ifdef KSH - { "select", SELECT, TRUE }, + { "select", SELECT, true }, #endif /* KSH */ - { "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 }, + { "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 }, #ifdef KSH - { "[[", DBRACKET, TRUE }, + { "[[", DBRACKET, true }, #endif /* KSH */ /* Lexical tokens (0[EOF], LWORD and REDIR handled specially) */ - { "&&", LOGAND, FALSE }, - { "||", LOGOR, FALSE }, - { ";;", BREAK, FALSE }, + { "&&", LOGAND, false }, + { "||", LOGOR, false }, + { ";;", BREAK, false }, #ifdef KSH - { "((", MDPAREN, FALSE }, - { "|&", COPROC, FALSE }, + { "((", MDPAREN, false }, + { "|&", COPROC, false }, #endif /* KSH */ /* and some special cases... */ - { "newline", '\n', FALSE }, + { "newline", '\n', false }, { .name = NULL } }; Index: src/bin/ksh/history.c diff -u src/bin/ksh/history.c:1.16 src/bin/ksh/history.c:1.17 --- src/bin/ksh/history.c:1.16 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/history.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: history.c,v 1.16 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: history.c,v 1.17 2017/06/30 04:41:19 kamil Exp $ */ /* * command history @@ -19,7 +19,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: history.c,v 1.16 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: history.c,v 1.17 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -163,8 +163,8 @@ c_fc(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); @@ -184,23 +184,23 @@ c_fc(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; } @@ -247,7 +247,7 @@ c_fc(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.. */ { @@ -311,7 +311,7 @@ hist_execute(cmd) } #ifdef EASY_HISTORY if (p != cmd) - histappend(p, TRUE); + histappend(p, true); else #endif /* EASY_HISTORY */ histsave(++(hist_source->line), p, 1); Index: src/bin/ksh/io.c diff -u src/bin/ksh/io.c:1.16 src/bin/ksh/io.c:1.17 --- src/bin/ksh/io.c:1.16 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/io.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.16 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: io.c,v 1.17 2017/06/30 04:41:19 kamil Exp $ */ /* * shell buffered IO and formatted output @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: io.c,v 1.16 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: io.c,v 1.17 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -29,7 +29,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); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); @@ -64,7 +64,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); @@ -92,7 +92,7 @@ internal_errorf(int jump, const char *fm { va_list va; - error_prefix(TRUE); + error_prefix(true); shf_fprintf(shl_out, "internal error: "); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); @@ -277,7 +277,7 @@ restfd(fd, 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); } } Index: src/bin/ksh/jobs.c diff -u src/bin/ksh/jobs.c:1.18 src/bin/ksh/jobs.c:1.19 --- src/bin/ksh/jobs.c:1.18 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/jobs.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.18 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: jobs.c,v 1.19 2017/06/30 04:41:19 kamil Exp $ */ /* * Process and job control @@ -21,7 +21,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: jobs.c,v 1.18 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.19 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> @@ -269,7 +269,7 @@ j_init(mflagset) else #endif /* JOBS */ if (Flag(FTALKING)) - tty_init(TRUE); + tty_init(true); } /* job cleanup before shell exit */ @@ -337,14 +337,14 @@ j_change() 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; } @@ -356,7 +356,7 @@ j_change() pid_t ttypgrp; if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) { - warningf(FALSE, + warningf(false, "j_init: tcgetpgrp() failed: %s", strerror(errno)); ttypgrp_ok = 0; @@ -372,13 +372,13 @@ j_change() 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; @@ -392,13 +392,13 @@ j_change() 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); @@ -589,7 +589,7 @@ exchild(t, flags, close_fd) #ifdef KSH /* Do this before restoring signal */ if (flags & XCOPROC) - coproc_cleanup(FALSE); + coproc_cleanup(false); #endif /* KSH */ sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0); cleanup_parents_env(); @@ -616,7 +616,7 @@ exchild(t, flags, 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); } } @@ -701,7 +701,7 @@ waitlast() 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"); sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0); @@ -892,7 +892,7 @@ j_resume(cp, 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)); @@ -1164,7 +1164,7 @@ j_waitj(j, flags, 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)); @@ -1280,7 +1280,7 @@ j_sigchld(sig) found: if (j == (Job *) 0) { /* 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; Index: src/bin/ksh/lex.c diff -u src/bin/ksh/lex.c:1.20 src/bin/ksh/lex.c:1.21 --- src/bin/ksh/lex.c:1.20 Fri Jun 30 02:51:14 2017 +++ src/bin/ksh/lex.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.20 2017/06/30 02:51:14 kamil Exp $ */ +/* $NetBSD: lex.c,v 1.21 2017/06/30 04:41:19 kamil Exp $ */ /* * lexical analysis and source input @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: lex.c,v 1.20 2017/06/30 02:51:14 kamil Exp $"); +__RCSID("$NetBSD: lex.c,v 1.21 2017/06/30 04:41:19 kamil Exp $"); #endif @@ -170,7 +170,7 @@ yylex(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; @@ -845,7 +845,7 @@ yyerror(const char *fmt, ...) source = source->next; source->str = null; /* zap pending input */ - error_prefix(TRUE); + error_prefix(true); va_start(va, fmt); shf_vfprintf(shl_out, fmt, va); va_end(va); Index: src/bin/ksh/mail.c diff -u src/bin/ksh/mail.c:1.7 src/bin/ksh/mail.c:1.8 --- src/bin/ksh/mail.c:1.7 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/mail.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: mail.c,v 1.7 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: mail.c,v 1.8 2017/06/30 04:41:19 kamil Exp $ */ /* * Mailbox checking code by Robert J. Gibson, adapted for PD ksh by @@ -7,7 +7,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: mail.c,v 1.7 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: mail.c,v 1.8 2017/06/30 04:41:19 kamil Exp $"); #endif #include "config.h" @@ -194,7 +194,7 @@ mbox_t *mbp; struct tbl *vp; /* Ignore setstr errors here (arbitrary) */ - setstr((vp = local("_", FALSE)), mbp->mb_path, KSH_RETURN_ERROR); + setstr((vp = local("_", false)), mbp->mb_path, KSH_RETURN_ERROR); shellf("%s\n", substitute(mbp->mb_msg ? mbp->mb_msg : MBMESSAGE, 0)); Index: src/bin/ksh/sh.h diff -u src/bin/ksh/sh.h:1.33 src/bin/ksh/sh.h:1.34 --- src/bin/ksh/sh.h:1.33 Fri Jun 30 04:30:26 2017 +++ src/bin/ksh/sh.h Fri Jun 30 04:41:19 2017 @@ -1,10 +1,10 @@ -/* $NetBSD: sh.h,v 1.33 2017/06/30 04:30:26 kamil Exp $ */ +/* $NetBSD: sh.h,v 1.34 2017/06/30 04:41:19 kamil Exp $ */ /* * Public Domain Bourne/Korn shell */ -/* $Id: sh.h,v 1.33 2017/06/30 04:30:26 kamil Exp $ */ +/* $Id: sh.h,v 1.34 2017/06/30 04:41:19 kamil Exp $ */ #include "config.h" /* system and option configuration info */ @@ -157,10 +157,6 @@ typedef RETSIGTYPE (*handler_t) ARGS((in # 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 */ Index: src/bin/ksh/trap.c diff -u src/bin/ksh/trap.c:1.12 src/bin/ksh/trap.c:1.13 --- src/bin/ksh/trap.c:1.12 Fri Jun 23 00:00:58 2017 +++ src/bin/ksh/trap.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.12 2017/06/23 00:00:58 kamil Exp $ */ +/* $NetBSD: trap.c,v 1.13 2017/06/30 04:41:19 kamil Exp $ */ /* * signal handling @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: trap.c,v 1.12 2017/06/23 00:00:58 kamil Exp $"); +__RCSID("$NetBSD: trap.c,v 1.13 2017/06/30 04:41:19 kamil Exp $"); #endif #include "sh.h" @@ -205,7 +205,7 @@ runtraps(flag) #ifdef KSH 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 Index: src/bin/ksh/var.c diff -u src/bin/ksh/var.c:1.19 src/bin/ksh/var.c:1.20 --- src/bin/ksh/var.c:1.19 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/var.c Fri Jun 30 04:41:19 2017 @@ -1,15 +1,16 @@ -/* $NetBSD: var.c,v 1.19 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: var.c,v 1.20 2017/06/30 04:41:19 kamil Exp $ */ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: var.c,v 1.19 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: var.c,v 1.20 2017/06/30 04:41:19 kamil Exp $"); #endif #include <sys/stat.h> #include <sys/time.h> #include <time.h> #include <ctype.h> +#include <stdbool.h> #include "sh.h" #include "ksh_limval.h" @@ -134,25 +135,25 @@ initvar() * non-zero if this is an array, sets *valp to the array index, returns * the basename of the array. */ -const char *array_index_calc(const char *n, bool_t *arrayp, int *valp); +const char *array_index_calc(const char *n, bool *arrayp, int *valp); const char * array_index_calc(n, arrayp, valp) const char *n; - bool_t *arrayp; + 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); @@ -177,7 +178,7 @@ global(n) register struct tbl *vp; register int c; unsigned h; - bool_t array; + bool array; int val; /* Check to see if this is an array */ @@ -255,12 +256,12 @@ global(n) struct tbl * local(n, copy) register const char *n; - bool_t copy; + bool copy; { register struct block *l = e->loc; register struct tbl *vp; unsigned h; - bool_t array; + bool array; int val; /* Check to see if this is an array */ @@ -376,7 +377,7 @@ setstr(vq, s, 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("%s", null); return 0; @@ -386,7 +387,7 @@ setstr(vq, s, 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); @@ -623,7 +624,7 @@ typeset(var, set, clr, field, 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 == '[') { @@ -662,7 +663,7 @@ typeset(var, set, clr, field, 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); @@ -860,7 +861,7 @@ int is_wdvarassign(s) const char *s; { - char *p = skip_wdvarname(s, TRUE); + char *p = skip_wdvarname(s, true); return p != s && p[0] == CHAR && p[1] == '='; } Index: src/bin/ksh/vi.c diff -u src/bin/ksh/vi.c:1.17 src/bin/ksh/vi.c:1.18 --- src/bin/ksh/vi.c:1.17 Fri Jun 30 03:56:12 2017 +++ src/bin/ksh/vi.c Fri Jun 30 04:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vi.c,v 1.17 2017/06/30 03:56:12 kamil Exp $ */ +/* $NetBSD: vi.c,v 1.18 2017/06/30 04:41:19 kamil Exp $ */ /* * vi command editing @@ -9,7 +9,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: vi.c,v 1.17 2017/06/30 03:56:12 kamil Exp $"); +__RCSID("$NetBSD: vi.c,v 1.18 2017/06/30 04:41:19 kamil Exp $"); #endif #include "config.h" @@ -226,7 +226,7 @@ x_vi(buf, 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) {