ctucx.git: stagit

ctucx' stagit fork

commit d6dc2626be4a4fc2544b1630a13c04469304982b
parent e8ba7a70178750a429c18d995200569087c30756
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 24 May 2022 13:42:17 +0200

move writeblobhtml between writeblobraw and writeblobpage
1 file changed, 46 insertions(+), 46 deletions(-)
M
stagit.c
|
92
++++++++++++++++++++++++++++++++++++++++----------------------------------------
diff --git a/stagit.c b/stagit.c
@@ -614,52 +614,6 @@ writefooter(FILE *fp)
     fprintf(fp, "</div><br><p>Generated on %s (UTC)</p>\n</body>\n</html>\n", gen_time);
 }
 
-size_t
-writeblobhtml(FILE *fp, const git_blob *blob)
-{
-	size_t n = 0, i, len, prev;
-	const char *nfmt = "<a href=\"#L%zu\" id=\"L%zu\">%zu</a> ";
-	const char *s = git_blob_rawcontent(blob);
-
-	len = git_blob_rawsize(blob);
-	fputs("<pre id=\"blob\"><span class=\"line-number\">", fp);
-
-	if (len > 0) {
-		for (i = 0, prev = 0; i < len; i++) {
-			if (s[i] != '\n')
-				continue;
-			n++;
-			fprintf(fp, nfmt, n, n, n);
-			putc('\n', fp);
-			prev = i + 1;
-		}
-		/* trailing data */
-		if ((len - prev) > 0) {
-			n++;
-			fprintf(fp, nfmt, n, n, n);
-		}
-	}
-
-	fputs("</span><code>", fp);
-
-	if (len > 0) {
-		for (i = 0, prev = 0; i < len; i++) {
-			if (s[i] != '\n') continue;
-			xmlencodeline(fp, &s[prev], i - prev + 1);
-			putc('\n', fp);
-			prev = i + 1;
-		}
-		/* trailing data */
-		if ((len - prev) > 0) {
-			xmlencodeline(fp, &s[prev], len - prev);
-		}
-	}
-
-	fputs("</code></pre><div class=\"clearfix\"></div>", fp);
-
-	return n;
-}
-
 void
 writecommit(FILE *fp, struct commitinfo *ci)
 {

@@ -941,6 +895,52 @@ writeblobraw(const git_blob *blob, const char *fpath, const char *filename, git_
 }
 
 size_t
+writeblobhtml(FILE *fp, const git_blob *blob)
+{
+	size_t n = 0, i, len, prev;
+	const char *nfmt = "<a href=\"#L%zu\" id=\"L%zu\">%zu</a> ";
+	const char *s = git_blob_rawcontent(blob);
+
+	len = git_blob_rawsize(blob);
+	fputs("<pre id=\"blob\"><span class=\"line-number\">", fp);
+
+	if (len > 0) {
+		for (i = 0, prev = 0; i < len; i++) {
+			if (s[i] != '\n')
+				continue;
+			n++;
+			fprintf(fp, nfmt, n, n, n);
+			putc('\n', fp);
+			prev = i + 1;
+		}
+		/* trailing data */
+		if ((len - prev) > 0) {
+			n++;
+			fprintf(fp, nfmt, n, n, n);
+		}
+	}
+
+	fputs("</span><code>", fp);
+
+	if (len > 0) {
+		for (i = 0, prev = 0; i < len; i++) {
+			if (s[i] != '\n') continue;
+			xmlencodeline(fp, &s[prev], i - prev + 1);
+			putc('\n', fp);
+			prev = i + 1;
+		}
+		/* trailing data */
+		if ((len - prev) > 0) {
+			xmlencodeline(fp, &s[prev], len - prev);
+		}
+	}
+
+	fputs("</code></pre><div class=\"clearfix\"></div>", fp);
+
+	return n;
+}
+
+size_t
 writeblobpage(git_object *obj, const char *fpath, const char *rpath, const char *filepath, const char *filename, size_t filesize)
 {
 	char tmp[PATH_MAX] = "";