636edb07cfa8605de2a53cf51256f65e5930d70c galt Wed Mar 3 03:55:44 2010 -0800 fixed bugs in output paths, added htmlEncode diff --git git-reports.c git-reports.c index ce57003..74adc97 100644 --- git-reports.c +++ git-reports.c @@ -6,6 +6,7 @@ #include "errabort.h" #include "hash.h" #include "linefile.h" +#include "htmshell.h" static char const rcsid[] = "$Id: git-reports.c,v 1.1 2010/03/02 08:43:07 galt Exp $"; @@ -109,7 +110,7 @@ w = nextWord(&line); if (!sameString("Date:", w)) errAbort("expected keyword Date: parsing commits.tmp\n"); - commit->date = cloneString(nextWord(&line)); + commit->date = cloneString(line); lineFileNext(lf, &line, &lineSize); if (!sameString("", line)) @@ -175,30 +176,27 @@ return commits; } -int makeHtml(char *diffPath, char *path, char *commitId) +int makeHtml(char *diffPath, char *htmlPath, char *path, char *commitId) /* Make a color-coded html diff * Return the number of lines changed */ { int linesChanged = 0; -char *ext = strrchr(diffPath,'.'); -*ext = 0; -char htmlPath[1024]; -safef(htmlPath, sizeof(htmlPath), "%s.html", diffPath); -*ext = '.'; FILE *h = mustOpen(htmlPath, "w"); struct lineFile *lf = lineFileOpen(diffPath, TRUE); int lineSize; char *line; +char *xline = NULL; boolean inBody = FALSE; boolean inBlock = TRUE; int blockP = 0, blockN = 0; fprintf(h, "\n
\n\n", path, commitId); while (lineFileNext(lf, &line, &lineSize)) { + xline = htmlEncode(line); if (line[0] == '-') { - fprintf(h, "%s\n", line); + fprintf(h, "%s\n", xline); if (inBody) { inBlock = TRUE; @@ -207,7 +205,7 @@ } else if (line[0] == '+') { - fprintf(h, "%s\n", line); + fprintf(h, "%s\n", xline); if (inBody) { inBlock = TRUE; @@ -216,7 +214,7 @@ } else { - fprintf(h, "%s\n", line); + fprintf(h, "%s\n", xline); if (inBody) { if (inBlock) @@ -235,12 +233,13 @@ if (line[0] == '@') inBody = TRUE; + freeMem(xline); + } lineFileClose(&lf); fprintf(h, "\n