#ifdef FONT
static void buildcolors(void) {
- int quit, txtfd, codefd;
- char *txt, *code, *p;
+ int quit, txtfd, codefd, d;
+ char *txt, *code, *p, *decl;
struct stat txtstat;
size_t l, i;
void *map;
goto munmap;
}
+ decl = "struct color colors[] = {";
+ d = (int)strlen(decl);
if (dprintf(codefd, "#include <stddef.h>\n\n"
"#include \"colors.h\"\n\n"
- "struct color colors[] = {\n"
- "\t{\"None\", 0x00ffffff},\n") == -1) {
+ "%s{\"None\", 0x00ffffff},\n", decl) == -1) {
warn("Unable to write to `%s'", code);
goto closecode;
}
r = strtol(p, &p, 10);
g = strtol(p, &p, 10);
b = strtol(p, &p, 10);
- if (dprintf(codefd, "\t{\"%s\", 0x%02x%02x%02x},\n",
- strsep(&p, "\n") + 2, r, g, b) == -1) {
+ if (dprintf(codefd, "%*s{\"%s\", 0x%02x%02x%02x},\n",
+ d, "", strsep(&p, "\n") + 2, r, g, b) == -1) {
warn("Unable to write to `%s'", code);
goto closecode;
}
for (m = 0; m < NUMMODES; ++m)
pixels[m * width * height + i * width + j] = colors[m * ncolors + k];
if (j != width || l != 0) warnx("Actual image width too narrow");
- else image = (Image){
- .data = pixels,
- .width = width,
- .height = height,
- .mipmaps = 1,
- .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
- };
+ else image = (Image){.data = pixels, .width = width, .height = height,
+ .mipmaps = 1,
+ .format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8};
free:
free(chars);