--- a/src/highlighter.c Fri Aug 26 14:15:29 2016 +0200 +++ b/src/highlighter.c Wed Aug 31 12:58:48 2016 +0200 @@ -52,7 +52,7 @@ ucx_buffer_puts(dest, ">"); } else if (c == '<') { ucx_buffer_puts(dest, "<"); - } else { + } else if (c) { ucx_buffer_putc(dest, c); } } @@ -126,10 +126,6 @@ char c; do { c = src[++sp]; - if (!c) { - /* TODO: might cause problems if code file does not end with NL */ - break; - } /* comments */ if (!isstring && c == '/') { @@ -195,7 +191,10 @@ } else { if (isstring) { put_htmlescaped(dest, c); - } else if (!isalnum(c) && c!='_' && c!='#') { + } else if (isalnum(c) || c == '_' || c == '#') { + /* buffer the current word */ + ucx_buffer_putc(wbuf, c); + } else { /* write buffered word, if any */ if (wbuf->size > 0) { sstr_t word = sstrn(wbuf->space, wbuf->size); @@ -226,15 +225,12 @@ /* write current character */ put_htmlescaped(dest, c); - } else { - /* buffer the current word */ - ucx_buffer_putc(wbuf, c); } } isescaping = !isescaping & (c == '\\'); } - } while (c != '\n'); + } while (c && c != '\n'); } /* Java Highlighter */ @@ -271,10 +267,6 @@ char c; do { c = src[++sp]; - if (!c) { - /* TODO: might cause problems if code file does not end with NL */ - break; - } /* comments */ if (!isstring && c == '/') { @@ -319,7 +311,10 @@ } else { if (isstring) { put_htmlescaped(dest, c); - } else if (!isalnum(c) && c!='_' && c!='@') { + } else if (isalnum(c) || c == '_' || c == '@') { + /* buffer the current word */ + ucx_buffer_putc(wbuf, c); + } else { /* write buffered word, if any */ if (wbuf->size > 0) { sstr_t word = sstrn(wbuf->space, wbuf->size); @@ -349,14 +344,11 @@ /* write current character */ put_htmlescaped(dest, c); - } else { - /* buffer the current word */ - ucx_buffer_putc(wbuf, c); } } isescaping = !isescaping & (c == '\\'); } - } while (c != '\n'); + } while (c && c != '\n'); }