1.1 --- a/src/highlighter.c Fri Aug 26 14:15:29 2016 +0200 1.2 +++ b/src/highlighter.c Wed Aug 31 12:58:48 2016 +0200 1.3 @@ -52,7 +52,7 @@ 1.4 ucx_buffer_puts(dest, ">"); 1.5 } else if (c == '<') { 1.6 ucx_buffer_puts(dest, "<"); 1.7 - } else { 1.8 + } else if (c) { 1.9 ucx_buffer_putc(dest, c); 1.10 } 1.11 } 1.12 @@ -126,10 +126,6 @@ 1.13 char c; 1.14 do { 1.15 c = src[++sp]; 1.16 - if (!c) { 1.17 - /* TODO: might cause problems if code file does not end with NL */ 1.18 - break; 1.19 - } 1.20 1.21 /* comments */ 1.22 if (!isstring && c == '/') { 1.23 @@ -195,7 +191,10 @@ 1.24 } else { 1.25 if (isstring) { 1.26 put_htmlescaped(dest, c); 1.27 - } else if (!isalnum(c) && c!='_' && c!='#') { 1.28 + } else if (isalnum(c) || c == '_' || c == '#') { 1.29 + /* buffer the current word */ 1.30 + ucx_buffer_putc(wbuf, c); 1.31 + } else { 1.32 /* write buffered word, if any */ 1.33 if (wbuf->size > 0) { 1.34 sstr_t word = sstrn(wbuf->space, wbuf->size); 1.35 @@ -226,15 +225,12 @@ 1.36 1.37 /* write current character */ 1.38 put_htmlescaped(dest, c); 1.39 - } else { 1.40 - /* buffer the current word */ 1.41 - ucx_buffer_putc(wbuf, c); 1.42 } 1.43 } 1.44 1.45 isescaping = !isescaping & (c == '\\'); 1.46 } 1.47 - } while (c != '\n'); 1.48 + } while (c && c != '\n'); 1.49 } 1.50 1.51 /* Java Highlighter */ 1.52 @@ -271,10 +267,6 @@ 1.53 char c; 1.54 do { 1.55 c = src[++sp]; 1.56 - if (!c) { 1.57 - /* TODO: might cause problems if code file does not end with NL */ 1.58 - break; 1.59 - } 1.60 1.61 /* comments */ 1.62 if (!isstring && c == '/') { 1.63 @@ -319,7 +311,10 @@ 1.64 } else { 1.65 if (isstring) { 1.66 put_htmlescaped(dest, c); 1.67 - } else if (!isalnum(c) && c!='_' && c!='@') { 1.68 + } else if (isalnum(c) || c == '_' || c == '@') { 1.69 + /* buffer the current word */ 1.70 + ucx_buffer_putc(wbuf, c); 1.71 + } else { 1.72 /* write buffered word, if any */ 1.73 if (wbuf->size > 0) { 1.74 sstr_t word = sstrn(wbuf->space, wbuf->size); 1.75 @@ -349,14 +344,11 @@ 1.76 1.77 /* write current character */ 1.78 put_htmlescaped(dest, c); 1.79 - } else { 1.80 - /* buffer the current word */ 1.81 - ucx_buffer_putc(wbuf, c); 1.82 } 1.83 } 1.84 1.85 isescaping = !isescaping & (c == '\\'); 1.86 } 1.87 - } while (c != '\n'); 1.88 + } while (c && c != '\n'); 1.89 } 1.90