Introduction
Introduction Statistics Contact Development Disclaimer Help
tadd function to print a single line, ignoring \r and \n - stagit - [fork] cust…
git clone git://src.adamsgaard.dk/stagit
Log
Files
Refs
README
LICENSE
---
commit d87119b82df29649c7dae1569af4777cfbaea236
parent 3ac65c5b4288740388815867ad0d2d2997ec3c7a
Author: Hiltjo Posthuma <[email protected]>
Date: Thu, 25 Mar 2021 18:13:13 +0100
add function to print a single line, ignoring \r and \n
This can happen when there is no newline at end of file in the diff which is
served by libgit2 as:
"\n\ No newline at end of file\n".
Diffstat:
M stagit.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/stagit.c b/stagit.c
t@@ -380,6 +380,26 @@ xmlencode(FILE *fp, const char *s, size_t len)
}
}
+/* Escape characters below as HTML 2.0 / XML 1.0, ignore printing '\n', '\r' */
+void
+xmlencodeline(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;
+ case '\r': break; /* ignore CR */
+ case '\n': break; /* ignore LF */
+ default: putc(*s, fp);
+ }
+ }
+}
+
int
mkdirp(const char *path)
{
t@@ -691,7 +711,8 @@ printshowfile(FILE *fp, struct commitinfo *ci)
i, j, k, i, j, k);
else
putc(' ', fp);
- xmlencode(fp, line->content, line->content_len…
+ xmlencodeline(fp, line->content, line->content…
+ putc('\n', fp);
if (line->old_lineno == -1 || line->new_lineno…
fputs("</a>", fp);
}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.