diff -r 6b1fba10c4cb -r 925172e535a9 src/c2html.c
--- a/src/c2html.c Fri Jun 21 12:49:46 2013 +0200
+++ b/src/c2html.c Fri Jun 21 13:32:31 2013 +0200
@@ -164,10 +164,13 @@
while (isspace(src[sp])) {
dest[dp++] = src[sp++];
}
- char word[WORDBUF_SIZE];
+
+ static char word[WORDBUF_SIZE];
+ static char includefile[FILENAME_MAX];
+
memset(word, 0, WORDBUF_SIZE);
- size_t wp = 0;
- int isstring = 0, iscomment = 0;
+ size_t wp = 0, ifp = 0;
+ int isstring = 0, iscomment = 0, isinclude = 0, parseinclude = 0;
static int iscommentml;
int isescaping = 0;
@@ -200,6 +203,40 @@
dp += 7;
}
dp = writeescapedchar(dest, dp, c);
+ } else if (isinclude) {
+ if (c == '<') {
+ memcpy(&(dest[dp]), "", 32);
+ dp += 32;
+ dp = writeescapedchar(dest, dp, c);
+ } else if (c == '\"') {
+ if (parseinclude) {
+ dest[dp++] = '\"';
+ dest[dp++] = '>';
+ memcpy(&(dest[dp]), includefile, ifp);
+ dp += ifp;
+
+ dp = writeescapedchar(dest, dp, c);
+ memcpy(&(dest[dp]), "", 4);
+ dp += 4;
+ parseinclude = 0;
+ } else {
+ memcpy(&(dest[dp]), "') {
+ dp = writeescapedchar(dest, dp, c);
+ memcpy(&(dest[dp]), "", 7);
+ dp += 7;
+ } else {
+ if (parseinclude) {
+ includefile[ifp++] = c;
+ }
+ dp = writeescapedchar(dest, dp, c);
+ }
} else {
/* strings */
if (!isescaping && (c == '\'' || c == '\"')) {
@@ -216,7 +253,7 @@
} else {
if (isstring) {
dp = writeescapedchar(dest, dp, c);
- } else if (!isalnum(c) && c != '_' && c != '#') {
+ } else if (!isalnum(c) && c != '_' && c != '#' && c != '.') {
/* interpret word int_t */
if (wp > 0 && wp < WORDBUF_SIZE) {
int closespan = 1;
@@ -227,6 +264,7 @@
memcpy(&(dest[dp]), "", 26);
dp += 26;
} else if (isdirective(word)) {
+ isinclude = !strncmp("#include", word, WORDBUF_SIZE);
memcpy(&(dest[dp]), "", 31);
dp += 31;
} else if (iscapsonly(word, wp)) {