stagit

Fork of `stagit` for git.knutsen.co.
git clone git://git.knutsen.co/stagit
Log | Files | Refs | README | LICENSE

commit 2c756c40777d33d10e27d514eb9c7bc52206a894
parent ba2dc046e649f0f48b0fbe65f12627bd33ec2d38
Author: Demonstrandum <moi@knutsen.co>
Date:   Wed,  5 Aug 2020 22:22:12 +0100

Fix highlight script location.

Diffstat:
Mrepo-gen.sh | 1+
Mstagit.c | 8++++++--
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/repo-gen.sh b/repo-gen.sh @@ -24,6 +24,7 @@ for repo in /srv/git/*.git; do [ ! -f style.css ] && ln -s ../style.css ./ [ ! -f favicon.png ] && ln -s ../favicon.png ./ [ ! -f logo.png ] && ln -s ../logo.png ./ + [ ! -f highlight ] && ln -s ../highlight ./ echo "git://git.knutsen.co/$repo" > "/srv/git/$repo.git/url" diff --git a/stagit.c b/stagit.c @@ -399,6 +399,10 @@ syntax_highlight(const char *filename, FILE *fp, const char *s, size_t len) { // Ruby script for syntax highlighting. FILE *child = popen("./highlight", "w"); + if (child == NULL) { + printf("child is null: %s", strerror(errno)); + exit(1); + } // Give filename: fprintf(child, "%s\n", filename); // Give code to highlight: @@ -406,13 +410,13 @@ syntax_highlight(const char *filename, FILE *fp, const char *s, size_t len) size_t i; for (i = 0; *s && i < len; s++, i++) { if (*s == '\n') lc++; - fputc(*s, child); + fprintf(child, "%c", *s); } // Write returned HTML to the HTML file. char c; while ((c = fgetc(child)) != EOF) - fputc(c, fp); + fprintf(fp, "%c", c); pclose(child); return lc;