From 2c756c40777d33d10e27d514eb9c7bc52206a894 Mon Sep 17 00:00:00 2001 From: Demonstrandum Date: Wed, 5 Aug 2020 22:22:12 +0100 Subject: [PATCH] Fix highlight script location. --- repo-gen.sh | 1 + stagit.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/repo-gen.sh b/repo-gen.sh index b58559f..c2a25a8 100755 --- 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 index b3f2e16..ed6c932 100644 --- 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; -- 2.39.2