37 "long", "register", "return", "short", "signed", "sizeof", "static", |
37 "long", "register", "return", "short", "signed", "sizeof", "static", |
38 "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", |
38 "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", |
39 "while", NULL |
39 "while", NULL |
40 }; |
40 }; |
41 |
41 |
42 int isctype(char *word, size_t len) { |
42 int check_ctype(char *word, size_t len) { |
43 return (word[len-2] == '_' && word[len-1] == 't'); |
43 return (word[len-2] == '_' && word[len-1] == 't'); |
44 } |
44 } |
45 |
45 |
46 int iscdirective(char *word) { |
46 int check_cdirective(char *word) { |
47 return (word[0] == '#'); |
47 return (word[0] == '#'); |
48 } |
48 } |
49 |
49 |
50 #define memcpy_const(darr,doff,str) memcpy(&(darr[doff]), str, sizeof(str)-1); \ |
50 #define memcpy_const(darr,doff,str) memcpy(&(darr[doff]), str, sizeof(str)-1); \ |
51 dp += sizeof(str)-1 |
51 dp += sizeof(str)-1 |
138 dp = writeescapedchar(dest, dp, c); |
138 dp = writeescapedchar(dest, dp, c); |
139 } else if (!iswordcharacter(c)) { |
139 } else if (!iswordcharacter(c)) { |
140 /* interpret word int_t */ |
140 /* interpret word int_t */ |
141 if (wp > 0 && wp < WORDBUF_SIZE) { |
141 if (wp > 0 && wp < WORDBUF_SIZE) { |
142 int closespan = 1; |
142 int closespan = 1; |
143 if (iskeyword(hltr->word, hltr->keywords)) { |
143 if (check_keyword(hltr->word, hltr->keywords)) { |
144 memcpy_const(dest, dp, |
144 memcpy_const(dest, dp, |
145 "<span class=\"c2html-keyword\">"); |
145 "<span class=\"c2html-keyword\">"); |
146 } else if (hltr->istype(hltr->word, wp)) { |
146 } else if (hltr->istype(hltr->word, wp)) { |
147 memcpy_const(dest, dp, |
147 memcpy_const(dest, dp, |
148 "<span class=\"c2html-type\">"); |
148 "<span class=\"c2html-type\">"); |
149 } else if (hltr->isdirective(hltr->word)) { |
149 } else if (hltr->isdirective(hltr->word)) { |
150 isinclude = !strncmp( |
150 isinclude = !strncmp( |
151 "#include", hltr->word, WORDBUF_SIZE); |
151 "#include", hltr->word, WORDBUF_SIZE); |
152 memcpy_const(dest, dp, |
152 memcpy_const(dest, dp, |
153 "<span class=\"c2html-directive\">"); |
153 "<span class=\"c2html-directive\">"); |
154 } else if (iscapsonly(hltr->word, wp)) { |
154 } else if (check_capsonly(hltr->word, wp)) { |
155 memcpy_const(dest, dp, |
155 memcpy_const(dest, dp, |
156 "<span class=\"c2html-macroconst\">"); |
156 "<span class=\"c2html-macroconst\">"); |
157 } else { |
157 } else { |
158 closespan = 0; |
158 closespan = 0; |
159 } |
159 } |