diff options
-rw-r--r-- | src/kilo.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/kilo.c b/src/kilo.c index 1e672c1..7ddfa39 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -244,14 +244,14 @@ static void editorUpdateSyntax(erow *row) { /* Handle single-line comments. */ if (prev_sep && *p == scs[0] && *(p+1) == scs[1]) { /* From here to end is a comment */ - memset(row->hl+i,HL_COMMENT,row->size-i); + memset(row->hl+i,HL_COMMENT,row->rsize-i); return; } /* Handle "" and '' */ if (in_string) { row->hl[i] = HL_STRING; - if (*p == '\\') { + if (*p == '\\' && *(p+1)) { row->hl[i+1] = HL_STRING; p += 2; i += 2; prev_sep = 0; @@ -290,12 +290,13 @@ static void editorUpdateSyntax(erow *row) { /* Handle keywords and lib calls */ if (prev_sep) { int j; + int ileft = row->rsize-i; for (j = 0; keywords[j]; j++) { int klen = strlen(keywords[j]); int kw2 = keywords[j][klen-1] == '|'; if (kw2) klen--; - if (!memcmp(p,keywords[j],klen) && + if (klen < ileft && !memcmp(p,keywords[j],klen) && is_separator(*(p+klen))) { /* Keyword */ |