From d5fb70a8f9cc88168fb7febc1fa264c56c07062d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 15 Mar 2017 09:11:12 -0400 Subject: [PATCH] Use stdbool because this is 2016 and there's no excuse not to --- builtins.c | 84 +++++++++++++++++++++++----------------------- except.c | 12 +++---- exec.c | 30 ++++++++--------- fn.c | 10 +++--- footobar.c | 24 ++++++------- glob.c | 22 ++++++------ glom.c | 14 ++++---- hash.c | 38 ++++++++++----------- heredoc.c | 20 +++++------ input.c | 22 ++++++------ lex.c | 40 +++++++++++----------- main.c | 46 ++++++++++++------------- match.c | 20 +++++------ open.c | 12 +++---- print.c | 20 +++++------ rc.h | 5 +-- redir.c | 2 +- status.c | 12 +++---- var.c | 20 +++++------ wait.c | 12 +++---- walk.c | 98 +++++++++++++++++++++++++++--------------------------- which.c | 12 +++---- 22 files changed, 286 insertions(+), 289 deletions(-) diff --git a/builtins.c b/builtins.c index 51cb36f..130dc09 100644 --- a/builtins.c +++ b/builtins.c @@ -49,25 +49,25 @@ extern void funcall(char **av) { Edata jreturn, star; if (sigsetjmp(j.j, 1)) return; - starassign(*av, av+1, TRUE); + starassign(*av, av+1, true); jreturn.jb = &j; star.name = "*"; except(eReturn, jreturn, &e1); except(eVarstack, star, &e2); - walk(treecpy(fnlookup(*av), nalloc), TRUE); - varrm("*", TRUE); + walk(treecpy(fnlookup(*av), nalloc), true); + varrm("*", true); unexcept(); /* eVarstack */ unexcept(); /* eReturn */ } static void arg_count(char *name) { fprint(2, RC "too many arguments to %s\n", name); - set(FALSE); + set(false); } static void badnum(char *num) { fprint(2, RC "`%s' is a bad number\n", num); - set(FALSE); + set(false); } /* a dummy command. (exec() performs "exec" simply by not forking) */ @@ -86,7 +86,7 @@ static void b_echo(char **av) { av++; } fprint(1, format, av); - set(TRUE); + set(true); } /* cd. traverse $cdpath if the directory given is not an absolute pathname */ @@ -104,10 +104,10 @@ static void b_cd(char **av) { } if (isabsolute(*av) || streq(*av, ".") || streq(*av, "..")) { /* absolute pathname? */ if (chdir(*av) < 0) { - set(FALSE); + set(false); uerror(*av); } else - set(TRUE); + set(true); } else { s = varlookup("cdpath"); if (s == NULL) { @@ -129,7 +129,7 @@ static void b_cd(char **av) { path = *av; } if (chdir(path) >= 0) { - set(TRUE); + set(true); if (interactive && *s->w != '\0' && !streq(s->w, ".")) fprint(1, "%s\n", path); return; @@ -137,14 +137,14 @@ static void b_cd(char **av) { s = s->n; } while (s != NULL); fprint(2, "couldn't cd to %s\n", *av); - set(FALSE); + set(false); } } static void b_umask(char **av) { int i; if (*++av == NULL) { - set(TRUE); + set(true); i = umask(0); umask(i); fprint(1, "0%o\n", i); @@ -152,10 +152,10 @@ static void b_umask(char **av) { i = o2u(*av); if ((unsigned int) i > 0777) { fprint(2, "bad umask\n"); - set(FALSE); + set(false); } else { umask(i); - set(TRUE); + set(true); } } else { arg_count("umask"); @@ -208,10 +208,10 @@ static void b_shift(char **av) { } if (s == NULL && shift != 0) { fprint(2, "cannot shift\n"); - set(FALSE); + set(false); } else { - varassign("*", append(dollarzero, s), FALSE); - set(TRUE); + varassign("*", append(dollarzero, s), false); + set(true); } } @@ -237,10 +237,10 @@ static void b_wait(char **av) { badnum(av[1]); return; } - if (rc_wait4(pid, &status, FALSE) > 0) + if (rc_wait4(pid, &status, false) > 0) setstatus(pid, status); else - set(FALSE); + set(false); sigchk(); } @@ -249,15 +249,15 @@ static void b_wait(char **av) { is defined as a variable, function or pathname. */ -#define not(b) ((b)^TRUE) +#define not(b) ((b)^true) #define show(b) (not(eff|vee|pee|bee|ess)|(b)) static bool issig(char *s) { int i; for (i = 0; i < NSIG; i++) if (streq(s, signals[i].name)) - return TRUE; - return FALSE; + return true; + return false; } /* push a string to be eval'ed onto the input stack. evaluate it */ @@ -266,9 +266,9 @@ static void b_eval(char **av) { bool i = interactive; if (av[1] == NULL) return; - interactive = FALSE; + interactive = false; pushstring(av + 1, i); /* don't reset line numbers on noninteractive eval */ - doit(TRUE); + doit(true); interactive = i; } @@ -279,7 +279,7 @@ static void b_eval(char **av) { extern void b_dot(char **av) { int fd; - bool old_i = interactive, i = FALSE; + bool old_i = interactive, i = false; Estack e; Edata star; av++; @@ -287,27 +287,27 @@ extern void b_dot(char **av) { return; if (streq(*av, "-i")) { av++; - i = TRUE; + i = true; } - if (dasheye) { /* rc -i file has to do the right thing. reset the dasheye state to FALSE, though. */ - dasheye = FALSE; - i = TRUE; + if (dasheye) { /* rc -i file has to do the right thing. reset the dasheye state to false, though. */ + dasheye = false; + i = true; } if (*av == NULL) return; fd = rc_open(*av, rFrom); if (fd < 0) { uerror(*av); - set(FALSE); + set(false); return; } - starassign(*av, av+1, TRUE); + starassign(*av, av+1, true); interactive = i; pushfd(fd); star.name = "*"; except(eVarstack, star, &e); - doit(TRUE); - varrm("*", TRUE); + doit(true); + varrm("*", true); unexcept(); /* eVarstack */ interactive = old_i; } @@ -395,13 +395,13 @@ static bool parselimit(const struct Limit *resource, rlim_t *limit, char *s) { *limit = 1; if (streq(s, "unlimited")) { *limit = RLIM_INFINITY; - return TRUE; + return true; } if (suf == TIMESUF && (t = strchr(s, ':')) != NULL) { int min, sec; *t++ = '\0'; min = a2u(s); sec = a2u(t); - if (min == -1 || sec == -1) return FALSE; + if (min == -1 || sec == -1) return false; *limit = 60 * min + sec; } else { int n; @@ -412,18 +412,18 @@ static bool parselimit(const struct Limit *resource, rlim_t *limit, char *s) { break; } n = a2u(s); - if (n == -1) return FALSE; + if (n == -1) return false; *limit *= n; } - return TRUE; + return true; } static void b_limit(char **av) { const struct Limit *lp = limits; - bool hard = FALSE; + bool hard = false; if (*++av != NULL && streq(*av, "-h")) { av++; - hard = TRUE; + hard = true; } if (*av == NULL) { for (; lp->name != NULL; lp++) @@ -433,7 +433,7 @@ static void b_limit(char **av) { for (;; lp++) { if (lp->name == NULL) { fprint(2, "no such limit\n"); - set(FALSE); + set(false); return; } if (streq(*av, lp->name)) @@ -447,7 +447,7 @@ static void b_limit(char **av) { getrlimit(lp->flag, &rlim); if (!parselimit(lp, &pl, *av)) { fprint(2, "bad limit\n"); - set(FALSE); + set(false); return; } if (hard) @@ -456,8 +456,8 @@ static void b_limit(char **av) { rlim.rlim_cur = pl; if (setrlimit(lp->flag, &rlim) == -1) { uerror("setrlimit"); - set(FALSE); + set(false); } else - set(TRUE); + set(true); } } diff --git a/except.c b/except.c index b78688c..82d421e 100644 --- a/except.c +++ b/except.c @@ -5,7 +5,7 @@ not. A signal goes to the last interactive level. (see below) */ -bool nl_on_intr = TRUE; +bool nl_on_intr = true; static Estack *estack; @@ -68,7 +68,7 @@ extern void rc_raise(ecodes e) { default: break; case eVarstack: - varrm(estack->data.name, TRUE); + varrm(estack->data.name, true); break; case eArena: restoreblock(estack->data.b); @@ -118,9 +118,9 @@ extern void pop_cmdarg(bool remove) { extern void rc_error(char *s) { pr_error(s, -1); - set(FALSE); + set(false); redirq = NULL; - cond = FALSE; /* no longer inside conditional */ + cond = false; /* no longer inside conditional */ rc_raise(eError); } @@ -130,8 +130,8 @@ extern void sigint(int s) { /* this is the newline you see when you hit ^C while typing a command */ if (interactive && nl_on_intr) fprint(2, "\n"); - nl_on_intr = TRUE; + nl_on_intr = true; redirq = NULL; - cond = FALSE; + cond = false; rc_raise(eError); } diff --git a/exec.c b/exec.c index 2136a96..af8043e 100644 --- a/exec.c +++ b/exec.c @@ -15,7 +15,7 @@ extern void exec(List *s, bool parent) { char *path = NULL; bool didfork, returning, saw_exec, saw_builtin; av = list2array(s, dashex); - saw_builtin = saw_exec = FALSE; + saw_builtin = saw_exec = false; do { if (*av == NULL || isabsolute(*av)) b = NULL; @@ -28,15 +28,15 @@ extern void exec(List *s, bool parent) { a builtin applies only to the immmediately following command, e.g., builtin exec echo hi */ - saw_builtin = FALSE; + saw_builtin = false; if (b == b_exec) { av++; - saw_exec = TRUE; - parent = FALSE; + saw_exec = true; + parent = false; } else if (b == b_builtin) { av++; - saw_builtin = TRUE; + saw_builtin = true; } } while (b == b_exec || b == b_builtin); if (*av == NULL && saw_exec) { /* do redirs and return on a null exec */ @@ -47,9 +47,9 @@ extern void exec(List *s, bool parent) { if (saw_exec) rc_pid = -1; if (b == NULL) { - path = which(*av, TRUE); + path = which(*av, true); if (path == NULL && *av != NULL) { /* perform null commands for redirections */ - set(FALSE); + set(false); redirq = NULL; if (parent) return; @@ -64,10 +64,10 @@ extern void exec(List *s, bool parent) { */ if ((parent && (b == NULL || redirq != NULL)) || outstanding_cmdarg()) { pid = rc_fork(); - didfork = TRUE; + didfork = true; } else { pid = 0; - didfork = FALSE; + didfork = false; } returning = (!didfork && parent); switch (pid) { @@ -77,8 +77,8 @@ extern void exec(List *s, bool parent) { /* NOTREACHED */ case 0: if (!returning) - setsigdefaults(FALSE); - pop_cmdarg(FALSE); + setsigdefaults(false); + pop_cmdarg(false); doredirs(); /* null commands performed for redirections */ @@ -104,7 +104,7 @@ extern void exec(List *s, bool parent) { /* NOTREACHED */ default: redirq = NULL; - rc_wait4(pid, &stat, TRUE); + rc_wait4(pid, &stat, true); setstatus(-1, stat); /* There is a very good reason for having this weird @@ -118,9 +118,9 @@ extern void exec(List *s, bool parent) { vector. */ if (WIFEXITED(stat)) - nl_on_intr = FALSE; + nl_on_intr = false; sigchk(); - nl_on_intr = TRUE; - pop_cmdarg(TRUE); + nl_on_intr = true; + pop_cmdarg(true); } } diff --git a/fn.c b/fn.c index 5e610e9..24bd925 100644 --- a/fn.c +++ b/fn.c @@ -7,7 +7,7 @@ static void fn_handler(int), dud_handler(int); -static bool runexit = FALSE; +static bool runexit = false; static Node *handlers[NSIG], null; static void (*def_sigint)(int) = SIG_DFL; static void (*def_sigquit)(int) = SIG_DFL; @@ -94,7 +94,7 @@ extern void setsigdefaults(bool sysvbackground) { } } delete_fn("sigexit"); - runexit = FALSE; /* No sigexit on subshells */ + runexit = false; /* No sigexit on subshells */ } /* rc's exit. if runexit is set, run the sigexit function. */ @@ -104,7 +104,7 @@ extern void rc_exit(int stat) { char *sig[2]; sig[0] = "sigexit"; sig[1] = NULL; - runexit = FALSE; + runexit = false; funcall(sig); stat = getstatus(); } @@ -144,7 +144,7 @@ extern void fnassign(char *name, Node *def) { new->extdef = NULL; if (strncmp(name, "sig", conststrlen("sig")) == 0) { /* slight optimization */ if (streq(name, "sigexit")) - runexit = TRUE; + runexit = true; for (i = 1; i < NSIG; i++) /* zero is a bogus signal */ if (streq(signals[i].name, name)) { handlers[i] = newdef; @@ -227,7 +227,7 @@ extern void fnrm(char *name) { } } if (streq(name, "sigexit")) - runexit = FALSE; + runexit = false; delete_fn(name); } diff --git a/footobar.c b/footobar.c index b445a33..0cf1efd 100644 --- a/footobar.c +++ b/footobar.c @@ -17,7 +17,7 @@ static bool Fconv(Format *f, int ignore) { fmtprint(f, "__%02x", c); else fmtputc(f, c); - return FALSE; + return false; } #endif @@ -34,7 +34,7 @@ static bool Dconv(Format *f, int ignore) { case rHerestring: name = "<<<"; break; } fmtcat(f, name); - return FALSE; + return false; } /* defaultfd -- return the default fd for a given redirection operation */ @@ -51,7 +51,7 @@ static bool Tconv(Format *f, int ignore) { if (n == NULL) { fmtprint(f, "()"); - return FALSE; + return false; } switch (n->type) { case nBang: fmtprint(f, "!%T", n->u[0].p); break; @@ -79,9 +79,9 @@ static bool Tconv(Format *f, int ignore) { case nLappend: { static bool inlist; if (!inlist) { - inlist = TRUE; + inlist = true; fmtprint(f, "(%T %T)", n->u[0].p, n->u[1].p); - inlist = FALSE; + inlist = false; } else { fmtprint(f, "%T %T", n->u[0].p, n->u[1].p); } @@ -168,7 +168,7 @@ static bool Tconv(Format *f, int ignore) { break; } } - return FALSE; + return false; } /* convert a List to an array, for execve() */ @@ -297,7 +297,7 @@ static bool Aconv(Format *f, int ignore) { while (*++a != NULL) fmtprint(f, " %s", *a); } - return FALSE; + return false; } /* %L -- print a list */ @@ -318,7 +318,7 @@ static bool Lconv(Format *f, int ignore) { if (n != NULL) fmtputc(f, *sep); } } - return FALSE; + return false; } /* %W -- print a list for exporting */ @@ -337,7 +337,7 @@ static bool Wconv(Format *f, int ignore) { n = l->n; if (n != NULL) fmtputc(f, ENV_SEP); } - return FALSE; + return false; } #define ISMETA(c) (c == '*' || c == '?' || c == '[') @@ -349,14 +349,14 @@ static bool Sconv(Format *f, int ignore) { bool metaquote = (f->flags & FMT_leftside) != 0; /* '-' */ if (*s == '\0') { fmtprint(f, "''"); - return FALSE; + return false; } if (!quoted) { while ((c = *t++) != '\0') if (nw[c] == 1 || (metaquote && ISMETA(c))) goto quoteit; fmtprint(f, "%s", s); - return FALSE; + return false; } quoteit: fmtputc(f, '\''); @@ -367,7 +367,7 @@ quoteit: } fmtputc(f, '\''); - return FALSE; + return false; } void initprint(void) { diff --git a/glob.c b/glob.c index 4d199c8..dcb7b2a 100644 --- a/glob.c +++ b/glob.c @@ -20,18 +20,18 @@ extern bool lmatch(List *s, List *p) { List *q; if (s == NULL) { if (p == NULL) /* null matches null */ - return TRUE; + return true; for (; p != NULL; p = p->n) /* one or more stars match null */ if (strspn(p->w, "*") == strlen(p->w) && p->m != NULL && strlen(p->m) == strlen(p->w)) - return TRUE; - return FALSE; + return true; + return false; } for (; s != NULL; s = s->n) for (q = p; q != NULL; q = q->n) if (match(q->w, q->m, s->w)) - return TRUE; - return FALSE; + return true; + return false; } /* @@ -42,9 +42,9 @@ extern bool lmatch(List *s, List *p) { extern List *glob(List *s) { List *top, *r; bool meta; - for (r = s, meta = FALSE; r != NULL; r = r->n) + for (r = s, meta = false; r != NULL; r = r->n) if (r->m != NULL) - meta = TRUE; + meta = true; if (!meta) return s; /* don't copy lists with no metacharacters in them */ for (top = r = NULL; s != NULL; s = s->n) { @@ -81,11 +81,11 @@ static List *dmatch(char *d, char *p, char *m) { return a match if there are no metacharacters; allows globbing through directories with no read permission. make sure the file exists, though. */ - matched = TRUE; + matched = true; if (m != NULL) for (i = 0; p[i] != '\0'; i++) if (m[i]) { - matched = FALSE; + matched = false; break; } @@ -111,7 +111,7 @@ static List *dmatch(char *d, char *p, char *m) { } while ((dp = readdir(dirp)) != NULL) if ((*dp->d_name != '.' || *p == '.') && match(p, m, dp->d_name)) { /* match ^. explicitly */ - matched = TRUE; + matched = true; if (top == NULL) top = r = nnew(List); else @@ -242,7 +242,7 @@ static List *sort(List *s) { if (nel > 1) { char **a; List *t; - qsort(a = list2array(s, FALSE), nel, sizeof(char *), starstrcmp); + qsort(a = list2array(s, false), nel, sizeof(char *), starstrcmp); for (t = s; t != NULL; t = t->n) t->w = *a++; } diff --git a/glom.c b/glom.c index 1d4ebe1..a787f25 100644 --- a/glom.c +++ b/glom.c @@ -178,9 +178,9 @@ static List *bqinput(List *ifs, int fd) { int n, state; /* a simple FSA is used to read in data */ memzero(isifs, sizeof isifs); - for (isifs['\0'] = TRUE; ifs != NULL; ifs = ifs->n) + for (isifs['\0'] = true; ifs != NULL; ifs = ifs->n) for (s = ifs->w; *s != '\0'; s++) - isifs[*(unsigned char *)s] = TRUE; + isifs[*(unsigned char *)s] = true; remain = bufsize = BUFSIZE; top = r = nnew(List); r->w = end = nalloc(bufsize + 1); @@ -255,15 +255,15 @@ static List *backq(Node *ifs, Node *n) { mvfd(p[1], 1); close(p[0]); redirq = NULL; - walk(n, FALSE); + walk(n, false); exit(getstatus()); } close(p[1]); bq = bqinput(glom(ifs), p[0]); close(p[0]); - rc_wait4(pid, &sp, TRUE); + rc_wait4(pid, &sp, true); statprint(-1, sp); - varassign("bqstatus", word(strstatus(sp), NULL), FALSE); + varassign("bqstatus", word(strstatus(sp), NULL), false); sigchk(); return bq; } @@ -296,7 +296,7 @@ static List *mkcmdarg(Node *n) { return NULL; } if (rc_fork() == 0) { - setsigdefaults(FALSE); + setsigdefaults(false); fd = rc_open(name, (n->u[0].i != rFrom) ? rFrom : rCreate); /* stupid hack */ if (fd < 0) { uerror("open"); @@ -305,7 +305,7 @@ static List *mkcmdarg(Node *n) { if (mvfd(fd, (n->u[0].i == rFrom)) < 0) /* same stupid hack */ exit(1); redirq = NULL; - walk(n->u[2].p, FALSE); + walk(n->u[2].p, false); exit(getstatus()); } efifo.name = name; diff --git a/hash.c b/hash.c index e66383d..aa66f39 100644 --- a/hash.c +++ b/hash.c @@ -22,7 +22,7 @@ static int fused, fsize, vused, vsize; static char **env; static int bozosize; static int envsize; -static bool env_dirty = TRUE; +static bool env_dirty = true; static char *dead = ""; #define HASHSIZE 64 /* rc was debugged with HASHSIZE == 2; 64 is about right for normal use */ @@ -65,11 +65,11 @@ static bool rehash(Htab *ht) { Htab *newhtab; if (ht == fp) { if (fsize > 2 * fused) - return FALSE; + return false; size = fsize; } else { if (vsize > 2 * vused) - return FALSE; + return false; size = vsize; } newsize = 2 * size; @@ -97,7 +97,7 @@ static bool rehash(Htab *ht) { vsize = newsize; } efree(ht); - return TRUE; + return true; } #define varfind(s) find(s, vp, vsize) @@ -119,7 +119,7 @@ extern void *lookup(char *s, Htab *ht) { extern rc_Function *get_fn_place(char *s) { int h = fnfind(s); - env_dirty = TRUE; + env_dirty = true; if (fp[h].name == NULL) { if (rehash(fp)) h = fnfind(s); @@ -135,7 +135,7 @@ extern Variable *get_var_place(char *s, bool stack) { Variable *new; int h = varfind(s); - env_dirty = TRUE; + env_dirty = true; if (vp[h].name == NULL) { if (rehash(vp)) @@ -163,7 +163,7 @@ extern void delete_fn(char *s) { int h = fnfind(s); if (fp[h].name == NULL) return; /* not found */ - env_dirty = TRUE; + env_dirty = true; free_fn(fp[h].p); efree(fp[h].p); efree(fp[h].name); @@ -180,7 +180,7 @@ extern void delete_var(char *s, bool stack) { Variable *v; if (vp[h].name == NULL) return; /* not found */ - env_dirty = TRUE; + env_dirty = true; v = vp[h].p; efree(v->extdef); listfree(v->def); @@ -233,15 +233,15 @@ static char *neverexport[] = { }; /* for a few variables that have default values, we export them only -if they've been explicitly set; maybeexport[n].flag is TRUE if this +if they've been explicitly set; maybeexport[n].flag is true if this has occurred. */ struct nameflag { char *name; bool flag; }; static struct nameflag maybeexport[] = { - { "prompt", FALSE }, - { "version", FALSE } + { "prompt", false }, + { "version", false } }; void set_exportable(char *s, bool b) { @@ -255,11 +255,11 @@ static bool var_exportable(char *s) { int i; for (i = 0; i < arraysize(neverexport); i++) if (streq(s, neverexport[i])) - return FALSE; + return false; for (i = 0; i < arraysize(maybeexport); i++) - if (maybeexport[i].flag == FALSE && streq(s, maybeexport[i].name)) - return FALSE; - return TRUE; + if (maybeexport[i].flag == false && streq(s, maybeexport[i].name)) + return false; + return true; } static bool fn_exportable(char *s) { @@ -267,11 +267,11 @@ static bool fn_exportable(char *s) { if (strncmp(s, "sig", conststrlen("sig")) == 0) { /* small speed hack */ for (i = 0; i < NSIG; i++) if (streq(s, signals[i].name)) - return FALSE; + return false; if (streq(s, "sigexit")) - return FALSE; + return false; } - return TRUE; + return true; } extern char **makeenv() { @@ -279,7 +279,7 @@ extern char **makeenv() { char *v; if (!env_dirty) return env; - env_dirty = FALSE; + env_dirty = false; ep = bozosize; if (vsize + fsize + 1 + bozosize > envsize) { envsize = 2 * (bozosize + vsize + fsize + 1); diff --git a/heredoc.c b/heredoc.c index 2717778..8fef56d 100644 --- a/heredoc.c +++ b/heredoc.c @@ -9,7 +9,7 @@ struct Hq { bool quoted; } *hq; -static bool dead = FALSE; +static bool dead = false; /* * read in a heredocument. A clever trick: skip over any partially matched end-of-file @@ -29,7 +29,7 @@ static char *readheredoc(char *eof) { size_t bufsize; t = buf = nalloc(bufsize = 512); bufend = &buf[bufsize]; - dead = FALSE; + dead = false; #define RESIZE(extra) { \ char *nbuf; \ bufsize = bufsize * 2 + extra; \ @@ -57,7 +57,7 @@ static char *readheredoc(char *eof) { for (;; c = gchar()) { if (c == EOF) { yyerror("heredoc incomplete"); - dead = TRUE; + dead = true; return NULL; } if (t + 1 >= bufend) @@ -74,7 +74,7 @@ static char *readheredoc(char *eof) { static Node *parseheredoc(char *s) { int c = *s; Node *result = NULL; - while (TRUE) { + while (true) { Node *node; switch (c) { default: { @@ -122,18 +122,18 @@ extern int heredoc(int end) { hq = NULL; if (end) { yyerror("heredoc incomplete"); - return FALSE; + return false; } do { Node *n = here->doc; char *s = readheredoc(here->name); if (dead) - return FALSE; - n->u[2].p = here->quoted ? mk(nWord, s, NULL, FALSE) : parseheredoc(s); + return false; + n->u[2].p = here->quoted ? mk(nWord, s, NULL, false) : parseheredoc(s); n->u[0].i = rHerestring; } while ((here = here->n) != NULL); } - return TRUE; + return true; } /* queue pending heredocs into a queue. called from yyparse */ @@ -143,7 +143,7 @@ extern int qdoc(Node *name, Node *n) { if (name->type != nWord) { yyerror("eof-marker not a single literal word"); skiptonl(); - return FALSE; + return false; } for (prev = &hq; (new = *prev) != NULL; prev = &new->n) ; @@ -152,5 +152,5 @@ extern int qdoc(Node *name, Node *n) { new->quoted = name->u[2].i; new->doc = n; new->n = NULL; - return TRUE; + return true; } diff --git a/input.c b/input.c index ddd6c03..b78075e 100644 --- a/input.c +++ b/input.c @@ -23,7 +23,7 @@ typedef struct Input { static char *inbuf; static size_t istacksize, chars_out, chars_in; -static bool save_lineno = TRUE; +static bool save_lineno = true; static Input *istack, *itop; int lastchar; @@ -157,7 +157,7 @@ static void pushcommon() { extern void pushfd(int fd) { pushcommon(); - save_lineno = TRUE; + save_lineno = true; istack->fd = fd; lineno = 1; istack->t = iFd; @@ -220,12 +220,12 @@ extern Node *doit(bool clobberexecit) { Edata jerror; if (dashen) - clobberexecit = FALSE; + clobberexecit = false; execit = clobberexecit; sigsetjmp(j.j, 1); jerror.jb = &j; except(eError, jerror, &e1); - for (eof = FALSE; !eof;) { + for (eof = false; !eof;) { Edata block; Estack e2; @@ -236,14 +236,14 @@ extern Node *doit(bool clobberexecit) { if (interactive) { List *s; if (!dashen && fnlookup("prompt") != NULL) { - static bool died = FALSE; + static bool died = false; static char *arglist[] = { "prompt", NULL }; if (!died) { - died = TRUE; + died = true; funcall(arglist); } - died = FALSE; + died = false; } s = varlookup("prompt"); if (s != NULL) { @@ -264,7 +264,7 @@ extern Node *doit(bool clobberexecit) { eof = (lastchar == EOF); /* "lastchar" can be clobbered during a walk() */ if (parsetree != NULL) { if (execit) - walk(parsetree, TRUE); + walk(parsetree, true); else if (dashex && dashen) fprint(2, "%T\n", parsetree); } @@ -283,9 +283,9 @@ extern Node *parseline(char *extdef) { Node *fun; in[0] = extdef; in[1] = NULL; - interactive = FALSE; - pushstring(in, TRUE); - fun = doit(FALSE); + interactive = false; + pushstring(in, true); + fun = doit(false); interactive = i; return fun; } diff --git a/lex.c b/lex.c index d487896..b682dcc 100644 --- a/lex.c +++ b/lex.c @@ -15,8 +15,8 @@ special cases. In our case, \ cannot be a word character, since we wish to read in all word characters in a tight loop. - Note: to save the trouble of declaring these arrays with TRUEs - and FALSEs, I am assuming that FALSE = 0, TRUE = 1. (and so is + Note: to save the trouble of declaring these arrays with trues + and falses, I am assuming that false = 0, true = 1. (and so is it declared in rc.h) */ @@ -71,9 +71,9 @@ const char q[] = { static size_t bufsize = BUFSIZE; static char *realbuf = NULL; -static bool newline = FALSE; -static bool errset = FALSE; -static bool prerror = FALSE; +static bool newline = false; +static bool errset = false; +static bool prerror = false; static wordstates w = NW; static int fd_left, fd_right; @@ -91,20 +91,20 @@ extern bool quotep(char *s, bool dollar) { meta = dollar ? dnw : q; while ((c = *s++)) if (meta[c]) - return TRUE; - return FALSE; + return true; + return false; } extern int yylex() { - static bool dollar = FALSE; - bool saw_meta = FALSE; + static bool dollar = false; + bool saw_meta = false; int c; size_t i; /* The purpose of all these local assignments is to */ const char *meta; /* allow optimizing compilers like gcc to load these */ char *buf = realbuf; /* values into registers. On a sparc this is a */ YYSTYPE *y = &yylval; /* win, in code size *and* execution time */ if (errset) { - errset = FALSE; + errset = false; return '\n'; } /* rc variable-names may contain only alnum, '*' and '_', so use dnw if we are scanning one. */ @@ -112,11 +112,11 @@ extern int yylex() { if (newline) { --lineno; /* slight space optimization; nextline() always increments lineno */ nextline(); - newline = FALSE; + newline = false; } top: while ((c = gchar()) == ' ' || c == '\t') w = NW; - if (c != '(') dollar = FALSE; + if (c != '(') dollar = false; if (c == EOF) return END; if (!meta[(unsigned char) c]) { /* it's a word or keyword. */ @@ -126,7 +126,7 @@ top: while ((c = gchar()) == ' ' || c == '\t') read: do { buf[i++] = c; if (c == '?' || c == '[' || c == '*') - saw_meta = TRUE; + saw_meta = true; if (i >= bufsize) buf = realbuf = erealloc(buf, bufsize *= 2); } while ((c = gchar()) != EOF && !meta[(unsigned char) c]); @@ -173,7 +173,7 @@ top: while ((c = gchar()) == ' ' || c == '\t') } else { y->word.m = NULL; } - y->word.q = FALSE; + y->word.q = false; return WORD; } if (c == '`' || c == '!' || c == '@' || c == '~' || c == '$' || c == '\'') { @@ -195,7 +195,7 @@ top: while ((c = gchar()) == ' ' || c == '\t') ugchar(c); return '`'; case '$': - dollar = TRUE; + dollar = true; c = gchar(); if (c == '#') return COUNT; @@ -223,7 +223,7 @@ top: while ((c = gchar()) == ' ' || c == '\t') buf[i] = '\0'; y->word.w = ncpy(buf); y->word.m = NULL; - y->word.q = TRUE; + y->word.q = true; return WORD; case '\\': if ((c = gchar()) == '\n') { @@ -248,7 +248,7 @@ top: while ((c = gchar()) == ' ' || c == '\t') /* FALLTHROUGH */ case '\n': lineno++; - newline = TRUE; + newline = true; /* FALLTHROUGH */ case ';': case '^': @@ -329,7 +329,7 @@ top: while ((c = gchar()) == ' ' || c == '\t') extern void yyerror(const char *s) { char *tok; if (prerror) { /* don't print "syntax error" if there's a more informative scanerror */ - prerror = FALSE; + prerror = false; return; } if (!interactive) { @@ -349,11 +349,11 @@ extern void yyerror(const char *s) { extern void scanerror(char *s) { skiptonl(); /* flush up to newline */ yyerror(s); - errset = prerror = TRUE; + errset = prerror = true; } extern void inityy() { - newline = FALSE; + newline = false; w = NW; hq = NULL; /* return memory to the system if the buffer got too large */ diff --git a/main.c b/main.c index aac9ddc..7ece961 100644 --- a/main.c +++ b/main.c @@ -25,22 +25,22 @@ extern int main(int argc, char *argv[], char *envp[]) { dashell = (*argv[0] == '-'); /* login shell, per unix tradition */ OPTBEGIN { - case 'd': dashdee = TRUE; break; - case 'e': dashee = TRUE; break; - case 'l': dashell = TRUE; break; - case 'n': dashen = TRUE; break; - case 'o': dashoh = TRUE; break; - case 'p': dashpee = TRUE; break; - case 's': dashess = TRUE; break; - case 'v': dashvee = TRUE; break; - case 'x': dashex = TRUE; break; + case 'd': dashdee = true; break; + case 'e': dashee = true; break; + case 'l': dashell = true; break; + case 'n': dashen = true; break; + case 'o': dashoh = true; break; + case 'p': dashpee = true; break; + case 's': dashess = true; break; + case 'v': dashvee = true; break; + case 'x': dashex = true; break; case 'i': - dasheye = TRUE; - interactive = TRUE; + dasheye = true; + interactive = true; break; case 'I': - dashEYE = TRUE; - interactive = FALSE; + dashEYE = true; + interactive = false; break; case 'c': dashsee[0] = EOPTARG(usage()); @@ -68,7 +68,7 @@ extern int main(int argc, char *argv[], char *envp[]) { initenv(envp); initinput(); null[0] = NULL; - starassign(dollarzero, null, FALSE); /* assign $0 to $* */ + starassign(dollarzero, null, false); /* assign $0 to $* */ inithandler(); if (dashell) { @@ -85,8 +85,8 @@ extern int main(int argc, char *argv[], char *envp[]) { pushfd(fd); push_interactive = interactive; - interactive = FALSE; - doit(TRUE); + interactive = false; + doit(true); interactive = push_interactive; close(fd); } @@ -94,19 +94,19 @@ extern int main(int argc, char *argv[], char *envp[]) { if (dashsee[0] != NULL || dashess) { /* input from -c or -s? */ if (*argv != NULL) - starassign(dollarzero, argv, FALSE); + starassign(dollarzero, argv, false); if (dashess) pushfd(0); else - pushstring(dashsee, TRUE); + pushstring(dashsee, true); } else if (*argv != NULL) { /* else from a file? */ b_dot(--argv); rc_exit(getstatus()); } else { /* else stdin */ pushfd(0); } - dasheye = FALSE; - doit(TRUE); + dasheye = false; + doit(true); rc_exit(getstatus()); return 0; /* Never really reached. */ } @@ -118,10 +118,10 @@ static void assigndefault(char *name,...) { va_start(ap, name); for (l = NULL; (v = va_arg(ap, char *)) != NULL;) l = append(l, word(v, NULL)); - varassign(name, l, FALSE); - set_exportable(name, FALSE); + varassign(name, l, false); + set_exportable(name, false); if (streq(name, "path")) - alias(name, l, FALSE); + alias(name, l, false); va_end(ap); } diff --git a/match.c b/match.c index 6f87614..3713e4a 100644 --- a/match.c +++ b/match.c @@ -20,39 +20,39 @@ extern bool match(char *p, char *m, char *s) { switch (p[i++]) { case '?': if (*s++ == '\0') - return FALSE; + return false; break; case '*': while (p[i] == '*' && m[i] == 1) /* collapse multiple stars */ i++; if (p[i] == '\0') /* star at end of pattern? */ - return TRUE; + return true; while (*s != '\0') if (match(p + i, m + i, s++)) - return TRUE; - return FALSE; + return true; + return false; case '[': if (*s == '\0') - return FALSE; + return false; switch (j = rangematch(p + i, *s)) { default: i += j; break; case RANGE_FAIL: - return FALSE; + return false; case RANGE_ERROR: if (*s != '[') - return FALSE; + return false; } s++; break; default: panic("bad metacharacter in match"); /* NOTREACHED */ - return FALSE; /* hush up gcc -Wall */ + return false; /* hush up gcc -Wall */ } } else if (p[i++] != *s++) - return FALSE; + return false; } } @@ -74,7 +74,7 @@ extern bool match(char *p, char *m, char *s) { static int rangematch(char *p, char c) { char *orig = p; bool neg = (*p == '~'); - bool matched = FALSE; + bool matched = false; if (neg) p++; if (*p == ']') { diff --git a/open.c b/open.c index f7932c2..af0f7f1 100644 --- a/open.c +++ b/open.c @@ -34,16 +34,16 @@ extern bool makeblocking(int fd) { rc_error(NULL); } if (! (flags & O_NONBLOCK)) - return FALSE; + return false; flags &= ~O_NONBLOCK; if (fcntl(fd, F_SETFL, (long) flags) == -1) { uerror("fcntl"); rc_error(NULL); } - return TRUE; + return true; } -/* make a file descriptor the same pgrp as us. Returns TRUE if +/* make a file descriptor the same pgrp as us. Returns true if it changes anything. */ extern bool makesamepgrp(int fd) { @@ -52,11 +52,11 @@ extern bool makesamepgrp(int fd) { grp = getpgrp(); if (tcgetpgrp(fd) == grp) - return FALSE; + return false; if (tcsetpgrp(fd, grp) < 0) { uerror("tcsetgrp"); - return FALSE; + return false; } - return TRUE; + return true; } diff --git a/print.c b/print.c index f948f43..f5e31bd 100644 --- a/print.c +++ b/print.c @@ -15,7 +15,7 @@ #define Flag(name, flag) \ static bool name(Format *format, int ignore) { \ format->flags |= flag; \ - return TRUE; \ + return true; \ } Flag(uconv, FMT_unsigned) @@ -32,14 +32,14 @@ static bool digitconv(Format *format, int c) { format->flags |= FMT_f1set; format->f1 = 10 * format->f1 + c - '0'; } - return TRUE; + return true; } static bool zeroconv(Format *format, int ignore) { if (format->flags & (FMT_f1set | FMT_f2set)) return digitconv(format, '0'); format->flags |= FMT_zeropad; - return TRUE; + return true; } static void pad(Format *format, size_t len, int c) { @@ -61,7 +61,7 @@ static bool sconv(Format *format, int ignore) { fmtappend(format, s, len); } } - return FALSE; + return false; } static char *rc_utoa(unsigned long u, char *t, unsigned int radix, const char *digit) { @@ -139,33 +139,33 @@ static void intconv(Format *format, unsigned int radix, int upper, const char *a static bool cconv(Format *format, int ignore) { fmtputc(format, va_arg(format->args, int)); - return FALSE; + return false; } static bool dconv(Format *format, int ignore) { intconv(format, 10, 0, ""); - return FALSE; + return false; } static bool oconv(Format *format, int ignore) { intconv(format, 8, 0, "0"); - return FALSE; + return false; } static bool xconv(Format *format, int ignore) { intconv(format, 16, 0, "0x"); - return FALSE; + return false; } static bool pctconv(Format *format, int ignore) { fmtputc(format, '%'); - return FALSE; + return false; } static bool badconv(Format *ignore, int ign0re) { panic("bad conversion character in printfmt"); /* NOTREACHED */ - return FALSE; /* hush up gcc -Wall */ + return false; /* hush up gcc -Wall */ } diff --git a/rc.h b/rc.h index ad9f6cb..9ec3717 100644 --- a/rc.h +++ b/rc.h @@ -1,4 +1,4 @@ -#undef NDEBUG +#undef NDEBUG // We really want the asserts? #define _XOPEN_SOURCE 700 /* Configuration options */ @@ -38,9 +38,6 @@ typedef long align_t; -#define TRUE true -#define FALSE false - /* If we have POSIX sigjmp_buf and friends, use them. If we don't, just use a jmp_buf. This probably fails on a traditional SysV machine, where jmp_bufs don't preserve signal masks. I'm not worrying about this till diff --git a/redir.c b/redir.c index b582341..54e4415 100644 --- a/redir.c +++ b/redir.c @@ -30,7 +30,7 @@ extern void doredirs() { rc_error(NULL); } if (rc_fork() == 0) { /* child writes to pipe */ - setsigdefaults(FALSE); + setsigdefaults(false); close(p[0]); if (fname != NULL) writeall(p[1], fname->w, strlen(fname->w)); diff --git a/status.c b/status.c index bdb9af0..cc59363 100644 --- a/status.c +++ b/status.c @@ -20,8 +20,8 @@ extern int istrue() { int i; for (i = 0; i < pipelength; i++) if (statuses[i] != 0) - return FALSE; - return TRUE; + return false; + return true; } /* @@ -126,25 +126,25 @@ extern void ssetstatus(char **av) { statuses[l - i] = j << 8; continue; } - found = FALSE; + found = false; for (k = 0; k < NSIG; k++) { if (streq(signals[k].name, av[i])) { statuses[l - i] = k; - found = TRUE; + found = true; break; } else { size_t len = strlen(signals[k].name); if (strncmp(signals[k].name, av[i], len) == 0 && streq(av[i] + len, "+core")) { statuses[l - i] = k + 0x80; - found = TRUE; + found = true; break; } } } if (!found) { fprint(2, "bad status\n"); - set(FALSE); + set(false); return; } } diff --git a/var.c b/var.c index 2881d58..6853077 100644 --- a/var.c +++ b/var.c @@ -18,34 +18,34 @@ extern void varassign(char *name, List *def, bool stack) { new = get_var_place(name, stack); new->def = newdef; new->extdef = NULL; - set_exportable(name, TRUE); + set_exportable(name, true); } /* assign a variable in string form. Check to see if it is aliased (e.g., PATH and path) */ extern bool varassign_string(char *extdef) { static bool aliasset[arraysize(aliases)] = { - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE + false, false, false, false, false, false }; char *name = get_name(extdef); Variable *new; int i; if (name == NULL) - return FALSE; /* add it to bozo env */ + return false; /* add it to bozo env */ if ((i = hasalias(name)) != -1) { - aliasset[i] = TRUE; + aliasset[i] = true; i ^= 1; /* set i to the "opposite" case subscript and */ if (i&1 && aliasset[i]) /* don't alias variables that are already set in upper case */ - return TRUE; + return true; } - new = get_var_place(name, FALSE); + new = get_var_place(name, false); new->def = NULL; new->extdef = ealloc(strlen(extdef) + 1); strcpy(new->extdef, extdef); if (i != -1) - alias(name, varlookup(name), FALSE); - set_exportable(name, TRUE); - return TRUE; + alias(name, varlookup(name), false); + set_exportable(name, true); + return true; } /* @@ -108,7 +108,7 @@ extern char *varlookup_string(char *name) { extern void varrm(char *name, bool stack) { int i = hasalias(name); if (streq(name, "*") && !stack) { /* when assigning () to $*, we want to preserve $0 */ - varassign("*", varlookup("0"), FALSE); + varassign("*", varlookup("0"), false); return; } delete_var(name, stack); diff --git a/wait.c b/wait.c index 91679b6..c93511f 100644 --- a/wait.c +++ b/wait.c @@ -1,6 +1,6 @@ #include "rc.h" -bool forked = FALSE; +bool forked = false; typedef struct Pid Pid; @@ -22,7 +22,7 @@ extern pid_t rc_fork() { rc_error(NULL); /* NOTREACHED */ case 0: - forked = TRUE; + forked = true; sigchk(); p = plist; q = 0; while (p) { @@ -36,7 +36,7 @@ extern pid_t rc_fork() { default: new = enew(Pid); new->pid = pid; - new->alive = TRUE; + new->alive = true; new->n = plist; plist = new; return pid; @@ -77,7 +77,7 @@ extern pid_t rc_wait4(pid_t pid, int *stat, bool nointr) { for (q = plist; q != NULL; q = q->n) if (q->pid == ret) { - q->alive = FALSE; + q->alive = false; q->stat = *stat; break; } @@ -111,11 +111,11 @@ extern void waitforall() { int stat; while (plist != NULL) { - pid_t pid = rc_wait4(plist->pid, &stat, FALSE); + pid_t pid = rc_wait4(plist->pid, &stat, false); if (pid > 0) setstatus(pid, stat); else { - set(FALSE); + set(false); if (errno == EINTR) return; } diff --git a/walk.c b/walk.c index f1de169..b6b8149 100644 --- a/walk.c +++ b/walk.c @@ -6,7 +6,7 @@ global which indicates whether rc is executing a test; used by rc -e so that if (false) does not exit. */ -bool cond = FALSE; +bool cond = false; static bool haspreredir(Node *); static bool isallpre(Node *); @@ -24,8 +24,8 @@ top: sigchk(); if (n == NULL) { if (!parent) exit(0); - set(TRUE); - return TRUE; + set(true); + return true; } switch (n->type) { case nArgs: case nBackq: case nConcat: case nCount: @@ -34,35 +34,35 @@ top: sigchk(); exec(glob(glom(n)), parent); /* simple command */ break; case nBody: - walk(n->u[0].p, TRUE); + walk(n->u[0].p, true); WALK(n->u[1].p, parent); /* WALK doesn't fall through */ case nNowait: { int pid; if ((pid = rc_fork()) == 0) { #if defined(RC_JOB) && defined(SIGTTOU) && defined(SIGTTIN) && defined(SIGTSTP) - setsigdefaults(FALSE); + setsigdefaults(false); rc_signal(SIGTTOU, SIG_IGN); /* Berkeleyized version: put it in a new pgroup. */ rc_signal(SIGTTIN, SIG_IGN); rc_signal(SIGTSTP, SIG_IGN); setpgid(0, getpid()); #else - setsigdefaults(TRUE); /* ignore SIGINT, SIGQUIT, SIGTERM */ + setsigdefaults(true); /* ignore SIGINT, SIGQUIT, SIGTERM */ #endif mvfd(rc_open("/dev/null", rFrom), 0); - walk(n->u[0].p, FALSE); + walk(n->u[0].p, false); exit(getstatus()); } if (interactive) fprint(2, "%d\n", pid); - varassign("apid", word(nprint("%d", pid), NULL), FALSE); + varassign("apid", word(nprint("%d", pid), NULL), false); redirq = NULL; /* kill pre-redir queue */ break; } case nAndalso: { bool oldcond = cond; - cond = TRUE; - if (walk(n->u[0].p, TRUE)) { + cond = true; + if (walk(n->u[0].p, true)) { cond = oldcond; WALK(n->u[1].p, parent); } else @@ -71,8 +71,8 @@ top: sigchk(); } case nOrelse: { bool oldcond = cond; - cond = TRUE; - if (!walk(n->u[0].p, TRUE)) { + cond = true; + if (!walk(n->u[0].p, true)) { cond = oldcond; WALK(n->u[1].p, parent); } else @@ -80,7 +80,7 @@ top: sigchk(); break; } case nBang: - set(!walk(n->u[0].p, TRUE)); + set(!walk(n->u[0].p, true)); break; case nIf: { bool oldcond = cond; @@ -89,8 +89,8 @@ top: sigchk(); false_cmd = true_cmd->u[1].p; true_cmd = true_cmd->u[0].p; } - cond = TRUE; - if (!walk(n->u[0].p, TRUE)) + cond = true; + if (!walk(n->u[0].p, true)) true_cmd = false_cmd; /* run the else clause */ cond = oldcond; WALK(true_cmd, parent); @@ -100,8 +100,8 @@ top: sigchk(); Edata jbreak; Estack e1, e2; bool testtrue, oldcond = cond; - cond = TRUE; - if (!walk(n->u[0].p, TRUE)) { /* prevent spurious breaks inside test */ + cond = true; + if (!walk(n->u[0].p, true)) { /* prevent spurious breaks inside test */ cond = oldcond; break; } @@ -114,10 +114,10 @@ top: sigchk(); block.b = newblock(); cond = oldcond; except(eArena, block, &e2); - walk(n->u[1].p, TRUE); - testtrue = walk(n->u[0].p, TRUE); + walk(n->u[1].p, true); + testtrue = walk(n->u[0].p, true); unexcept(); /* eArena */ - cond = TRUE; + cond = true; } while (testtrue); cond = oldcond; unexcept(); /* eBreak */ @@ -134,27 +134,27 @@ top: sigchk(); except(eBreak, jbreak, &e1); for (l = listcpy(glob(glom(n->u[1].p)), nalloc); l != NULL; l = l->n) { Edata block; - assign(var, word(l->w, NULL), FALSE); + assign(var, word(l->w, NULL), false); block.b = newblock(); except(eArena, block, &e2); - walk(n->u[2].p, TRUE); + walk(n->u[2].p, true); unexcept(); /* eArena */ } unexcept(); /* eBreak */ break; } case nSubshell: - if (dofork(TRUE)) { - setsigdefaults(FALSE); - walk(n->u[0].p, FALSE); + if (dofork(true)) { + setsigdefaults(false); + walk(n->u[0].p, false); rc_exit(getstatus()); } break; case nAssign: if (n->u[0].p == NULL) rc_error("null variable name"); - assign(glom(n->u[0].p), glob(glom(n->u[1].p)), FALSE); - set(TRUE); + assign(glom(n->u[0].p), glob(glom(n->u[1].p)), false); + set(true); break; case nPipe: dopipe(n); @@ -169,7 +169,7 @@ top: sigchk(); fnassign(l->w, n->u[1].p); l = l->n; } - set(TRUE); + set(true); break; } case nRmfn: { @@ -180,7 +180,7 @@ top: sigchk(); fnrm(l->w); l = l->n; } - set(TRUE); + set(true); break; } case nDup: @@ -203,7 +203,7 @@ top: sigchk(); } while (n->u[0].p == NULL || n->u[0].p->type != nCase); if (lmatch(v, glom(n->u[0].p->u[0].p))) { for (n = n->u[1].p; n != NULL && (n->u[0].p == NULL || n->u[0].p->type != nCase); n = n->u[1].p) - walk(n->u[0].p, TRUE); + walk(n->u[0].p, true); break; } } @@ -214,26 +214,26 @@ top: sigchk(); if (n->u[0].p->type == nRedir || n->u[0].p->type == nDup) { if (redirq == NULL && !dofork(parent)) /* subshell on first preredir */ break; - setsigdefaults(FALSE); + setsigdefaults(false); qredir(n->u[0].p); if (!haspreredir(n->u[1].p)) doredirs(); /* no more preredirs, empty queue */ - walk(n->u[1].p, FALSE); + walk(n->u[1].p, false); rc_exit(getstatus()); /* NOTREACHED */ } else if (n->u[0].p->type == nAssign) { if (isallpre(n->u[1].p)) { - walk(n->u[0].p, TRUE); + walk(n->u[0].p, true); WALK(n->u[1].p, parent); } else { Estack e; Edata var; v = glom(n->u[0].p->u[0].p); - assign(v, glob(glom(n->u[0].p->u[1].p)), TRUE); + assign(v, glob(glom(n->u[0].p->u[1].p)), true); var.name = v->w; except(eVarstack, var, &e); walk(n->u[1].p, parent); - varrm(v->w, TRUE); + varrm(v->w, true); unexcept(); /* eVarstack */ } } else @@ -244,10 +244,10 @@ top: sigchk(); if (n->u[1].p == NULL) { WALK(n->u[0].p, parent); } else if (dofork(parent)) { - setsigdefaults(FALSE); - walk(n->u[1].p, TRUE); /* Do redirections */ + setsigdefaults(false); + walk(n->u[1].p, true); /* Do redirections */ redirq = NULL; /* Reset redirection queue */ - walk(n->u[0].p, FALSE); /* Do commands */ + walk(n->u[0].p, false); /* Do commands */ rc_exit(getstatus()); /* NOTREACHED */ } @@ -275,10 +275,10 @@ top: sigchk(); static bool haspreredir(Node *n) { while (n != NULL && n->type == nPre) { if (n->u[0].p->type == nDup || n->u[0].p->type == nRedir) - return TRUE; + return true; n = n->u[1].p; } - return FALSE; + return false; } /* checks to see whether a subtree is all pre-command directives, i.e., assignments and redirs only */ @@ -298,12 +298,12 @@ static bool dofork(bool parent) { int pid, sp; if (!parent || (pid = rc_fork()) == 0) - return TRUE; + return true; redirq = NULL; /* clear out the pre-redirection queue in the parent */ - rc_wait4(pid, &sp, TRUE); + rc_wait4(pid, &sp, true); setstatus(-1, sp); sigchk(); - return FALSE; + return false; } static void dopipe(Node *n) { @@ -320,13 +320,13 @@ static void dopipe(Node *n) { rc_error(NULL); } if ((pid = rc_fork()) == 0) { - setsigdefaults(FALSE); + setsigdefaults(false); redirq = NULL; /* clear preredir queue */ mvfd(p[0], r->u[1].i); if (fd_prev != 1) mvfd(fd_prev, fd_out); close(p[1]); - walk(r->u[3].p, FALSE); + walk(r->u[3].p, false); exit(getstatus()); } if (fd_prev != 1) @@ -337,9 +337,9 @@ static void dopipe(Node *n) { close(p[0]); } if ((pid = rc_fork()) == 0) { - setsigdefaults(FALSE); + setsigdefaults(false); mvfd(fd_prev, fd_out); - walk(r, FALSE); + walk(r, false); exit(getstatus()); /* NOTREACHED */ } @@ -349,9 +349,9 @@ static void dopipe(Node *n) { /* collect statuses */ - intr = FALSE; + intr = false; for (j = 0; j < i; j++) { - rc_wait4(pids[j], &sp, TRUE); + rc_wait4(pids[j], &sp, true); stats[j] = sp; intr |= (sp == SIGINT); } diff --git a/which.c b/which.c index b67e8dc..43c9e1d 100644 --- a/which.c +++ b/which.c @@ -15,7 +15,7 @@ #define X_OTH 0001 #define X_ALL (X_USR|X_GRP|X_OTH) -static bool initialized = FALSE; +static bool initialized = false; static uid_t uid; static gid_t gid; @@ -43,7 +43,7 @@ static bool rc_access(char *path, bool verbose) { if (stat(path, &st) != 0) { if (verbose) /* verbose flag only set for absolute pathname */ uerror(path); - return FALSE; + return false; } if (uid == 0) mask = X_ALL; @@ -54,11 +54,11 @@ static bool rc_access(char *path, bool verbose) { else mask = X_OTH; if (((st.st_mode & S_IFMT) == S_IFREG) && (st.st_mode & mask)) - return TRUE; + return true; errno = EACCES; if (verbose) uerror(path); - return FALSE; + return false; } /* replace non-printing characters with question marks in a freshly @@ -84,7 +84,7 @@ extern char *which(char *name, bool verbose) { if (name == NULL) /* no filename? can happen with "> foo" as a command */ return NULL; if (!initialized) { - initialized = TRUE; + initialized = true; uid = geteuid(); gid = getegid(); ngroups = getgroups(0, (gid_t *)0); @@ -114,7 +114,7 @@ extern char *which(char *name, bool verbose) { strcat(test, "/"); strcat(test, name); } - if (rc_access(test, FALSE)) + if (rc_access(test, false)) return test; } if (verbose) { -- 2.49.0