From 63c0c77ea5c58cc0da694ab530150e08c808544d Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Thu, 21 Dec 2017 08:44:50 +0300 Subject: [PATCH] #477 fixed wrong highlight, when word nested api or keyword --- src/code.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/code.c b/src/code.c index 9afcb5c..49ea44a 100644 --- a/src/code.c +++ b/src/code.c @@ -324,12 +324,13 @@ static void parse(const char* start, u8* color, const SyntaxConfig* config) { while(!islineend(*ptr) && isalnum_(*ptr)) ptr++; + s32 len = ptr - wordStart; bool keyword = false; { for(s32 i = 0; i < config->keywordsCount; i++) - if(memcmp(wordStart, config->keywords[i], strlen(config->keywords[i])) == 0) + if(len == strlen(config->keywords[i]) && memcmp(wordStart, config->keywords[i], len) == 0) { - memset(color + (wordStart - start), getConfig()->theme.code.keyword, ptr - wordStart); + memset(color + (wordStart - start), getConfig()->theme.code.keyword, len); keyword = true; break; } @@ -340,9 +341,9 @@ static void parse(const char* start, u8* color, const SyntaxConfig* config) static const char* const Api[] = API_KEYWORDS; for(s32 i = 0; i < COUNT_OF(Api); i++) - if(memcmp(wordStart, Api[i], strlen(Api[i])) == 0) + if(len == strlen(Api[i]) && memcmp(wordStart, Api[i], len) == 0) { - memset(color + (wordStart - start), getConfig()->theme.code.api, ptr - wordStart); + memset(color + (wordStart - start), getConfig()->theme.code.api, len); break; } }