src/javacodegen.c

changeset 39
ac35daceb24c
parent 36
be60c22cddfe
child 45
1f3835182aeb
--- a/src/javacodegen.c	Tue Aug 23 12:06:46 2016 +0200
+++ b/src/javacodegen.c	Tue Aug 23 13:49:38 2016 +0200
@@ -54,7 +54,7 @@
 
 void jparseline(char *src, char *dest, highlighter_t *hltr) {
     memset(hltr->word, 0, WORDBUF_SIZE);
-    size_t wp = 0, sp = 0, dp = 0;
+    size_t wp = 0, sp = (size_t)-1, dp = 0;
     int isstring = 0, iscomment = 0, isimport = 0;
     char quote = '\0';
     int isescaping = 0;
@@ -64,7 +64,11 @@
         memcpy_const(dest, dp, "<span class=\"c2html-comment\">");
     }
 
-    for (char c = src[sp] ; c ; c=src[++sp]) {
+    char c;
+    do {
+        c = src[++sp];
+        if (!c) break;
+        
         /* comments */
         if (!isstring && c == '/') {
             if (hltr->iscommentml && sp > 0 && src[sp-1] == '*') {
@@ -155,6 +159,6 @@
 
             isescaping = !isescaping & (c == '\\');
         }
-    }
+    } while (c != '\n');
     dest[dp] = 0;
 }

mercurial