# HG changeset patch # User Mike Becker # Date 1371814351 -7200 # Node ID 925172e535a9fffaaf4e341cb7ee276698062af0 # Parent 6b1fba10c4cb9af6beedf1be51fd68d660bd1566 includes (with links in user includes) 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)) { diff -r 6b1fba10c4cb -r 925172e535a9 test/header.html --- a/test/header.html Fri Jun 21 12:49:46 2013 +0200 +++ b/test/header.html Fri Jun 21 13:32:31 2013 +0200 @@ -10,18 +10,31 @@ span.c2html-keyword { color: blue; } - span.c2html-type, span.c2html-macroconst { + span.c2html-macroconst { + color: cornflowerblue; + } + span.c2html-type { color: cornflowerblue; } span.c2html-directive { color: green; } span.c2html-string { - color: orange; + color: darkorange; } span.c2html-comment { color: grey; } + span.c2html-stdinclude { + color: darkorange; + } + span.c2html-userinclude { + color: darkorange; + } + a.c2html-userinclude { + color: darkorange; + text-decoration: underline; + }