git-tar-tree: no more void pointer arithmetic
[git.git] / mailsplit.c
index eb58b1e..70a569c 100644 (file)
@@ -11,7 +11,6 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <stdio.h>
-#include <assert.h>
 #include "cache.h"
 
 static const char git_mailsplit_usage[] =
@@ -163,14 +162,17 @@ int main(int argc, const char **argv)
 
        while (*argp) {
                const char *file = *argp++;
-               FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "rt");
+               FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
                int file_done = 0;
 
                if ( !f )
                        die ("cannot open mbox %s", file);
 
-               if (fgets(buf, sizeof(buf), f) == NULL)
+               if (fgets(buf, sizeof(buf), f) == NULL) {
+                       if (f == stdin)
+                               break; /* empty stdin is OK */
                        die("cannot read mbox %s", file);
+               }
 
                while (!file_done) {
                        sprintf(name, "%s/%0*d", dir, nr_prec, ++nr);