Skip to content

Commit e3b60b0

Browse files
authored
Merge pull request #266 from venomix666/z65
z65 - Fix separator handling in tokenizer
2 parents 6205d02 + 2476660 commit e3b60b0

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

third_party/z65/z65.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ static uint8_t encode_a2(char c)
594594
{
595595
for (uint8_t i = 0; zalph[2][i]; i++) {
596596
if (zalph[2][i] == c)
597-
return i;
597+
return i+6;
598598
}
599599
return 0;
600600
}
@@ -666,8 +666,9 @@ static uint8_t tokenize(char *in, uint16_t parse_buf, uint16_t text_buf)
666666
max_tok = MAX_TOKENS;
667667

668668
while (in[i] && count < max_tok) {
669-
while (is_sep(in[i]))
669+
while (in[i] == ' ')
670670
i++;
671+
671672
if (!in[i])
672673
break;
673674

@@ -676,13 +677,21 @@ static uint8_t tokenize(char *in, uint16_t parse_buf, uint16_t text_buf)
676677
uint8_t dict_len = 0;
677678
uint8_t word_len = 0;
678679

679-
while (in[i] && !is_sep(in[i])) {
680-
if (dict_len < 7)
681-
word[dict_len++] = in[i];
682-
word_len++;
683-
i++;
684-
}
685-
680+
if(is_sep(in[i])) {
681+
word[0] = in[i];
682+
word_len = 1;
683+
i++;
684+
} else {
685+
while (in[i] && in[i] != ' ') {
686+
if(is_sep(in[i]))
687+
break;
688+
689+
if (dict_len < 7)
690+
word[dict_len++] = in[i];
691+
word_len++;
692+
i++;
693+
}
694+
}
686695
uint16_t dict = dict_lookup(word);
687696

688697
uint16_t entry = parse_buf + 2 + (count << 2);

0 commit comments

Comments
 (0)