Skip to content

Commit 1b717b2

Browse files
authored
Merge pull request #3364 from oddbookworm/braces
No more one-line statements without braces
2 parents 866b611 + b0121ed commit 1b717b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2406
-1201
lines changed

Diff for: src_c/.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ AlignAfterOpenBracket: Align
77
BreakBeforeBraces: Stroustrup
88
ColumnLimit: 79
99
DerivePointerAlignment: false
10+
InsertBraces: true
1011
# These settings are mirrored in .editorconfig. Keep them in sync.
1112
IndentWidth: 4
1213
Language: Cpp

Diff for: src_c/SDL_gfx/SDL_gfxPrimitives.c

+86-43
Original file line numberDiff line numberDiff line change
@@ -2069,8 +2069,9 @@ _clipLine(SDL_Surface *dst, Sint16 *x1, Sint16 *y1, Sint16 *x2, Sint16 *y2)
20692069
draw = 1;
20702070
break;
20712071
}
2072-
else if (CLIP_REJECT(code1, code2))
2072+
else if (CLIP_REJECT(code1, code2)) {
20732073
break;
2074+
}
20742075
else {
20752076
if (CLIP_INSIDE(code1)) {
20762077
swaptmp = *x2;
@@ -3270,10 +3271,12 @@ arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start,
32703271
end %= 360;
32713272
// 0 <= start & end < 360; note that sometimes start > end - if so, arc
32723273
// goes back through 0.
3273-
while (start < 0)
3274+
while (start < 0) {
32743275
start += 360;
3275-
while (end < 0)
3276+
}
3277+
while (end < 0) {
32763278
end += 360;
3279+
}
32773280
start %= 360;
32783281
end %= 360;
32793282

@@ -3317,13 +3320,15 @@ arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start,
33173320
// pixel at x = ((int)temp).
33183321

33193322
// and whether to draw in this octant initially
3320-
if (oct % 2)
3323+
if (oct % 2) {
33213324
drawoct |=
33223325
(1 << oct); // this is basically like saying drawoct[oct]
33233326
// = true, if drawoct were a bool array
3324-
else
3327+
}
3328+
else {
33253329
drawoct &= 255 - (1 << oct); // this is basically like saying
33263330
// drawoct[oct] = false
3331+
}
33273332
}
33283333
if (oct == endoct) {
33293334
// need to compute stopval_end for this octant
@@ -3364,10 +3369,12 @@ arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start,
33643369
drawoct &= 255 - (1 << oct);
33653370
}
33663371
}
3367-
else if (oct % 2)
3372+
else if (oct % 2) {
33683373
drawoct &= 255 - (1 << oct);
3369-
else
3374+
}
3375+
else {
33703376
drawoct |= (1 << oct);
3377+
}
33713378
}
33723379
else if (oct != startoct) { // already verified that it's != endoct
33733380
drawoct |= (1 << oct); // draw this entire segment
@@ -3421,48 +3428,60 @@ arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start,
34213428
xmcx = x - cx;
34223429
// always check if we're drawing a certain octant before adding
34233430
// a pixel to that octant.
3424-
if (drawoct & 4)
3431+
if (drawoct & 4) {
34253432
result |= fastPixelColorNolock(
34263433
dst, xmcx, ypcy,
34273434
color); // drawoct & 4 = 22; drawoct[2]
3428-
if (drawoct & 2)
3435+
}
3436+
if (drawoct & 2) {
34293437
result |= fastPixelColorNolock(dst, xpcx, ypcy, color);
3430-
if (drawoct & 32)
3438+
}
3439+
if (drawoct & 32) {
34313440
result |= fastPixelColorNolock(dst, xmcx, ymcy, color);
3432-
if (drawoct & 64)
3441+
}
3442+
if (drawoct & 64) {
34333443
result |= fastPixelColorNolock(dst, xpcx, ymcy, color);
3444+
}
34343445
}
34353446
else {
3436-
if (drawoct & 6)
3447+
if (drawoct & 6) {
34373448
result |= fastPixelColorNolock(
34383449
dst, x, ypcy,
34393450
color); // 4 + 2; drawoct[2] || drawoct[1]
3440-
if (drawoct & 96)
3451+
}
3452+
if (drawoct & 96) {
34413453
result |=
34423454
fastPixelColorNolock(dst, x, ymcy, color); // 32 + 64
3455+
}
34433456
}
34443457

34453458
xpcy = x + cy;
34463459
xmcy = x - cy;
34473460
if (cx > 0 && cx != cy) {
34483461
ypcx = y + cx;
34493462
ymcx = y - cx;
3450-
if (drawoct & 8)
3463+
if (drawoct & 8) {
34513464
result |= fastPixelColorNolock(dst, xmcy, ypcx, color);
3452-
if (drawoct & 1)
3465+
}
3466+
if (drawoct & 1) {
34533467
result |= fastPixelColorNolock(dst, xpcy, ypcx, color);
3454-
if (drawoct & 16)
3468+
}
3469+
if (drawoct & 16) {
34553470
result |= fastPixelColorNolock(dst, xmcy, ymcx, color);
3456-
if (drawoct & 128)
3471+
}
3472+
if (drawoct & 128) {
34573473
result |= fastPixelColorNolock(dst, xpcy, ymcx, color);
3474+
}
34583475
}
34593476
else if (cx == 0) {
3460-
if (drawoct & 24)
3477+
if (drawoct & 24) {
34613478
result |=
34623479
fastPixelColorNolock(dst, xmcy, y, color); // 8 + 16
3463-
if (drawoct & 129)
3480+
}
3481+
if (drawoct & 129) {
34643482
result |=
34653483
fastPixelColorNolock(dst, xpcy, y, color); // 1 + 128
3484+
}
34663485
}
34673486

