From 47d30d3654cf24d4ec9aafef82d97f35e40a500d Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 3 Feb 2022 22:36:09 +0300 Subject: [PATCH] Fixed #1 --- Makefile | 2 +- src/args.c | 2 +- src/commons.c | 8 ++++++++ src/commons.h | 1 + src/main.c | 8 +++++++- src/mod_blocks.c | 2 +- src/mod_braille.c | 2 +- 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 48b502e..bab9cbf 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS := -Wall -Wextra -Werror -pedantic -std=c99 -ggdb +CFLAGS := -Wall -Wextra -Werror -pedantic -std=c99 CLIBS := -lm INCLUDES := -Isrc OBJECTS := obj/stb_image.o obj/stb_image_resize.o \ diff --git a/src/args.c b/src/args.c index 0767b45..201113c 100644 --- a/src/args.c +++ b/src/args.c @@ -52,7 +52,7 @@ const __option_t __style_options[ASC_STL_ENDL + 1] = { "24-bit RGB (TrueColor)" }, { ASC_STL_PALETTE, { "pal", "palette", "custom", NULL }, - "Custom palette (specified via -P)" }, + "Custom palette (specified via -P). Either GIMP palette file or N*3 RGB pixels" }, { -1, { NULL }, NULL } }; diff --git a/src/commons.c b/src/commons.c index 7cda1d6..4934930 100644 --- a/src/commons.c +++ b/src/commons.c @@ -1,5 +1,7 @@ #include "colors.h" #include "commons.h" +#include +#include void m_prepare_dither(asc_state_t *state) { @@ -37,3 +39,9 @@ void m_prepare_dither(asc_state_t *state) } } } + +void c_fatal(int code, const char *reason) +{ + fprintf(stderr, "Error: %s\n", reason); + exit(code); +} diff --git a/src/commons.h b/src/commons.h index a1f9d78..5962021 100644 --- a/src/commons.h +++ b/src/commons.h @@ -3,6 +3,7 @@ #include "args.h" +void c_fatal(int code, const char *reason); void m_prepare_dither(asc_state_t *state); #endif diff --git a/src/main.c b/src/main.c index e5ffc3b..75fe7fa 100644 --- a/src/main.c +++ b/src/main.c @@ -28,7 +28,13 @@ int main(int argc, char **argv) mod_braille_prepare(&state); mod_braille_main(state); break; - default: + case ASC_MOD_GRADIENT: + fprintf(stderr, "Error: ASC_MOD_GRADIENT is not implemented yet\n"); + break; + case ASC_MOD_BRUTEFORCE: + fprintf(stderr, "Error: ASC_MOD_BRUTEFORCE is not implemented yet\n"); + break; + case ASC_MOD_ENDL: break; } diff --git a/src/mod_blocks.c b/src/mod_blocks.c index 4594c6c..9c42fc0 100644 --- a/src/mod_blocks.c +++ b/src/mod_blocks.c @@ -199,7 +199,7 @@ void __blk_put_pixel(asc_state_t state, rgba8 top, rgba8 bot, bool final) case ASC_STL_ANSI_VGA: pal = c_palette_ansi_vga; break; case ASC_STL_ANSI_XTERM: pal = c_palette_ansi_xterm; break; case ASC_STL_ANSI_DISCORD: pal = c_palette_ansi_discord; break; - default: break; + default: c_fatal(9, "[UNREACH] Palette is unset"); return; } int index_top = closest_color(pal, top), index_bot = closest_color(pal, bot); diff --git a/src/mod_braille.c b/src/mod_braille.c index 710f4ad..574ba3d 100644 --- a/src/mod_braille.c +++ b/src/mod_braille.c @@ -152,7 +152,7 @@ void __bra_put_pixel(asc_state_t state, rgba8 min, rgba8 max, uint8_t ch, bool f case ASC_STL_ANSI_VGA: pal = c_palette_ansi_vga; break; case ASC_STL_ANSI_XTERM: pal = c_palette_ansi_xterm; break; case ASC_STL_ANSI_DISCORD: pal = c_palette_ansi_discord; break; - default: break; + default: c_fatal(9, "[UNREACH] Palette is unset"); return; } __bra_putc_ansi(state, closest_color(pal, min), closest_color(pal, max), ch, pal, final);