fix writeheader not being called when flags are used before repos - stagit-gopher - A git gopher frontend. (mirror)
 (HTM) git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit cba17854219972673d7079e9cb11185cc2565710
 (DIR) parent d0d070040d949d825c4464022d0d43cb1582db1f
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sun,  2 Sep 2018 15:50:33 +0200
       
       fix writeheader not being called when flags are used before repos
       
       Diffstat:
         M stagit-gopher-index.c               |       6 +++---
       
       1 file changed, 3 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/stagit-gopher-index.c b/stagit-gopher-index.c
       @@ -214,7 +214,7 @@ main(int argc, char *argv[])
                FILE *fp;
                char path[PATH_MAX], repodirabs[PATH_MAX + 1];
                const char *repodir = NULL;
       -        int i, ret = 0;
       +        int i, r, ret = 0;
        
                setlocale(LC_CTYPE, "");
        
       @@ -225,7 +225,7 @@ main(int argc, char *argv[])
                        err(1, "pledge");
        #endif
        
       -        for (i = 1; i < argc; i++) {
       +        for (i = 1, r = 0; i < argc; i++) {
                        if (argv[i][0] == '-') {
                                if (argv[i][1] != 'b' || i + 1 >= argc)
                                        usage(argv[0]);
       @@ -233,7 +233,7 @@ main(int argc, char *argv[])
                                continue;
                        }
        
       -                if (i == 1)
       +                if (r++ == 0)
                                writeheader(stdout);
        
                        repodir = argv[i];