made a seperate function that doesnt print \n
This commit is contained in:
parent
c007c6a585
commit
faa9141d89
1 changed files with 21 additions and 2 deletions
23
stagit.c
23
stagit.c
|
@ -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("<", fp); break;
|
||||
case '>': fputs(">", fp); break;
|
||||
case '\'': fputs("'", fp); break;
|
||||
case '&': fputs("&", fp); break;
|
||||
case '"': fputs(""", 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");
|
||||
|
|
Loading…
Reference in a new issue