]> git.armaanb.net Git - stagit.git/commitdiff
Fix highlight script location.
authorDemonstrandum <moi@knutsen.co>
Wed, 5 Aug 2020 21:22:12 +0000 (22:22 +0100)
committerDemonstrandum <moi@knutsen.co>
Wed, 5 Aug 2020 21:22:12 +0000 (22:22 +0100)
repo-gen.sh
stagit.c

index b58559fb7d1ba32a8ce80c70b5ac75dd02e02483..c2a25a81c29ad9cde5b5523cb93847af608e2866 100755 (executable)
@@ -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"
 
index b3f2e161c71a7630b2c26fa0779483ac6eac7cdb..ed6c9323c37204365b6d6c2d724b55f424e68e48 100644 (file)
--- 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;