src/highlighter.c

changeset 55
bf54085ce341
parent 54
b3f24e23bc25
child 57
eba880c1705c
--- a/src/highlighter.c	Wed Aug 31 12:58:48 2016 +0200
+++ b/src/highlighter.c	Wed Aug 31 14:41:56 2016 +0200
@@ -29,23 +29,12 @@
 
 #include "highlighter.h"
 
-HighlighterData* new_highlighter_data() {
-    HighlighterData* hd = malloc(sizeof(HighlighterData));
-    if (hd == NULL) {
-        return NULL;
-    } else {
-        hd->multiline_comment = 0;
-        hd->primary_buffer = ucx_buffer_new(NULL, 256, UCX_BUFFER_AUTOEXTEND);
-        hd->secondary_buffer = ucx_buffer_new(NULL, 32, UCX_BUFFER_AUTOEXTEND);
-        return hd;
-    }
-}
-
-void free_highlighter_data(HighlighterData *hd) {
-    ucx_buffer_free(hd->primary_buffer);
-    ucx_buffer_free(hd->secondary_buffer);
-    free(hd);
-}
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include "ucx/string.h"
+#include "ucx/utils.h"
 
 static void put_htmlescaped(UcxBuffer *dest, char c) {
     if (c == '>') {
@@ -84,7 +73,7 @@
 
 /* Plaintext Highlighter */
 
-void plain_highlighter(char *src, UcxBuffer *dest, HighlighterData *hd) {
+void c2html_plain_highlighter(char *src, UcxBuffer *dest, c2html_highlighter_data *hd) {
     while (*src && *src != '\n') {
         put_htmlescaped(dest, *src);
         src++;
@@ -102,7 +91,7 @@
     "while", NULL
 };
 
-void c_highlighter(char *src, UcxBuffer *dest, HighlighterData *hd) {
+void c2html_c_highlighter(char *src, UcxBuffer *dest, c2html_highlighter_data *hd) {
     /* reset buffers without clearing them */
     hd->primary_buffer->size = hd->primary_buffer->pos = 0;
     hd->secondary_buffer->size = hd->secondary_buffer->pos = 0;
@@ -245,7 +234,7 @@
     "volatile", "const", "float", "native", "super", "while", NULL
 };
 
-void java_highlighter(char *src, UcxBuffer *dest, HighlighterData *hd) {
+void c2html_java_highlighter(char *src, UcxBuffer *dest, c2html_highlighter_data *hd) {
     /* reset buffers without clearing them */
     hd->primary_buffer->size = hd->primary_buffer->pos = 0;
     hd->secondary_buffer->size = hd->secondary_buffer->pos = 0;

mercurial