ansilove

ANSI and ASCII art to PNG converter in C
Log | Files | Refs | README | LICENSE

commit 7ce883dee0100b7ce827a09db7bafb26a5b5bd26
parent 8332e331b5014d44e81f707a85ba121c5a8d7afb
Author: Frederic Cambus <fred@statdns.com>
Date:   Sat, 15 Apr 2017 18:01:30 +0200

Use the ternary operator when shitfing cursor position

Diffstat:
Msrc/loaders/ansi.c | 24++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c @@ -163,11 +163,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr); free(seqGrab); - if (seq_line == 0) { - seq_line = 1; - } - - position_y = position_y - seq_line; + position_y -= seq_line ? seq_line : 1; loop+=ansi_sequence_loop+2; break; @@ -183,11 +179,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c int32_t seq_line = strtonum(seqGrab, 0, INT32_MAX, &errstr); free(seqGrab); - if (seq_line == 0) { - seq_line = 1; - } - - position_y = position_y + seq_line; + position_y += seq_line ? seq_line : 1; loop+=ansi_sequence_loop+2; break; @@ -203,11 +195,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr); free(seqGrab); - if (seq_column == 0) { - seq_column = 1; - } - - position_x = position_x + seq_column; + position_x += seq_column ? seq_column : 1; if (position_x>80) { @@ -228,11 +216,7 @@ void ansi(unsigned char *inputFileBuffer, int32_t inputFileSize, char *output, c int32_t seq_column = strtonum(seqGrab, 0, INT32_MAX, &errstr); free(seqGrab); - if (seq_column == 0) { - seq_column = 1; - } - - position_x = position_x - seq_column; + position_x -= seq_column ? seq_column : 1; if (position_x < 0) {