diff -r 17408c3607ce -r f25ba6fd7a08 src/c2html.c --- a/src/c2html.c Thu Aug 25 11:30:30 2016 +0200 +++ b/src/c2html.c Thu Aug 25 12:16:57 2016 +0200 @@ -45,7 +45,7 @@ "\n"); } -static void plain_highlighter(char *src, UcxBuffer *dest, int* x) { +static void plain_highlighter(char *src, UcxBuffer *dest, HighlighterData *hd) { while (*src && *src != '\n') { put_htmlescaped(dest, *src); src++; @@ -65,19 +65,17 @@ while ((p*=10) < lines) lnw++; } - /* allocate line buffer */ - UcxBuffer *line = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); - if(!line) { - perror("Error allocating line buffer for output"); - return; - } - /* start monospace formatting */ out("
\n", 1, 6, stream);
 
     /* process lines */
     size_t lineno = 0;
-    int multiline_comment = 0;
+    HighlighterData *hd = new_highlighter_data();
+    UcxBuffer *line = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
+    if(!line || !hd) {
+        perror("Error allocating buffer for output");
+        return;
+    }
     
     UCX_FOREACH(sourceline, in) {
         /* increase line number and clean line buffer */
@@ -92,7 +90,7 @@
         }
         
         /* process code line */
-        highlighter(sourceline->data, line, &multiline_comment);
+        highlighter(sourceline->data, line, hd);
         
         /* write code line */
         out(line->space, 1, line->size, stream);
@@ -102,6 +100,7 @@
     out("
\n", 1, 7, stream); /* cleanup and return */ + free_highlighter_data(hd); ucx_buffer_free(line); }