diff --git a/programs/dtphoto/dtphoto.c b/programs/dtphoto/dtphoto.c index bf5d0ad8..7613ad33 100644 --- a/programs/dtphoto/dtphoto.c +++ b/programs/dtphoto/dtphoto.c @@ -53,6 +53,14 @@ #include #include +/* M_PI is not in POSIX: math.h carries it only for _XOPEN_SOURCE or + * _NETBSD_SOURCE, and _POSIX_C_SOURCE 200809L (line 16) turns both off. + * Guarded, so it stays quiet where the header has it. Same as + * lib/McdeSys/test_audio.c does. */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + #define MAXMENUS 16 #define MAXITEMS 80 #define MAXDEPTH 4 @@ -8398,7 +8406,7 @@ OpExtrude(int cell, int depth, int solidFront) { unsigned char *rgb, *out; int w, h, x, y, bx, by, c; - unsigned char br, bg, bb; + unsigned char br, bg, bb, front[3]; if (cell < 2) cell = 2; if (depth < 1) depth = 1; @@ -8409,11 +8417,15 @@ OpExtrude(int cell, int depth, int solidFront) return; } PixelToRGB(bgPixel, &br, &bg, &bb); + /* A compound literal here would put its commas between memcpy's + * own argument commas: _FORTIFY_SOURCE sees five arguments, not + * three. A named array keeps the call a three-argument call. */ + front[0] = solidFront ? br : 0; + front[1] = solidFront ? bg : 0; + front[2] = solidFront ? bb : 0; for (y = 0; y < h; y++) for (x = 0; x < w; x++) - memcpy(out + ((size_t) y * w + x) * 3, (unsigned char[]) { - solidFront ? br : 0, solidFront ? bg : 0, - solidFront ? bb : 0 }, 3); + memcpy(out + ((size_t) y * w + x) * 3, front, 3); for (by = 0; by < h; by += cell) for (bx = 0; bx < w; bx += cell) { int n = NoiseAt(bx, by, 5u);