# HG changeset patch # User Mike Becker # Date 1432902722 -7200 # Node ID 0bfd4d6f086a1c62428fcc5034e2bb3f35b87de3 # Parent ec6e97454e646352128c109fefeddf9dc8e72109 added HTML escaping for plain text files diff -r ec6e97454e64 -r 0bfd4d6f086a Makefile --- a/Makefile Sat Apr 25 19:14:57 2015 +0200 +++ b/Makefile Fri May 29 14:32:02 2015 +0200 @@ -37,12 +37,13 @@ $(MKDIR) build test: compile - ./build/$(BIN) $(ARGS) test/ctestfile.c -o build/ctest.html \ + ./build/$(BIN) test/ctestfile.c -o build/ctest.html \ -H test/header.html -F test/footer.html - ./build/$(BIN) $(ARGS) -j test/javatestfile.java -o build/javatest.html \ + ./build/$(BIN) -j test/javatestfile.java -o build/javatest.html \ + -H test/jheader.html -F test/footer.html + ./build/$(BIN) test/bigtestfile.c -o build/bigtest.html \ -H test/header.html -F test/footer.html - ./build/$(BIN) $(ARGS) test/bigtestfile.c -o build/bigtest.html \ + ./build/$(BIN) -p test/plain.csp -o build/plain.html \ -H test/header.html -F test/footer.html - clean: $(RM) -f -R build diff -r ec6e97454e64 -r 0bfd4d6f086a src/c2html.c --- a/src/c2html.c Sat Apr 25 19:14:57 2015 +0200 +++ b/src/c2html.c Fri May 29 14:32:02 2015 +0200 @@ -158,13 +158,18 @@ int lnw = lnint(in->count); for (int i = 0 ; i < in->count ; i++) { - char *ln = line; if (highlighter) { highlighter->parser(in->lines[i], line, highlighter); } else { - ln = in->lines[i]; + char *c = in->lines[i]; + size_t dp = 0; + while (*c) { + dp = writeescapedchar(line, dp, *c); + c++; + } + line[dp] = '\0'; } - + // write line number if (showln) { WRITECONST(stream, out, ""); @@ -181,7 +186,7 @@ } // write formated (or plain) code line - out(ln, 1, strlen(ln), stream); + out(line, 1, strlen(line), stream); } WRITECONST(stream, out, "\n"); diff -r ec6e97454e64 -r 0bfd4d6f086a test/plain.csp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/plain.csp Fri May 29 14:32:02 2015 +0200 @@ -0,0 +1,6 @@ + + + +