libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit cd8f10b605b6f7ba8f7804d69db06421ab247c4f
parent 64f01fd69cc25a7baedd76af3c70c46714832aa8
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri,  7 Jun 2019 14:43:36 +0200

Use a switch statement to set 24-bit background and foreground values.

Diffstat:
Msrc/loaders/ansi.c | 13++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -389,11 +389,14 @@ ansilove_ansi(struct ansilove_ctx *ctx, struct ansilove_options *options) seqTok = strtok(NULL, ";"); color_B = seqTok ? strtonum(seqTok, 0, UCHAR_MAX, &errstr) & 0xff : 0; - if (seqValue == 0) - background = (color_R << 16) | (color_G << 8) | color_B; - - if (seqValue == 1) - foreground = (color_R << 16) | (color_G << 8) | color_B; + switch (seqValue) { + case 0: + background = (color_R << 16) | (color_G << 8) | (color_B); + break; + case 1: + foreground = (color_R << 16) | (color_G << 8) | (color_B); + break; + } options->truecolor = true; }