1.1 --- a/src/c2html.c Thu Aug 25 11:30:30 2016 +0200 1.2 +++ b/src/c2html.c Thu Aug 25 12:16:57 2016 +0200 1.3 @@ -45,7 +45,7 @@ 1.4 "\n"); 1.5 } 1.6 1.7 -static void plain_highlighter(char *src, UcxBuffer *dest, int* x) { 1.8 +static void plain_highlighter(char *src, UcxBuffer *dest, HighlighterData *hd) { 1.9 while (*src && *src != '\n') { 1.10 put_htmlescaped(dest, *src); 1.11 src++; 1.12 @@ -65,19 +65,17 @@ 1.13 while ((p*=10) < lines) lnw++; 1.14 } 1.15 1.16 - /* allocate line buffer */ 1.17 - UcxBuffer *line = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); 1.18 - if(!line) { 1.19 - perror("Error allocating line buffer for output"); 1.20 - return; 1.21 - } 1.22 - 1.23 /* start monospace formatting */ 1.24 out("<pre>\n", 1, 6, stream); 1.25 1.26 /* process lines */ 1.27 size_t lineno = 0; 1.28 - int multiline_comment = 0; 1.29 + HighlighterData *hd = new_highlighter_data(); 1.30 + UcxBuffer *line = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); 1.31 + if(!line || !hd) { 1.32 + perror("Error allocating buffer for output"); 1.33 + return; 1.34 + } 1.35 1.36 UCX_FOREACH(sourceline, in) { 1.37 /* increase line number and clean line buffer */ 1.38 @@ -92,7 +90,7 @@ 1.39 } 1.40 1.41 /* process code line */ 1.42 - highlighter(sourceline->data, line, &multiline_comment); 1.43 + highlighter(sourceline->data, line, hd); 1.44 1.45 /* write code line */ 1.46 out(line->space, 1, line->size, stream); 1.47 @@ -102,6 +100,7 @@ 1.48 out("</pre>\n", 1, 7, stream); 1.49 1.50 /* cleanup and return */ 1.51 + free_highlighter_data(hd); 1.52 ucx_buffer_free(line); 1.53 } 1.54