ansilove

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

commit c5d23870aab3c7ae14c2ee68bb493eb9649f5056
parent 40cb08e4bd5b7aa62f699e1c161901819a0f9793
Author: ByteProject <stefan.vogt@byteproject.net>
Date:   Sat, 24 Mar 2012 12:03:00 +0100

obey to the master of segfaults!

Wiping a bug that occurred when the no coordinates were specified in
the 'move cursor' escape sequence. The ANSi escape docs say we have to
move to home position then, which we are doing now.

Diffstat:
Mansilove/ansilove.c | 24+++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/ansilove/ansilove.c b/ansilove/ansilove.c @@ -326,7 +326,7 @@ void alAnsiLoader(char *input, char output[], char font[], char bits[], char ice int32_t saved_position_y, saved_position_x; // sequence parsing variables - int32_t seqContent, seqValue, seqArrayCount; + int32_t seqContent, seqValue, seqArrayCount, seq_line, seq_column; char *seqGrab; char **seqArray; @@ -401,14 +401,20 @@ void alAnsiLoader(char *input, char output[], char font[], char bits[], char ice // create sequence content array seqArrayCount = explode(&seqArray, ';', seqGrab); - // convert grabbed sequence content to integers - int32_t seq_line = atoi(seqArray[0]); - int32_t seq_column = atoi(seqArray[1]); - - // finally set the positions - position_y = seq_line-1; - position_x = seq_column-1; - + if (seqArrayCount > 1) { + // convert grabbed sequence content to integers + seq_line = atoi(seqArray[0]); + seq_column = atoi(seqArray[1]); + + // finally set the positions + position_y = seq_line-1; + position_x = seq_column-1; + } + else { + // no coordinates specified? we move to the home position + position_y = 0; + position_x = 0; + } loop+=ansi_sequence_loop+2; break; }