theme: colours as bytes, not as a compound literal in memcpy
NetBSD's ssp/string.h defines memcpy() as a three-argument macro, and the preprocessor counts the commas inside a braced literal as arguments of the macro: 'macro "memcpy" passed 5 arguments, but takes just 3'. That is what stopped misc/splinter in the cross build of make release (build/logs/release-2026-11-23.log:21775, src/backend/theme.c:335). Test: gcc -fsyntax-only -Werror against build/obj/destdir.amd64/usr/include (NetBSD headers) passes; a clean native make -j8 here builds the binary and ./splinter --version answers.
This commit is contained in:
1 parent
44f457b68d
commit
91f0136e9d
1 file changed
+35
-22
+35
-22
@@ -21,6 +21,19 @@ luma(const unsigned char *c)
|
||||
|
||||
#define LIGHT 127500 /* luma above this: a light surface, black text */
|
||||
|
||||
/* a colour as three bytes. Not a compound literal in the call: NetBSD's
|
||||
* ssp/string.h defines memcpy() as a three-argument macro and counts the
|
||||
* commas inside a braced literal as arguments of its own ("macro memcpy
|
||||
* passed 5 arguments, but takes just 3", measured 2026-11-23 in the cross
|
||||
* build of misc/splinter). */
|
||||
static void
|
||||
rgb(unsigned char dst[3], unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
dst[0] = r;
|
||||
dst[1] = g;
|
||||
dst[2] = b;
|
||||
}
|
||||
|
||||
/* CDE's rule for the text on a colour set: black on light, white on dark */
|
||||
static void
|
||||
cde_fg(const unsigned char bg[3], unsigned char fg[3])
|
||||
@@ -313,33 +326,33 @@ load_flat(int dark, struct sp_theme *out)
|
||||
memset(out, 0, sizeof(*out));
|
||||
out->name = dark ? SP_THEME_DARK : SP_THEME_LIGHT;
|
||||
if (!dark) {
|
||||
memcpy(out->bg, (const unsigned char[]){255, 255, 255}, 3);
|
||||
memcpy(out->fg, (const unsigned char[]){0, 0, 0}, 3);
|
||||
memcpy(out->border, (const unsigned char[]){96, 96, 96}, 3);
|
||||
memcpy(out->accent, (const unsigned char[]){0, 0, 176}, 3);
|
||||
memcpy(out->agent, (const unsigned char[]){0, 112, 0}, 3);
|
||||
memcpy(out->think, (const unsigned char[]){104, 0, 148}, 3);
|
||||
memcpy(out->tool, (const unsigned char[]){0, 104, 116}, 3);
|
||||
memcpy(out->notice, (const unsigned char[]){148, 0, 120}, 3);
|
||||
memcpy(out->error, (const unsigned char[]){176, 0, 0}, 3);
|
||||
rgb(out->bg, 255, 255, 255);
|
||||
rgb(out->fg, 0, 0, 0);
|
||||
rgb(out->border, 96, 96, 96);
|
||||
rgb(out->accent, 0, 0, 176);
|
||||
rgb(out->agent, 0, 112, 0);
|
||||
rgb(out->think, 104, 0, 148);
|
||||
rgb(out->tool, 0, 104, 116);
|
||||
rgb(out->notice, 148, 0, 120);
|
||||
rgb(out->error, 176, 0, 0);
|
||||
memcpy(out->input_bg, out->bg, 3);
|
||||
memcpy(out->input_fg, out->fg, 3);
|
||||
memcpy(out->status, (const unsigned char[]){230, 230, 230}, 3);
|
||||
memcpy(out->status_fg, (const unsigned char[]){0, 0, 0}, 3);
|
||||
rgb(out->status, 230, 230, 230);
|
||||
rgb(out->status_fg, 0, 0, 0);
|
||||
} else {
|
||||
memcpy(out->bg, (const unsigned char[]){0, 0, 0}, 3);
|
||||
memcpy(out->fg, (const unsigned char[]){235, 235, 235}, 3);
|
||||
memcpy(out->border, (const unsigned char[]){160, 160, 160}, 3);
|
||||
memcpy(out->accent, (const unsigned char[]){120, 170, 255}, 3);
|
||||
memcpy(out->agent, (const unsigned char[]){120, 230, 140}, 3);
|
||||
memcpy(out->think, (const unsigned char[]){200, 160, 255}, 3);
|
||||
memcpy(out->tool, (const unsigned char[]){90, 220, 230}, 3);
|
||||
memcpy(out->notice, (const unsigned char[]){240, 140, 220}, 3);
|
||||
memcpy(out->error, (const unsigned char[]){255, 110, 110}, 3);
|
||||
rgb(out->bg, 0, 0, 0);
|
||||
rgb(out->fg, 235, 235, 235);
|
||||
rgb(out->border, 160, 160, 160);
|
||||
rgb(out->accent, 120, 170, 255);
|
||||
rgb(out->agent, 120, 230, 140);
|
||||
rgb(out->think, 200, 160, 255);
|
||||
rgb(out->tool, 90, 220, 230);
|
||||
rgb(out->notice, 240, 140, 220);
|
||||
rgb(out->error, 255, 110, 110);
|
||||
memcpy(out->input_bg, out->bg, 3);
|
||||
memcpy(out->input_fg, out->fg, 3);
|
||||
memcpy(out->status, (const unsigned char[]){40, 40, 40}, 3);
|
||||
memcpy(out->status_fg, (const unsigned char[]){235, 235, 235}, 3);
|
||||
rgb(out->status, 40, 40, 40);
|
||||
rgb(out->status_fg, 235, 235, 235);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user