made a seperate function that doesnt print \n

This commit is contained in:
Noah Swerhun 2021-04-16 19:43:46 -05:00
parent c007c6a585
commit faa9141d89

View file

@ -360,8 +360,27 @@ efopen(const char *filename, const char *flags)
}
/* Escape characters below as HTML 2.0 / XML 1.0. */
int
size_t
xmlencode(FILE *fp, const char *s, size_t len)
{
size_t i;
for (i = 0; *s && i < len; s++, i++) {
switch(*s) {
case '<': fputs("&lt;", fp); break;
case '>': fputs("&gt;", fp); break;
case '\'': fputs("&#39;", fp); break;
case '&': fputs("&amp;", fp); break;
case '"': fputs("&quot;", fp); break;
default: putc(*s, fp);
}
}
return i;
}
int
xmlencode_no_nl(FILE *fp, const char *s, size_t len)
{
size_t i;
int nl_only;
@ -523,7 +542,7 @@ writeblobhtml(FILE *fp, const git_blob *blob)
fprintf(fp, nfmt, n, n, n);
//fprintf(fp, "<span class=\"text\">");
fprintf(fp, "<td class=\"blob-item\">");
nl_only = xmlencode(fp, &s[prev], i - prev + 1);
nl_only = xmlencode_no_nl(fp, &s[prev], i - prev + 1);
if (nl_only)
putc('\n', fp);
//fprintf(fp, "</span>\n");