commit 435bfb97fe3609c8d85f39a0bc6e86120f88e7a0
parent 2d159f9008ceef2aac7620c86ae81d18da252315
Author: Frederic Cambus <fred@statdns.com>
Date: Mon, 2 Jul 2018 21:28:08 +0200
Use strtok instead of the explode function to get SGR attributes
Diffstat:
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/loaders/ansi.c b/src/loaders/ansi.c
@@ -60,7 +60,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// ANSi processing loops
size_t loop = 0;
- uint32_t ansi_sequence_loop, seq_graphics_loop;
+ uint32_t ansi_sequence_loop;
// character definitions
int32_t current_character, next_character, character;
@@ -80,6 +80,7 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
uint32_t seqValue, seqArrayCount, seq_line, seq_column;
char *seqGrab;
char **seqArray;
+ char *seqTok;
// ANSi buffer structure array definition
int32_t structIndex = 0;
@@ -264,14 +265,8 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
// create substring from the sequence's content
seqGrab = strndup((char *)inputFile->buffer + loop + 2, ansi_sequence_loop);
- // create sequence content array
- seqArrayCount = explode(&seqArray, ';', seqGrab);
- free(seqGrab);
-
- // a loophole in limbo
- for (seq_graphics_loop = 0; seq_graphics_loop < seqArrayCount; seq_graphics_loop++) {
- // convert split content value to integer
- seqValue = strtonum(seqArray[seq_graphics_loop], 0, INT32_MAX, &errstr);
+ while ((seqTok = strtok(seqGrab, ";")) != NULL) {
+ seqValue = strtonum(seqTok, 0, INT32_MAX, &errstr);
if (seqValue == 0) {
background = 0;
@@ -318,6 +313,8 @@ int ansilove_ansi(struct input *inputFile, struct output *outputFile)
if (blink && outputFile->icecolors)
background += 8;
}
+
+ seqGrab = NULL;
}
loop += ansi_sequence_loop+2;