34683487
/*
@@ -3471,16 +3490,20 @@ arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start,
34713490
if (stopval_start == cx) {
34723491
// works like an on-off switch because start & end may be in
34733492
// the same octant.
3474-
if (drawoct & (1 << startoct))
3493+
if (drawoct & (1 << startoct)) {
34753494
drawoct &= 255 - (1 << startoct);
3476-
else
3495+
}
3496+
else {
34773497
drawoct |= (1 << startoct);
3498+
}
34783499
}
34793500
if (stopval_end == cx) {
3480-
if (drawoct & (1 << endoct))
3501+
if (drawoct & (1 << endoct)) {
34813502
drawoct &= 255 - (1 << endoct);
3482-
else
3503+
}
3504+
else {
34833505
drawoct |= (1 << endoct);
3506+
}
34843507
}
34853508

34863509
/*
@@ -3519,41 +3542,53 @@ arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start,
35193542

35203543
// always check if we're drawing a certain octant before adding
35213544
// a pixel to that octant.
3522-
if (drawoct & 4)
3545+
if (drawoct & 4) {
35233546
result |= pixelColorNolock(dst, xmcx, ypcy, color);
3524-
if (drawoct & 2)
3547+
}
3548+
if (drawoct & 2) {
35253549
result |= pixelColorNolock(dst, xpcx, ypcy, color);
3526-
if (drawoct & 32)
3550+
}
3551+
if (drawoct & 32) {
35273552
result |= pixelColorNolock(dst, xmcx, ymcy, color);
3528-
if (drawoct & 64)
3553+
}
3554+
if (drawoct & 64) {
35293555
result |= pixelColorNolock(dst, xpcx, ymcy, color);
3556+
}
35303557
}
35313558
else {
3532-
if (drawoct & 96)
3559+
if (drawoct & 96) {
35333560
result |= pixelColorNolock(dst, x, ymcy, color);
3534-
if (drawoct & 6)
3561+
}
3562+
if (drawoct & 6) {
35353563
result |= pixelColorNolock(dst, x, ypcy, color);
3564+
}
35363565
}
35373566

35383567
xpcy = x + cy;
35393568
xmcy = x - cy;
35403569
if (cx > 0 && cx != cy) {
35413570
ypcx = y + cx;
35423571
ymcx = y - cx;
3543-
if (drawoct & 8)
3572+
if (drawoct & 8) {
35443573
result |= pixelColorNolock(dst, xmcy, ypcx, color);
3545-
if (drawoct & 1)
3574+
}
3575+
if (drawoct & 1) {
35463576
result |= pixelColorNolock(dst, xpcy, ypcx, color);
3547-
if (drawoct & 16)
3577+
}
3578+
if (drawoct & 16) {
35483579
result |= pixelColorNolock(dst, xmcy, ymcx, color);
3549-
if (drawoct & 128)
3580+
}
3581+
if (drawoct & 128) {
35503582
result |= pixelColorNolock(dst, xpcy, ymcx, color);
3583+
}
35513584
}
35523585
else if (cx == 0) {
3553-
if (drawoct & 24)
3586+
if (drawoct & 24) {
35543587
result |= pixelColorNolock(dst, xmcy, y, color);
3555-
if (drawoct & 129)
3588+
}
3589+
if (drawoct & 129) {
35563590
result |= pixelColorNolock(dst, xpcy, y, color);
3591+
}
35573592
}
35583593

35593594
/*
@@ -3562,16 +3597,20 @@ arcColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start,
35623597
if (stopval_start == cx) {
35633598
// works like an on-off switch.
35643599
// This is just in case start & end are in the same octant.
3565-
if (drawoct & (1 << startoct))
3600+
if (drawoct & (1 << startoct)) {
35663601
drawoct &= 255 - (1 << startoct);
3567-
else
3602+
}
3603+
else {
35683604
drawoct |= (1 << startoct);
3605+
}
35693606
}
35703607
if (stopval_end == cx) {
3571-
if (drawoct & (1 << endoct))
3608+
if (drawoct & (1 << endoct)) {
35723609
drawoct &= 255 - (1 << endoct);
3573-
else
3610+
}
3611+
else {
35743612
drawoct |= (1 << endoct);
3613+
}
35753614
}
35763615

35773616
/*
@@ -4362,11 +4401,13 @@ aaellipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry,
43624401
xp--;
43634402
d += t - b2;
43644403

4365-
if (d >= 0)
4404+
if (d >= 0) {
43664405
ys = yp - 1;
4406+
}
43674407
else if ((d - s - a2) > 0) {
4368-
if ((2 * d - s - a2) >= 0)
4408+
if ((2 * d - s - a2) >= 0) {
43694409
ys = yp + 1;
4410+
}
43704411
else {
43714412
ys = yp;
43724413
yp++;
@@ -4423,11 +4464,13 @@ aaellipseColor(SDL_Surface *dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry,
44234464
yp++;
44244465
d -= s + a2;
44254466

4426-
if (d <= 0)
4467+
if (d <= 0) {
44274468
xs = xp + 1;
4469+
}
44284470
else if ((d + t - b2) < 0) {
4429-
if ((2 * d + t - b2) <= 0)
4471+
if ((2 * d + t - b2) <= 0) {
44304472
xs = xp - 1;
4473+
}
44314474
else {
44324475
xs = xp;
44334476
xp--;

0 commit comments

Comments
 (0)