src/ccodegen.c

changeset 39
ac35daceb24c
parent 36
be60c22cddfe
child 45
1f3835182aeb
equal deleted inserted replaced
38:77c158821738 39:ac35daceb24c
51 dp += sizeof(str)-1 51 dp += sizeof(str)-1
52 52
53 void cparseline(char *src, char *dest, highlighter_t *hltr) { 53 void cparseline(char *src, char *dest, highlighter_t *hltr) {
54 54
55 memset(hltr->word, 0, WORDBUF_SIZE); 55 memset(hltr->word, 0, WORDBUF_SIZE);
56 size_t wp = 0, ifp = 0, sp = 0, dp = 0; 56 size_t wp = 0, ifp = 0, sp = (size_t)-1, dp = 0;
57 int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0; 57 int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0;
58 char quote = '\0'; 58 char quote = '\0';
59 int isescaping = 0; 59 int isescaping = 0;
60 60
61 /* continue a multi line comment highlighting */ 61 /* continue a multi line comment highlighting */
62 if (hltr->iscommentml) { 62 if (hltr->iscommentml) {
63 iscomment = 1; 63 iscomment = 1;
64 memcpy_const(dest, dp, "<span class=\"c2html-comment\">"); 64 memcpy_const(dest, dp, "<span class=\"c2html-comment\">");
65 } 65 }
66 66
67 for (char c = src[sp] ; c ; c=src[++sp]) { 67 char c;
68 do {
69 c = src[++sp];
70 if (!c) break;
71
68 /* comments */ 72 /* comments */
69 if (!isstring && c == '/') { 73 if (!isstring && c == '/') {
70 if (hltr->iscommentml && sp > 0 && src[sp-1] == '*') { 74 if (hltr->iscommentml && sp > 0 && src[sp-1] == '*') {
71 iscomment = 0; 75 iscomment = 0;
72 hltr->iscommentml = 0; 76 hltr->iscommentml = 0;
183 } 187 }
184 } 188 }
185 189
186 isescaping = !isescaping & (c == '\\'); 190 isescaping = !isescaping & (c == '\\');
187 } 191 }
188 } 192 } while (c != '\n');
189 dest[dp] = 0; 193 dest[dp] = 0;
190 } 194 }

mercurial