Apply clang-format update to repo (#1154)

Commit bc6c183 introduced a bunch of discrepancies between what files
look like in the repo and what clang-format says they should look like.
However, there were already a few discrepancies prior to that. Most of
these discrepancies seemed to be unintentional, but a few of them were
load-bearing (e.g., a #include that violated header ordering needing
something to have been #defined by a 'later' #include.)

I opted to take what I hope is a relatively smooth-brained approach: I
reverted the .clang-format change, ran clang-format on the whole repo,
reapplied the .clang-format change, reran clang-format again, and then
reverted the commit that contained the first run. Thus the full effect
of this PR should only be to apply the changed formatting rules to the
repo, and from skimming the results, this seems to be the case.

My work can be checked by applying the short, manual commits, and then
rerunning the command listed in the autogenerated commits (those whose
messages I have prefixed auto:) and seeing if your results agree.

It might be that the other diffs should be fixed at some point but I'm
leaving that aside for now.

fd '\.c(c|pp)?$' --print0| xargs -0 clang-format -i
This commit is contained in:
Jōshin 2024-04-25 10:38:00 -07:00 committed by GitHub
parent 342d0c81e5
commit 6e6fc38935
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
863 changed files with 9201 additions and 4627 deletions

View file

@ -28,9 +28,12 @@
nosideeffect int CountSimpleParameters(int x) {
int i;
for (i = 0; x; ++i, x = Cdr(x)) {
if (x > 0) return -1; // variadic args aren't simple
if (!Car(x)) return -1; // nil parameters aren't simple
if (Car(x) < 0) return -1; // destructured parameters aren't simple
if (x > 0)
return -1; // variadic args aren't simple
if (!Car(x))
return -1; // nil parameters aren't simple
if (Car(x) < 0)
return -1; // destructured parameters aren't simple
}
return i;
}
@ -38,157 +41,201 @@ nosideeffect int CountSimpleParameters(int x) {
nosideeffect int CountSimpleArguments(int x) {
int i;
for (i = 0; x; ++i, x = Cdr(x)) {
if (x > 0) return -1; // apply isn't simple
if (x > 0)
return -1; // apply isn't simple
}
return i;
}
static dword PlanQuote(int e, int a, int s) {
if (Cdr(e) >= 0) React(e, e, kQuote); // one normal parameter required
if (Cdr(e) >= 0)
React(e, e, kQuote); // one normal parameter required
return MAKE(DF(DispatchQuote), Cadr(e)); // >1 prms is sectorlisp comment
}
static dword PlanCar(int e, int a, int s) {
if (!Cdr(e)) return DF(DispatchNil); // (⍅) ⟺ (⍅ ⊥)
if (Cddr(e)) React(e, e, kCar); // too many args
if (!Cadr(e)) return DF(DispatchNil);
if (!Cdr(e))
return DF(DispatchNil); // (⍅) ⟺ (⍅ ⊥)
if (Cddr(e))
React(e, e, kCar); // too many args
if (!Cadr(e))
return DF(DispatchNil);
return MAKE(DF(DispatchCar), Cadr(e));
}
static dword PlanCdr(int e, int a, int s) {
if (!Cdr(e)) return DF(DispatchNil); // (⍆) ⟺ (⍆ ⊥)
if (Cddr(e)) React(e, e, kCdr); // too many args
if (!ARG1(e)) return DF(DispatchNil);
if (!Cdr(e))
return DF(DispatchNil); // (⍆) ⟺ (⍆ ⊥)
if (Cddr(e))
React(e, e, kCdr); // too many args
if (!ARG1(e))
return DF(DispatchNil);
return MAKE(DF(DispatchCdr), Cadr(e));
}
static dword PlanAtom(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) != 1) React(e, e, kAtom);
if (CountSimpleArguments(Cdr(e)) != 1)
React(e, e, kAtom);
return MAKE(DF(DispatchAtom), Cadr(e));
}
static dword PlanEq(int e, int a, int s) {
int n = CountSimpleArguments(Cdr(e));
if (n != 2 && n != 1) React(e, e, kAtom); // (≡ 𝑥) is our (null 𝑥)
if (n != 2 && n != 1)
React(e, e, kAtom); // (≡ 𝑥) is our (null 𝑥)
return MAKE(DF(DispatchEq), Caddr(e));
}
static dword PlanCmp(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) != 2) React(e, e, kCmp);
if (CountSimpleArguments(Cdr(e)) != 2)
React(e, e, kCmp);
return MAKE(DF(DispatchCmp), Caddr(e));
}
static dword PlanOrder(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) != 2) React(e, e, kOrder);
if (CountSimpleArguments(Cdr(e)) != 2)
React(e, e, kOrder);
return MAKE(DF(DispatchOrder), Caddr(e));
}
static dword PlanCons(int e, int a, int s) {
int p = CountSimpleArguments(Cdr(e));
if (p == -1) Error("cons dot arg");
if (p > 2) Error("too many args");
if (p == -1)
Error("cons dot arg");
if (p > 2)
Error("too many args");
return MAKE(DF(DispatchCons), Caddr(e));
}
static dword PlanLambda(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) == -1) Error("bad lambda: %S", e);
if (CountSimpleArguments(Cdr(e)) == -1)
Error("bad lambda: %S", e);
return DF(DispatchLambda);
}
static dword PlanCond(int e, int a, int s) {
int x;
if (!Cdr(e)) return DF(DispatchNil); // (ζ) ⟺ ⊥
if (!Cdr(e))
return DF(DispatchNil); // (ζ) ⟺ ⊥
for (x = e; (x = Cdr(x));) {
if (x > 0) React(e, e, kCond); // (ζ . 𝑣) not allowed
if (Car(x) >= 0) React(e, e, kCond); // (ζ 𝑣) not allowed
if (Cdr(Car(x)) > 0) React(e, e, kCond); // (ζ (𝑥 . 𝑣)) not allowed
if (x > 0)
React(e, e, kCond); // (ζ . 𝑣) not allowed
if (Car(x) >= 0)
React(e, e, kCond); // (ζ 𝑣) not allowed
if (Cdr(Car(x)) > 0)
React(e, e, kCond); // (ζ (𝑥 . 𝑣)) not allowed
}
return MAKE(DF(DispatchCond), Cdr(e));
}
static dword PlanProgn(int e, int a, int s) {
if (!Cdr(e)) return DF(DispatchNil); // (progn) ⟺ ⊥
if (CountSimpleArguments(Cdr(e)) == -1) React(e, e, kProgn);
if (!Cdr(e))
return DF(DispatchNil); // (progn) ⟺ ⊥
if (CountSimpleArguments(Cdr(e)) == -1)
React(e, e, kProgn);
return MAKE(DF(DispatchProgn), Cdr(e));
}
static dword PlanQuiet(int e, int a, int s) {
if (Cdr(e) > 0) React(e, e, kQuiet); // apply not allowed
if (!Cdr(e)) React(e, e, kQuiet); // zero args not allowed
if (Cdr(Cdr(e))) React(e, e, kQuiet); // >1 args not allowed
if (Cdr(e) > 0)
React(e, e, kQuiet); // apply not allowed
if (!Cdr(e))
React(e, e, kQuiet); // zero args not allowed
if (Cdr(Cdr(e)))
React(e, e, kQuiet); // >1 args not allowed
return DF(DispatchQuiet);
}
static dword PlanTrace(int e, int a, int s) {
if (Cdr(e) > 0) React(e, e, kTrace); // apply not allowed
if (!Cdr(e)) React(e, e, kTrace); // zero args not allowed
if (Cdr(Cdr(e))) React(e, e, kTrace); // >1 args not allowed
if (Cdr(e) > 0)
React(e, e, kTrace); // apply not allowed
if (!Cdr(e))
React(e, e, kTrace); // zero args not allowed
if (Cdr(Cdr(e)))
React(e, e, kTrace); // >1 args not allowed
return DF(DispatchTrace);
}
static dword PlanFtrace(int e, int a, int s) {
if (Cdr(e) > 0) React(e, e, kFtrace); // apply not allowed
if (!Cdr(e)) React(e, e, kFtrace); // zero args not allowed
if (Cdr(Cdr(e))) React(e, e, kFtrace); // >1 args not allowed
if (Cdr(e) > 0)
React(e, e, kFtrace); // apply not allowed
if (!Cdr(e))
React(e, e, kFtrace); // zero args not allowed
if (Cdr(Cdr(e)))
React(e, e, kFtrace); // >1 args not allowed
return DF(DispatchFtrace);
}
static dword PlanFunction(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) != 1) Raise(kFunction);
if (CountSimpleArguments(Cdr(e)) != 1)
Raise(kFunction);
return MAKE(DF(DispatchFunction), Cadr(e));
}
static dword PlanBeta(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) != 1) Raise(kBeta);
if (CountSimpleArguments(Cdr(e)) != 1)
Raise(kBeta);
return MAKE(DF(DispatchBeta), Cadr(e));
}
static dword PlanIgnore(int e, int a, int s) {
if (!Cdr(e)) return DF(DispatchIgnore0);
if (Cdr(e) > 0) React(e, e, kIgnore); // apply not allowed
if (!Cdr(e)) React(e, e, kIgnore); // zero args not allowed
if (Cdr(Cdr(e))) React(e, e, kIgnore); // >1 args not allowed
if (!Cdr(e))
return DF(DispatchIgnore0);
if (Cdr(e) > 0)
React(e, e, kIgnore); // apply not allowed
if (!Cdr(e))
React(e, e, kIgnore); // zero args not allowed
if (Cdr(Cdr(e)))
React(e, e, kIgnore); // >1 args not allowed
return DF(DispatchIgnore1);
}
static dword PlanExpand(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) != 1) React(e, e, kExpand);
if (CountSimpleArguments(Cdr(e)) != 1)
React(e, e, kExpand);
return MAKE(DF(DispatchExpand), Cadr(e));
}
static dword PlanPrint(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) == -1) React(e, e, kPrint);
if (CountSimpleArguments(Cdr(e)) == -1)
React(e, e, kPrint);
return DF(DispatchPrint);
}
static dword PlanGensym(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e))) React(e, e, kGensym);
if (CountSimpleArguments(Cdr(e)))
React(e, e, kGensym);
return DF(DispatchGensym);
}
static dword PlanPprint(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) == -1) React(e, e, kPprint);
if (CountSimpleArguments(Cdr(e)) == -1)
React(e, e, kPprint);
return DF(DispatchPprint);
}
static dword PlanPrintheap(int e, int a, int s) {
int p = CountSimpleArguments(Cdr(e));
if (p != 0 && p != 1) React(e, e, kPrintheap);
if (p != 0 && p != 1)
React(e, e, kPrintheap);
return DF(DispatchPrintheap);
}
static dword PlanGc(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) != 1) React(e, e, kGc);
if (CountSimpleArguments(Cdr(e)) != 1)
React(e, e, kGc);
return MAKE(DF(DispatchGc), Cadr(e));
}
static dword PlanPrinc(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) == -1) React(e, e, kPrinc);
if (CountSimpleArguments(Cdr(e)) == -1)
React(e, e, kPrinc);
return DF(DispatchPrinc);
}
static dword PlanFlush(int e, int a, int s) {
if (CountSimpleArguments(Cdr(e)) == -1) React(e, e, kFlush);
if (CountSimpleArguments(Cdr(e)) == -1)
React(e, e, kFlush);
return DF(DispatchFlush);
}
@ -197,12 +244,14 @@ static dword PlanError(int e, int a, int s) {
}
static dword PlanExit(int e, int a, int s) {
if (Cdr(e)) React(e, e, kExit);
if (Cdr(e))
React(e, e, kExit);
return DF(DispatchExit);
}
static dword PlanRead(int e, int a, int s) {
if (Cdr(e)) React(e, e, kRead);
if (Cdr(e))
React(e, e, kRead);
return DF(DispatchRead);
}
@ -216,16 +265,20 @@ static dword PlanClosure(int e, int a, int s) {
static dword PlanLet(int e, int a, int s) {
int n;
if ((n = CountSimpleArguments(Cdr(e))) == -1) return DF(DispatchFuncall);
if (CountSimpleArguments(Car(e)) < 3) React(e, e, kLambda); // need (λ 𝑥 𝑦)
if ((n = CountSimpleArguments(Cdr(e))) == -1)
return DF(DispatchFuncall);
if (CountSimpleArguments(Car(e)) < 3)
React(e, e, kLambda); // need (λ 𝑥 𝑦)
switch (CountSimpleParameters(Cadr(Car(e)))) {
case -1:
return DF(DispatchFuncall);
case 0:
if (n != 0) Error("let argument count mismatch: %S", e);
if (n != 0)
Error("let argument count mismatch: %S", e);
return MAKE(DF(DispatchShortcut), Caddr(Car(e))); // ((λ ⊥ 𝑦)) becomes 𝑦
case 1:
if (n != 1) Error("let argument count mismatch: %S", e);
if (n != 1)
Error("let argument count mismatch: %S", e);
return MAKE(DF(DispatchLet1), Cdar(e));
default:
return MAKE(DF(DispatchFuncall), 0);
@ -234,37 +287,68 @@ static dword PlanLet(int e, int a, int s) {
static dontinline dword PlanPrecious(int e, int a, int s, int f) {
DCHECK_GT(f, 0);
if (f == kCar) return PlanCar(e, a, s);
if (f == kCdr) return PlanCdr(e, a, s);
if (f == kGc) return PlanGc(e, a, s);
if (f == kEq) return PlanEq(e, a, s);
if (f == kCmp) return PlanCmp(e, a, s);
if (f == kBeta) return PlanBeta(e, a, s);
if (f == kCond) return PlanCond(e, a, s);
if (f == kAtom) return PlanAtom(e, a, s);
if (f == kCons) return PlanCons(e, a, s);
if (f == kExit) return PlanExit(e, a, s);
if (f == kRead) return PlanRead(e, a, s);
if (f == kOrder) return PlanOrder(e, a, s);
if (f == kQuote) return PlanQuote(e, a, s);
if (f == kProgn) return PlanProgn(e, a, s);
if (f == kQuiet) return PlanQuiet(e, a, s);
if (f == kTrace) return PlanTrace(e, a, s);
if (f == kPrint) return PlanPrint(e, a, s);
if (f == kPrinc) return PlanPrinc(e, a, s);
if (f == kFlush) return PlanFlush(e, a, s);
if (f == kError) return PlanError(e, a, s);
if (f == kMacro) return PlanLambda(e, a, s);
if (f == kFtrace) return PlanFtrace(e, a, s);
if (f == kLambda) return PlanLambda(e, a, s);
if (f == kGensym) return PlanGensym(e, a, s);
if (f == kPprint) return PlanPprint(e, a, s);
if (f == kIgnore) return PlanIgnore(e, a, s);
if (f == kExpand) return PlanExpand(e, a, s);
if (f == kDefine) return PlanDefine(e, a, s);
if (f == kClosure) return PlanClosure(e, a, s);
if (f == kFunction) return PlanFunction(e, a, s);
if (f == kPrintheap) return PlanPrintheap(e, a, s);
if (f == kCar)
return PlanCar(e, a, s);
if (f == kCdr)
return PlanCdr(e, a, s);
if (f == kGc)
return PlanGc(e, a, s);
if (f == kEq)
return PlanEq(e, a, s);
if (f == kCmp)
return PlanCmp(e, a, s);
if (f == kBeta)
return PlanBeta(e, a, s);
if (f == kCond)
return PlanCond(e, a, s);
if (f == kAtom)
return PlanAtom(e, a, s);
if (f == kCons)
return PlanCons(e, a, s);
if (f == kExit)
return PlanExit(e, a, s);
if (f == kRead)
return PlanRead(e, a, s);
if (f == kOrder)
return PlanOrder(e, a, s);
if (f == kQuote)
return PlanQuote(e, a, s);
if (f == kProgn)
return PlanProgn(e, a, s);
if (f == kQuiet)
return PlanQuiet(e, a, s);
if (f == kTrace)
return PlanTrace(e, a, s);
if (f == kPrint)
return PlanPrint(e, a, s);
if (f == kPrinc)
return PlanPrinc(e, a, s);
if (f == kFlush)
return PlanFlush(e, a, s);
if (f == kError)
return PlanError(e, a, s);
if (f == kMacro)
return PlanLambda(e, a, s);
if (f == kFtrace)
return PlanFtrace(e, a, s);
if (f == kLambda)
return PlanLambda(e, a, s);
if (f == kGensym)
return PlanGensym(e, a, s);
if (f == kPprint)
return PlanPprint(e, a, s);
if (f == kIgnore)
return PlanIgnore(e, a, s);
if (f == kExpand)
return PlanExpand(e, a, s);
if (f == kDefine)
return PlanDefine(e, a, s);
if (f == kClosure)
return PlanClosure(e, a, s);
if (f == kFunction)
return PlanFunction(e, a, s);
if (f == kPrintheap)
return PlanPrintheap(e, a, s);
if (!a) {
Push(e);
Push(f);
@ -280,26 +364,34 @@ dontinline dword Plan(int e, int a, int s) {
if ((x1 = IsCar(e))) {
if ((x2 = IsCar(x1))) {
if ((x3 = IsCar(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCaaaar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCaaadr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCaaaar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCaaadr), x4);
return MAKE(DF(DispatchCaaar), x3);
}
if ((x3 = IsCdr(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCaadar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCaaddr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCaadar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCaaddr), x4);
return MAKE(DF(DispatchCaaar), x3);
}
return MAKE(DF(DispatchCaar), x2);
}
if ((x2 = IsCdr(x1))) {
if ((x3 = IsCar(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCadaar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCadadr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCadaar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCadadr), x4);
return MAKE(DF(DispatchCadar), x3);
}
if ((x3 = IsCdr(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCaddar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCadddr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCaddar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCadddr), x4);
return MAKE(DF(DispatchCaddr), x3);
}
return MAKE(DF(DispatchCadr), x2);
@ -310,26 +402,34 @@ dontinline dword Plan(int e, int a, int s) {
if ((x1 = IsCdr(e))) {
if ((x2 = IsCar(x1))) {
if ((x3 = IsCar(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCdaaar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCdaadr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCdaaar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCdaadr), x4);
return MAKE(DF(DispatchCdaar), x3);
}
if ((x3 = IsCdr(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCdadar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCdaddr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCdadar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCdaddr), x4);
return MAKE(DF(DispatchCdadr), x3);
}
return MAKE(DF(DispatchCdar), x2);
}
if ((x2 = IsCdr(x1))) {
if ((x3 = IsCar(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCddaar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCddadr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCddaar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCddadr), x4);
return MAKE(DF(DispatchCddar), x3);
}
if ((x3 = IsCdr(x2))) {
if ((x4 = IsCar(x3))) return MAKE(DF(DispatchCdddar), x4);
if ((x4 = IsCdr(x3))) return MAKE(DF(DispatchCddddr), x4);
if ((x4 = IsCar(x3)))
return MAKE(DF(DispatchCdddar), x4);
if ((x4 = IsCdr(x3)))
return MAKE(DF(DispatchCddddr), x4);
return MAKE(DF(DispatchCdddr), x3);
}
return MAKE(DF(DispatchCddr), x2);