src/javacodegen.c

changeset 39
ac35daceb24c
parent 36
be60c22cddfe
child 45
1f3835182aeb
equal deleted inserted replaced
38:77c158821738 39:ac35daceb24c
52 #define memcpy_const(darr,doff,str) memcpy(&(darr[doff]), str, sizeof(str)-1); \ 52 #define memcpy_const(darr,doff,str) memcpy(&(darr[doff]), str, sizeof(str)-1); \
53 dp += sizeof(str)-1 53 dp += sizeof(str)-1
54 54
55 void jparseline(char *src, char *dest, highlighter_t *hltr) { 55 void jparseline(char *src, char *dest, highlighter_t *hltr) {
56 memset(hltr->word, 0, WORDBUF_SIZE); 56 memset(hltr->word, 0, WORDBUF_SIZE);
57 size_t wp = 0, sp = 0, dp = 0; 57 size_t wp = 0, sp = (size_t)-1, dp = 0;
58 int isstring = 0, iscomment = 0, isimport = 0; 58 int isstring = 0, iscomment = 0, isimport = 0;
59 char quote = '\0'; 59 char quote = '\0';
60 int isescaping = 0; 60 int isescaping = 0;
61 61
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;
153 } 157 }
154 } 158 }
155 159
156 isescaping = !isescaping & (c == '\\'); 160 isescaping = !isescaping & (c == '\\');
157 } 161 }
158 } 162 } while (c != '\n');
159 dest[dp] = 0; 163 dest[dp] = 0;
160 } 164 }

mercurial