commit 969af168ea450bf79f800da620efefa91ed1f174
parent 9475ab261beabd848267f925940c15f9fd6eb96e
Author: Toby Goodwin <toby@paccrat.org>
Date: Mon, 26 Mar 2018 18:20:39 +0100
whitespace cleanups
Diffstat:
17 files changed, 366 insertions(+), 366 deletions(-)
diff --git a/builtins.c b/builtins.c
@@ -46,27 +46,27 @@ static struct {
{ b_eval, "eval" },
{ b_exec, "exec" },
{ b_exit, "exit" },
- { b_flag, "flag" },
+ { b_flag, "flag" },
#if HAVE_SETRLIMIT
- { b_limit, "limit" },
+ { b_limit, "limit" },
#endif
- { b_newpgrp, "newpgrp" },
- { b_return, "return" },
- { b_shift, "shift" },
- { b_umask, "umask" },
- { b_wait, "wait" },
- { b_whatis, "whatis" },
- { b_dot, "." },
+ { b_newpgrp, "newpgrp" },
+ { b_return, "return" },
+ { b_shift, "shift" },
+ { b_umask, "umask" },
+ { b_wait, "wait" },
+ { b_whatis, "whatis" },
+ { b_dot, "." },
#ifdef ADDONS
- ADDONS
+ ADDONS
#endif
};
extern builtin_t *isbuiltin(char *s) {
int i;
for (i = 0; i < arraysize(builtins); i++)
- if (streq(builtins[i].name, s))
- return builtins[i].p;
+ if (streq(builtins[i].name, s))
+ return builtins[i].p;
return NULL;
}
@@ -110,10 +110,10 @@ extern void b_exec(char **ignore) {
static void b_echo(char **av) {
char *format = "%A\n";
if (*++av != NULL) {
- if (streq(*av, "-n"))
- format = "%A", av++;
- else if (streq(*av, "--"))
- av++;
+ if (streq(*av, "-n"))
+ format = "%A", av++;
+ else if (streq(*av, "--"))
+ av++;
}
fprint(1, format, av);
set(TRUE);
@@ -127,70 +127,70 @@ static void b_cd(char **av) {
char *path = NULL;
size_t t, pathlen = 0;
if (*++av == NULL) {
- s = varlookup("home");
- *av = (s == NULL) ? "/" : s->w;
+ s = varlookup("home");
+ *av = (s == NULL) ? "/" : s->w;
} else if (av[1] != NULL) {
- arg_count("cd");
- return;
+ arg_count("cd");
+ return;
}
if (isabsolute(*av) || streq(*av, ".") || streq(*av, "..")) { /* absolute pathname? */
- if (chdir(*av) < 0) {
- set(FALSE);
- uerror(*av);
- } else
- set(TRUE);
+ if (chdir(*av) < 0) {
+ set(FALSE);
+ uerror(*av);
+ } else
+ set(TRUE);
} else {
- s = varlookup("cdpath");
- if (s == NULL) {
- s = &nil;
- nil.w = "";
- nil.n = NULL;
- }
- do {
- if (s != &nil && *s->w != '\0') {
- t = strlen(*av) + strlen(s->w) + 2;
- if (t > pathlen)
- path = nalloc(pathlen = t);
- strcpy(path, s->w);
- if (!streq(s->w, "/")) /* "//" is special to POSIX */
- strcat(path, "/");
- strcat(path, *av);
- } else {
- pathlen = 0;
- path = *av;
- }
- if (chdir(path) >= 0) {
- set(TRUE);
- if (interactive && *s->w != '\0' && !streq(s->w, "."))
- fprint(1, "%s\n", path);
- return;
- }
- s = s->n;
- } while (s != NULL);
- fprint(2, "couldn't cd to %s\n", *av);
- set(FALSE);
+ s = varlookup("cdpath");
+ if (s == NULL) {
+ s = &nil;
+ nil.w = "";
+ nil.n = NULL;
+ }
+ do {
+ if (s != &nil && *s->w != '\0') {
+ t = strlen(*av) + strlen(s->w) + 2;
+ if (t > pathlen)
+ path = nalloc(pathlen = t);
+ strcpy(path, s->w);
+ if (!streq(s->w, "/")) /* "//" is special to POSIX */
+ strcat(path, "/");
+ strcat(path, *av);
+ } else {
+ pathlen = 0;
+ path = *av;
+ }
+ if (chdir(path) >= 0) {
+ set(TRUE);
+ if (interactive && *s->w != '\0' && !streq(s->w, "."))
+ fprint(1, "%s\n", path);
+ return;
+ }
+ s = s->n;
+ } while (s != NULL);
+ fprint(2, "couldn't cd to %s\n", *av);
+ set(FALSE);
}
}
static void b_umask(char **av) {
int i;
if (*++av == NULL) {
- set(TRUE);
- i = umask(0);
- umask(i);
- fprint(1, "0%o\n", i);
+ set(TRUE);
+ i = umask(0);
+ umask(i);
+ fprint(1, "0%o\n", i);
} else if (av[1] == NULL) {
- i = o2u(*av);
- if ((unsigned int) i > 0777) {
- fprint(2, "bad umask\n");
- set(FALSE);
- } else {
- umask(i);
- set(TRUE);
- }
+ i = o2u(*av);
+ if ((unsigned int) i > 0777) {
+ fprint(2, "bad umask\n");
+ set(FALSE);
+ } else {
+ umask(i);
+ set(TRUE);
+ }
} else {
- arg_count("umask");
- return;
+ arg_count("umask");
+ return;
}
}
@@ -203,7 +203,7 @@ static void b_exit(char **av) {
static void b_flag(char **av) {
bool *flagp = NULL;
char f;
- int mode = 3; /* 0 = reset (-), 1 = set (+), 2 = test */
+ int mode = 3; /* 0 = reset (-), 1 = set (+), 2 = test */
const char *usage = "usage: flag f [ + | - ]\n";
if (*++av == NULL) {
@@ -246,7 +246,7 @@ static void b_flag(char **av) {
flagp = &dashess; break;
case 'v': flagp = &dashvee; break;
case 'x': flagp = &dashex; break;
- }
+ }
if (flagp != NULL) {
if (mode == 2)
set(*flagp);
diff --git a/develop.c b/develop.c
@@ -7,300 +7,300 @@ void dump(Node *, int);
/* dump a Node * as a tree */
static void dump_1(char *p, Node *n, int indent) {
- fprint(2, "%s:\n", p);
- dump(n->u[0].p, indent + 1);
+ fprint(2, "%s:\n", p);
+ dump(n->u[0].p, indent + 1);
}
static void dump_2(char *p, Node *n, int indent) {
- fprint(2, "%s:\n", p);
- dump(n->u[0].p, indent + 1);
- if (n->u[1].p != NULL)
- dump(n->u[1].p, indent + 1);
+ fprint(2, "%s:\n", p);
+ dump(n->u[0].p, indent + 1);
+ if (n->u[1].p != NULL)
+ dump(n->u[1].p, indent + 1);
}
static void dump_3(char *p, Node *n, int indent) {
- fprint(2, "%s:\n", p);
- dump(n->u[0].p, indent + 1);
- if (n->u[1].p != NULL)
- dump(n->u[1].p, indent + 1);
- if (n->u[2].p != NULL)
- dump(n->u[2].p, indent + 1);
+ fprint(2, "%s:\n", p);
+ dump(n->u[0].p, indent + 1);
+ if (n->u[1].p != NULL)
+ dump(n->u[1].p, indent + 1);
+ if (n->u[2].p != NULL)
+ dump(n->u[2].p, indent + 1);
}
static void dump_s(char *p, Node *n, int indent) {
- fprint(2, "%s: %S\n", p, n->u[0].s);
+ fprint(2, "%s: %S\n", p, n->u[0].s);
}
static void dump_pipe(char *p, Node *n, int indent) {
- int ifd = n->u[0].i, ofd = n->u[1].i;
- fprint(2, "%s %d %d:\n", p, ifd, ofd);
- dump(n->u[2].p, indent + 1);
- dump(n->u[3].p, indent + 1);
+ int ifd = n->u[0].i, ofd = n->u[1].i;
+ fprint(2, "%s %d %d:\n", p, ifd, ofd);
+ dump(n->u[2].p, indent + 1);
+ dump(n->u[3].p, indent + 1);
}
static char *redir(int op) {
- switch (op) {
- case rCreate: return ">";
- case rAppend: return ">>";
- case rFrom: return "<";
- case rHeredoc: return "<<";
- case rHerestring: return "<<<";
- default: return "?";
- }
+ switch (op) {
+ case rCreate: return ">";
+ case rAppend: return ">>";
+ case rFrom: return "<";
+ case rHeredoc: return "<<";
+ case rHerestring: return "<<<";
+ default: return "?";
+ }
}
static void dump_dup(char *p, Node *n, int indent) {
- fprint(2, "%s %s %d %d:\n", p, redir(n->u[0].i), n->u[1].i, n->u[2].i);
+ fprint(2, "%s %s %d %d:\n", p, redir(n->u[0].i), n->u[1].i, n->u[2].i);
}
static void dump_redir(char *p, Node *n, int indent) {
- fprint(2, "%s %s %d:\n", p, redir(n->u[0].i), n->u[1].i);
- dump(n->u[2].p, indent + 1);
+ fprint(2, "%s %s %d:\n", p, redir(n->u[0].i), n->u[1].i);
+ dump(n->u[2].p, indent + 1);
}
void dump(Node *n, int indent) {
- int i;
+ int i;
- if (n == NULL)
- return;
+ if (n == NULL)
+ return;
- for (i = 0; i < indent; ++i)
- fprint(2, " ");
+ for (i = 0; i < indent; ++i)
+ fprint(2, " ");
- switch (n->type) {
- case nAndalso:
- dump_2("nAndalso", n, indent);
- break;
- case nArgs:
- dump_2("nArgs", n, indent);
- break;
- case nAssign:
- dump_2("nAassign", n, indent);
- break;
- case nBackq:
- dump_1("nBackq", n, indent);
- break;
- case nBang:
- dump_1("nBang", n, indent);
- break;
- case nBody:
- dump_2("nBody", n, indent);
- break;
- case nBrace:
- dump_1("nBrace", n, indent);
- break;
- case nCase:
- dump_1("nCase", n, indent);
- break;
- case nCbody:
- dump_2("nCbody", n, indent);
- break;
- case nConcat:
- dump_2("nConcat", n, indent);
- break;
- case nCount:
- dump_1("nCount", n, indent);
- break;
- case nDup:
- dump_dup("nDup", n, indent);
- break;
- case nElse:
- dump_2("nElse", n, indent);
- break;
- case nEpilog:
- dump_2("nEpilog", n, indent);
- break;
- case nFlat:
- dump_1("nFlat", n, indent);
- break;
- case nForin:
- dump_3("nForin", n, indent);
- break;
- case nIf:
- dump_2("nIf", n, indent);
- break;
- case nIfnot:
- dump_1("nIfnot", n, indent);
- break;
- case nLappend:
- dump_2("nLappend", n, indent);
- break;
- case nMatch:
- dump_2("nMatch", n, indent);
- break;
- case nNewfn:
- dump_2("nNewfn", n, indent);
- break;
- case nNmpipe:
- dump_redir("nNowait", n, indent);
- break;
- case nNowait:
- dump_1("nNowait", n, indent);
- break;
- case nOrelse:
- dump_2("nNowait", n, indent);
- break;
- case nPipe:
- dump_pipe("nPipe", n, indent);
- break;
- case nPre:
- dump_2("nPre", n, indent);
- break;
- case nRedir:
- dump_redir("nRedir", n, indent);
- break;
- case nRmfn:
- dump_1("nRmfn", n, indent);
- break;
- case nSubshell:
- dump_1("nSubshell", n, indent);
- break;
- case nSwitch:
- dump_2("nSwitch", n, indent);
- break;
- case nVar:
- dump_1("nVar", n, indent);
- break;
- case nVarsub:
- dump_2("nVarsub", n, indent);
- break;
- case nWhile:
- dump_2("nWhile", n, indent);
- break;
- case nWord:
- dump_s("nWord", n, indent);
- break;
- default:
- fprint(2, "unknown\n");
- break;
- }
+ switch (n->type) {
+ case nAndalso:
+ dump_2("nAndalso", n, indent);
+ break;
+ case nArgs:
+ dump_2("nArgs", n, indent);
+ break;
+ case nAssign:
+ dump_2("nAassign", n, indent);
+ break;
+ case nBackq:
+ dump_1("nBackq", n, indent);
+ break;
+ case nBang:
+ dump_1("nBang", n, indent);
+ break;
+ case nBody:
+ dump_2("nBody", n, indent);
+ break;
+ case nBrace:
+ dump_1("nBrace", n, indent);
+ break;
+ case nCase:
+ dump_1("nCase", n, indent);
+ break;
+ case nCbody:
+ dump_2("nCbody", n, indent);
+ break;
+ case nConcat:
+ dump_2("nConcat", n, indent);
+ break;
+ case nCount:
+ dump_1("nCount", n, indent);
+ break;
+ case nDup:
+ dump_dup("nDup", n, indent);
+ break;
+ case nElse:
+ dump_2("nElse", n, indent);
+ break;
+ case nEpilog:
+ dump_2("nEpilog", n, indent);
+ break;
+ case nFlat:
+ dump_1("nFlat", n, indent);
+ break;
+ case nForin:
+ dump_3("nForin", n, indent);
+ break;
+ case nIf:
+ dump_2("nIf", n, indent);
+ break;
+ case nIfnot:
+ dump_1("nIfnot", n, indent);
+ break;
+ case nLappend:
+ dump_2("nLappend", n, indent);
+ break;
+ case nMatch:
+ dump_2("nMatch", n, indent);
+ break;
+ case nNewfn:
+ dump_2("nNewfn", n, indent);
+ break;
+ case nNmpipe:
+ dump_redir("nNowait", n, indent);
+ break;
+ case nNowait:
+ dump_1("nNowait", n, indent);
+ break;
+ case nOrelse:
+ dump_2("nNowait", n, indent);
+ break;
+ case nPipe:
+ dump_pipe("nPipe", n, indent);
+ break;
+ case nPre:
+ dump_2("nPre", n, indent);
+ break;
+ case nRedir:
+ dump_redir("nRedir", n, indent);
+ break;
+ case nRmfn:
+ dump_1("nRmfn", n, indent);
+ break;
+ case nSubshell:
+ dump_1("nSubshell", n, indent);
+ break;
+ case nSwitch:
+ dump_2("nSwitch", n, indent);
+ break;
+ case nVar:
+ dump_1("nVar", n, indent);
+ break;
+ case nVarsub:
+ dump_2("nVarsub", n, indent);
+ break;
+ case nWhile:
+ dump_2("nWhile", n, indent);
+ break;
+ case nWord:
+ dump_s("nWord", n, indent);
+ break;
+ default:
+ fprint(2, "unknown\n");
+ break;
+ }
}
void tree_dump(Node *f) {
- dump(f, 0);
+ dump(f, 0);
}
#if 0
- bool dollar = f->flags & FMT_altform;
- Node *n = va_arg(f->args, Node *);
+ bool dollar = f->flags & FMT_altform;
+ Node *n = va_arg(f->args, Node *);
- if (n == NULL) {
- fmtprint(f, "()");
- return FALSE;
- }
- switch (n->type) {
- case nBang: fmtprint(f, "!%X", n->u[0].p); break;
- case nCase: fmtprint(f, "case %X", n->u[0].p); break;
- case nNowait: fmtprint(f, "%X&", n->u[0].p); break;
- case nRmfn: fmtprint(f, "fn %X", n->u[0].p); break;
- case nSubshell: fmtprint(f, "@ %X", n->u[0].p); break;
- case nAndalso: fmtprint(f, "%X&&%X", n->u[0].p, n->u[1].p); break;
- case nAssign: fmtprint(f, "%X=%X", n->u[0].p, n->u[1].p); break;
- case nConcat: fmtprint(f, "%X^%X", n->u[0].p, n->u[1].p); break;
- case nElse: fmtprint(f, "{%X}else %X", n->u[0].p, n->u[1].p); break;
- case nNewfn: fmtprint(f, "fn %X {%X}", n->u[0].p, n->u[1].p); break;
- case nIf: fmtprint(f, "if(%X)%X", n->u[0].p, n->u[1].p); break;
- case nOrelse: fmtprint(f, "%X||%X", n->u[0].p, n->u[1].p); break;
- case nArgs: fmtprint(f, "nArgs: ");
- Xconv(n->u[0].p, 4);
- Xconv(n->u[1].p, 4); break;
- case nSwitch: fmtprint(f, "switch(%X){%X}", n->u[0].p, n->u[1].p); break;
- case nMatch: fmtprint(f, "~ %X %X", n->u[0].p, n->u[1].p); break;
- case nWhile: fmtprint(f, "while(%X)%X", n->u[0].p, n->u[1].p); break;
- case nForin: fmtprint(f, "for(%X in %X)%X", n->u[0].p, n->u[1].p, n->u[2].p); break;
- case nVarsub: fmtprint(f, "$%X(%X)", n->u[0].p, n->u[1].p); break;
- case nWord:
- fmtprint(f, n->u[2].i && quotep(n->u[0].s, dollar) ?
- "%#S" : "%S", n->u[0].s);
- break;
- case nLappend: {
- static bool inlist;
- if (!inlist) {
- inlist = TRUE;
- fmtprint(f, "(%X %X)", n->u[0].p, n->u[1].p);
- inlist = FALSE;
- } else {
- fmtprint(f, "%X %X", n->u[0].p, n->u[1].p);
- }
- break;
- }
- case nCount: case nFlat: case nVar: {
- char *lp = "", *rp = "";
- Node *n0 = n->u[0].p;
+ if (n == NULL) {
+ fmtprint(f, "()");
+ return FALSE;
+ }
+ switch (n->type) {
+ case nBang: fmtprint(f, "!%X", n->u[0].p); break;
+ case nCase: fmtprint(f, "case %X", n->u[0].p); break;
+ case nNowait: fmtprint(f, "%X&", n->u[0].p); break;
+ case nRmfn: fmtprint(f, "fn %X", n->u[0].p); break;
+ case nSubshell: fmtprint(f, "@ %X", n->u[0].p); break;
+ case nAndalso: fmtprint(f, "%X&&%X", n->u[0].p, n->u[1].p); break;
+ case nAssign: fmtprint(f, "%X=%X", n->u[0].p, n->u[1].p); break;
+ case nConcat: fmtprint(f, "%X^%X", n->u[0].p, n->u[1].p); break;
+ case nElse: fmtprint(f, "{%X}else %X", n->u[0].p, n->u[1].p); break;
+ case nNewfn: fmtprint(f, "fn %X {%X}", n->u[0].p, n->u[1].p); break;
+ case nIf: fmtprint(f, "if(%X)%X", n->u[0].p, n->u[1].p); break;
+ case nOrelse: fmtprint(f, "%X||%X", n->u[0].p, n->u[1].p); break;
+ case nArgs: fmtprint(f, "nArgs: ");
+ Xconv(n->u[0].p, 4);
+ Xconv(n->u[1].p, 4); break;
+ case nSwitch: fmtprint(f, "switch(%X){%X}", n->u[0].p, n->u[1].p); break;
+ case nMatch: fmtprint(f, "~ %X %X", n->u[0].p, n->u[1].p); break;
+ case nWhile: fmtprint(f, "while(%X)%X", n->u[0].p, n->u[1].p); break;
+ case nForin: fmtprint(f, "for(%X in %X)%X", n->u[0].p, n->u[1].p, n->u[2].p); break;
+ case nVarsub: fmtprint(f, "$%X(%X)", n->u[0].p, n->u[1].p); break;
+ case nWord:
+ fmtprint(f, n->u[2].i && quotep(n->u[0].s, dollar) ?
+ "%#S" : "%S", n->u[0].s);
+ break;
+ case nLappend: {
+ static bool inlist;
+ if (!inlist) {
+ inlist = TRUE;
+ fmtprint(f, "(%X %X)", n->u[0].p, n->u[1].p);
+ inlist = FALSE;
+ } else {
+ fmtprint(f, "%X %X", n->u[0].p, n->u[1].p);
+ }
+ break;
+ }
+ case nCount: case nFlat: case nVar: {
+ char *lp = "", *rp = "";
+ Node *n0 = n->u[0].p;
- if (n0->type != nWord)
- lp = "(", rp = ")";
+ if (n0->type != nWord)
+ lp = "(", rp = ")";
- switch (n->type) {
- default: panic("this can't happen"); break;
- case nCount: fmtprint(f, "$#%s%#T%s", lp, n0, rp); break;
- case nFlat: fmtprint(f, "$^%s%#T%s", lp, n0, rp); break;
- case nVar: fmtprint(f, "$%s%#T%s", lp, n0, rp); break;
- }
- break;
- }
- case nDup:
- if (n->u[2].i != -1)
- fmtprint(f, "%D[%d=%d]", n->u[0].i, n->u[1].i, n->u[2].i);
- else
- fmtprint(f, "%D[%d=]", n->u[0].i, n->u[1].i);
- break;
- case nBackq: {
- Node *n0 = n->u[0].p, *n00;
- if (n0 != NULL && n0->type == nVar
- && (n00 = n0->u[0].p) != NULL && n00->type == nWord && streq(n00->u[0].s, "ifs"))
- fmtprint(f, "`");
- else
- fmtprint(f, "``%X", n0);
- fmtprint(f, "{%X}", n->u[1].p);
- break;
- }
- case nCbody:
- case nBody: {
- Node *n0 = n->u[0].p;
- if (n0 != NULL)
- fmtprint(f, "%X", n->u[0].p);
- if (n->u[1].p != NULL) {
- if (n0 != NULL && n0->type != nNowait)
- fmtprint(f, ";");
- fmtprint(f, "%X", n->u[1].p);
- }
- break;
- }
- case nBrace:
- fmtprint(f, "{%X}", n->u[0].p);
- if (n->u[1].p != NULL)
- fmtprint(f, "%X", n->u[1].p);
- break;
- case nEpilog:
- case nPre:
- fmtprint(f, "%X", n->u[0].p);
- if (n->u[1].p != NULL)
- fmtprint(f, " %X", n->u[1].p);
- break;
- case nPipe: {
- int ofd = n->u[0].i, ifd = n->u[1].i;
- fmtprint(f, "%X|", n->u[2].p);
- if (ifd != 0)
- fmtprint(f, "[%d=%d]", ofd, ifd);
- else if (ofd != 1)
- fmtprint(f, "[%d]", ofd);
- fmtprint(f, "%X", n->u[3].p);
- break;
- }
- case nRedir: {
- int op = n->u[0].i;
- fmtprint(f, "%D", op);
- fmtprint(f, "[%d]", n->u[1].i);
- fmtprint(f, "%X", n->u[2].p);
- break;
- }
- case nNmpipe: {
- int op = n->u[0].i;
- fmtprint(f, "%D", op);
- fmtprint(f, "[%d]", n->u[1].i);
- fmtprint(f, "{%X}", n->u[2].p);
- break;
- }
- }
- return FALSE;
+ switch (n->type) {
+ default: panic("this can't happen"); break;
+ case nCount: fmtprint(f, "$#%s%#T%s", lp, n0, rp); break;
+ case nFlat: fmtprint(f, "$^%s%#T%s", lp, n0, rp); break;
+ case nVar: fmtprint(f, "$%s%#T%s", lp, n0, rp); break;
+ }
+ break;
+ }
+ case nDup:
+ if (n->u[2].i != -1)
+ fmtprint(f, "%D[%d=%d]", n->u[0].i, n->u[1].i, n->u[2].i);
+ else
+ fmtprint(f, "%D[%d=]", n->u[0].i, n->u[1].i);
+ break;
+ case nBackq: {
+ Node *n0 = n->u[0].p, *n00;
+ if (n0 != NULL && n0->type == nVar
+ && (n00 = n0->u[0].p) != NULL && n00->type == nWord && streq(n00->u[0].s, "ifs"))
+ fmtprint(f, "`");
+ else
+ fmtprint(f, "``%X", n0);
+ fmtprint(f, "{%X}", n->u[1].p);
+ break;
+ }
+ case nCbody:
+ case nBody: {
+ Node *n0 = n->u[0].p;
+ if (n0 != NULL)
+ fmtprint(f, "%X", n->u[0].p);
+ if (n->u[1].p != NULL) {
+ if (n0 != NULL && n0->type != nNowait)
+ fmtprint(f, ";");
+ fmtprint(f, "%X", n->u[1].p);
+ }
+ break;
+ }
+ case nBrace:
+ fmtprint(f, "{%X}", n->u[0].p);
+ if (n->u[1].p != NULL)
+ fmtprint(f, "%X", n->u[1].p);
+ break;
+ case nEpilog:
+ case nPre:
+ fmtprint(f, "%X", n->u[0].p);
+ if (n->u[1].p != NULL)
+ fmtprint(f, " %X", n->u[1].p);
+ break;
+ case nPipe: {
+ int ofd = n->u[0].i, ifd = n->u[1].i;
+ fmtprint(f, "%X|", n->u[2].p);
+ if (ifd != 0)
+ fmtprint(f, "[%d=%d]", ofd, ifd);
+ else if (ofd != 1)
+ fmtprint(f, "[%d]", ofd);
+ fmtprint(f, "%X", n->u[3].p);
+ break;
+ }
+ case nRedir: {
+ int op = n->u[0].i;
+ fmtprint(f, "%D", op);
+ fmtprint(f, "[%d]", n->u[1].i);
+ fmtprint(f, "%X", n->u[2].p);
+ break;
+ }
+ case nNmpipe: {
+ int op = n->u[0].i;
+ fmtprint(f, "%D", op);
+ fmtprint(f, "[%d]", n->u[1].i);
+ fmtprint(f, "{%X}", n->u[2].p);
+ break;
+ }
+ }
+ return FALSE;
}
#endif
diff --git a/edit-editline.c b/edit-editline.c
@@ -17,11 +17,11 @@ void *edit_begin(int fd) {
List *hist;
struct cookie *c;
- hist = varlookup("history");
- if (hist != NULL)
- if (read_history(hist->w) != 0 &&
+ hist = varlookup("history");
+ if (hist != NULL)
+ if (read_history(hist->w) != 0 &&
errno != ENOENT) /* ignore if missing */
- uerror(hist->w);
+ uerror(hist->w);
c = ealloc(sizeof *c);
c->buffer = NULL;
diff --git a/edit-vrl.c b/edit-vrl.c
@@ -21,8 +21,8 @@ void *edit_begin(int fd) {
struct cookie *c;
- hist = varlookup("history");
- if (hist != NULL)
+ hist = varlookup("history");
+ if (hist != NULL)
;
/* XXX will need to loop calling add_history() */
diff --git a/footobar.c b/footobar.c
@@ -170,7 +170,7 @@ static bool Tconv(Format *f, int ignore) {
fmtprint(f, "{%T}", n->u[2].p);
break;
}
- }
+ }
return FALSE;
}
diff --git a/getopt.c b/getopt.c
@@ -6,9 +6,9 @@ int rc_optopt;
char *rc_optarg;
/* getopt routine courtesy of David Sanderson */
-
+
extern int rc_getopt(int argc, char **argv, char *opts) {
- static int sp = 1;
+ static int sp = 1;
int c;
char *cp;
if (rc_optind == 0) /* reset rc_getopt() */
diff --git a/glob.c b/glob.c
@@ -94,7 +94,7 @@ static List *dmatch(char *d, char *p, char *m) {
int i;
/*
- return a match if there are no metacharacters; allows globbing through
+ return a match if there are no metacharacters; allows globbing through
directories with no read permission. make sure the file exists, though.
*/
matched = TRUE;
diff --git a/history.c b/history.c
@@ -13,7 +13,7 @@
BUGS:
There is an implicit assumption that commands are no
- more than 1k characters long.
+ more than 1k characters long.
*/
#include "rc.h"
@@ -318,7 +318,7 @@ next: s = getcommand();
if (!isin(s, replace[i].old))
goto next;
else {
- int j;
+ int j;
for (j = 0; j <= replace[i].reps; j++)
s = sub(s, replace[i].old, replace[i].new);
}
diff --git a/input.c b/input.c
@@ -308,7 +308,7 @@ extern Node *doit(bool clobberexecit) {
eof = (lastchar == EOF); /* "lastchar" can be clobbered during a walk() */
if (parsetree != NULL) {
if (RC_DEVELOP)
- tree_dump(parsetree);
+ tree_dump(parsetree);
if (execit)
walk(parsetree, TRUE);
else if (dashex && dashen)
diff --git a/main.c b/main.c
@@ -83,17 +83,17 @@ quitopts:
inithash();
initparse();
assigndefault("ifs", " ", "\t", "\n", (void *)0);
- assigndefault("nl", "\n", (void *)0);
+ assigndefault("nl", "\n", (void *)0);
#ifdef DEFAULTPATH
assigndefault("path", DEFAULTPATH, (void *)0);
#endif
assigndefault("pid", nprint("%d", rc_pid), (void *)0);
assigndefault("prompt", "; ", "", (void *)0);
- assigndefault("tab", "\t", (void *)0);
+ assigndefault("tab", "\t", (void *)0);
assigndefault("version",
- VERSION,
- "$Release: @(#)" PACKAGE " " VERSION " " DESCRIPTION " $",
- (void *)0 );
+ VERSION,
+ "$Release: @(#)" PACKAGE " " VERSION " " DESCRIPTION " $",
+ (void *)0 );
initenv(envp);
initinput();
null[0] = NULL;
diff --git a/mksignal.c b/mksignal.c
@@ -224,7 +224,7 @@ int main(void) {
/* yes, we could avoid the quadratic searching with an aux array. fap. */
for (s = 1; s <= maxsig; ++s) {
- for (snp = signamings; snp->signo && snp->signo != s; ++snp)
+ for (snp = signamings; snp->signo && snp->signo != s; ++snp)
/* */;
if (snp->signo)
fprintf(outf, "\t{\"%s\",\t\"%s\"},\n",
diff --git a/nalloc.c b/nalloc.c
@@ -44,13 +44,13 @@ static void getblock(size_t n) {
extern void *nalloc(size_t n) {
size_t base;
Block *ulp;
- n = alignto(n, sizeof(align_t));
+ n = alignto(n, sizeof(align_t));
ulp = ul;
if (ulp != NULL && n + (base = ulp->used) < ulp->size) {
ulp->used = base + n;
return &ulp->mem[base];
} else {
- getblock(n);
+ getblock(n);
assert(ul->used == 0);
(ulp = ul)->used = n;
return &ulp->mem[0];
diff --git a/signal.c b/signal.c
@@ -16,8 +16,8 @@ void (*sys_signal(int signum, void (*handler)(int)))(int) {
new.sa_flags = 0; /* clear SA_RESTART */
sigfillset(&new.sa_mask);
if (sigaction(signum, &new, &old) == 0)
- return old.sa_handler;
- return SIG_DFL;
+ return old.sa_handler;
+ return SIG_DFL;
}
#else
void (*sys_signal(int signum, void (*handler)(int)))(int) {
diff --git a/status.c b/status.c
@@ -133,7 +133,7 @@ extern void ssetstatus(char **av) {
statuses[l - i] = k;
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")) {
diff --git a/tree.c b/tree.c
@@ -27,10 +27,10 @@ static Node *desugar_ifnot(Node *n) {
Node *no = n->u[1].p->u[0].p;
Node *els = nalloc(offsetof(Node, u[2]));
els->type = nElse;
- els->u[1].p = no->u[0].p;
- els->u[0].p = yes->u[1].p;
- yes->u[1].p = els;
- n->u[1].p = n->u[1].p->u[1].p;
+ els->u[1].p = no->u[0].p;
+ els->u[0].p = yes->u[1].p;
+ yes->u[1].p = els;
+ n->u[1].p = n->u[1].p->u[1].p;
} else goto fail;
}
@@ -68,7 +68,7 @@ extern Node *mk(enum nodetype t,...) {
n = nalloc(offsetof(Node, u[1]));
n->u[0].p = va_arg(ap, Node *);
break;
- case nAndalso: case nAssign: case nBackq: case nBody: case nBrace: case nConcat:
+ case nAndalso: case nAssign: case nBackq: case nBody: case nBrace: case nConcat:
case nElse: case nEpilog: case nIf: case nNewfn: case nCbody:
case nOrelse: case nPre: case nArgs: case nSwitch:
case nMatch: case nVarsub: case nWhile: case nLappend:
@@ -96,7 +96,7 @@ extern Node *mk(enum nodetype t,...) {
n->u[1].i = va_arg(ap, int);
n->u[2].p = va_arg(ap, Node *);
break;
- }
+ }
n->type = t;
n = desugar_ifnot(n);
diff --git a/walk.c b/walk.c
@@ -98,13 +98,13 @@ top: sigchk();
true_cmd = true_cmd->u[0].p;
}
cond = TRUE;
- if_state = walk(n->u[0].p, TRUE);
+ if_state = walk(n->u[0].p, TRUE);
cond = oldcond;
WALK(if_state ? true_cmd : false_cmd, parent);
}
- case nIfnot: {
- if (if_state == 2)
- rc_error("`if not' must follow `if'");
+ case nIfnot: {
+ if (if_state == 2)
+ rc_error("`if not' must follow `if'");
if (if_state == 0)
walk(n->u[0].p, TRUE);
if_state = 2;
diff --git a/which.c b/which.c
@@ -83,7 +83,7 @@ static char *protect(char *in) {
out[i] = '\0';
return out;
}
-
+
/* return a full pathname by searching $path, and by checking the status of the file */
extern char *which(char *name, bool verbose) {