commit: 42020ee157fce1fe38ed01f3aab1f16597a294bf
parent d20cc967c695e15d55cc4cfd197b00003f096e0e
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 2 Jun 2021 10:00:01 +0200
bin/xcd: Move int line_width to #define WIDTH
Diffstat:
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/bin/xcd.c b/bin/xcd.c
@@ -64,17 +64,18 @@ print_plain_rgb(unsigned char *line, size_t len)
printf("<");
}
+#define WIDTH 16
+
int
main(void)
{
int cols = 0;
- int line_width = 16;
- char line[line_width];
+ char line[WIDTH];
unsigned char c;
unsigned int bytes = 0;
struct rgb pos_rgb;
- memset(&line, 0, line_width);
+ memset(&line, 0, WIDTH);
LANODAN_XCD_RESET
@@ -82,10 +83,10 @@ main(void)
printf("[38;2;%d;%d;%dm%06x ", pos_rgb.red, pos_rgb.green, pos_rgb.blue, bytes);
while(fread(&c, 1, 1, stdin) > 0)
{
- if(cols >= line_width)
+ if(cols >= WIDTH)
{
print_plain_rgb(&line, (size_t)cols);
- memset(&line, 0, line_width);
+ memset(&line, 0, WIDTH);
pos_rgb = rgb_char(bytes);
printf("\n[38;2;%d;%d;%dm%06x ", pos_rgb.red, pos_rgb.green, pos_rgb.blue, bytes);
@@ -101,7 +102,7 @@ main(void)
}
// Fill the rest of the hex space with spaces
- for(cols; cols < line_width; cols++)
+ for(;cols < WIDTH; cols++)
printf(" ");
LANODAN_XCD_RESET