src/c2html.c

changeset 48
b2724c711203
parent 47
c39ecbbca7c0
child 49
f86f0b054464
--- a/src/c2html.c	Tue Aug 23 16:34:02 2016 +0200
+++ b/src/c2html.c	Tue Aug 23 17:24:58 2016 +0200
@@ -47,18 +47,12 @@
         "\n");
 }
 
-/* TODO: remove this workaround after refactoring highlighter structure */
-static void plainparseline(char *src, UcxBuffer *dest, int* x) {
-    size_t dp = 0;
-    char *buf = dest->space + dest->pos;
+static void plain_highlighter(char *src, UcxBuffer *dest, int* x) {
     while (*src && *src != '\n') {
-        dp = writeescapedchar(buf, dp, *src);
+        put_htmlescaped(dest, *src);
         src++;
     }
-    buf[dp++] = '\n';
-    buf[dp] = '\0';
-    dest->pos += dp;
-    dest->size += dp;
+    ucx_buffer_putc(dest, '\n');
 }
 
 int formatlines(highlighter_func highlighter,
@@ -101,7 +95,7 @@
         /* process code line */
         highlighter(sourceline->data, line, &multiline_comment);
         
-        /* write code line */
+        /* write code line and reset buffer */
         out(line->space, 1, line->size, stream);
     }
     
@@ -177,13 +171,13 @@
         highlighter_func hltr = NULL;
         switch (sourcetype) {
             case SOURCE_C:
-                hltr = cparseline;
+                hltr = c_highlighter;
                 break;
             case SOURCE_JAVA:
-                hltr = jparseline;
+                hltr = java_highlighter;
                 break;
             case SOURCE_PLAIN:
-                hltr = plainparseline;
+                hltr = plain_highlighter;
                 break;
             default: /* should be unreachable */
                 fprintf(stderr, "error in enum source_type\n");

mercurial