Fri, 29 May 2015 14:32:02 +0200
added HTML escaping for plain text files
Makefile | file | annotate | diff | comparison | revisions | |
src/c2html.c | file | annotate | diff | comparison | revisions | |
test/plain.csp | file | annotate | diff | comparison | revisions |
1.1 --- a/Makefile Sat Apr 25 19:14:57 2015 +0200 1.2 +++ b/Makefile Fri May 29 14:32:02 2015 +0200 1.3 @@ -37,12 +37,13 @@ 1.4 $(MKDIR) build 1.5 1.6 test: compile 1.7 - ./build/$(BIN) $(ARGS) test/ctestfile.c -o build/ctest.html \ 1.8 + ./build/$(BIN) test/ctestfile.c -o build/ctest.html \ 1.9 -H test/header.html -F test/footer.html 1.10 - ./build/$(BIN) $(ARGS) -j test/javatestfile.java -o build/javatest.html \ 1.11 + ./build/$(BIN) -j test/javatestfile.java -o build/javatest.html \ 1.12 + -H test/jheader.html -F test/footer.html 1.13 + ./build/$(BIN) test/bigtestfile.c -o build/bigtest.html \ 1.14 -H test/header.html -F test/footer.html 1.15 - ./build/$(BIN) $(ARGS) test/bigtestfile.c -o build/bigtest.html \ 1.16 + ./build/$(BIN) -p test/plain.csp -o build/plain.html \ 1.17 -H test/header.html -F test/footer.html 1.18 - 1.19 clean: 1.20 $(RM) -f -R build
2.1 --- a/src/c2html.c Sat Apr 25 19:14:57 2015 +0200 2.2 +++ b/src/c2html.c Fri May 29 14:32:02 2015 +0200 2.3 @@ -158,13 +158,18 @@ 2.4 2.5 int lnw = lnint(in->count); 2.6 for (int i = 0 ; i < in->count ; i++) { 2.7 - char *ln = line; 2.8 if (highlighter) { 2.9 highlighter->parser(in->lines[i], line, highlighter); 2.10 } else { 2.11 - ln = in->lines[i]; 2.12 + char *c = in->lines[i]; 2.13 + size_t dp = 0; 2.14 + while (*c) { 2.15 + dp = writeescapedchar(line, dp, *c); 2.16 + c++; 2.17 + } 2.18 + line[dp] = '\0'; 2.19 } 2.20 - 2.21 + 2.22 // write line number 2.23 if (showln) { 2.24 WRITECONST(stream, out, "<span class=\"c2html-lineno\">"); 2.25 @@ -181,7 +186,7 @@ 2.26 } 2.27 2.28 // write formated (or plain) code line 2.29 - out(ln, 1, strlen(ln), stream); 2.30 + out(line, 1, strlen(line), stream); 2.31 } 2.32 2.33 WRITECONST(stream, out, "</pre>\n");
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/plain.csp Fri May 29 14:32:02 2015 +0200 3.3 @@ -0,0 +1,6 @@ 3.4 +</body> 3.5 +</html> 3.6 +<!c 3.7 +pblock_free(q); 3.8 +!> 3.9 +