diff -r 2e812df2b231 -r ebbf0776c1bc src/c2html.c
--- a/src/c2html.c Fri Aug 30 10:51:49 2013 +0200
+++ b/src/c2html.c Fri Aug 30 11:23:44 2013 +0200
@@ -73,11 +73,17 @@
return word[0] == '@';
}
-typedef struct {
+typedef struct _highlighter_t highlighter_t;
+
+struct _highlighter_t {
const char** keywords;
int(*istype)(char*,size_t);
int(*isdirective)(char*);
-} highlighter_t;
+ void(*parser)(char*,char*,highlighter_t*);
+ int iscommentml;
+ char word[WORDBUF_SIZE];
+ char includefile[FILENAME_MAX];
+};
typedef struct {
char* outfilename;
@@ -193,23 +199,23 @@
return 1;
}
-void parseline(char *src, char *dest, highlighter_t *highlighter) {
+void parseline(char *src, char *dest, highlighter_t *hltr) {
+ hltr->parser(src, dest, hltr);
+}
+
+void cjparseline(char *src, char *dest, highlighter_t *hltr) {
size_t sp = 0, dp = 0;
/* indent */
while (isspace(src[sp])) {
dest[dp++] = src[sp++];
}
- static char word[WORDBUF_SIZE];
- static char includefile[FILENAME_MAX];
-
- memset(word, 0, WORDBUF_SIZE);
+ memset(hltr->word, 0, WORDBUF_SIZE);
size_t wp = 0, ifp = 0;
int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0;
- static int iscommentml;
int isescaping = 0;
- if (iscommentml) {
+ if (hltr->iscommentml) {
iscomment = 1;
memcpy(&(dest[dp]), "", 8);
dp += 8;
continue;
} else if (!iscomment && (src[sp+1] == '/' || src[sp+1] == '*')) {
iscomment = 1;
- iscommentml = (src[sp+1] == '*');
+ hltr->iscommentml = (src[sp+1] == '*');
memcpy(&(dest[dp]), "